Beispiel #1
0
        private LexicalScope EnterTopScope()
        {
            LexicalScope result = new LexicalScope(null);

            _lexicalScopes.Push(result);
            return(result);
        }
Beispiel #2
0
        private LexicalScope EnterNestedScope()
        {
            LexicalScope result = new LexicalScope(CurrentScope);

            _lexicalScopes.Push(result);
            return(result);
        }
Beispiel #3
0
        internal LexicalScope /*!*/ GetInnermostStaticTopScope()
        {
            Debug.Assert(!IsRuntimeScope);

            LexicalScope scope = this;

            while (!scope.IsStaticTop)
            {
                scope = scope.OuterScope;
                Debug.Assert(scope != null);
            }
            return(scope);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
 private LexicalScope /*!*/ EnterScope(LexicalScope /*!*/ scope)
 {
     Assert.NotNull(scope);
     _lexicalScopes.Push(scope);
     return(scope);
 }
Beispiel #7
0
 protected LexicalScope(LexicalScope outerScope, int depth)
 {
     _outerScope = outerScope;
     _depth      = depth;
 }
Beispiel #8
0
 // 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);
 }
Beispiel #9
0
 public PaddingLexicalScope(LexicalScope /*!*/ outerScope)
     : base(outerScope)
 {
     Debug.Assert(outerScope != null);
 }
Beispiel #10
0
 public BlockLexicalScope(LexicalScope /*!*/ outerScope)
     : base(outerScope)
 {
     Debug.Assert(outerScope != null);
 }
Beispiel #11
0
 public TopLocalDefinitionLexicalScope(LexicalScope /*!*/ outerScope)
     : base(outerScope)
 {
     Debug.Assert(outerScope != null);
 }
Beispiel #12
0
 public TopStaticLexicalScope(LexicalScope outerScope)
     : base(outerScope)
 {
 }
Beispiel #13
0
 // 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)
 {
 }
Beispiel #14
0
 public BlockLexicalScope(LexicalScope outerScope)
     : base(outerScope)
 {
 }
Beispiel #15
0
 public TopLexicalScope(LexicalScope outerScope)
     : base(outerScope)
 {
 }
Beispiel #16
0
 internal LexicalScope(LexicalScope outerScope)
 {
     _outerScope = outerScope;
 }