diff options
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -111,6 +111,12 @@ int runvm(State *S) { break; } + case OP_GETLOCAL: { + uint8_t lidx = RBYTE(); + PUSH(th->stack[lidx]); + break; + } + #define BINARY_OP(opcode, OP, RET_TYPE) \ case opcode: { \ Val b = POP(); \ @@ -148,8 +154,8 @@ int runvm(State *S) { goto done; } PUSH(VAL_NUM(fmod(AS_NUM(a), AS_NUM(b)))); - } break; + } case OP_NIL: PUSH(VAL_NIL); break; @@ -173,8 +179,16 @@ int runvm(State *S) { th->ch = &func->ch; th->ip = 0; + break; + } + + case OP_ENDSCOPE: { + uint8_t nlocals = RBYTE(); + Val retval = POP(); + th->sp -= nlocals; + PUSH(retval); + break; } - break; case OP_RET: { StackFrame *sf = &th->rstack[--th->rsp]; |