--- parser3/src/main/execute.C 2001/03/07 11:14:12 1.62 +++ parser3/src/main/execute.C 2001/03/08 10:13:26 1.67 @@ -1,5 +1,5 @@ /* - $Id: execute.C,v 1.62 2001/03/07 11:14:12 paf Exp $ + $Id: execute.C,v 1.67 2001/03/08 10:13:26 paf Exp $ */ #include "pa_array.h" @@ -23,10 +23,11 @@ char *opcode_name[]={ // literals - "VALUE", "CODE", "CLASS", + "VALUE", "CODE__STORE_PARAM", // actions "WITH_SELF", "WITH_ROOT", "WITH_READ", "WITH_WRITE", + "GET_CLASS", "CONSTRUCT", "WRITE", "GET_ELEMENT", "GET_ELEMENT__WRITE", @@ -69,13 +70,9 @@ void dump(int level, const Array& ops) { Value *value=static_cast(ops.quick_get(++i)); fprintf(stderr, " \"%s\" %s", value->get_string()->cstr(), value->type()); } - if(op.code==OP_CLASS) { - VClass *vclass=static_cast(ops.quick_get(++i)); - fprintf(stderr, " \"%s\"", vclass->name().cstr()); - } fprintf(stderr, "\n"); - if(op.code==OP_CODE) { + if(op.code==OP_CODE__STORE_PARAM) { const Array *local_ops=reinterpret_cast(ops.quick_get(++i)); dump(level+1, *local_ops); } @@ -95,7 +92,7 @@ void Request::execute(const Array& ops) for(int i=0; i(stack[stack.top()]); + // code const Array *local_ops=reinterpret_cast(ops.quick_get(++i)); fprintf(stderr, " (%d)\n", local_ops->size()); dump(1, *local_ops); - // TODO: rcontext junction должен быть контекстом вызываемого объекта - // чтобы вот эти конструкции орудовали одними полями внутри {} : - // $var{$field} - // ^var.menu{$field} - // поскольку они суть одно и то же, и так удобнее + Junction& j=*NEW Junction(pool(), *self, 0, 0, - root,rcontext,wcontext,local_ops); + root, frame, frame, local_ops); Value *value=NEW VJunction(j); - PUSH(value); + value->set_name(frame->name()); + + // store param + frame->store_param(value); break; } - case OP_CLASS: + case OP_GET_CLASS: { - VClass *vclass=static_cast(ops.quick_get(++i)); - fprintf(stderr, " \"%s\"", vclass->name().cstr()); - PUSH(vclass); + String& name=POP_NAME(); + VClass *vclass=static_cast(classes().get(name)); + if(!vclass) + THROW(0,0, + &name, + ": undefined class"); + + PUSH(vclass); break; } @@ -248,6 +251,7 @@ void Request::execute(const Array& ops) value->type()); //unless(method) method=operators.get_method[...;code/native_code](name) VMethodFrame *frame=NEW VMethodFrame(pool(), *junction); + frame->set_name(junction->self.name()); PUSH(frame); break; } @@ -520,8 +524,9 @@ void Request::execute(const Array& ops) } default: - fprintf(stderr, "\tTODO"); - break; + THROW(0,0, + 0, + "unhandled '%s' opcode", opcode_name[op.code]); } fprintf(stderr, "\n"); } @@ -561,9 +566,9 @@ Value *Request::get_element() { fprintf(stderr, "<-ja returned"); } - } else { + } else value=NEW VUnknown(pool()); - value->set_name(name); - } + + value->set_name(name); return value; }