diff options
Diffstat (limited to 'dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java')
| -rw-r--r-- | dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java b/dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java index 93a75b9..c6aa0a7 100644 --- a/dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java +++ b/dice-lang/src/main/java/bjc/dicelang/IDiceExpression.java @@ -14,4 +14,27 @@ public interface IDiceExpression { * @return The result of rowing the dice */ public int roll(); -} + + /** + * Optimize this expression to a scalar value + * + * @return This expression, optimized to a scalar value + * + * @throws UnsupportedOperationException + * if this type of expression can't be optimized + */ + public default int optimize() { + throw new UnsupportedOperationException( + "Can't optimize this type of expression"); + } + + /** + * Check if this expression can be optimized to a scalar value + * + * @return Whether or not this expression can be optimized to a scalar + * value + */ + public default boolean canOptimize() { + return false; + } +}
\ No newline at end of file |
