public ListComprehensionAnalysisUnit(Comprehension node, PythonAst parent, AnalysisUnit outerUnit, InterpreterScope outerScope) : base(node, parent, new ComprehensionScope(new ListInfo(VariableDef.EmptyArray, outerUnit.ProjectState.ClassInfos[BuiltinTypeId.List], node), node, outerScope), outerUnit) { }
public DictionaryComprehensionAnalysisUnit(Comprehension node, PythonAst parent, AnalysisUnit outerUnit, InterpreterScope outerScope) : base(node, parent, new ComprehensionScope(new DictionaryInfo(outerUnit.ProjectEntry, node), node, outerScope), outerUnit) { }
public AnalysisUnit(ScopeStatement ast, InterpreterScope scope) : this(ast, (ast != null ? ast.GlobalParent : null), scope, false) { }
public SetComprehensionAnalysisUnit(Comprehension node, PythonAst parent, AnalysisUnit outerUnit, InterpreterScope outerScope) : base(node, parent, new ComprehensionScope(new SetInfo(outerUnit.ProjectState, node), node, outerScope), outerUnit) { }
internal static FunctionInfo AddFunction(FunctionDefinition node, AnalysisUnit outerUnit) { InterpreterScope scope; if (!outerUnit.DeclaringModule.NodeScopes.TryGetValue(node, out scope)) { if (node.Body == null || node.Name == null) { return(null); } var scopes = new InterpreterScope[outerUnit.Scopes.Length + 1]; outerUnit.Scopes.CopyTo(scopes, 0); var unit = new FunctionAnalysisUnit(node, scopes); var function = new FunctionInfo(unit); if (node.Decorators != null) { foreach (var d in node.Decorators) { NameExpression ne = d as NameExpression; if (ne != null) { if (ne.Name == "property") { function.IsProperty = true; } else if (ne.Name == "staticmethod") { function.IsStatic = true; } else if (ne.Name == "classmethod") { function.IsClassMethod = true; } } } } var funcScope = new FunctionScope(function, node); outerUnit.DeclaringModule.NodeScopes[node] = funcScope; var declScope = outerUnit.Scopes[outerUnit.Scopes.Length - 1]; declScope.Children.Add(funcScope); scopes[scopes.Length - 1] = funcScope; scope = funcScope; if (!node.IsLambda) { // lambdas don't have their names published declScope.SetVariable(node, unit, node.Name, function.SelfSet); } var newParams = new VariableDef[node.Parameters.Count]; int index = 0; foreach (var param in node.Parameters) { newParams[index++] = funcScope.DefineVariable(param, unit); } function.SetParameters(newParams); unit.Enqueue(); } return(scope.Namespace as FunctionInfo); }