diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-20 17:08:27 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-20 17:08:27 +0000 |
commit | 2e0e356584559b1a45bce430f9a92485b5763eac (patch) | |
tree | e85881c5f6adb0a98bf91e3cd2f2e39c53a0bde8 /expr.c | |
parent | cd848d018172b7fac89997a569adc9a01c5953b1 (diff) | |
download | rsyslog-2e0e356584559b1a45bce430f9a92485b5763eac.tar.gz rsyslog-2e0e356584559b1a45bce430f9a92485b5763eac.tar.xz rsyslog-2e0e356584559b1a45bce430f9a92485b5763eac.zip |
used new classes in expr.c
Diffstat (limited to 'expr.c')
-rw-r--r-- | expr.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -163,6 +163,7 @@ val(expr_t *pThis, ctok_t *ctok) /* TODO: this must be a loop! */ dbgprintf("plus/minus\n"); CHKiRet(ctok_tokenDestruct(&pToken)); /* no longer needed */ + // vm: +/-??? CHKiRet(ctokGetToken(ctok, &pToken)); /* get next one */ } else { /* we could not process the token, so push it back */ @@ -170,7 +171,6 @@ val(expr_t *pThis, ctok_t *ctok) } CHKiRet(term(pThis, ctok)); - // vm: +/- finalize_it: RETiRet; @@ -192,10 +192,9 @@ e_cmp(expr_t *pThis, ctok_t *ctok) CHKiRet(ctokGetToken(ctok, &pToken)); if(ctok_tokenIsCmpOp(pToken)) { dbgoprint((obj_t*) pThis, "cmp\n"); - /* fill structure */ - CHKiRet(ctok_tokenDestruct(&pToken)); /* no longer needed */ CHKiRet(val(pThis, ctok)); - // vm: cmpop + CHKiRet(vmprgAddVarOperation(pThis->pVmprg, (opcode_t) pToken->tok, NULL)); /* add to program */ + CHKiRet(ctok_tokenDestruct(&pToken)); /* no longer needed */ } else { /* we could not process the token, so push it back */ CHKiRet(ctokUngetToken(ctok, pToken)); @@ -225,7 +224,7 @@ e_and(expr_t *pThis, ctok_t *ctok) /* fill structure */ CHKiRet(ctok_tokenDestruct(&pToken)); /* no longer needed */ CHKiRet(e_cmp(pThis, ctok)); - // VM: and + CHKiRet(vmprgAddVarOperation(pThis->pVmprg, opcode_AND, NULL)); /* add to program */ CHKiRet(ctokGetToken(ctok, &pToken)); } @@ -257,7 +256,7 @@ expr(expr_t *pThis, ctok_t *ctok) dbgoprint((obj_t*) pThis, "found OR\n"); CHKiRet(ctok_tokenDestruct(&pToken)); /* no longer needed */ CHKiRet(e_and(pThis, ctok)); - // VM: or + CHKiRet(vmprgAddVarOperation(pThis->pVmprg, opcode_OR, NULL)); /* add to program */ CHKiRet(ctokGetToken(ctok, &pToken)); } @@ -298,7 +297,8 @@ rsRetVal exprConstructFinalize(expr_t *pThis) /* destructor for the expr object */ BEGINobjDestruct(expr) /* be sure to specify the object type also in END and CODESTART macros! */ CODESTARTobjDestruct(expr) - /* ... then free resources */ + if(pThis->pVmprg != NULL) + vmprgDestruct(&pThis->pVmprg); ENDobjDestruct(expr) @@ -352,8 +352,14 @@ exprParse(expr_t *pThis, ctok_t *ctok) ISOBJ_TYPE_assert(pThis, expr); ISOBJ_TYPE_assert(ctok, ctok); + /* first, we need to make sure we have a program where we can add to what we parse... */ + CHKiRet(vmprgConstruct(&pThis->pVmprg)); + CHKiRet(vmprgConstructFinalize(pThis->pVmprg)); + + /* happy parsing... */ CHKiRet(expr(pThis, ctok)); dbgoprint((obj_t*) pThis, "successfully parsed/created expression\n"); +vmprgDebugPrint(pThis->pVmprg); finalize_it: RETiRet; |