--- parser3/src/main/execute.C 2001/03/07 13:54:48 1.63 +++ parser3/src/main/execute.C 2001/03/08 12:13:36 1.68 @@ -1,5 +1,5 @@ /* - $Id: execute.C,v 1.63 2001/03/07 13:54:48 paf Exp $ + $Id: execute.C,v 1.68 2001/03/08 12:13:36 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); } @@ -106,27 +103,35 @@ void Request::execute(const Array& ops) PUSH(value); break; } - case OP_CODE: + case OP_CODE__STORE_PARAM: { VMethodFrame *frame=static_cast(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); Junction& j=*NEW Junction(pool(), *self, 0, 0, - rcontext, frame, frame, local_ops); + root, frame, frame, local_ops); Value *value=NEW VJunction(j); value->set_name(frame->name()); - PUSH(value); + + // 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; } @@ -288,7 +293,12 @@ void Request::execute(const Array& ops) VAliased *aliased=self->get_aliased(); // substitute class alias to the class they are called AS Temp_alias temp_alias(*aliased, *frame->junction.vclass); - execute(frame->junction.method->code); + + Method& method=frame->junction.method; + if(method->native_code) // native code? + (*method->native_code)(*this); // execute it + else // parser code + execute(*method->parser_code); // execute it } Value *value=wcontext->result(); @@ -519,8 +529,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"); }