public void ChangeNativeToFrameLocal(ScopeEntry entry) { if (Names == null) { Names = new List<Symbol>(); } UsesFramedVariables = true; Names.Add(entry.Key); entry.Value = Names.Count - 1; }
public bool FindLocal(Symbol sym, ScopeFlags reason, out int depth, out ScopeEntry entry) { bool noCapturedNativeParametersBeyondThisPoint = false; depth = 0; entry = null; for (AnalysisScope sc = this; sc != null; sc = sc.Parent) { ScopeEntry item; if (sc.IsBlockScope && sym == Symbols.Tilde) { if (sc.Tilde == null) { sc.Tilde = sc.DefineNativeLocal(Symbols.Tilde, ScopeFlags.All); } } for (var i = sc.Variables.Count - 1; i >= 0; --i) { item = sc.Variables[i]; // Looking for exact match if (LexicalSymEqual(item.Key, sym)) { entry = item; item.Flags |= reason; if (item.Index != -1 || item.MacroValue != null || item.SymbolMacroValue != null) { } else if (reason != 0 && noCapturedNativeParametersBeyondThisPoint && !LexicalSymEqual(sym, Symbols.Tilde)) { // Linq.Expression closures do not support native variables defined // outside the LambdaExpression. Whenever we encounter such a variable // it is added to the free variables and also added as frame variable // to keep the compiler happy. // The recompile that comes later uses the list of free variables to // choose the correct implementation scheme. sc.FreeVariables.Add(sym); sc.ChangeNativeToFrameLocal(item); } return true; } } if (sc.IsBlockScope && sym == Symbols.Tilde) { // boundary for ~ variable which is tightly coupled to its DO block. break; } if (sc.IsLambda) { // boundary for native variables in closures. noCapturedNativeParametersBeyondThisPoint = true; } if (sc.Names != null) { ++depth; } } depth = 0; return false; }