diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2018-09-14 23:00:39 +0000 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-02-28 00:38:24 +0100 |
commit | ec3a86b8a0ccf8e499c15eed8e873d2a62959a13 (patch) | |
tree | ad2f17e2a2eec2bc9410e1e967de1ff1fe85aaec /filter/filter.c | |
parent | 7c36eb3e8bd7d06f65dc7319d42b6abe782c5b89 (diff) |
WIP native functionnative/native-function
Diffstat (limited to 'filter/filter.c')
-rw-r--r-- | filter/filter.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/filter/filter.c b/filter/filter.c index 37cf16a3..88da05b4 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -610,7 +610,8 @@ static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS; #define INTERPRET(val, what_) \ val = interpret(what_); \ - if (val.type & T_RETURN) \ + debug("INTERPRET %d\n", val.type); \ + if (val.type & T_RETURN) \ return val; #define ACCESS_RTE \ @@ -886,8 +887,10 @@ interpret(struct f_inst *what) res.val.t = what->a2.p; else if (res.type == T_STRING) res.val.s = what->a2.p; - else + else { res.val.i = what->a2.i; + debug("FI_CONSTANT %d\n", res.val.i); + } break; case FI_VARIABLE: case FI_CONSTANT_INDIRECT: @@ -1309,6 +1312,15 @@ interpret(struct f_inst *what) return res; res.type &= ~T_RETURN; break; + case FI_CALL_NATIVE: /* CALL: this is special: if T_RETURN and returning some value, mask it out */ + ARG_ANY(1); + debug("**********************foobar1**************************%d %x\n", v1.type, v1.val.s); + struct f_val (*f)(void) = what->a2.p; + res = f(); + if (res.type == T_RETURN) + return res; + res.type &= ~T_RETURN; + break; case FI_CLEAR_LOCAL_VARS: /* Clear local variables */ for (sym = what->a1.p; sym != NULL; sym = sym->aux2) ((struct f_val *) sym->def)->type = T_VOID; @@ -1578,6 +1590,7 @@ interpret(struct f_inst *what) default: bug( "Unknown instruction %d (%c)", what->fi_code, what->fi_code & 0xff); }} + debug("return %d\n", res.type); return res; } |