summaryrefslogtreecommitdiffhomepage
path: root/eval.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-10-06 15:49:27 +0200
committerJo-Philipp Wich <jo@mein.io>2020-10-06 15:49:27 +0200
commit5f19e5870007d57034adea5f124e3c87413a1aaf (patch)
tree4efa64ad38b7352e73dc455a441fa1296ee690b4 /eval.c
parent95b9a70d57e05e30a92183921c2c8e8472d56dd8 (diff)
ast, eval: track current file name across function invocations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index e9c797b..881766b 100644
--- a/eval.c
+++ b/eval.c
@@ -1004,6 +1004,7 @@ ut_invoke(struct ut_state *state, uint32_t off, struct json_object *this,
struct json_object *rv = NULL;
struct ut_function *fn;
struct ut_scope *sc;
+ char *filename;
size_t arridx;
ut_c_fn *cfn;
@@ -1022,7 +1023,10 @@ ut_invoke(struct ut_state *state, uint32_t off, struct json_object *this,
fn->scope->ctx = json_object_get(this ? this : state->ctx);
sc = state->scope;
+ filename = state->filename;
+
state->scope = ut_acquire_scope(fn->scope);
+ state->filename = fn->filename;
if (fn->args)
for (arridx = 0; arridx < json_object_array_length(fn->args); arridx++)
@@ -1055,10 +1059,13 @@ ut_invoke(struct ut_state *state, uint32_t off, struct json_object *this,
json_object_put(fn->scope->ctx);
fn->scope->ctx = NULL;
- /* ... and reset the function scope */
+ /* ... and reset the function scope... */
ut_release_scope(fn->scope);
fn->scope = NULL;
+ /* ... and the file name context */
+ state->filename = filename;
+
return rv;
}