summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/v1/ast/optimization/ArithmeticCollapser.java
diff options
context:
space:
mode:
Diffstat (limited to 'dice-lang/src/bjc/dicelang/v1/ast/optimization/ArithmeticCollapser.java')
-rw-r--r--dice-lang/src/bjc/dicelang/v1/ast/optimization/ArithmeticCollapser.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/dice-lang/src/bjc/dicelang/v1/ast/optimization/ArithmeticCollapser.java b/dice-lang/src/bjc/dicelang/v1/ast/optimization/ArithmeticCollapser.java
index 0d10a07..9fb0a5e 100644
--- a/dice-lang/src/bjc/dicelang/v1/ast/optimization/ArithmeticCollapser.java
+++ b/dice-lang/src/bjc/dicelang/v1/ast/optimization/ArithmeticCollapser.java
@@ -13,17 +13,15 @@ import bjc.utils.funcdata.IList;
import bjc.utils.data.Tree;
class ArithmeticCollapser {
- private BinaryOperator<Integer> reducer;
- private OperatorDiceNode type;
+ private BinaryOperator<Integer> reducer;
+ private OperatorDiceNode type;
- public ArithmeticCollapser(BinaryOperator<Integer> reducr,
- OperatorDiceNode typ) {
+ public ArithmeticCollapser(BinaryOperator<Integer> reducr, OperatorDiceNode typ) {
reducer = reducr;
this.type = typ;
}
- public ITree<IDiceASTNode> collapse(
- IList<ITree<IDiceASTNode>> children) {
+ public ITree<IDiceASTNode> collapse(IList<ITree<IDiceASTNode>> children) {
boolean allConstant = children.allMatch((subtree) -> {
return subtree.transformHead((node) -> {
if (node.getType() == DiceASTType.LITERAL) {
@@ -40,10 +38,8 @@ class ArithmeticCollapser {
int initState = DiceASTUtils.literalToInteger(children.first());
- return children.tail().reduceAux(initState,
- (currentNode, state) -> {
- return reducer.apply(state,
- DiceASTUtils.literalToInteger(currentNode));
- }, (state) -> new Tree<>(new IntegerLiteralNode(state)));
+ return children.tail().reduceAux(initState, (currentNode, state) -> {
+ return reducer.apply(state, DiceASTUtils.literalToInteger(currentNode));
+ }, (state) -> new Tree<>(new IntegerLiteralNode(state)));
}
}