--- parser3/src/main/execute.C 2001/07/26 12:25:37 1.186 +++ parser3/src/main/execute.C 2001/09/26 10:32:26 1.192 @@ -2,10 +2,10 @@ Parser: executor part of request class. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + + $Id: execute.C,v 1.192 2001/09/26 10:32:26 parser Exp $ */ -static const char *RCSId="$Id: execute.C,v 1.186 2001/07/26 12:25:37 parser Exp $"; #include "pa_opcode.h" #include "pa_array.h" @@ -24,7 +24,7 @@ static const char *RCSId="$Id: execute.C //#define DEBUG_EXECUTE -const uint ANTI_ENDLESS_EXECUTE_RECOURSION=500; +const uint ANTI_ENDLESS_EXECUTE_RECOURSION=400; #ifdef DEBUG_EXECUTE char *opcode_name[]={ @@ -32,7 +32,7 @@ char *opcode_name[]={ "VALUE", "CURLY_CODE__STORE_PARAM", "EXPR_CODE__STORE_PARAM", // actions - "WITH_SELF", "WITH_READ", "WITH_WRITE", + "WITH_ROOT", "WITH_SELF", "WITH_READ", "WITH_WRITE", "GET_CLASS", "CONSTRUCT_VALUE", "CONSTRUCT_EXPR", "CURLY_CODE__CONSTRUCT", "WRITE_VALUE", "WRITE_EXPR_RESULT", "STRING__WRITE", @@ -68,24 +68,13 @@ void debug_printf(Pool& pool, const char } void debug_dump(Pool& pool, int level, const Array& ops) { -/* { - int size=ops.quick_size(); - //debug_printf(pool, "size=%d\n", size); - for(int i=0; i(ops.quick_get(++i)); + Value *value=static_cast(i.next()); debug_printf(pool, "%*s%s" " \"%s\" %s", @@ -99,7 +88,7 @@ void debug_dump(Pool& pool, int level, c case OP_CURLY_CODE__STORE_PARAM: case OP_EXPR_CODE__STORE_PARAM: case OP_CURLY_CODE__CONSTRUCT: - const Array *local_ops=reinterpret_cast(ops.quick_get(++i)); + const Array *local_ops=reinterpret_cast(i.next()); debug_dump(pool, level+1, *local_ops); } } @@ -117,11 +106,10 @@ void Request::execute(const Array& ops) debug_printf(pool(), "execution-------------------------\n"); #endif - int size=ops.quick_size(); - //debug_printf(pool(), "size=%d\n", size); - for(int i=0; i(ops.quick_get(++i)); + Value *value=static_cast(i.next()); #ifdef DEBUG_EXECUTE debug_printf(pool(), " \"%s\" %s", value->get_string()->cstr(), value->type()); #endif @@ -142,7 +130,7 @@ void Request::execute(const Array& ops) { VMethodFrame *frame=static_cast(stack.top_value()); // code - const Array *local_ops=reinterpret_cast(ops.quick_get(++i)); + const Array *local_ops=reinterpret_cast(i.next()); #ifdef DEBUG_EXECUTE debug_printf(pool(), " (%d)\n", local_ops->size()); debug_dump(pool(), 1, *local_ops); @@ -184,6 +172,11 @@ void Request::execute(const Array& ops) } // OP_WITH + case OP_WITH_ROOT: + { + PUSH(root); + break; + } case OP_WITH_SELF: { PUSH(self); @@ -221,7 +214,7 @@ void Request::execute(const Array& ops) } case OP_CURLY_CODE__CONSTRUCT: { - const Array *local_ops=reinterpret_cast(ops.quick_get(++i)); + const Array *local_ops=reinterpret_cast(i.next()); #ifdef DEBUG_EXECUTE debug_printf(pool(), " (%d)\n", local_ops->size()); debug_dump(pool(), 1, *local_ops); @@ -258,7 +251,7 @@ void Request::execute(const Array& ops) } case OP_STRING__WRITE: { - VString *vstring=static_cast(ops.quick_get(++i)); + VString *vstring=static_cast(i.next()); #ifdef DEBUG_EXECUTE debug_printf(pool(), " \"%s\"", vstring->string().cstr()); #endif @@ -709,6 +702,7 @@ void Request::execute(const Array& ops) } case OP_IS: { + //_asm int 3; Value *b=POP(); Value *a=POP(); Value *value=NEW VBool(pool(), b->as_string() == a->type()); PUSH(value); @@ -731,7 +725,7 @@ Value *Request::get_element() { if(Method* method=OP.get_method(name)) { // maybe operator? // as if that method were in self and we have normal dynamic method here Junction& junction=*NEW Junction(pool(), - *self, self->get_class(), method, 0,0,0,0); + *root/*self*/, self->get_class(), method, 0,0,0,0); value=NEW VJunction(junction); } if(value) @@ -847,7 +841,7 @@ const String *Request::execute_virtual_m if(Junction *junction=value->get_junction()) if(const Method *method=junction->method) return execute_method(aself, *method, return_cstr); - + return 0; }