Annotation of parser3/src/main/execute.C, revision 1.12
1.1 paf 1: /*
1.12 ! paf 2: $Id: execute.C,v 1.11 2001/02/21 17:36:58 paf Exp $
1.1 paf 3: */
4:
1.8 paf 5: #include "pa_array.h"
1.1 paf 6: #include "code.h"
1.11 paf 7: #include "pa_request.h"
1.1 paf 8:
9: #include <stdio.h>
10:
1.11 paf 11:
1.1 paf 12: char *opcode_name[]={
13: "STRING",
14: "CODE_ARRAY",
15: "WITH_ROOT", "WITH_SELF", "WITH_READ", "WITH_WRITE",
16: "CONSTRUCT",
17: "EXPRESSION_EVAL", "MODIFY_EVAL",
18: "WRITE",
19: "GET_ELEMENT", "GET_ELEMENT__WRITE",
20: "CREATE_EWPOOL", "REDUCE_EWPOOL",
21: "CREATE_RWPOOL", "REDUCE_RWPOOL",
22: "GET_METHOD_FRAME",
23: "CREATE_JUNCTION",
24: "STORE_PARAM",
25: "CALL"
26: };
27:
1.9 paf 28: void dump(int level, const Array& ops) {
29: int size=ops.size();
1.1 paf 30: for(int i=0; i<size; i++) {
1.10 paf 31: int code=reinterpret_cast<int>(ops.quick_get(i));
1.1 paf 32: printf("%*s%s", level*4, "", opcode_name[code]);
33:
34: if(code==OP_STRING) {
1.12 ! paf 35: const String *string=static_cast<const String *>(ops.quick_get(++i));
! 36: printf(" \"%s\"", string->cstr());
1.1 paf 37: }
38: printf("\n");
39:
40: if(code==OP_CODE_ARRAY) {
1.10 paf 41: const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));
1.9 paf 42: dump(level+1, *local_ops);
1.1 paf 43: }
44: }
45: }
46:
1.11 paf 47: void Request::execute(Array& ops) {
1.12 ! paf 48: if(1) {
! 49: puts("---------------------------");
! 50: dump(0, ops);
! 51: puts("---------------------------");
! 52: }
! 53:
1.11 paf 54: int size=ops.size();
55: for(int i=0; i<size; i++) {
56: int code=reinterpret_cast<int>(ops.quick_get(i));
57: printf("%s\n", opcode_name[code]);
58:
59: if(code==OP_CODE_ARRAY) {
60: const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));
61: //dump(level+1, *local_ops);
62: }
63:
64: switch(code) {
65: case OP_WITH_WRITE:
66: {
67: stack.push(wcontext);
68: break;
69: }
70:
71: case OP_STRING:
72: {
73: String *string=static_cast<String *>(ops.quick_get(++i));
74: stack.push(string);
75: break;
76: }
77:
78: case OP_CONSTRUCT:
79: {
80: Value *value=static_cast<Value *>(stack.pop());
81: String *name=static_cast<String *>(stack.pop());
82: Value *ncontext=static_cast<Value *>(stack.pop());
83: ncontext->put_element(*name, value);
84: break;
85: }
86:
87: case OP_GET_ELEMENT:
88: {
89: String *name=static_cast<String *>(stack.pop());
90: Value *ncontext=static_cast<Value *>(stack.pop());
91: Value *value=ncontext->get_element(*name); // name áûâàåò method, òîãäà âûäà¸ò new junction(ÀÂÒÎÂÛ×ÈÑËßÒÜ=false, root,self,rcontext,wcontext,code)
92: // name áûâàåò èìÿ junction, òîãäà èëè îñòàâëÿåò â ïîêîå, èëè âû÷èñëÿåò â çàâèñèìîñòè îò ôëàãà ÀÂÒÎÂÛ×ÈÑËßÒÜ
93: stack.push(value);
94: break;
95: }
96:
97: default:
98: printf("\tTODO\n");
99: break;
100: }
101: }
1.1 paf 102: }
E-mail: