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

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

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

            LexicalScope scope = this;

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