protected override IEnumerable <BaseStatement> Visit(Assignment ass) { var a = new ExpressionDecomposition(_names).Visit(ass.Right).ToArray(); var b = new Assignment(ass.Left, new Variable(((Assignment)a.Last()).Left)); return(a.Append(b)); }
protected override IEnumerable <BaseStatement> Visit(If @if) { var a = new ExpressionDecomposition(_names).Visit(@if.Condition); var b = new If(new Variable(((Assignment)a.Last()).Left), new StatementList(Visit(@if.TrueBranch)), new StatementList(Visit(@if.FalseBranch))); return(a.Append(b)); }
protected override IEnumerable <BaseStatement> Visit(CompoundAssignment compAss) { var tmp = new VariableName(_names.Name()); var a = new ExpressionDecomposition(_names).Visit(compAss.Expression).ToArray(); var b = new Assignment(tmp, BaseBinaryExpression.Create(compAss.Op, new Variable(new VariableName(compAss.Left.Name)), new Variable(((Assignment)a.Last()).Left))); var c = new Assignment(new VariableName(compAss.Left.Name), new Variable(tmp)); return(a.Append(b).Append(c)); }
protected override IEnumerable <BaseStatement> Visit(Goto @goto) { if (@goto.Destination.IsConstant) { var v = @goto.Destination.StaticEvaluate(); if (v.Type == Execution.Type.Number) { return new[] { @goto } } ; } var a = new ExpressionDecomposition(_names).Visit(@goto.Destination); var b = new Goto(new Variable(((Assignment)a.Last()).Left)); return(a.Append(b)); }