internal InstanceAccessExpression(LeftHandValueExpression lvalue, List <FunctionArgument> callArgs)
 {
     Value     = lvalue;
     Arguments = callArgs;
 }
示例#2
0
 internal AssignmentExpression(LeftHandValueExpression left, Expression right, ExpressionType assignType)
 {
     Left          = left;
     Right         = right ?? Constant(null);
     ExtraNodeType = assignType;
 }
 internal ConditionalAssignmentExpression(LeftHandValueExpression left, Expression right, KumaExpressionType conditionalAssignmentType)
     : base(left, right, ExpressionType.Assign)
 {
     ConditionalAssignmentType = conditionalAssignmentType;
 }
示例#4
0
        public override Expression Reduce()
        {
            var forLabel = Label("<kuma_for>");
            VariableExpression      forReturn   = null;
            LeftHandValueExpression forReturnLh = null;
            var useReturn = true;

            if (Body.Type == typeof(void))
            {
                useReturn = false;
            }
            else
            {
                forReturn         = Variable(Constant("<kuma_for_return>"));
                forReturnLh       = LeftHandValue(forReturn);
                forReturn.Scope   = ((KumaExpression)Body).Scope;
                forReturnLh.Scope = ((KumaExpression)Body).Scope;
            }
            var forTest   = Variable(Constant("<kuma_for_test>"));
            var forTestLh = LeftHandValue(forTest);

            forTest.Scope   = ((KumaExpression)Body).Scope;
            forTestLh.Scope = ((KumaExpression)Body).Scope;
            var realBody = new List <Expression> {
                Init,
                Label(forLabel),
            };
            var testAssign = Assign(forTestLh, Test);

            realBody.Add(Label(KumaParser.RetryTarget));
            testAssign.Scope = (Body as KumaExpression).Scope;
            realBody.Add(testAssign);
            IfExpression testIf;

            if (useReturn)
            {
                var returnAssign = Assign(forReturnLh, Body);
                returnAssign.Scope = (Body as KumaExpression).Scope;
                testIf             = IfThen(forTest, returnAssign);
            }
            else
            {
                testIf = IfThen(forTest, Body);
            }
            testIf.Scope = ((KumaExpression)Body).Scope;
            realBody.Add(testIf);
            realBody.Add(Label(KumaParser.ContinueTarget));
            realBody.Add(Step);
            realBody.Add(IfThen(forTest, Goto(forLabel)));
            realBody.Add(Label(KumaParser.BreakTarget));
            if (useReturn)
            {
                realBody.Add(forReturn);
            }

            var block = new BlockExpression(realBody)
            {
                Scope = (Body as KumaExpression).Scope
            };

            return(Convert(block, Type));
        }
示例#5
0
 public static ConditionalAssignmentExpression ConditionalAssign(LeftHandValueExpression left, Expression right,
                                                                 KumaExpressionType conditionalAssignmentType)
 {
     return(new ConditionalAssignmentExpression(left, right, conditionalAssignmentType));
 }
示例#6
0
 public static AssignmentExpression Assign(LeftHandValueExpression left, Expression right, ExpressionType type)
 {
     return(new AssignmentExpression(left, right, type));
 }
示例#7
0
 public static AssignmentExpression Assign(LeftHandValueExpression left, Expression right)
 {
     return(Assign(left, right, ExpressionType.Assign));
 }