Beispiel #1
0
def resolveFunction(node: Node, parentScope: Scope):
    for child in node.getChildNodes():
        if child.nodeType == NodeType.FUNCTION:
            child.parentScope = parentScope
            name = child.getChild('name')

            if parentScope.classType:
                if name != '__init__':
                    name = parentScope.classType.name + '__' + name
                else:
                    name = parentScope.classType.name + name

            type_ = getFunctionReturnType(child)
            symbol = Symbol(name, type_)
            child.symbol = symbol
            child.resolvedType = type_
            global_ = parentScope
            while global_.parent != None:
                global_ = global_.parent

            global_.define(symbol)

            scope = Scope(parentScope)
            scope.isFunction = True
            scope.classType = parentScope.classType
            child.scope = scope
Beispiel #2
0
def resolveClass(node: Node, parentScope: Scope):
    for child in node.getChildNodes():
        if child.nodeType == NodeType.CLASS:
            name = child.getChild('name')
            type_ = Type(name, True)
            symbol = Symbol(name, type_, SymbolKind.CLASS)
            child.symbol = symbol
            child.resolvedType = type_
            parentScope.define(symbol)

            scope = Scope(parentScope)
            scope.classType = type_
            child.scope = scope