Exemplo n.º 1
0
    def importFromFile(self, origin, moduleName, names):
        from ti.tgnode import VariableTGNode, EdgeType

        import config
        data = config.data

        quasiAlias = utils.QuasiAlias(moduleName)

        module = self.importFile(origin, quasiAlias)
        if not module:
            return None

        scope = module.getScope()

        for alias in names:
            name = alias.name
            if name == '*':
                #TODO
                pass
            else:
                if alias.asname:
                    aliasName = alias.asname
                else:
                    aliasName = name
                oldVar = scope.findName(name)
                if oldVar:
                    newVar = VariableTGNode(aliasName)
                    data.currentScope.addVariable(newVar)
                    EdgeType.processAssign(oldVar, newVar)

        return module
Exemplo n.º 2
0
def initBuiltinFunction(scope, name, quasi, num,
                        defaults = None, listArgs = False, dictArgs = False):
    from ti.tgnode import ExternalFunctionDefinitionTGNode, EdgeType
    func = ExternalFunctionDefinitionTGNode(num, quasi, name, scope,
                                            defaults, listArgs, dictArgs)
    var  = scope.findOrAddName(name)
    EdgeType.processAssign(func, var)
    scope.addVariable(var)
Exemplo n.º 3
0
 def addModuleHere(self, scope, name, module):
     from ti.tgnode import EdgeType
     if module:
         var = scope.findOrAddName(name)
         EdgeType.processAssign(module, var)
Exemplo n.º 4
0
def initBuiltinVariable(scope, name, typeFunction):
    from ti.tgnode import VariableTGNode, EdgeType 
    ext = VariableTGNode(None, typeFunction())
    var = scope.findOrAddName(name)
    EdgeType.processAssign(ext, var)
    scope.addVariable(var)