--- parser3/src/main/execute.C 2001/08/02 06:54:12 1.188 +++ parser3/src/main/execute.C 2001/10/19 12:43:30 1.196 @@ -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.196 2001/10/19 12:43:30 parser Exp $ */ -static const char *RCSId="$Id: execute.C,v 1.188 2001/08/02 06:54:12 parser Exp $"; #include "pa_opcode.h" #include "pa_array.h" @@ -21,6 +21,7 @@ static const char *RCSId="$Id: execute.C #include "pa_vtable.h" #include "pa_vfile.h" #include "pa_vimage.h" +#include "pa_wwrapper.h" //#define DEBUG_EXECUTE @@ -68,24 +69,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 +89,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 +107,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 +131,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); @@ -175,7 +164,7 @@ void Request::execute(const Array& ops) const String& name=POP_NAME(); Value *value=static_cast(classes().get(name)); if(!value) - THROW(0,0, + throw Exception(0,0, &name, "class is undefined"); @@ -226,7 +215,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); @@ -263,7 +252,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 @@ -338,7 +327,7 @@ void Request::execute(const Array& ops) // not a code-junction Junction *junction=value->get_junction(); if(!junction) - THROW(0, 0, + throw Exception(0, 0, &value->name(), "(%s) not a method or junction, can not call it", value->type()); @@ -389,7 +378,7 @@ void Request::execute(const Array& ops) String::UL_CLEAN // not used, always an object, not string ); } else - THROW(0, 0, + throw Exception(0, 0, &frame->name(), "method is static and can not be used as constructor"); } else { @@ -421,7 +410,7 @@ void Request::execute(const Array& ops) method.call_type==Method::CT_ANY || method.call_type==call_type) // allowed call type? if(method.native_code) { // native code? - method.check_actual_numbered_params(pool(), + method.check_actual_numbered_params( frame->junction.self, frame->name(), frame->numbered_params()); method.native_code( @@ -430,7 +419,7 @@ void Request::execute(const Array& ops) } else { // parser code if(++anti_endless_execute_recoursion==ANTI_ENDLESS_EXECUTE_RECOURSION) { anti_endless_execute_recoursion=0; // give @exception a chance - THROW(0, 0, + throw Exception(0, 0, &frame->name(), "endless recursion detected"); } @@ -439,7 +428,7 @@ void Request::execute(const Array& ops) anti_endless_execute_recoursion--; } else - THROW(0, 0, + throw Exception(0, 0, &frame->name(), "is not allowed to be called %s", call_type==Method::CT_STATIC?"statically":"dynamically"); @@ -549,7 +538,7 @@ void Request::execute(const Array& ops) if(!problem_source->origin().file) problem_source=&b->name(); #endif - THROW(0, 0, + throw Exception(0, 0, problem_source, "Division by zero"); } @@ -571,7 +560,7 @@ void Request::execute(const Array& ops) if(!problem_source->origin().file) problem_source=&b->name(); #endif - THROW(0, 0, + throw Exception(0, 0, problem_source, "Modulus by zero"); } @@ -714,6 +703,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); @@ -721,7 +711,7 @@ void Request::execute(const Array& ops) } default: - THROW(0,0, + throw Exception(0,0, 0, "invalid opcode %d", op.code); } @@ -736,7 +726,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)