From d80f404865656b6d1a8faf41cecdd61343adcd0b Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 28 Jul 2016 16:38:59 -0400 Subject: Fixed an issue with instantiating lazy values. Also, work on language impl. notes --- .../main/java/bjc/dicelang/ast/ArithmeticCollapser.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'dice-lang/src/main/java/bjc/dicelang/ast/ArithmeticCollapser.java') diff --git a/dice-lang/src/main/java/bjc/dicelang/ast/ArithmeticCollapser.java b/dice-lang/src/main/java/bjc/dicelang/ast/ArithmeticCollapser.java index 44904e5..7537005 100644 --- a/dice-lang/src/main/java/bjc/dicelang/ast/ArithmeticCollapser.java +++ b/dice-lang/src/main/java/bjc/dicelang/ast/ArithmeticCollapser.java @@ -43,8 +43,7 @@ final class ArithmeticCollapser implements IOperatorCollapser { currentState, accumulatedState) -> { // Force evaluation of accumulated state to prevent // certain bugs from occuring - // @TODO lets see if some of these bugs are fixed - // accumulatedState.merge((l, r) -> null); + //accumulatedState.merge((l, r) -> null); return reduceStates(accumulatedState, currentState); }; @@ -94,6 +93,18 @@ final class ArithmeticCollapser implements IOperatorCollapser { private IPair> doArithmeticCollapse( IResult accumulatedValue, ITree accumulatedTree, IResult currentValue) { + if (accumulatedValue.getType() == ResultType.DUMMY + || currentValue.getType() == ResultType.DUMMY) { + DummyResult result = new DummyResult( + "Found dummy result with either accumulated dummy (" + + ((DummyResult) accumulatedValue).getData() + + ") or current dummy (" + + ((DummyResult) currentValue).getData() + + ")."); + + return new Pair<>(result, accumulatedTree); + } + boolean currentIsInt = currentValue .getType() == ResultType.INTEGER; boolean accumulatedIsInt = accumulatedValue -- cgit v1.2.3