private IStrongBox GetBox(ParameterExpression variable)
            {
                // Skip variables that are shadowed by a nested scope/lambda
                foreach (Set <ParameterExpression> hidden in _shadowedVars)
                {
                    if (hidden.Contains(variable))
                    {
                        return(null);
                    }
                }

                HoistedLocals scope = _scope;

                object[] locals = _locals;
                while (true)
                {
                    int hoistIndex;
                    if (scope.Indexes.TryGetValue(variable, out hoistIndex))
                    {
                        return((IStrongBox)locals[hoistIndex]);
                    }
                    scope = scope.Parent;
                    if (scope == null)
                    {
                        break;
                    }
                    locals = HoistedLocals.GetParent(locals);
                }

                // Unbound variable: an error should've been thrown already
                // from VariableBinder
                throw ContractUtils.Unreachable;
            }
Exemplo n.º 2
0
            private IStrongBox GetBox(ParameterExpression variable)
            {
                // Skip variables that are shadowed by a nested scope/lambda
                foreach (Set <ParameterExpression> hidden in _hiddenVars)
                {
                    if (hidden.Contains(variable))
                    {
                        return(null);
                    }
                }

                HoistedLocals scope = _scope;

                object[] locals = _locals;
                while (true)
                {
                    int hoistIndex;
                    if (scope.Indexes.TryGetValue(variable, out hoistIndex))
                    {
                        return((IStrongBox)locals[hoistIndex]);
                    }
                    scope = scope.Parent;
                    if (scope == null)
                    {
                        break;
                    }
                    locals = HoistedLocals.GetParent(locals);
                }

                // TODO: this should be unreachable because it's an unbound
                // variable, so we should throw here. It's a breaking change,
                // however
                return(null);
            }
Exemplo n.º 3
0
            private IStrongBox GetBox(ParameterExpression variable)
            {
                int num;

                foreach (Set <ParameterExpression> set in this._shadowedVars)
                {
                    if (set.Contains(variable))
                    {
                        return(null);
                    }
                }
                HoistedLocals parent = this._scope;

                object[] objArray = this._locals;
                while (!parent.Indexes.TryGetValue(variable, out num))
                {
                    parent = parent.Parent;
                    if (parent == null)
                    {
                        throw ContractUtils.Unreachable;
                    }
                    objArray = HoistedLocals.GetParent(objArray);
                }
                return((IStrongBox)objArray[num]);
            }
Exemplo n.º 4
0
            private IStrongBox GetStrongBox(int index)
            {
                long num = this._indexes[index];

                object[] locals = this._data;
                for (int i = (int)(num >> 0x20); i > 0; i--)
                {
                    locals = HoistedLocals.GetParent(locals);
                }
                return((IStrongBox)locals[(int)num]);
            }
Exemplo n.º 5
0
            private IStrongBox GetStrongBox(int index)
            {
                // We lookup the closure using two ints:
                // 1. The high dword is the number of parents to go up
                // 2. The low dword is the index into that array
                long closureKey = _indexes[index];

                // walk up the parent chain to find the real environment
                object[] result = _data;
                for (int parents = (int)(closureKey >> 32); parents > 0; parents--)
                {
                    result = HoistedLocals.GetParent(result);
                }

                // Return the variable storage
                return((IStrongBox)result[unchecked ((int)closureKey)]);
            }
Exemplo n.º 6
0
            public IStrongBox this[int index] {
                get {
                    // We lookup the closure using two ints:
                    // 1. The high dword is the number of parents to go up
                    // 2. The low dword is the index into that array
                    long closureKey = _indexes[index];

                    // walk up the parent chain to find the real environment
                    object[] result = _data;
                    for (int parents = (int)(closureKey >> 32); parents > 0; parents--)
                    {
                        result = HoistedLocals.GetParent(result);
                    }

                    // Return the variable storage
                    return((IStrongBox)result[(int)closureKey]);
                }
                set {
                    throw Error.CollectionReadOnly();
                }
            }