internal static FunctionInfo AddFunction(FunctionDefinition node, AnalysisUnit outerUnit, InterpreterScope prevScope) { InterpreterScope scope; if (!prevScope.TryGetNodeScope(node, out scope)) { if (node.Body == null || node.Name == null) { return(null); } var func = new FunctionInfo(node, outerUnit, prevScope); var unit = func.AnalysisUnit; scope = unit.InterpreterScope; (unit as FunctionAnalysisUnit)?.EnsureParameters(); prevScope.Children.Add(scope); prevScope.AddNodeScope(node, scope); if (!node.IsLambda && node.Name != "<genexpr>") { // Create the variable (except for lambdas) but do not add any // values yet. (This happens in FunctionAnalysisUnit.) prevScope.AddLocatedVariable(node.Name, node.NameExpression, unit); } unit.Enqueue(); } return(scope.AnalysisValue as FunctionInfo); }
internal static FunctionInfo AddFunction(FunctionDefinition node, AnalysisUnit outerUnit, InterpreterScope prevScope) { InterpreterScope scope; if (!prevScope.TryGetNodeScope(node, out scope)) { if (node.Body == null || node.Name == null) { return(null); } var func = new FunctionInfo(node, outerUnit, prevScope); var unit = func.AnalysisUnit; scope = unit.Scope; prevScope.Children.Add(scope); prevScope.AddNodeScope(node, scope); if (!node.IsLambda && node.Name != "<genexpr>") { // lambdas don't have their names published var funcVar = prevScope.AddLocatedVariable(node.Name, node.NameExpression, unit); // Decorated functions don't have their type set yet if (node.Decorators == null) { funcVar.AddTypes(unit, func.SelfSet); } } unit.Enqueue(); } return(scope.AnalysisValue as FunctionInfo); }
public override bool Walk(Parameter node) { if (!string.IsNullOrEmpty(node.Name)) { // ensure we have a variable here so we don't get unresolved errors _scope.AddLocatedVariable(node.Name, node, _curUnit, node.Kind); } return(base.Walk(node)); }
internal static FunctionInfo AddFunction(FunctionDefinition node, AnalysisUnit outerUnit, InterpreterScope prevScope) { InterpreterScope scope; if (!prevScope.TryGetNodeScope(node, out scope)) { if (node.Body == null || node.Name == null) { return null; } var func = new FunctionInfo(node, outerUnit, prevScope); var unit = func.AnalysisUnit; scope = unit.Scope; prevScope.Children.Add(scope); prevScope.AddNodeScope(node, scope); if (!node.IsLambda && node.Name != "<genexpr>") { // lambdas don't have their names published var funcVar = prevScope.AddLocatedVariable(node.Name, node.NameExpression, unit); // Decorated functions don't have their type set yet if (node.Decorators == null) { funcVar.AddTypes(unit, func.SelfSet); } } unit.Enqueue(); } return scope.AnalysisValue as FunctionInfo; }