From 9eb3c4fc42c48c7ae13b23809a625be21c64997e Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 9 Apr 2020 12:56:47 +0000 Subject: [PATCH] enhanced a function caller to take a string and find a function to execute it --- hawk/lib/run.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hawk/lib/run.c b/hawk/lib/run.c index 40223c2e..a04b0368 100644 --- a/hawk/lib/run.c +++ b/hawk/lib/run.c @@ -5994,19 +5994,22 @@ static hawk_val_t* eval_fncall_var (hawk_rtx_t* rtx, hawk_nde_t* nde) { hawk_nde_fncall_t* call = (hawk_nde_fncall_t*)nde; hawk_val_t* fv, * rv; + hawk_fun_t* fun; fv = eval_expression(rtx, (hawk_nde_t*)call->u.var.var); if (!fv) return HAWK_NULL; hawk_rtx_refupval (rtx, fv); - if (HAWK_RTX_GETVALTYPE(rtx, fv) != HAWK_VAL_FUN) + fun = hawk_rtx_valtofun(rtx, fv); + if (!fun) { - hawk_rtx_seterrfmt (rtx, &nde->loc, HAWK_ENOTFUN, HAWK_T("non-function value in %.*js"), call->u.var.var->id.name.len, call->u.var.var->id.name.ptr); + if (hawk_rtx_geterrnum(rtx) == HAWK_EINVAL) + hawk_rtx_seterrfmt (rtx, &nde->loc, HAWK_ENOTFUN, HAWK_T("non-function value in %.*js"), call->u.var.var->id.name.len, call->u.var.var->id.name.ptr); rv = HAWK_NULL; + ADJERR_LOC (rtx, &nde->loc); } else { - hawk_fun_t* fun = ((hawk_val_fun_t*)fv)->fun; rv = __eval_call(rtx, nde, fun, push_arg_from_nde, HAWK_NULL, HAWK_NULL, HAWK_NULL); } hawk_rtx_refdownval (rtx, fv);