aboutsummaryrefslogtreecommitdiffstats
path: root/interpret.h
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-09-04 09:49:44 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-09-04 09:49:44 +0300
commit7448f28d356fc5cd8d9117111baea3a549e0930e (patch)
treef24d82d8b121d8321cfc0366dabad236d3f3dac3 /interpret.h
parenta205df7903bce201577df4f7049c190e283f1ea4 (diff)
parent8beb9796b17b6ca48eb62df8fd3d31421e43c761 (diff)
downloadegawk-7448f28d356fc5cd8d9117111baea3a549e0930e.tar.gz
egawk-7448f28d356fc5cd8d9117111baea3a549e0930e.tar.bz2
egawk-7448f28d356fc5cd8d9117111baea3a549e0930e.zip
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'interpret.h')
-rw-r--r--interpret.h42
1 files changed, 36 insertions, 6 deletions
diff --git a/interpret.h b/interpret.h
index be017355..fee8136e 100644
--- a/interpret.h
+++ b/interpret.h
@@ -1039,13 +1039,42 @@ match_re:
}
if (f == NULL) {
- /* FIXME: See if function is a built-in and try to call it */
- fatal(_("`%s' is not a user-defined function, so it cannot be called indirectly"),
+ int arg_count = (pc + 1)->expr_count;
+ builtin_func_t the_func = lookup_builtin(t1->stptr);
+
+ if (the_func == NULL)
+ fatal(_("`%s' is not a user-defined function, so it cannot be called indirectly"),
t1->stptr);
- } else if(f->type != Node_func) {
- if (f->type == Node_ext_func || f->type == Node_old_ext_func)
- fatal(_("cannot (yet) call extension functions indirectly"));
- else
+
+ /* call it */
+ r = the_func(arg_count);
+ PUSH(r);
+ break;
+ } else if (f->type != Node_func) {
+ if ( f->type == Node_ext_func
+ || f->type == Node_old_ext_func) {
+ /* code copied from below, keep in sync */
+ INSTRUCTION *bc;
+ char *fname = pc->func_name;
+ int arg_count = (pc + 1)->expr_count;
+ static INSTRUCTION npc[2];
+
+ npc[0] = *pc;
+
+ bc = f->code_ptr;
+ assert(bc->opcode == Op_symbol);
+ if (f->type == Node_ext_func)
+ npc[0].opcode = Op_ext_builtin; /* self modifying code */
+ else
+ npc[0].opcode = Op_old_ext_builtin; /* self modifying code */
+ npc[0].extfunc = bc->extfunc;
+ npc[0].expr_count = arg_count; /* actual argument count */
+ npc[1] = pc[1];
+ npc[1].func_name = fname; /* name of the builtin */
+ npc[1].expr_count = bc->expr_count; /* defined max # of arguments */
+ ni = npc;
+ JUMPTO(ni);
+ } else
fatal(_("function called indirectly through `%s' does not exist"),
pc->func_name);
}
@@ -1069,6 +1098,7 @@ match_re:
}
if (f->type == Node_ext_func || f->type == Node_old_ext_func) {
+ /* keep in sync with indirect call code */
INSTRUCTION *bc;
char *fname = pc->func_name;
int arg_count = (pc + 1)->expr_count;