From 12bb6730791e2f91a93279c742e94f29945caef6 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 2 Sep 2020 22:11:02 +0200 Subject: eval, lib: use tagged JSON objects to register C functions Signed-off-by: Jo-Philipp Wich --- eval.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index c7012d8..e47b395 100644 --- a/eval.c +++ b/eval.c @@ -806,8 +806,8 @@ ut_invoke(struct ut_state *state, struct ut_opcode *op, struct json_object *scop { struct ut_opcode *decl = json_object_get_userdata(func); struct ut_opcode *arg = decl ? decl->operand[1] : NULL; + struct ut_tagvalue *tag = (struct ut_tagvalue *)decl; struct json_object *s, *rv = NULL; - struct ut_opcode *tag; size_t arridx; ut_c_fn *cfn; @@ -815,8 +815,8 @@ ut_invoke(struct ut_state *state, struct ut_opcode *op, struct json_object *scop return NULL; /* is native function */ - if (decl->type == T_CFUNC) { - cfn = (ut_c_fn *)decl->operand[0]; + if (tag->type == T_CFUNC) { + cfn = (ut_c_fn *)tag->data; return cfn ? cfn(state, op, argvals) : NULL; } @@ -838,7 +838,7 @@ ut_invoke(struct ut_state *state, struct ut_opcode *op, struct json_object *scop case T_BREAK: case T_CONTINUE: ut_putval(rv); - rv = ut_exception(state, tag, "Syntax error: %s statement must be inside loop", + rv = ut_exception(state, (struct ut_opcode *)tag, "Syntax error: %s statement must be inside loop", tokennames[tag->type]); break; -- cgit v1.2.3