public VariableScope(LocalVariable variable, int start, VariableScope parent) { Variable = variable; Start = start; Parent = parent; }
internal LocalVariable AddClosureVariable(ParameterExpression variable) { if (_closureVariables == null) { _closureVariables = new Dictionary<ParameterExpression, LocalVariable>(); } LocalVariable result = new LocalVariable(_closureVariables.Count, true, false); _closureVariables.Add(variable, result); return result; }
public LocalDefinition DefineLocal(ParameterExpression variable, int start) { ContractUtils.RequiresNotNull(variable, "variable"); ContractUtils.Requires(start >= 0, "start", "start must be positive"); LocalVariable result = new LocalVariable(_localCount++, false, false); _maxLocalCount = System.Math.Max(_localCount, _maxLocalCount); VariableScope existing, newScope; if (_variables.TryGetValue(variable, out existing)) { newScope = new VariableScope(result, start, existing); if (existing.ChildScopes == null) { existing.ChildScopes = new List<VariableScope>(); } existing.ChildScopes.Add(newScope); } else { newScope = new VariableScope(result, start, null); } _variables[variable] = newScope; return new LocalDefinition(result.Index, variable); }
public bool TryGetLocalOrClosure(ParameterExpression var, out LocalVariable local) { VariableScope scope; if (_variables.TryGetValue(var, out scope)) { local = scope.Variable; return true; } if (_closureVariables != null && _closureVariables.TryGetValue(var, out local)) { return true; } local = null; return false; }
internal LocalDefinition DefineLocal(ParameterExpression variable, int start) { LocalVariable result = new LocalVariable(_localCount++, false, false); _maxLocalCount = System.Math.Max(_localCount, _maxLocalCount); VariableScope existing, newScope; if (_variables.TryGetValue(variable, out existing)) { newScope = new VariableScope(result, start, existing); if (existing.ChildScopes == null) { existing.ChildScopes = new List<VariableScope>(); } existing.ChildScopes.Add(newScope); } else { newScope = new VariableScope(result, start, null); } _variables[variable] = newScope; return new LocalDefinition(result.Index, variable); }
internal void Box(ParameterExpression variable) { LocalVariable local = _variables[variable]; Debug.Assert(!local.IsBoxed && !local.InClosure); _variables[variable] = new LocalVariable(local.Index, false, true); _boxedCount++; }
public LocalVariable DefineLocal(ParameterExpression variable) { // the current variable definition shadows the existing one: if (_variables.ContainsKey(variable)) { throw new NotSupportedException("Variable shadowing not supported"); } LocalVariable result = new LocalVariable(_localCount++, false, false); _variables.Add(variable, result); return result; }
internal LocalVariable AddClosureVariable(ParameterExpression variable) { LocalVariable result = new LocalVariable(_closureSize++, true, false); _variables.Add(variable, result); return result; }
public bool TryGetLocal(ParameterExpression var, out LocalVariable local) { return _variables.TryGetValue(var, out local); }