Example #1
0
        protected override Expr SimplifyChildren(VariableScope variables)
        {
            var simplifiedValue = Value.Simplify(variables);

            if (simplifiedValue is LiteralExpr)
            {
                var newScope = variables.AddVariable(Name, ((LiteralExpr)simplifiedValue).Literal);
                return(new AssignmentExpr(Location, Name, simplifiedValue, _pipedInto.Simplify(newScope)));
            }
            else if (simplifiedValue is ExpressionExpr)
            {
                var newScope = variables.AddVariable(Name, new AsyncExpression(((ExpressionExpr)simplifiedValue).InnerExpression));
                return(new AssignmentExpr(Location, Name, simplifiedValue, _pipedInto.Simplify(newScope)));
            }
            else
            {
                return(new AssignmentExpr(Location, Name, simplifiedValue, _pipedInto.Simplify(variables)));
            }
        }