Search in sources :

Example 1 with Variable

use of net.taken.redsnake.tree.Variable 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)

Example 2 with Variable

use of net.taken.redsnake.tree.Variable in project redsnake by Taken0711.

the class AssignmentTest method createAssignment.

public static Assignment createAssignment(String name, int value) {
    Variable var = mockVariable(name);
    Expression expr = mockExpression(value);
    return new Assignment(var, expr);
}
Also used : Variable(net.taken.redsnake.tree.Variable)

Aggregations

Variable (net.taken.redsnake.tree.Variable)2 RedsBoolean (net.taken.redsnake.lang.RedsBoolean)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