From 8212af7c70d1603013da32e0501969ed98431caf Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Wed, 11 May 2016 21:10:53 -0400 Subject: Adapt to upstream changes --- .../java/bjc/dicelang/ast/DiceASTEvaluator.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'dice-lang/src/main/java/bjc/dicelang/ast/DiceASTEvaluator.java') diff --git a/dice-lang/src/main/java/bjc/dicelang/ast/DiceASTEvaluator.java b/dice-lang/src/main/java/bjc/dicelang/ast/DiceASTEvaluator.java index 4e7d6fb..d2c127f 100644 --- a/dice-lang/src/main/java/bjc/dicelang/ast/DiceASTEvaluator.java +++ b/dice-lang/src/main/java/bjc/dicelang/ast/DiceASTEvaluator.java @@ -9,8 +9,8 @@ import bjc.utils.data.LazyPair; import bjc.utils.data.Pair; import bjc.utils.funcdata.FunctionalList; import bjc.utils.funcdata.FunctionalMap; -import bjc.utils.funcdata.IFunctionalList; -import bjc.utils.funcdata.IFunctionalMap; +import bjc.utils.funcdata.IList; +import bjc.utils.funcdata.IMap; import bjc.utils.funcdata.ITree; import bjc.utils.funcdata.Tree; @@ -32,7 +32,7 @@ import bjc.dicelang.ast.nodes.VariableDiceNode; */ public class DiceASTEvaluator { private static IResult bindLiteralValue(IDiceASTNode leafNode, - IFunctionalMap> enviroment) { + IMap> enviroment) { String variableName = ((VariableDiceNode) leafNode).getVariable(); if (enviroment.containsKey(variableName)) { @@ -53,9 +53,9 @@ public class DiceASTEvaluator { * The enviroment to evaluate bindings and such against * @return The operations to use when collapsing the AST */ - private static IFunctionalMap buildOperations( - IFunctionalMap> enviroment) { - IFunctionalMap operatorCollapsers = new FunctionalMap<>(); + private static IMap buildOperations( + IMap> enviroment) { + IMap operatorCollapsers = new FunctionalMap<>(); operatorCollapsers.put(OperatorDiceNode.ADD, new ArithmeticCollapser(OperatorDiceNode.ADD, @@ -95,7 +95,7 @@ public class DiceASTEvaluator { // This is so that arrays respect lazy results properly Supplier resultSupplier = () -> { - IFunctionalList resultList = new FunctionalList<>(); + IList resultList = new FunctionalList<>(); nodes.forEach((node) -> { resultList.add(node.getLeft()); @@ -122,7 +122,7 @@ public class DiceASTEvaluator { } private static void doArrayAssign( - IFunctionalMap> enviroment, + IMap> enviroment, IPair> nameNode, ITree nameTree, ITree valueTree, IHolder childCount, ITree child) { @@ -151,8 +151,8 @@ public class DiceASTEvaluator { * @return The integer value of the expression */ public static IResult evaluateAST(ITree expression, - IFunctionalMap> enviroment) { - IFunctionalMap collapsers = buildOperations( + IMap> enviroment) { + IMap collapsers = buildOperations( enviroment); return expression.collapse( @@ -162,7 +162,7 @@ public class DiceASTEvaluator { private static IPair> evaluateLeaf( IDiceASTNode leafNode, - IFunctionalMap> enviroment) { + IMap> enviroment) { ITree returnedAST = new Tree<>(leafNode); switch (leafNode.getType()) { @@ -203,8 +203,8 @@ public class DiceASTEvaluator { } private static IPair> parseBinding( - IFunctionalMap> enviroment, - IFunctionalList>> nodes) { + IMap> enviroment, + IList>> nodes) { if (nodes.getSize() != 2) { throw new UnsupportedOperationException( "Can only bind nodes with two children. Problem children are " @@ -265,7 +265,7 @@ public class DiceASTEvaluator { } private static IPair> parseGroup( - IFunctionalList>> nodes) { + IList>> nodes) { if (nodes.getSize() != 2) { throw new UnsupportedOperationException( "Can only form a group from two dice"); @@ -290,8 +290,8 @@ public class DiceASTEvaluator { } private static IPair> parseLet( - IFunctionalMap> enviroment, - IFunctionalList>> nodes) { + IMap> enviroment, + IList>> nodes) { if (nodes.getSize() != 2) { throw new UnsupportedOperationException( "Can only use let with two expressions."); @@ -301,13 +301,13 @@ public class DiceASTEvaluator { ITree expressionTree = nodes.getByIndex(1) .getRight(); - IFunctionalMap> letEnviroment = enviroment + IMap> letEnviroment = enviroment .extend(); evaluateAST(bindTree, letEnviroment); IResult exprResult = evaluateAST(expressionTree, letEnviroment); - IFunctionalList> childrn = nodes + IList> childrn = nodes .map((pair) -> pair.getRight()); return new Pair<>(exprResult, -- cgit v1.2.3