Commit 74bb5b37 authored by Sarah Grebing's avatar Sarah Grebing
Browse files

fixed own introduced bug

parent c6f8d090
Pipeline #10613 passed with stage
in 1 minute and 59 seconds
......@@ -146,24 +146,30 @@ public class Interpreter<T> extends DefaultASTVisitor<T> {
List<CaseStatement> cases = casesStatement.getCases();
Iterator<CaseStatement> casesIter = cases.iterator();
while (casesIter.hasNext()) {
//get information for case
CaseStatement currentCase =;
Expression guard = currentCase.getGuard();
Statements body = currentCase.getBody();
Iterator<GoalNode> goalIter = copiedList.iterator();
Set<GoalNode> forCase = new HashSet<>();
//iterate over all available goals and select those that evaluate to true with the guard
//assumption, matchpattern handles varAssignments
while (goalIter.hasNext()) {
GoalNode g =;
Evaluator goalEval = new Evaluator(g);
Value eval = goalEval.eval(guard);
if (eval.getData().equals(Value.TRUE)) {
if (eval.getData().equals(true)) {
// if (eval.getData().equals(Value.TRUE)) {
//for each selected goal put a state onto tze stack and visit the body of the case
Iterator<GoalNode> caseGoals = forCase.iterator();
while (caseGoals.hasNext()) {
GoalNode current =;
......@@ -172,16 +178,19 @@ public class Interpreter<T> extends DefaultASTVisitor<T> {
State s = new State(goalList, current);
//after executing the body collect the newly created goals form the stack and remove the state
State aftercase = (State) stateStack.pop();
//jetzt body auswerten mit der Liste der Ziele
//for all remaining goals execute default
if (!copiedList.isEmpty()) {
Statements defaultCase = casesStatement.getDefaultCase();
//exit scope
//exit scope and create a new state using the union of all newly created goals
State newStateAfterCases;
if (!goalsAfterCases.isEmpty()) {
......@@ -40,11 +40,11 @@ public class Value<T> {
public static Value<Boolean> from(BooleanLiteral b) {
return new Value(Type.BOOL, (b.isValue() ? Value.TRUE : Value.FALSE));
return new Value(Type.BOOL, b.isValue());
public static Value<Boolean> from(boolean equals) {
return new Value(Type.BOOL, (equals ? Value.TRUE : Value.FALSE));
return new Value(Type.BOOL, equals);
public static Value<BigInteger> from(BigInteger apply) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment