|
|
| version 1.26, 2001/02/23 11:53:06 | version 1.30, 2001/02/23 17:48:00 |
|---|---|
| Line 8 | Line 8 |
| #include "pa_vstring.h" | #include "pa_vstring.h" |
| #include "pa_vhash.h" | #include "pa_vhash.h" |
| #include "pa_vunknown.h" | #include "pa_vunknown.h" |
| #include "pa_vframe.h" | |
| #include "pa_wwrapper.h" | |
| #include <stdio.h> | #include <stdio.h> |
| #define PUSH(value) stack.push(value) | #define PUSH(value) stack.push(value) |
| #define POP() static_cast<Value *>(stack.pop()) | #define POP() static_cast<Value *>(stack.pop()) |
| #define POP_SR() static_cast<Value *>(stack.pop())->as_string() | |
| char *opcode_name[]={ | char *opcode_name[]={ |
| Line 33 char *opcode_name[]={ | Line 36 char *opcode_name[]={ |
| void dump(int level, const Array& ops) { | void dump(int level, const Array& ops) { |
| if(0){ | if(0){ |
| int size=ops.size(); | int size=ops.size(); |
| printf("size=%d\n", size); | //printf("size=%d\n", size); |
| for(int i=0; i<size; i++) { | for(int i=0; i<size; i++) { |
| Operation op; | Operation op; |
| op.cast=ops.quick_get(i); | op.cast=ops.quick_get(i); |
| Line 42 void dump(int level, const Array& ops) { | Line 45 void dump(int level, const Array& ops) { |
| } | } |
| int size=ops.size(); | int size=ops.size(); |
| printf("size=%d\n", size); | //printf("size=%d\n", size); |
| for(int i=0; i<size; i++) { | for(int i=0; i<size; i++) { |
| Operation op; | Operation op; |
| op.cast=ops.quick_get(i); | op.cast=ops.quick_get(i); |
| Line 62 void dump(int level, const Array& ops) { | Line 65 void dump(int level, const Array& ops) { |
| } | } |
| void Request::execute(Array& ops) { | void Request::execute(Array& ops) { |
| if(0) { | if(1) { |
| puts("---------------------------"); | puts("---------------------------"); |
| dump(0, ops); | dump(0, ops); |
| puts("---------------------------"); | puts("---------------------------"); |
| } | } |
| int size=ops.size(); | int size=ops.size(); |
| printf("size=%d\n", size); | //printf("size=%d\n", size); |
| for(int i=0; i<size; i++) { | for(int i=0; i<size; i++) { |
| Operation op; | Operation op; |
| op.cast=ops.quick_get(i); | op.cast=ops.quick_get(i); |
| Line 113 void Request::execute(Array& ops) { | Line 116 void Request::execute(Array& ops) { |
| case OP_CONSTRUCT: | case OP_CONSTRUCT: |
| { | { |
| Value *value=POP(); | Value *value=POP(); |
| String& name=POP()->as_string(); | String& name=POP_SR(); |
| Value *ncontext=POP(); | Value *ncontext=POP(); |
| value->set_name(name); | value->set_name(name); |
| ncontext->put_element(name, value); | ncontext->put_element(name, value); |
| Line 144 void Request::execute(Array& ops) { | Line 147 void Request::execute(Array& ops) { |
| case OP_CREATE_EWPOOL: | case OP_CREATE_EWPOOL: |
| { | { |
| PUSH(wcontext); | PUSH(wcontext); |
| wcontext=NEW WContext(pool(), 0 /* empty */); | wcontext=NEW WWrapper(pool(), 0 /* empty */); |
| break; | break; |
| } | } |
| case OP_REDUCE_EWPOOL: | case OP_REDUCE_EWPOOL: |
| Line 161 void Request::execute(Array& ops) { | Line 164 void Request::execute(Array& ops) { |
| PUSH(rcontext); | PUSH(rcontext); |
| rcontext=ncontext; | rcontext=ncontext; |
| PUSH(wcontext); | PUSH(wcontext); |
| wcontext=NEW WContext(pool(), ncontext); | wcontext=NEW WWrapper(pool(), ncontext); |
| break; | break; |
| } | } |
| case OP_REDUCE_RWPOOL: | case OP_REDUCE_RWPOOL: |
| Line 174 void Request::execute(Array& ops) { | Line 177 void Request::execute(Array& ops) { |
| break; | break; |
| } | } |
| case OP_GET_METHOD_FRAME: | |
| { | |
| String& name=POP_SR(); // ýòî áûâàåò junction, íå name | |
| Value *ncontext=static_cast<Value *>(stack[0]); | |
| // [self/class?;params;local;code/native_code](name) | |
| Method *method=ncontext->get_method(name); | |
| if(!method) | |
| THROW(0,0, | |
| &name, | |
| "method not found in %s", ncontext->name()->cstr()); | |
| //unless(method) method=operators.get_method[...;code/native_code](name) | |
| VFrame *frame=NEW VFrame(pool(), *method); | |
| PUSH(frame); | |
| break; | |
| } | |
| case OP_STORE_PARAM: | |
| { | |
| Value *value=POP(); | |
| VFrame *frame=static_cast<VFrame *>(stack[0]); | |
| frame->store_param(value); | |
| break; | |
| } | |
| case OP_CALL: | |
| { | |
| printf("->\n"); | |
| VFrame *frame=static_cast<VFrame *>(POP()); | |
| Value *ncontext=POP(); | |
| PUSH(root); PUSH(self); PUSH(rcontext); PUSH(wcontext); | |
| //left_class=ncontext.get_class() | |
| //right_class=frame.self.get_class() | |
| //self=f(left_class[thoughts' food], right_self[junction], right_class[static], wcontext.value()[dynamic], new(right_class)[construct]) | |
| self=rcontext; | |
| frame->set_self(self); | |
| root=rcontext=wcontext=frame; | |
| execute(frame->method.code); | |
| Value *value=wcontext->value(); | |
| wcontext=static_cast<WContext *>(POP()); rcontext=POP(); self=POP(); root=POP(); | |
| wcontext->write(value); | |
| printf("<-returned"); | |
| break; | |
| } | |
| default: | default: |
| printf("\tTODO"); | printf("\tTODO"); |
| break; | break; |
| Line 183 void Request::execute(Array& ops) { | Line 230 void Request::execute(Array& ops) { |
| } | } |
| Value *Request::get_element() { | Value *Request::get_element() { |
| String& name=POP()->as_string(); | String& name=POP_SR(); |
| Value *ncontext=POP(); | Value *ncontext=POP(); |
| Value *value=ncontext->get_element(name); // name áûâàåò method, òîãäà âûäà¸ò new junction(ÀÂÒÎÂÛ×ÈÑËßÒÜ=false, root,self,rcontext,wcontext,code) | Value *value=ncontext->get_element(name); // name áûâàåò method, òîãäà âûäà¸ò new junction(ÀÂÒÎÂÛ×ÈÑËßÒÜ=false, root,self,rcontext,wcontext,code) |
| // name áûâàåò èìÿ junction, òîãäà èëè îñòàâëÿåò â ïîêîå, èëè âû÷èñëÿåò â çàâèñèìîñòè îò ôëàãà ÀÂÒÎÂÛ×ÈÑËßÒÜ | // name áûâàåò èìÿ junction, òîãäà èëè îñòàâëÿåò â ïîêîå, èëè âû÷èñëÿåò â çàâèñèìîñòè îò ôëàãà ÀÂÒÎÂÛ×ÈÑËßÒÜ |