|
|
| version 1.2, 2001/02/20 19:21:13 | version 1.12, 2001/02/21 17:50:02 |
|---|---|
| Line 2 | Line 2 |
| $Id$ | $Id$ |
| */ | */ |
| #include "pa_array.h" | #include "pa_array.h" |
| #include "code.h" | #include "code.h" |
| #include "pa_request.h" | |
| #include <stdio.h> | #include <stdio.h> |
| char *opcode_name[]={ | char *opcode_name[]={ |
| "STRING", | "STRING", |
| "CODE_ARRAY", | "CODE_ARRAY", |
| Line 14 char *opcode_name[]={ | Line 16 char *opcode_name[]={ |
| "CONSTRUCT", | "CONSTRUCT", |
| "EXPRESSION_EVAL", "MODIFY_EVAL", | "EXPRESSION_EVAL", "MODIFY_EVAL", |
| "WRITE", | "WRITE", |
| "REPLACE_RESULT", | |
| "GET_ELEMENT", "GET_ELEMENT__WRITE", | "GET_ELEMENT", "GET_ELEMENT__WRITE", |
| "CREATE_EWPOOL", "REDUCE_EWPOOL", | "CREATE_EWPOOL", "REDUCE_EWPOOL", |
| "CREATE_RWPOOL", "REDUCE_RWPOOL", | "CREATE_RWPOOL", "REDUCE_RWPOOL", |
| Line 24 char *opcode_name[]={ | Line 25 char *opcode_name[]={ |
| "CALL" | "CALL" |
| }; | }; |
| void dump(int level, const Array *ops) { | void dump(int level, const Array& ops) { |
| if(!ops) | int size=ops.size(); |
| return; | |
| int size=ops->size(); | |
| for(int i=0; i<size; i++) { | for(int i=0; i<size; i++) { |
| int code=reinterpret_cast<int>(ops->raw_get(i)); | int code=reinterpret_cast<int>(ops.quick_get(i)); |
| printf("%*s%s", level*4, "", opcode_name[code]); | printf("%*s%s", level*4, "", opcode_name[code]); |
| if(code==OP_STRING) { | if(code==OP_STRING) { |
| printf(" \"%s\"", static_cast<const String *>(ops->raw_get(++i))->cstr()); | const String *string=static_cast<const String *>(ops.quick_get(++i)); |
| printf(" \"%s\"", string->cstr()); | |
| } | } |
| printf("\n"); | printf("\n"); |
| if(code==OP_CODE_ARRAY) { | if(code==OP_CODE_ARRAY) { |
| const Array *local_ops=reinterpret_cast<const Array *>(ops->raw_get(++i)); | const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i)); |
| dump(level=1, local_ops); | dump(level+1, *local_ops); |
| } | } |
| } | } |
| } | } |
| void execute(Pool *pool, const Array *ops) { | void Request::execute(Array& ops) { |
| if(!ops) | if(1) { |
| return; | puts("---------------------------"); |
| dump(0, ops); | |
| puts("---------------------------"); | puts("---------------------------"); |
| dump(0, ops); | } |
| puts("---------------------------"); | |
| int size=ops.size(); | |
| for(int i=0; i<size; i++) { | |
| int code=reinterpret_cast<int>(ops.quick_get(i)); | |
| printf("%s\n", opcode_name[code]); | |
| if(code==OP_CODE_ARRAY) { | |
| const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i)); | |
| //dump(level+1, *local_ops); | |
| } | |
| switch(code) { | |
| case OP_WITH_WRITE: | |
| { | |
| stack.push(wcontext); | |
| break; | |
| } | |
| case OP_STRING: | |
| { | |
| String *string=static_cast<String *>(ops.quick_get(++i)); | |
| stack.push(string); | |
| break; | |
| } | |
| case OP_CONSTRUCT: | |
| { | |
| Value *value=static_cast<Value *>(stack.pop()); | |
| String *name=static_cast<String *>(stack.pop()); | |
| Value *ncontext=static_cast<Value *>(stack.pop()); | |
| ncontext->put_element(*name, value); | |
| break; | |
| } | |
| case OP_GET_ELEMENT: | |
| { | |
| String *name=static_cast<String *>(stack.pop()); | |
| Value *ncontext=static_cast<Value *>(stack.pop()); | |
| Value *value=ncontext->get_element(*name); // name áûâàåò method, òîãäà âûäà¸ò new junction(ÀÂÒÎÂÛ×ÈÑËßÒÜ=false, root,self,rcontext,wcontext,code) | |
| // name áûâàåò èìÿ junction, òîãäà èëè îñòàâëÿåò â ïîêîå, èëè âû÷èñëÿåò â çàâèñèìîñòè îò ôëàãà ÀÂÒÎÂÛ×ÈÑËßÒÜ | |
| stack.push(value); | |
| break; | |
| } | |
| default: | |
| printf("\tTODO\n"); | |
| break; | |
| } | |
| } | |
| } | } |