summaryrefslogtreecommitdiffstats
path: root/execute.c
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2014-12-28 00:32:06 -0600
committerNicolas Williams <nico@cryptonector.com>2014-12-30 11:42:45 -0600
commit7dc34b92aff7a38e16c0ef608238d03e1ac3d213 (patch)
tree12c5b487c154b3a63d82778731cf5249544884a1 /execute.c
parentcbfc0d6130b784799256f29bb515727df9d894f4 (diff)
Add `label $name | EXP`; fix `break`
This is to fix the problem where `break` is dynamic, not lexical. With this it should be possible to do this sort of thing: label $break | inputs | if ... then $break|error else . end This is a backwards-incompatible change for master, but the previous `break` hadn't shipped yet. Still needed: - testing
Diffstat (limited to 'execute.c')
-rw-r--r--execute.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/execute.c b/execute.c
index 67a1629b..3be6abf3 100644
--- a/execute.c
+++ b/execute.c
@@ -37,6 +37,7 @@ struct jq_state {
int subexp_nest;
int debug_trace_enabled;
int initial_execution;
+ unsigned next_label;
jv attrs;
jq_input_cb input_cb;
@@ -351,6 +352,11 @@ jv jq_next(jq_state *jq) {
break;
}
+ case GENLABEL: {
+ stack_push(jq, JV_OBJECT(jv_string("__jq"), jv_number(jq->next_label++)));
+ break;
+ }
+
case DUP: {
jv v = stack_pop(jq);
stack_push(jq, jv_copy(v));
@@ -838,6 +844,7 @@ jq_state *jq_init(void) {
return NULL;
jq->bc = 0;
+ jq->next_label = 0;
stack_init(&jq->stk);
jq->stk_top = 0;