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

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

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

            LexicalScope scope = this;

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