diff options
-rw-r--r-- | eval.c | 4 | ||||
-rw-r--r-- | lexer.h | 3 | ||||
-rw-r--r-- | lib.c | 4 |
3 files changed, 6 insertions, 5 deletions
@@ -811,7 +811,7 @@ ut_invoke(struct ut_state *state, struct ut_opcode *op, struct json_object *scop return NULL; /* is native function */ - if (json_object_get_boolean(func)) { + if (decl->type == T_CFUNC) { cfn = (ut_c_fn *)decl->operand[0]; return cfn ? cfn(state, op, argvals) : NULL; @@ -866,7 +866,7 @@ ut_execute_call(struct ut_state *state, struct ut_opcode *op) struct json_object *rv; char *lhs; - if (!decl || decl->type != T_FUNC) { + if (!decl || (decl->type != T_FUNC && decl->type != T_CFUNC)) { lhs = ut_ref_to_str(op->operand[0]); rv = ut_exception(state, op->operand[0], "Type error: %s is not a function", @@ -20,7 +20,8 @@ #include "ast.h" #define __T_MAX 69 -#define T_EXCEPTION (__T_MAX + 0) +#define T_EXCEPTION (__T_MAX + 0) +#define T_CFUNC (__T_MAX + 1) extern const char *tokennames[__T_MAX]; @@ -1609,8 +1609,8 @@ func_to_string(struct json_object *v, struct printbuf *pb, int level, int flags) static bool add_function(struct ut_state *state, struct json_object *scope, const char *name, ut_c_fn *fn) { - struct ut_opcode *op = ut_new_op(state, T_FUNC, - json_object_new_boolean(1), (struct ut_opcode *)fn, (void *)1); + struct ut_opcode *op = ut_new_op(state, T_CFUNC, + json_object_new_boolean(0), (struct ut_opcode *)fn, (void *)1); json_object_set_serializer(op->val, func_to_string, op, NULL); |