summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/EvaluatorResult.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-04-11 17:51:13 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-04-11 17:51:13 -0400
commit40858cee415643769ee5f6216b0cd4335996ff2f (patch)
tree86b1c334fa2e5b79cddc16984f5ad43c3c72e41f /dice-lang/src/bjc/dicelang/EvaluatorResult.java
parent767ca1b248da19b754d42a814b71b43ef16090be (diff)
General cleanup and fixes
Diffstat (limited to 'dice-lang/src/bjc/dicelang/EvaluatorResult.java')
-rw-r--r--dice-lang/src/bjc/dicelang/EvaluatorResult.java306
1 files changed, 210 insertions, 96 deletions
diff --git a/dice-lang/src/bjc/dicelang/EvaluatorResult.java b/dice-lang/src/bjc/dicelang/EvaluatorResult.java
index 276e801..09d7687 100644
--- a/dice-lang/src/bjc/dicelang/EvaluatorResult.java
+++ b/dice-lang/src/bjc/dicelang/EvaluatorResult.java
@@ -1,97 +1,211 @@
-package bjc.dicelang;
-
-import bjc.dicelang.dice.Die;
-import bjc.dicelang.dice.DieExpression;
-import bjc.dicelang.dice.DieList;
-import bjc.utils.data.ITree;
-import bjc.utils.data.Tree;
-
-public class EvaluatorResult {
- public static enum Type {
- FAILURE, INT, FLOAT, DICE, STRING
- }
-
- public final EvaluatorResult.Type type;
-
- // These may or may not have values based
- // off of the result type
- public long intVal;
- public double floatVal;
- public DieExpression diceVal;
- public String stringVal;
-
- // Original node data
- public ITree<Node> origVal;
-
- public EvaluatorResult(EvaluatorResult.Type typ) {
- type = typ;
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, ITree<Node> orig) {
- this(typ);
-
- origVal = orig;
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, Node orig) {
- this(typ, new Tree<>(orig));
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, EvaluatorResult orig) {
- this(typ, new Node(Node.Type.RESULT, orig));
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, long iVal) {
- this(typ);
-
- intVal = iVal;
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, double dVal) {
- this(typ);
-
- floatVal = dVal;
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, DieExpression dVal) {
- this(typ);
-
- diceVal = dVal;
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, Die dVal) {
- this(typ);
-
- diceVal = new DieExpression(dVal);
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, DieList dVal) {
- this(typ);
-
- diceVal = new DieExpression(dVal);
- }
-
- public EvaluatorResult(EvaluatorResult.Type typ, String strang) {
- this(typ);
-
- stringVal = strang;
- }
-
- @Override
- public String toString() {
- switch(type) {
- case INT:
- return type.toString() + "(" + intVal + ")";
- case FLOAT:
- return type.toString() + "(" + floatVal + ")";
- case DICE:
- return type.toString() + "(" + diceVal + ")";
- case STRING:
- return type.toString() + "(" + stringVal + ")";
- case FAILURE:
- return type.toString();
- default:
- return "Unknown result type " + type.toString();
- }
- }
+package bjc.dicelang;
+
+import bjc.dicelang.dice.Die;
+import bjc.dicelang.dice.DieExpression;
+import bjc.dicelang.dice.DieList;
+import bjc.utils.data.ITree;
+import bjc.utils.data.Tree;
+
+/**
+ * The result from the evaluator.
+ *
+ * @author EVE
+ *
+ */
+public class EvaluatorResult {
+ /**
+ * The type of the result.
+ *
+ * @author EVE
+ *
+ */
+ public static enum Type {
+ /**
+ * The type of a failure.
+ */
+ FAILURE,
+ /**
+ * The type of an integer.
+ */
+ INT,
+ /**
+ * The type of a float.
+ */
+ FLOAT,
+ /**
+ * The type of a dice.
+ */
+ DICE,
+ /**
+ * The type of a string.
+ */
+ STRING
+ }
+
+ /**
+ * The type of the result.
+ */
+ public final EvaluatorResult.Type type;
+
+ // These may or may not have values based
+ // off of the result type
+ /**
+ * The integer value of the result.
+ */
+ public long intVal;
+ /**
+ * The float value of the result.
+ */
+ public double floatVal;
+ /**
+ * The dice value of the result.
+ */
+ public DieExpression diceVal;
+ /**
+ * The string value of the result.
+ */
+ public String stringVal;
+
+ /**
+ * Original node data
+ */
+ public ITree<Node> origVal;
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * The type of the result.
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ) {
+ type = typ;
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * The type of the result.
+ *
+ * @param orig
+ * The original value of the result.
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, ITree<Node> orig) {
+ this(typ);
+
+ origVal = orig;
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * The type of the result.
+ *
+ * @param orig
+ * The original value of the result.
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, Node orig) {
+ this(typ, new Tree<>(orig));
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * @param orig
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, EvaluatorResult orig) {
+ this(typ, new Node(Node.Type.RESULT, orig));
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * @param iVal
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, long iVal) {
+ this(typ);
+
+ intVal = iVal;
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * @param dVal
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, double dVal) {
+ this(typ);
+
+ floatVal = dVal;
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * @param dVal
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, DieExpression dVal) {
+ this(typ);
+
+ diceVal = dVal;
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * @param dVal
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, Die dVal) {
+ this(typ);
+
+ diceVal = new DieExpression(dVal);
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * @param dVal
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, DieList dVal) {
+ this(typ);
+
+ diceVal = new DieExpression(dVal);
+ }
+
+ /**
+ * Create a new result.
+ *
+ * @param typ
+ * @param strang
+ */
+ public EvaluatorResult(EvaluatorResult.Type typ, String strang) {
+ this(typ);
+
+ stringVal = strang;
+ }
+
+ @Override
+ public String toString() {
+ switch(type) {
+ case INT:
+ return type.toString() + "(" + intVal + ")";
+ case FLOAT:
+ return type.toString() + "(" + floatVal + ")";
+ case DICE:
+ return type.toString() + "(" + diceVal + ")";
+ case STRING:
+ return type.toString() + "(" + stringVal + ")";
+ case FAILURE:
+ return type.toString();
+ default:
+ return "Unknown result type " + type.toString();
+ }
+ }
} \ No newline at end of file