5b68efd05149d4da8590ed4635f981aba88fe25d
[fur] / templates / arithmetic_instruction.c
1 void {{ name }}(struct Thread* thread, const union Argument argument) {
2   // We're going to reuse result as both the first input and the result
3   assert(!Stack_isEmpty(&(thread->stack)));
4   Object result = Stack_pop(&(thread->stack));
5   assert(result.type == INTEGER);
6
7   assert(!Stack_isEmpty(&(thread->stack)));
8   Object other = Stack_pop(&(thread->stack));
9   assert(other.type == INTEGER);
10
11   result.value.integer = other.value.integer {{ operation }} result.value.integer;
12
13   Stack_push(&(thread->stack), result);
14 }