protected override Expression VisitChildren(ExpressionVisitor visitor) { Expression newContext = visitor.Visit(_newContext); Expression body = visitor.Visit(_body); if (newContext == _newContext && body == _body) { return(this); } return(Utils.CodeContextScope(body, newContext)); }
private Expression MakeBody() { Expression body = _body; // wrap a CodeContext scope if needed if (!_global && !DoNotAddContext) { var vars = new List <ParameterExpression>(_visibleVars.Count); foreach (var v in _visibleVars) { if (EmitDictionary || v.Value) { vars.Add(v.Key); } } if (vars.Count > 0) { body = Utils.CodeContextScope( body, Expression.Call( typeof(RuntimeHelpers).GetMethod("CreateNestedCodeContext"), Utils.VariableDictionary(vars), Utils.CodeContext(), Expression.Constant(_visible) ) ); } } // wrap a scope if needed if (_locals != null && _locals.Count > 0) { body = Expression.Block(new ReadOnlyCollection <ParameterExpression>(_locals.ToArray()), body); } return(body); }