aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/vm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytecode/vm.h')
-rw-r--r--src/bytecode/vm.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/bytecode/vm.h b/src/bytecode/vm.h
index d9b37a3..cc9f846 100644
--- a/src/bytecode/vm.h
+++ b/src/bytecode/vm.h
@@ -68,6 +68,31 @@ vm_interpret(VM vm) {
68 Object obj = vm.chunk->constants[constant]; 68 Object obj = vm.chunk->constants[constant];
69 array_push(vm.stack, obj); 69 array_push(vm.stack, obj);
70 } break; 70 } break;
71 case OP_SUM: {
72 Object a = array_pop(vm.stack);
73 Object b = array_pop(vm.stack);
74 array_push(vm.stack, a + b);
75 } break;
76 case OP_SUB: {
77 Object a = array_pop(vm.stack);
78 Object b = array_pop(vm.stack);
79 array_push(vm.stack, a - b);
80 } break;
81 case OP_MUL: {
82 Object a = array_pop(vm.stack);
83 Object b = array_pop(vm.stack);
84 array_push(vm.stack, a * b);
85 } break;
86 case OP_DIV: {
87 Object a = array_pop(vm.stack);
88 Object b = array_pop(vm.stack);
89 array_push(vm.stack, a / b);
90 } break;
91 case OP_MOD: {
92 Object a = array_pop(vm.stack);
93 Object b = array_pop(vm.stack);
94 array_push(vm.stack, a % b);
95 } break;
71 case OP_RETURN: { 96 case OP_RETURN: {
72 display(array_pop(vm.stack)); 97 display(array_pop(vm.stack));
73 printf("\n"); 98 printf("\n");