Annotation of parser3/src/main/execute.C, revision 1.2
1.1 paf 1: /*
1.2 ! paf 2: $Id: execute.C,v 1.1 2001/02/20 18:45:52 paf Exp $
1.1 paf 3: */
4:
5: #include "pa_array.h"
6: #include "code.h"
7:
8: #include <stdio.h>
9:
10: char *opcode_name[]={
11: "STRING",
12: "CODE_ARRAY",
13: "WITH_ROOT", "WITH_SELF", "WITH_READ", "WITH_WRITE",
14: "CONSTRUCT",
15: "EXPRESSION_EVAL", "MODIFY_EVAL",
16: "WRITE",
17: "REPLACE_RESULT",
18: "GET_ELEMENT", "GET_ELEMENT__WRITE",
19: "CREATE_EWPOOL", "REDUCE_EWPOOL",
20: "CREATE_RWPOOL", "REDUCE_RWPOOL",
21: "GET_METHOD_FRAME",
22: "CREATE_JUNCTION",
23: "STORE_PARAM",
24: "CALL"
25: };
26:
27: void dump(int level, const Array *ops) {
1.2 ! paf 28: if(!ops)
! 29: return;
! 30:
1.1 paf 31: int size=ops->size();
32: for(int i=0; i<size; i++) {
33: int code=reinterpret_cast<int>(ops->raw_get(i));
34: printf("%*s%s", level*4, "", opcode_name[code]);
35:
36: if(code==OP_STRING) {
37: printf(" \"%s\"", static_cast<const String *>(ops->raw_get(++i))->cstr());
38: }
39: printf("\n");
40:
41: if(code==OP_CODE_ARRAY) {
42: const Array *local_ops=reinterpret_cast<const Array *>(ops->raw_get(++i));
43: dump(level=1, local_ops);
44: }
45: }
46: }
47:
48: void execute(Pool *pool, const Array *ops) {
49: if(!ops)
50: return;
51:
1.2 ! paf 52: puts("---------------------------");
1.1 paf 53: dump(0, ops);
1.2 ! paf 54: puts("---------------------------");
1.1 paf 55: }
E-mail: