示例#1
0
 public override Expression Reduce()
 {
     return(Expression.Call(
                typeof(ScriptingRuntimeHelpers).GetMethod("LookupName"),
                Utils.CodeContext(),
                AstUtils.Constant(_name)
                ));
 }
 public override Expression Reduce()
 {
     return(Expression.Call(
                typeof(ExpressionHelpers).GetMethod("RemoveName"),
                new [] {
         Utils.CodeContext(),
         AstUtils.Constant(_name)
     }
                ));
 }
示例#3
0
 public override Expression Reduce()
 {
     return(Expression.Call(
                null,
                typeof(ScriptingRuntimeHelpers).GetMethod("SetName"),
                new Expression[] {
         Utils.CodeContext(),
         AstUtils.Constant(_name),
         Expression.Convert(_value, typeof(object))
     }
                ));
 }
示例#4
0
        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);
        }