Implemented integer comparison
[fur] / templates / comparison_instruction.c
diff --git a/templates/comparison_instruction.c b/templates/comparison_instruction.c
new file mode 100644 (file)
index 0000000..dabd905
--- /dev/null
@@ -0,0 +1,15 @@
+void {{ name }}(struct Thread* thread, const union Argument argument) {
+  // We're going to reuse result as both the first input and the result
+  assert(!Stack_isEmpty(&(thread->stack)));
+  Object result = Stack_pop(&(thread->stack));
+  assert(result.type == INTEGER);
+
+  assert(!Stack_isEmpty(&(thread->stack)));
+  Object other = Stack_pop(&(thread->stack));
+  assert(other.type == INTEGER);
+
+  result.type = BOOLEAN;
+  result.value.boolean = other.value.integer {{ operation }} result.value.integer;
+
+  Stack_push(&(thread->stack), result);
+}