Add LOADVN opcode.

Does a variable load, but sets the variable to be null afterwards.
This commit is contained in:
Stephen Dolan committed 2013-05-16 15:02:18 +01:00
1 parent 919292764a
commit 8fbee891b3
2 files changed
+18

No files matched your search

+17
View File
@@ -311,6 +311,23 @@ jv jq_next(jq_state *jq) {
break; break;
} }
// Does a load but replaces the variable with null
case LOADVN: {
uint16_t level = *pc++;
uint16_t v = *pc++;
frame_ptr fp = frame_get_level(&jq->frame_stk, frame_current(&jq->frame_stk), level);
jv* var = frame_local_var(fp, v);
if (jq->debug_trace_enabled) {
printf("V%d = ", v);
jv_dump(jv_copy(*var), 0);
printf("\n");
}
jv_free(stack_pop(jq));
stack_push(jq, *var);
*var = jv_null();
break;
}
case STOREV: { case STOREV: {
uint16_t level = *pc++; uint16_t level = *pc++;
uint16_t v = *pc++; uint16_t v = *pc++;
+1
View File
@@ -3,6 +3,7 @@ OP(DUP, NONE, 1, 2)
OP(DUP2, NONE, 2, 3) OP(DUP2, NONE, 2, 3)
OP(POP, NONE, 1, 0) OP(POP, NONE, 1, 0)
OP(LOADV, VARIABLE, 1, 1) OP(LOADV, VARIABLE, 1, 1)
OP(LOADVN, VARIABLE, 1, 1)
OP(STOREV, VARIABLE, 1, 0) OP(STOREV, VARIABLE, 1, 0)
OP(INDEX, NONE, 2, 1) OP(INDEX, NONE, 2, 1)
OP(EACH, NONE, 1, 1) OP(EACH, NONE, 1, 1)