summaryrefslogtreecommitdiffstats
path: root/vmop.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-02-20 18:54:20 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-02-20 18:54:20 +0000
commit44bb5af7ccef417a1d088527fc02af5f0e8d3dc5 (patch)
tree6a28892a1253b4f199a4f55c64b1a65fbdd38386 /vmop.c
parentfa150f43db5f9673a5b9dfb0727767eca60e4453 (diff)
downloadrsyslog-44bb5af7ccef417a1d088527fc02af5f0e8d3dc5.tar.gz
rsyslog-44bb5af7ccef417a1d088527fc02af5f0e8d3dc5.tar.xz
rsyslog-44bb5af7ccef417a1d088527fc02af5f0e8d3dc5.zip
begun expr compile process, first steps done
Diffstat (limited to 'vmop.c')
-rw-r--r--vmop.c87
1 files changed, 85 insertions, 2 deletions
diff --git a/vmop.c b/vmop.c
index 705a8a12..95e567b7 100644
--- a/vmop.c
+++ b/vmop.c
@@ -58,10 +58,15 @@ CODESTARTobjDestruct(vmop)
ENDobjDestruct(vmop)
-/* destructor for the vmop object */
+/* DebugPrint support for the vmop object */
BEGINobjDebugPrint(vmop) /* be sure to specify the object type also in END and CODESTART macros! */
+ uchar *pOpcodeName;
CODESTARTobjDebugPrint(vmop)
- dbgoprint((obj_t*) pThis, "operation: %d, next %p\n", (int) pThis->opcode, pThis->pNext);
+ vmopOpcode2Str(pThis, &pOpcodeName);
+ dbgoprint((obj_t*) pThis, "opcode: %d\t(%s), next %p, var in next line\n", (int) pThis->opcode, pOpcodeName,
+ pThis->pNext);
+ if(pThis->operand.pVar != NULL)
+ varDebugPrint(pThis->operand.pVar);
ENDobjDebugPrint(vmop)
@@ -92,6 +97,84 @@ vmopSetOpcode(vmop_t *pThis, opcode_t opcode)
}
+/* a way to turn an opcode into a readable string
+ */
+rsRetVal
+vmopOpcode2Str(vmop_t *pThis, uchar **ppName)
+{
+ DEFiRet;
+ ISOBJ_TYPE_assert(pThis, vmop);
+
+ switch(pThis->opcode) {
+ case opcode_OR:
+ *ppName = (uchar*) "or";
+ break;
+ case opcode_AND:
+ *ppName = (uchar*) "and";
+ break;
+ case opcode_PLUS:
+ *ppName = (uchar*) "+";
+ break;
+ case opcode_MINUS:
+ *ppName = (uchar*) "-";
+ break;
+ case opcode_TIMES:
+ *ppName = (uchar*) "*";
+ break;
+ case opcode_DIV:
+ *ppName = (uchar*) "/";
+ break;
+ case opcode_MOD:
+ *ppName = (uchar*) "%";
+ break;
+ case opcode_NOT:
+ *ppName = (uchar*) "not";
+ break;
+ case opcode_CMP_EQ:
+ *ppName = (uchar*) "==";
+ break;
+ case opcode_CMP_NEQ:
+ *ppName = (uchar*) "!=";
+ break;
+ case opcode_CMP_LT:
+ *ppName = (uchar*) "<";
+ break;
+ case opcode_CMP_GT:
+ *ppName = (uchar*) ">";
+ break;
+ case opcode_CMP_LTEQ:
+ *ppName = (uchar*) "<=";
+ break;
+ case opcode_CMP_CONTAINS:
+ *ppName = (uchar*) "contains";
+ break;
+ case opcode_CMP_STARTSWITH:
+ *ppName = (uchar*) "startswith";
+ break;
+ case opcode_CMP_GTEQ:
+ *ppName = (uchar*) ">=";
+ break;
+ case opcode_PUSHSYSVAR:
+ *ppName = (uchar*) "PUSHSYSVAR";
+ break;
+ case opcode_PUSHMSGVAR:
+ *ppName = (uchar*) "PUSHMSGVAR";
+ break;
+ case opcode_PUSHCONSTANT:
+ *ppName = (uchar*) "PUSHCONSTANT";
+ break;
+ case opcode_POP:
+ *ppName = (uchar*) "";
+ break;
+ default:
+ *ppName = (uchar*) "INVALID opcode";
+ break;
+ }
+
+ RETiRet;
+}
+
+
/* Initialize the vmop class. Must be called as the very first method
* before anything else is called inside this class.
* rgerhards, 2008-02-19