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
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)
def addModuleHere(self, scope, name, module): from ti.tgnode import EdgeType if module: var = scope.findOrAddName(name) EdgeType.processAssign(module, var)
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)