Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core\module] add documentation example #1622

Open
github-actions bot opened this issue Apr 29, 2024 · 0 comments
Open

[Core\module] add documentation example #1622

github-actions bot opened this issue Apr 29, 2024 · 0 comments
Labels
→ Core documentation Improvements or additions to documentation easy Easy issues that can be solved in little time library Issues related to the standard library todo Automatically generated issues from TODOs in the code

Comments

@github-actions
Copy link

[Core\module] add documentation example

# TODO(Core\module) add documentation example

            push(newMethodFromDefinition(argBlock, y, isDistinct, isPublic, inPath))

    builtin "module",
        alias       = unaliased,
        op          = opNop,
        rule        = PrefixPrecedence,
        description = "create new module with given contents",
        args        = {
            "contents"  : {Block, Dictionary}
        },
        attrs       = {
            "with"  : ({Block},"use given initialization parameters"),
        },
        returns     = {Module},
        # TODO(Core\module) add documentation example
        #  labels: library, documentation, easy
        example     = """
        """:
            #=======================================================
            var definitions: ValueDict = newOrderedTable[string,Value]()
            var inherits: Value = VNULL
            var super: ValueDict = newOrderedTable[string,Value]()
            var initUsing: ValueArray = @[]

            if checkAttr("with"):
                initUsing = aWith.a

            if xKind == Block:
                if (let constructorMethod = generatedConstructor(x.a); not constructorMethod.isNil):
                    definitions[$ConstructorM] = constructorMethod
                else:
                    for k,v in newDictionary(execDictionary(x)).d:
                        definitions[k] = v
            elif xKind == Dictionary:
                for k,v in x.d:
                    definitions[k] = copyValue(v)

            # TODO(Core\module) should show error in case magic methods are included
            #  magic methods are of no use in that case
            #  labels: vm, error handling
            
            # Get fields
            let fieldTable = getFieldTable(definitions)

            # Generate internal module identifier
            when not defined(WEB):
                let moduleId = "module" & "_" & $(genOid())
            else:
                let moduleId = "module" & "_" & $(rand(1_000_000_000..2_000_000_000))

            let proto = newPrototype(moduleId, definitions, inherits, fieldTable, super)
            let singleton = generateNewObject(proto, initUsing)

            push(newModule(singleton))

    builtin "new",
        alias       = unaliased, 
        op          = opNop,

9946a0264e1472e6b18b7cf99a93a22a0221c7b9

@github-actions github-actions bot added documentation Improvements or additions to documentation easy Easy issues that can be solved in little time library Issues related to the standard library todo Automatically generated issues from TODOs in the code labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
→ Core documentation Improvements or additions to documentation easy Easy issues that can be solved in little time library Issues related to the standard library todo Automatically generated issues from TODOs in the code
Projects
None yet
Development

No branches or pull requests

1 participant