Search in sources :

Example 1 with StatementList

use of net.taken.redsnake.tree.statements.StatementList in project redsnake by Taken0711.

the class IfTest method createIfWithAssignments.

private static If createIfWithAssignments(String variableName, boolean condition, int trueValue, int falseValue) {
    Variable var = mockVariable(variableName);
    Expression cond = mockExpression(new RedsBoolean(condition));
    StatementList thenBody = new StatementList(ImmutableList.of(new Assignment(mockVariable(variableName), mockExpression(trueValue))));
    StatementList elseBody = new StatementList(ImmutableList.of(new Assignment(mockVariable(variableName), mockExpression(falseValue))));
    return new If(cond, thenBody, elseBody);
}
Also used : Assignment(net.taken.redsnake.tree.statements.expressions.Assignment) Variable(net.taken.redsnake.tree.Variable) Expression(net.taken.redsnake.tree.statements.expressions.Expression) RedsBoolean(net.taken.redsnake.lang.RedsBoolean) StatementList(net.taken.redsnake.tree.statements.StatementList) If(net.taken.redsnake.tree.statements.If)

Aggregations

RedsBoolean (net.taken.redsnake.lang.RedsBoolean)1 Variable (net.taken.redsnake.tree.Variable)1 If (net.taken.redsnake.tree.statements.If)1 StatementList (net.taken.redsnake.tree.statements.StatementList)1 Assignment (net.taken.redsnake.tree.statements.expressions.Assignment)1 Expression (net.taken.redsnake.tree.statements.expressions.Expression)1