Beispiel #1
0
        internal IDictionary <object, object> GetLocalsScope()
        {
            ScopeData scopeData = CurrentScopeData;
            IDictionary <object, object> scope = scopeData.Scope;

            if (scope == null)
            {
                Debug.Assert(_liftedLocals != null);

                List <string>       visibleSymbols = new List <string>();
                List <VariableInfo> visibleLocals  = new List <VariableInfo>();

                // Add parameters
                for (int i = 0; i < _funcInfo.Variables.Count; i++)
                {
                    if (_funcInfo.Variables[i].IsParameter && !_funcInfo.Variables[i].Hidden)
                    {
                        visibleSymbols.Add(_funcInfo.Variables[i].Name);
                        visibleLocals.Add(_funcInfo.Variables[i]);
                    }
                }

                // Add locals
                foreach (VariableInfo varInfo in LocalsInCurrentScope)
                {
                    if (!varInfo.Hidden)
                    {
                        visibleSymbols.Add(varInfo.Name);
                        visibleLocals.Add(varInfo);
                    }
                }

                IRuntimeVariables scopedLocals = new ScopedRuntimeVariables(visibleLocals, _liftedLocals);

                scope = new LocalsDictionary(scopedLocals, visibleSymbols.ToArray());

                scopeData.Scope = scope;
            }

            return(scope);
        }
Beispiel #2
0
        internal Scope GetLocalsScope() {
            ScopeData scopeData = CurrentScopeData;
            Scope scope = scopeData.Scope;
            if (scope == null) {
                Debug.Assert(_liftedLocals != null);

                List<SymbolId> visibleSymbols = new List<SymbolId>();
                List<VariableInfo> visibleLocals = new List<VariableInfo>();

                // Add parameters
                for (int i = 0; i < _funcInfo.Variables.Count; i++) {
                    if (_funcInfo.Variables[i].IsParameter && !_funcInfo.Variables[i].Hidden) {
                        visibleSymbols.Add(_funcInfo.Variables[i].Symbol);
                        visibleLocals.Add(_funcInfo.Variables[i]);
                    }
                }

                // Add locals
                foreach (VariableInfo varInfo in LocalsInCurrentScope) {
                    if (!varInfo.Hidden) {
                        visibleSymbols.Add(varInfo.Symbol);
                        visibleLocals.Add(varInfo);
                    }
                }

                IRuntimeVariables scopedLocals = new ScopedRuntimeVariables(visibleLocals, _liftedLocals);

                scope = new Scope(new LocalsDictionary(scopedLocals, visibleSymbols.ToArray()));

                scopeData.Scope = scope;
            }

            return scope;
        }