diff options
-rw-r--r-- | src/primitives/eval.d | 4 | ||||
-rw-r--r-- | src/primitives/impl.d | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/primitives/eval.d b/src/primitives/eval.d index 3f91e80..3f52e6d 100644 --- a/src/primitives/eval.d +++ b/src/primitives/eval.d @@ -42,6 +42,10 @@ bool evaluate(string word) { return unary_op_stack_dup; case "swp": return binary_op_stack_swp; + case "<": + return binary_cond_lt; + case "=": + return binary_cond_eq; default: return false; } diff --git a/src/primitives/impl.d b/src/primitives/impl.d index 4ec9019..56ea4ce 100644 --- a/src/primitives/impl.d +++ b/src/primitives/impl.d @@ -117,3 +117,19 @@ bool binary_op_stack_swp() { return true; } + +bool binary_cond_lt() { + int b = stack.pop.get!int; + int a = stack.pop.get!int; + + stack.push(a < b); + return true; +} + +bool binary_cond_eq() { + int b = stack.pop.get!int; + int a = stack.pop.get!int; + + stack.push(a == b); + return true; +} |