summaryrefslogtreecommitdiff
path: root/execute.c
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2014-12-30 13:13:30 -0600
committerNicolas Williams <nico@cryptonector.com>2014-12-31 20:09:53 -0600
commitae7f8d6ab9d29bd72f462fdafa4d7a9270706d3b (patch)
tree3be6c09d87619b65f87e13e4bee4cdf24b064639 /execute.c
parent7dc34b92aff7a38e16c0ef608238d03e1ac3d213 (diff)
downloadjq-ae7f8d6ab9d29bd72f462fdafa4d7a9270706d3b.tar.gz
Further module system revamp (fix #659)
To import a module now use: # Import module.jq file: import "relative/path/to/module" as foo; # Use the module's defs as foo::<def-name> To import a JSON file: # Read file.json: import "relative/path/to/file" as $foo; # # Use as $foo::foo Using `-L` now drops the builtin library path and appends the requested path to the empty array (or the result of an earlier `-L`). Support for the `$JQ_LIBRARY_PATH` environment variable has been removed.
Diffstat (limited to 'execute.c')
-rw-r--r--execute.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/execute.c b/execute.c
index 3be6abf..b760a7d 100644
--- a/execute.c
+++ b/execute.c
@@ -508,6 +508,25 @@ jv jq_next(jq_state *jq) {
break;
}
+ case STORE_GLOBAL: {
+ // Get the constant
+ jv val = jv_array_get(jv_copy(frame_current(jq)->bc->constants), *pc++);
+ assert(jv_is_valid(val));
+
+ // Store the var
+ uint16_t level = *pc++;
+ uint16_t v = *pc++;
+ jv* var = frame_local_var(jq, v, level);
+ if (jq->debug_trace_enabled) {
+ printf("V%d = ", v);
+ jv_dump(jv_copy(val), 0);
+ printf(" (%d)\n", jv_get_refcnt(val));
+ }
+ jv_free(*var);
+ *var = val;
+ break;
+ }
+
case PATH_BEGIN: {
jv v = stack_pop(jq);
stack_push(jq, jq->path);