private LexicalScope EnterTopScope() { LexicalScope result = new LexicalScope(null); _lexicalScopes.Push(result); return(result); }
private LexicalScope EnterNestedScope() { LexicalScope result = new LexicalScope(CurrentScope); _lexicalScopes.Push(result); return(result); }
internal LexicalScope /*!*/ GetInnermostStaticTopScope() { Debug.Assert(!IsRuntimeScope); LexicalScope scope = this; while (!scope.IsStaticTop) { scope = scope.OuterScope; Debug.Assert(scope != null); } return(scope); }
public LocalVariable ResolveVariable(string /*!*/ name) { LexicalScope scope = this; do { LocalVariable result; if (scope.TryGetValue(name, out result)) { return(result); } scope = scope.OuterScope; } while (scope != null); return(null); }
/// <summary> /// Looks the scope chain for a variable of a given name. /// Includes runtime scope in the lookup if available. /// </summary> public LocalVariable ResolveVariable(string /*!*/ name) { LexicalScope scope = this; while (true) { LocalVariable result; if (scope.TryGetValue(name, out result)) { return(result); } if (scope.IsTop) { break; } scope = scope.OuterScope; } return(null); }
private LexicalScope /*!*/ EnterScope(LexicalScope /*!*/ scope) { Assert.NotNull(scope); _lexicalScopes.Push(scope); return(scope); }
protected LexicalScope(LexicalScope outerScope, int depth) { _outerScope = outerScope; _depth = depth; }
// Note on dynamic scopes. // We don't statically define variables defined in top-level eval'd code so the depth of the top-level scope is -1 // if the outer scope is a runtime scope. // // eval('x = 1') <-- this variable needs to be defined in containing runtime scope, not in top-level eval scope // eval('puts x') // // eval('1.times { x = 1 }') <-- x could be statically defined in the block since it is not visible outside the block // internal LexicalScope(LexicalScope outerScope) { _outerScope = outerScope; _depth = IsTop ? 0 : (outerScope.IsRuntimeScope ? -1 : outerScope._depth + 1); }
public PaddingLexicalScope(LexicalScope /*!*/ outerScope) : base(outerScope) { Debug.Assert(outerScope != null); }
public BlockLexicalScope(LexicalScope /*!*/ outerScope) : base(outerScope) { Debug.Assert(outerScope != null); }
public TopLocalDefinitionLexicalScope(LexicalScope /*!*/ outerScope) : base(outerScope) { Debug.Assert(outerScope != null); }
public TopStaticLexicalScope(LexicalScope outerScope) : base(outerScope) { }
// Note on dynamic scopes. // We don't statically define variables defined in top-level eval'd code so the depth of the top-level scope is -1 // if the outer scope is a runtime scope. // // eval('x = 1') <-- this variable needs to be defined in containing runtime scope, not in top-level eval scope // eval('puts x') // // eval('1.times { x = 1 }') <-- x could be statically defined in the block since it is not visible outside the block // internal LexicalScope(LexicalScope outerScope) : this(outerScope, (outerScope != null) ? (outerScope.IsRuntimeScope ? -1 : outerScope._depth + 1) : 0) { }
public BlockLexicalScope(LexicalScope outerScope) : base(outerScope) { }
public TopLexicalScope(LexicalScope outerScope) : base(outerScope) { }
internal LexicalScope(LexicalScope outerScope) { _outerScope = outerScope; }