public override bool Walk(FunctionDefinition node) { if (node.IsLambda) { return(false); } var dec = (node.Decorators?.DecoratorsInternal).MaybeEnumerate(); if (dec.OfType <NameExpression>().Any(n => n.Name == "property")) { AddProperty(node); return(false); } foreach (var setter in dec.OfType <MemberExpression>().Where(n => n.Name == "setter")) { if (setter.Target is NameExpression src) { var existingProp = _scope.LookupNameInScopes(src.Name, NameLookupContext.LookupOptions.Local) as AstPythonProperty; if (existingProp != null) { // Setter for an existing property, so don't create a function existingProp.MakeSettable(); return(false); } } } var existing = _scope.LookupNameInScopes(node.Name, NameLookupContext.LookupOptions.Local) as AstPythonFunction; if (existing == null) { existing = new AstPythonFunction(_ast, _module, CurrentClass, node, GetLoc(node)); _scope.SetInScope(node.Name, existing); } var funcScope = _scope.Clone(); if (CreateBuiltinTypes) { funcScope.SuppressBuiltinLookup = true; } var funcWalk = new AstAnalysisFunctionWalker(funcScope, node); _postWalkers.Add(funcWalk); existing.AddOverload(funcWalk.Overload); // Do not recurse into functions return(false); }
public override bool Walk(FunctionDefinition node) { if (node.IsLambda) { return(false); } var existing = _scope.LookupNameInScopes(node.Name, NameLookupContext.LookupOptions.Local) as AstPythonFunction; if (existing == null) { existing = new AstPythonFunction(_ast, _module, CurrentClass, node, GetLoc(node)); _scope.SetInScope(node.Name, existing); } var funcScope = _scope.Clone(); if (CreateBuiltinTypes) { funcScope.SuppressBuiltinLookup = true; } var funcWalk = new AstAnalysisFunctionWalker(funcScope, node); _postWalkers.Add(funcWalk); existing.AddOverload(funcWalk.Overload); // Do not recurse into functions return(false); }