From d7af27dab45dd6f82c27519e6b4fd2faa162f884 Mon Sep 17 00:00:00 2001 From: student Date: Mon, 12 Feb 2018 11:30:54 -0500 Subject: Refactor SCL token into seperate class --- base/src/bjc/dicelang/Node.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'base/src/bjc/dicelang/Node.java') diff --git a/base/src/bjc/dicelang/Node.java b/base/src/bjc/dicelang/Node.java index 4238cfc..746ba34 100644 --- a/base/src/bjc/dicelang/Node.java +++ b/base/src/bjc/dicelang/Node.java @@ -1,5 +1,9 @@ package bjc.dicelang; +import static bjc.dicelang.EvaluatorResult.Type.FAILURE; + +import bjc.utils.data.ITree; + /* * @TODO 10/09/17 Ben Culkin :NodeReorg * Same thing, different class. Split into subclasses based off of the type @@ -102,4 +106,25 @@ public class Node { public int hashCode() { return super.hashCode(); } + + static Node FAIL(final EvaluatorResult res) { + EvaluatorResult eres = new EvaluatorResult(FAILURE, new Node(Type.RESULT, res)); + return new Node(Type.RESULT, eres); + } + + static Node FAIL(final Node orig) { + return new Node(Type.RESULT, new EvaluatorResult(FAILURE, orig)); + } + + static Node FAIL(final ITree orig) { + return new Node(Type.RESULT, new EvaluatorResult(FAILURE, orig)); + } + + /* @TODO 10/09/17 Ben Culkin :NodeFAIL + * These methods should be moved to Node. + */ + /* Create a failing node. */ + static Node FAIL() { + return new Node(Type.RESULT, new EvaluatorResult(FAILURE)); + } } -- cgit v1.2.3