diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-04-21 16:54:05 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-04-21 16:54:05 +0200 |
commit | 88caccecf8dd8beaf46915df05241a44f7d635f6 (patch) | |
tree | 7d6db5808b3bdd2453f041fef5c808b8fab36119 /runtime/vm.c | |
parent | 6e410a76f64d74fec03de27a6ca1f3f996844917 (diff) | |
parent | 8e536c5b25ca1a7106f541149cf0d76bdf9237da (diff) | |
download | rsyslog-88caccecf8dd8beaf46915df05241a44f7d635f6.tar.gz rsyslog-88caccecf8dd8beaf46915df05241a44f7d635f6.tar.xz rsyslog-88caccecf8dd8beaf46915df05241a44f7d635f6.zip |
Merge branch 'master' into beta
Conflicts:
ChangeLog
configure.ac
doc/manual.html
Diffstat (limited to 'runtime/vm.c')
-rw-r--r-- | runtime/vm.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/runtime/vm.c b/runtime/vm.c index bc6c3dd2..a25476c2 100644 --- a/runtime/vm.c +++ b/runtime/vm.c @@ -331,6 +331,34 @@ finalize_it: ENDop(PUSHSYSVAR) +/* The function call operation is only very roughly implemented. While the plumbing + * to reach this instruction is fine, the instruction itself currently supports only + * functions with a single argument AND with a name that we know. + * TODO: later, we can add here the real logic, that involves looking up function + * names, loading them dynamically ... and all that... + * implementation begun 2009-03-10 by rgerhards + */ +BEGINop(FUNC_CALL) /* remember to set the instruction also in the ENDop macro! */ + var_t *numOperands; + var_t *operand1; + int iStrlen; +CODESTARTop(FUNC_CALL) + vmstk.PopNumber(pThis->pStk, &numOperands); + if(numOperands->val.num != 1) + ABORT_FINALIZE(RS_RET_INVLD_NBR_ARGUMENTS); + vmstk.PopString(pThis->pStk, &operand1); /* guess there's just one ;) */ + if(!rsCStrSzStrCmp(pOp->operand.pVar->val.pStr, (uchar*) "strlen", 6)) { /* only one supported so far ;) */ +RUNLOG_VAR("%s", rsCStrGetSzStr(operand1->val.pStr)); + iStrlen = strlen((char*) rsCStrGetSzStr(operand1->val.pStr)); +RUNLOG_VAR("%d", iStrlen); + } else + ABORT_FINALIZE(RS_RET_INVLD_FUNC); + PUSHRESULTop(operand1, iStrlen); // TODO: dummy, FIXME + var.Destruct(&numOperands); /* no longer needed */ +finalize_it: +ENDop(FUNC_CALL) + + /* ------------------------------ end instruction set implementation ------------------------------ */ @@ -412,6 +440,7 @@ execProg(vm_t *pThis, vmprg_t *pProg) doOP(DIV); doOP(MOD); doOP(UNARY_MINUS); + doOP(FUNC_CALL); default: ABORT_FINALIZE(RS_RET_INVALID_VMOP); dbgoprint((obj_t*) pThis, "invalid instruction %d in vmprg\n", pCurrOp->opcode); |