~ubuntu-branches/ubuntu/karmic/rsyslog/karmic

« back to all changes in this revision

Viewing changes to vm.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2009-04-08 00:59:14 UTC
  • mfrom: (1.1.9 upstream) (3.2.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090408005914-gfyay7o45szt05zl
Tags: 3.20.5-1
* New upstream release.
* debian/rsyslog.logcheck.ignore.server
  - Install a logcheck ignore file for rsyslog (using dh_installlogcheck).
    Thanks to Kim Holviala for the patch. Closes: #522164

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* vm.c - the arithmetic stack of a virtual machine.
2
 
 *
3
 
 * Module begun 2008-02-22 by Rainer Gerhards
4
 
 *
5
 
 * Copyright 2008 Rainer Gerhards and Adiscon GmbH.
6
 
 *
7
 
 * This file is part of the rsyslog runtime library.
8
 
 *
9
 
 * The rsyslog runtime library is free software: you can redistribute it and/or modify
10
 
 * it under the terms of the GNU Lesser General Public License as published by
11
 
 * the Free Software Foundation, either version 3 of the License, or
12
 
 * (at your option) any later version.
13
 
 *
14
 
 * The rsyslog runtime library is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU Lesser General Public License for more details.
18
 
 *
19
 
 * You should have received a copy of the GNU Lesser General Public License
20
 
 * along with the rsyslog runtime library.  If not, see <http://www.gnu.org/licenses/>.
21
 
 *
22
 
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
23
 
 * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
24
 
 */
25
 
 
26
 
#include "config.h"
27
 
#include <stdlib.h>
28
 
#include <assert.h>
29
 
 
30
 
#include "rsyslog.h"
31
 
#include "obj.h"
32
 
#include "vm.h"
33
 
#include "sysvar.h"
34
 
#include "stringbuf.h"
35
 
 
36
 
/* static data */
37
 
DEFobjStaticHelpers
38
 
DEFobjCurrIf(vmstk)
39
 
DEFobjCurrIf(var)
40
 
DEFobjCurrIf(sysvar)
41
 
 
42
 
 
43
 
/* ------------------------------ instruction set implementation ------------------------------ *
44
 
 * The following functions implement the VM's instruction set.
45
 
 */
46
 
#define BEGINop(instruction) \
47
 
        static rsRetVal op##instruction(vm_t *pThis, __attribute__((unused)) vmop_t *pOp) \
48
 
        { \
49
 
                DEFiRet;
50
 
 
51
 
#define CODESTARTop(instruction) \
52
 
                ISOBJ_TYPE_assert(pThis, vm);
53
 
 
54
 
#define PUSHRESULTop(operand, res) \
55
 
        /* we have a result, so let's push it */ \
56
 
        var.SetNumber(operand, res); \
57
 
        vmstk.Push(pThis->pStk, operand); /* result */
58
 
 
59
 
#define ENDop(instruction) \
60
 
                RETiRet; \
61
 
        }
62
 
 
63
 
/* code generator for boolean operations */
64
 
#define BOOLOP(name, OPERATION) \
65
 
BEGINop(name) /* remember to set the instruction also in the ENDop macro! */ \
66
 
        var_t *operand1; \
67
 
        var_t *operand2; \
68
 
CODESTARTop(name) \
69
 
        vmstk.PopBool(pThis->pStk, &operand1); \
70
 
        vmstk.PopBool(pThis->pStk, &operand2); \
71
 
        if(operand1->val.num OPERATION operand2->val.num) { \
72
 
                CHKiRet(var.SetNumber(operand1, 1)); \
73
 
        } else { \
74
 
                CHKiRet(var.SetNumber(operand1, 0)); \
75
 
        } \
76
 
        vmstk.Push(pThis->pStk, operand1); /* result */ \
77
 
        var.Destruct(&operand2); /* no longer needed */ \
78
 
finalize_it: \
79
 
ENDop(name)
80
 
BOOLOP(OR,  ||)
81
 
BOOLOP(AND, &&)
82
 
#undef BOOLOP
83
 
 
84
 
 
85
 
/* code generator for numerical operations */
86
 
#define NUMOP(name, OPERATION) \
87
 
BEGINop(name) /* remember to set the instruction also in the ENDop macro! */ \
88
 
        var_t *operand1; \
89
 
        var_t *operand2; \
90
 
CODESTARTop(name) \
91
 
        vmstk.PopNumber(pThis->pStk, &operand1); \
92
 
        vmstk.PopNumber(pThis->pStk, &operand2); \
93
 
        operand1->val.num = operand1->val.num OPERATION operand2->val.num; \
94
 
        vmstk.Push(pThis->pStk, operand1); /* result */ \
95
 
        var.Destruct(&operand2); /* no longer needed */ \
96
 
ENDop(name)
97
 
NUMOP(PLUS,   +)
98
 
NUMOP(MINUS,  -)
99
 
NUMOP(TIMES,  *)
100
 
NUMOP(DIV,    /)
101
 
NUMOP(MOD,    %)
102
 
#undef BOOLOP
103
 
 
104
 
 
105
 
/* code generator for compare operations */
106
 
#define BEGINCMPOP(name) \
107
 
BEGINop(name) \
108
 
        var_t *operand1; \
109
 
        var_t *operand2; \
110
 
        number_t bRes; \
111
 
CODESTARTop(name) \
112
 
        CHKiRet(vmstk.Pop2CommOp(pThis->pStk, &operand1, &operand2)); \
113
 
        /* data types are equal (so we look only at operand1), but we must \
114
 
         * check which type we have to deal with... \
115
 
         */ \
116
 
        switch(operand1->varType) {
117
 
#define ENDCMPOP(name) \
118
 
                default: \
119
 
                        bRes = 0; /* we do not abort just so that we have a value. TODO: reconsider */ \
120
 
                        break; \
121
 
        } \
122
 
 \
123
 
        /* we have a result, so let's push it */ \
124
 
        var.SetNumber(operand1, bRes); \
125
 
        vmstk.Push(pThis->pStk, operand1); /* result */ \
126
 
        var.Destruct(&operand2); /* no longer needed */ \
127
 
finalize_it: \
128
 
ENDop(name)
129
 
 
130
 
BEGINCMPOP(CMP_EQ) /* remember to change the name also in the END macro! */
131
 
        case VARTYPE_NUMBER:
132
 
                bRes = operand1->val.num == operand2->val.num;
133
 
                break;
134
 
        case VARTYPE_STR:
135
 
                bRes = !rsCStrCStrCmp(operand1->val.pStr, operand2->val.pStr);
136
 
                break;
137
 
ENDCMPOP(CMP_EQ)
138
 
 
139
 
BEGINCMPOP(CMP_NEQ) /* remember to change the name also in the END macro! */
140
 
        case VARTYPE_NUMBER:
141
 
                bRes = operand1->val.num != operand2->val.num;
142
 
                break;
143
 
        case VARTYPE_STR:
144
 
                bRes = rsCStrCStrCmp(operand1->val.pStr, operand2->val.pStr);
145
 
                break;
146
 
ENDCMPOP(CMP_EQ)
147
 
 
148
 
BEGINCMPOP(CMP_LT) /* remember to change the name also in the END macro! */
149
 
        case VARTYPE_NUMBER:
150
 
                bRes = operand1->val.num < operand2->val.num;
151
 
                break;
152
 
        case VARTYPE_STR:
153
 
                bRes = rsCStrCStrCmp(operand1->val.pStr, operand2->val.pStr) < 0;
154
 
                break;
155
 
ENDCMPOP(CMP_LT)
156
 
 
157
 
BEGINCMPOP(CMP_GT) /* remember to change the name also in the END macro! */
158
 
        case VARTYPE_NUMBER:
159
 
                bRes = operand1->val.num > operand2->val.num;
160
 
                break;
161
 
        case VARTYPE_STR:
162
 
                bRes = rsCStrCStrCmp(operand1->val.pStr, operand2->val.pStr) > 0;
163
 
                break;
164
 
ENDCMPOP(CMP_GT)
165
 
 
166
 
BEGINCMPOP(CMP_LTEQ) /* remember to change the name also in the END macro! */
167
 
        case VARTYPE_NUMBER:
168
 
                bRes = operand1->val.num <= operand2->val.num;
169
 
                break;
170
 
        case VARTYPE_STR:
171
 
                bRes = rsCStrCStrCmp(operand1->val.pStr, operand2->val.pStr) <= 0;
172
 
                break;
173
 
ENDCMPOP(CMP_LTEQ)
174
 
 
175
 
BEGINCMPOP(CMP_GTEQ) /* remember to change the name also in the END macro! */
176
 
        case VARTYPE_NUMBER:
177
 
                bRes = operand1->val.num >= operand2->val.num;
178
 
                break;
179
 
        case VARTYPE_STR:
180
 
                bRes = rsCStrCStrCmp(operand1->val.pStr, operand2->val.pStr) >= 0;
181
 
                break;
182
 
ENDCMPOP(CMP_GTEQ)
183
 
 
184
 
#undef BEGINCMPOP
185
 
#undef ENDCMPOP
186
 
/* end regular compare operations */
187
 
 
188
 
/* comare operations that work on strings, only */
189
 
BEGINop(CMP_CONTAINS) /* remember to set the instruction also in the ENDop macro! */
190
 
        var_t *operand1;
191
 
        var_t *operand2;
192
 
        number_t bRes;
193
 
CODESTARTop(CMP_CONTAINS)
194
 
        /* operand2 is on top of stack, so needs to be popped first */
195
 
        vmstk.PopString(pThis->pStk, &operand2);
196
 
        vmstk.PopString(pThis->pStk, &operand1);
197
 
        /* TODO: extend cstr class so that it supports location of cstr inside cstr */
198
 
        bRes = (rsCStrLocateInSzStr(operand2->val.pStr, rsCStrGetSzStr(operand1->val.pStr)) == -1) ? 0 : 1;
199
 
 
200
 
        /* we have a result, so let's push it */
201
 
RUNLOG_VAR("%lld", bRes); \
202
 
        PUSHRESULTop(operand1, bRes);
203
 
        var.Destruct(&operand2); /* no longer needed */
204
 
ENDop(CMP_CONTAINS)
205
 
 
206
 
 
207
 
BEGINop(CMP_CONTAINSI) /* remember to set the instruction also in the ENDop macro! */
208
 
        var_t *operand1;
209
 
        var_t *operand2;
210
 
        number_t bRes;
211
 
CODESTARTop(CMP_CONTAINSI)
212
 
        /* operand2 is on top of stack, so needs to be popped first */
213
 
        vmstk.PopString(pThis->pStk, &operand2);
214
 
        vmstk.PopString(pThis->pStk, &operand1);
215
 
var.DebugPrint(operand1); \
216
 
var.DebugPrint(operand2); \
217
 
        /* TODO: extend cstr class so that it supports location of cstr inside cstr */
218
 
        bRes = (rsCStrCaseInsensitiveLocateInSzStr(operand2->val.pStr, rsCStrGetSzStr(operand1->val.pStr)) == -1) ? 0 : 1;
219
 
 
220
 
        /* we have a result, so let's push it */
221
 
RUNLOG_VAR("%lld", bRes); \
222
 
        PUSHRESULTop(operand1, bRes);
223
 
        var.Destruct(&operand2); /* no longer needed */
224
 
ENDop(CMP_CONTAINSI)
225
 
 
226
 
 
227
 
BEGINop(CMP_STARTSWITH) /* remember to set the instruction also in the ENDop macro! */
228
 
        var_t *operand1;
229
 
        var_t *operand2;
230
 
        number_t bRes;
231
 
CODESTARTop(CMP_STARTSWITH)
232
 
        /* operand2 is on top of stack, so needs to be popped first */
233
 
        vmstk.PopString(pThis->pStk, &operand2);
234
 
        vmstk.PopString(pThis->pStk, &operand1);
235
 
        /* TODO: extend cstr class so that it supports location of cstr inside cstr */
236
 
        bRes = (rsCStrStartsWithSzStr(operand1->val.pStr, rsCStrGetSzStr(operand2->val.pStr),
237
 
                rsCStrLen(operand2->val.pStr)) == 0) ? 1 : 0;
238
 
 
239
 
        /* we have a result, so let's push it */
240
 
RUNLOG_VAR("%lld", bRes); \
241
 
        PUSHRESULTop(operand1, bRes);
242
 
        var.Destruct(&operand2); /* no longer needed */
243
 
ENDop(CMP_STARTSWITH)
244
 
 
245
 
 
246
 
BEGINop(CMP_STARTSWITHI) /* remember to set the instruction also in the ENDop macro! */
247
 
        var_t *operand1;
248
 
        var_t *operand2;
249
 
        number_t bRes;
250
 
CODESTARTop(CMP_STARTSWITHI)
251
 
        /* operand2 is on top of stack, so needs to be popped first */
252
 
        vmstk.PopString(pThis->pStk, &operand2);
253
 
        vmstk.PopString(pThis->pStk, &operand1);
254
 
        /* TODO: extend cstr class so that it supports location of cstr inside cstr */
255
 
        bRes = (rsCStrCaseInsensitveStartsWithSzStr(operand1->val.pStr, rsCStrGetSzStr(operand2->val.pStr),
256
 
                rsCStrLen(operand2->val.pStr)) == 0) ? 1 : 0;
257
 
 
258
 
        /* we have a result, so let's push it */
259
 
        PUSHRESULTop(operand1, bRes);
260
 
        var.Destruct(&operand2); /* no longer needed */
261
 
ENDop(CMP_STARTSWITHI)
262
 
 
263
 
/* end comare operations that work on strings, only */
264
 
 
265
 
BEGINop(STRADD) /* remember to set the instruction also in the ENDop macro! */
266
 
        var_t *operand1;
267
 
        var_t *operand2;
268
 
CODESTARTop(STRADD)
269
 
        vmstk.PopString(pThis->pStk, &operand2);
270
 
        vmstk.PopString(pThis->pStk, &operand1);
271
 
 
272
 
        CHKiRet(rsCStrAppendCStr(operand1->val.pStr, operand2->val.pStr));
273
 
 
274
 
        /* we have a result, so let's push it */
275
 
        vmstk.Push(pThis->pStk, operand1);
276
 
        var.Destruct(&operand2); /* no longer needed */
277
 
finalize_it:
278
 
ENDop(STRADD)
279
 
 
280
 
BEGINop(NOT) /* remember to set the instruction also in the ENDop macro! */
281
 
        var_t *operand;
282
 
CODESTARTop(NOT)
283
 
        vmstk.PopBool(pThis->pStk, &operand);
284
 
        PUSHRESULTop(operand, !operand->val.num);
285
 
ENDop(NOT)
286
 
 
287
 
BEGINop(UNARY_MINUS) /* remember to set the instruction also in the ENDop macro! */
288
 
        var_t *operand;
289
 
CODESTARTop(UNARY_MINUS)
290
 
        vmstk.PopNumber(pThis->pStk, &operand);
291
 
        PUSHRESULTop(operand, -operand->val.num);
292
 
ENDop(UNARY_MINUS)
293
 
 
294
 
 
295
 
BEGINop(PUSHCONSTANT) /* remember to set the instruction also in the ENDop macro! */
296
 
        var_t *pVarDup;   /* we need to duplicate the var, as we need to hand it over */
297
 
CODESTARTop(PUSHCONSTANT)
298
 
        CHKiRet(var.Duplicate(pOp->operand.pVar, &pVarDup));
299
 
        vmstk.Push(pThis->pStk, pVarDup);
300
 
finalize_it:
301
 
ENDop(PUSHCONSTANT)
302
 
 
303
 
 
304
 
BEGINop(PUSHMSGVAR) /* remember to set the instruction also in the ENDop macro! */
305
 
        var_t *pVal; /* the value to push */
306
 
        cstr_t *pstrVal;
307
 
CODESTARTop(PUSHMSGVAR)
308
 
        if(pThis->pMsg == NULL) {
309
 
                /* TODO: flag an error message! As a work-around, we permit
310
 
                 * execution to continue here with an empty string
311
 
                 */
312
 
                /* TODO: create a method in var to create a string var? */
313
 
                CHKiRet(var.Construct(&pVal));
314
 
                CHKiRet(var.ConstructFinalize(pVal));
315
 
                CHKiRet(rsCStrConstructFromszStr(&pstrVal, (uchar*)""));
316
 
                CHKiRet(var.SetString(pVal, pstrVal));
317
 
        } else {
318
 
                /* we have a message, so pull value from there */
319
 
                CHKiRet(msgGetMsgVar(pThis->pMsg, pOp->operand.pVar->val.pStr, &pVal));
320
 
        }
321
 
 
322
 
        /* if we reach this point, we have a valid pVal and can push it */
323
 
        vmstk.Push(pThis->pStk, pVal);
324
 
finalize_it:
325
 
ENDop(PUSHMSGVAR)
326
 
 
327
 
 
328
 
BEGINop(PUSHSYSVAR) /* remember to set the instruction also in the ENDop macro! */
329
 
        var_t *pVal; /* the value to push */
330
 
CODESTARTop(PUSHSYSVAR)
331
 
        CHKiRet(sysvar.GetVar(pOp->operand.pVar->val.pStr, &pVal));
332
 
        vmstk.Push(pThis->pStk, pVal);
333
 
finalize_it:
334
 
ENDop(PUSHSYSVAR)
335
 
 
336
 
 
337
 
/* ------------------------------ end instruction set implementation ------------------------------ */
338
 
 
339
 
 
340
 
/* Standard-Constructor
341
 
 */
342
 
BEGINobjConstruct(vm) /* be sure to specify the object type also in END macro! */
343
 
ENDobjConstruct(vm)
344
 
 
345
 
 
346
 
/* ConstructionFinalizer
347
 
 * rgerhards, 2008-01-09
348
 
 */
349
 
static rsRetVal
350
 
vmConstructFinalize(vm_t __attribute__((unused)) *pThis)
351
 
{
352
 
        DEFiRet;
353
 
        ISOBJ_TYPE_assert(pThis, vm);
354
 
        
355
 
        CHKiRet(vmstk.Construct(&pThis->pStk));
356
 
        CHKiRet(vmstk.ConstructFinalize(pThis->pStk));
357
 
 
358
 
finalize_it:
359
 
        RETiRet;
360
 
}
361
 
 
362
 
 
363
 
/* destructor for the vm object */
364
 
BEGINobjDestruct(vm) /* be sure to specify the object type also in END and CODESTART macros! */
365
 
CODESTARTobjDestruct(vm)
366
 
        if(pThis->pStk != NULL)
367
 
                vmstk.Destruct(&pThis->pStk);
368
 
        if(pThis->pMsg != NULL)
369
 
                msgDestruct(&pThis->pMsg);
370
 
ENDobjDestruct(vm)
371
 
 
372
 
 
373
 
/* debugprint for the vm object */
374
 
BEGINobjDebugPrint(vm) /* be sure to specify the object type also in END and CODESTART macros! */
375
 
CODESTARTobjDebugPrint(vm)
376
 
        dbgoprint((obj_t*) pThis, "rsyslog virtual machine, currently no state info available\n");
377
 
ENDobjDebugPrint(vm)
378
 
 
379
 
 
380
 
/* execute a program
381
 
 */
382
 
static rsRetVal
383
 
execProg(vm_t *pThis, vmprg_t *pProg)
384
 
{
385
 
        DEFiRet;
386
 
        vmop_t *pCurrOp; /* virtual instruction pointer */
387
 
 
388
 
        ISOBJ_TYPE_assert(pThis, vm);
389
 
        ISOBJ_TYPE_assert(pProg, vmprg);
390
 
 
391
 
#define doOP(OP) case opcode_##OP: CHKiRet(op##OP(pThis, pCurrOp)); break
392
 
        pCurrOp = pProg->vmopRoot; /* TODO: do this via a method! */
393
 
        while(pCurrOp != NULL && pCurrOp->opcode != opcode_END_PROG) {
394
 
                switch(pCurrOp->opcode) {
395
 
                        doOP(OR);
396
 
                        doOP(AND);
397
 
                        doOP(CMP_EQ);
398
 
                        doOP(CMP_NEQ);
399
 
                        doOP(CMP_LT);
400
 
                        doOP(CMP_GT);
401
 
                        doOP(CMP_LTEQ);
402
 
                        doOP(CMP_GTEQ);
403
 
                        doOP(CMP_CONTAINS);
404
 
                        doOP(CMP_CONTAINSI);
405
 
                        doOP(CMP_STARTSWITH);
406
 
                        doOP(CMP_STARTSWITHI);
407
 
                        doOP(NOT);
408
 
                        doOP(PUSHCONSTANT);
409
 
                        doOP(PUSHMSGVAR);
410
 
                        doOP(PUSHSYSVAR);
411
 
                        doOP(STRADD);
412
 
                        doOP(PLUS);
413
 
                        doOP(MINUS);
414
 
                        doOP(TIMES);
415
 
                        doOP(DIV);
416
 
                        doOP(MOD);
417
 
                        doOP(UNARY_MINUS);
418
 
                        default:
419
 
                                ABORT_FINALIZE(RS_RET_INVALID_VMOP);
420
 
                                dbgoprint((obj_t*) pThis, "invalid instruction %d in vmprg\n", pCurrOp->opcode);
421
 
                                break;
422
 
                }
423
 
                /* so far, we have plain sequential execution, so on to next... */
424
 
                pCurrOp = pCurrOp->pNext;
425
 
        }
426
 
#undef doOP
427
 
 
428
 
        /* if we reach this point, our program has intintionally terminated
429
 
         * (no error state).
430
 
         */
431
 
 
432
 
finalize_it:
433
 
        RETiRet;
434
 
}
435
 
 
436
 
 
437
 
/* Set the current message object for the VM. It *is* valid to set a
438
 
 * NULL message object, what simply means there is none. Message
439
 
 * objects are properly reference counted.
440
 
 */
441
 
static rsRetVal
442
 
SetMsg(vm_t *pThis, msg_t *pMsg)
443
 
{
444
 
        DEFiRet;
445
 
        if(pThis->pMsg != NULL) {
446
 
                msgDestruct(&pThis->pMsg);
447
 
        }
448
 
 
449
 
        if(pMsg != NULL) {
450
 
                pThis->pMsg = MsgAddRef(pMsg);
451
 
        }
452
 
 
453
 
        RETiRet;
454
 
}
455
 
 
456
 
 
457
 
/* Pop a var from the stack and return it to caller. The variable type is not
458
 
 * changed, it is taken from the stack as is. This functionality is
459
 
 * partly needed. We may (or may not ;)) be able to remove it once we have
460
 
 * full RainerScript support. -- rgerhards, 2008-02-25
461
 
 */
462
 
static rsRetVal
463
 
PopVarFromStack(vm_t *pThis, var_t **ppVar)
464
 
{
465
 
        DEFiRet;
466
 
        CHKiRet(vmstk.Pop(pThis->pStk, ppVar));
467
 
finalize_it:
468
 
        RETiRet;
469
 
}
470
 
 
471
 
 
472
 
/* Pop a boolean from the stack and return it to caller. This functionality is
473
 
 * partly needed. We may (or may not ;)) be able to remove it once we have
474
 
 * full RainerScript support. -- rgerhards, 2008-02-25
475
 
 */
476
 
static rsRetVal
477
 
PopBoolFromStack(vm_t *pThis, var_t **ppVar)
478
 
{
479
 
        DEFiRet;
480
 
        CHKiRet(vmstk.PopBool(pThis->pStk, ppVar));
481
 
finalize_it:
482
 
        RETiRet;
483
 
}
484
 
 
485
 
 
486
 
/* queryInterface function
487
 
 * rgerhards, 2008-02-21
488
 
 */
489
 
BEGINobjQueryInterface(vm)
490
 
CODESTARTobjQueryInterface(vm)
491
 
        if(pIf->ifVersion != vmCURR_IF_VERSION) { /* check for current version, increment on each change */
492
 
                ABORT_FINALIZE(RS_RET_INTERFACE_NOT_SUPPORTED);
493
 
        }
494
 
 
495
 
        /* ok, we have the right interface, so let's fill it
496
 
         * Please note that we may also do some backwards-compatibility
497
 
         * work here (if we can support an older interface version - that,
498
 
         * of course, also affects the "if" above).
499
 
         */
500
 
        pIf->Construct = vmConstruct;
501
 
        pIf->ConstructFinalize = vmConstructFinalize;
502
 
        pIf->Destruct = vmDestruct;
503
 
        pIf->DebugPrint = vmDebugPrint;
504
 
        pIf->ExecProg = execProg;
505
 
        pIf->PopBoolFromStack = PopBoolFromStack;
506
 
        pIf->PopVarFromStack = PopVarFromStack;
507
 
        pIf->SetMsg = SetMsg;
508
 
finalize_it:
509
 
ENDobjQueryInterface(vm)
510
 
 
511
 
 
512
 
/* Initialize the vm class. Must be called as the very first method
513
 
 * before anything else is called inside this class.
514
 
 * rgerhards, 2008-02-19
515
 
 */
516
 
BEGINObjClassInit(vm, 1, OBJ_IS_CORE_MODULE) /* class, version */
517
 
        /* request objects we use */
518
 
        CHKiRet(objUse(vmstk, CORE_COMPONENT));
519
 
        CHKiRet(objUse(var, CORE_COMPONENT));
520
 
        CHKiRet(objUse(sysvar, CORE_COMPONENT));
521
 
 
522
 
        /* set our own handlers */
523
 
        OBJSetMethodHandler(objMethod_DEBUGPRINT, vmDebugPrint);
524
 
        OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, vmConstructFinalize);
525
 
ENDObjClassInit(vm)
526
 
 
527
 
/* vi:set ai:
528
 
 */