Add alternation destructuring operator ?//
This is a first pass to show the implementation. It needs tests and evaluation, but doesn't break any existing tests. NOT READY FOR MERGING
This commit is contained in:
1 parent
b142d484d5
commit
3a8c8f4747
7 files changed
+206
-27
No files matched your search
@@ -451,6 +451,15 @@ jv jq_next(jq_state *jq) {
|
||||
break;
|
||||
}
|
||||
|
||||
case PUSHK_UNDER: {
|
||||
jv v = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);
|
||||
assert(jv_is_valid(v));
|
||||
jv v2 = stack_pop(jq);
|
||||
stack_push(jq, v);
|
||||
stack_push(jq, v2);
|
||||
break;
|
||||
}
|
||||
|
||||
case POP: {
|
||||
jv_free(stack_pop(jq));
|
||||
break;
|
||||
@@ -548,6 +557,8 @@ jv jq_next(jq_state *jq) {
|
||||
break;
|
||||
}
|
||||
|
||||
case STOREVN:
|
||||
stack_save(jq, pc - 1, stack_get_pos(jq));
|
||||
case STOREV: {
|
||||
uint16_t level = *pc++;
|
||||
uint16_t v = *pc++;
|
||||
@@ -563,6 +574,16 @@ jv jq_next(jq_state *jq) {
|
||||
break;
|
||||
}
|
||||
|
||||
case ON_BACKTRACK(STOREVN): {
|
||||
uint16_t level = *pc++;
|
||||
uint16_t v = *pc++;
|
||||
jv* var = frame_local_var(jq, v, level);
|
||||
jv_free(*var);
|
||||
*var = jv_null();
|
||||
goto do_backtrack;
|
||||
break;
|
||||
}
|
||||
|
||||
case STORE_GLOBAL: {
|
||||
// Get the constant
|
||||
jv val = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);
|
||||
|
||||
Reference in new issue
Block a user