--- parser3/src/main/execute.C 2003/02/17 11:29:53 1.295.2.12 +++ parser3/src/main/execute.C 2003/02/17 15:41:26 1.295.2.14 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_EXECUTE_C="$Date: 2003/02/17 11:29:53 $"; +static const char* IDENT_EXECUTE_C="$Date: 2003/02/17 15:41:26 $"; #include "pa_opcode.h" #include "pa_array.h" @@ -24,14 +24,6 @@ static const char* IDENT_EXECUTE_C="$Dat #include "pa_wwrapper.h" #define DEBUG_EXECUTE -//#define DEBUG_STRING_APPENDS_VS_EXPANDS - - -#ifdef DEBUG_STRING_APPENDS_VS_EXPANDS -ulong wcontext_result_size=0; -#endif - - #ifdef DEBUG_EXECUTE char *opcode_name[]={ @@ -75,7 +67,7 @@ void debug_printf(SAPI_Info& sapi_info, va_end(args); } -void debug_dump(SAPI_Info& sapi_info, int level, ArrayOperation& ops) { +void debug_dump(SAPI_Info& sapi_info, Pool& pool, int level, ArrayOperation& ops) { Array_iterator i(ops); while(i.has_next()) { Operation& op=i.next(); @@ -86,7 +78,7 @@ void debug_dump(SAPI_Info& sapi_info, in "%*s%s" " \"%s\" %s", level*4, "", opcode_name[op.code], - value->get_string(0)->cstr().get(), value->type()); + value->get_string(&pool)->cstr().get(), value->type()); continue; } debug_printf(sapi_info, "%*s%s", level*4, "", opcode_name[op.code]); @@ -100,8 +92,8 @@ void debug_dump(SAPI_Info& sapi_info, in case OP_STRING_POOL: case OP_CALL: case OP_CALL__WRITE: - ArrayOperation& local_ops=*i.next().ops; - debug_dump(sapi_info, level+1, local_ops); + if(ArrayOperation* local_ops=i.next().ops.get()) + debug_dump(sapi_info, pool, level+1, *local_ops); } } } @@ -113,7 +105,7 @@ void Request::execute(ArrayOperation& op // _asm int 3; #ifdef DEBUG_EXECUTE debug_printf(sapi_info, "source----------------------------\n"); - debug_dump(sapi_info, 0, ops); + debug_dump(sapi_info, pool(), 0, ops); debug_printf(sapi_info, "execution-------------------------\n"); #endif StringPtr last_get_element_name(0); @@ -145,7 +137,7 @@ void Request::execute(ArrayOperation& op { value=i.next().value; #ifdef DEBUG_EXECUTE - debug_printf(sapi_info, " \"%s\" %s", value->get_string(0)->cstr().get(), value->type()); + debug_printf(sapi_info, " \"%s\" %s", value->get_string(&pool())->cstr().get(), value->type()); #endif stack.push(value); break; @@ -218,7 +210,7 @@ void Request::execute(ArrayOperation& op local_ops=i.next().ops; #ifdef DEBUG_EXECUTE debug_printf(sapi_info, " (%d)\n", local_ops->count()); - debug_dump(sapi_info, 1, *local_ops); + debug_dump(sapi_info, pool(), 1, *local_ops); #endif value=ValuePtr(new VJunction(JunctionPtr(new Junction( get_self(), 0, @@ -237,7 +229,7 @@ void Request::execute(ArrayOperation& op local_ops=i.next().ops; #ifdef DEBUG_EXECUTE debug_printf(sapi_info, " (%d)\n", local_ops->count()); - debug_dump(sapi_info, 1, *local_ops); + debug_dump(sapi_info, pool(), 1, *local_ops); #endif stack.push(local_ops); break; @@ -347,7 +339,7 @@ void Request::execute(ArrayOperation& op VMethodFrame *frame=static_cast(stack.top_value().ptr); #ifdef DEBUG_EXECUTE debug_printf(sapi_info, " (%d)\n", local_ops->count()); - debug_dump(sapi_info, 1, *local_ops); + debug_dump(sapi_info, pool(), 1, *local_ops); #endif // when they evaluate expression parameter, // the object expression result @@ -385,8 +377,9 @@ void Request::execute(ArrayOperation& op { local_ops=i.next().ops; #ifdef DEBUG_EXECUTE - debug_printf(sapi_info, " (%d)\n", local_ops->count()); - debug_dump(sapi_info, 1, *local_ops); + debug_printf(sapi_info, " (%d)\n", local_ops?local_ops->count():0); + if(local_ops) + debug_dump(sapi_info, pool(), 1, *local_ops); debug_printf(sapi_info, "->\n"); #endif @@ -411,7 +404,7 @@ void Request::execute(ArrayOperation& op value->type()); */ - VMethodFrame frame(pool(), last_get_element_name, *junction, method_frame/*caller*/); + VMethodFrame frame(pool(), last_get_element_name, *junction, method_frame/*caller*/); frame.ref(); if(local_ops){ // store param code goes here stack.push(&frame); // argument for *STORE_PARAM ops execute(*local_ops); @@ -490,11 +483,6 @@ void Request::execute(ArrayOperation& op rcontext=saved_rcontext; method_frame=saved_method_frame; -#ifdef DEBUG_STRING_APPENDS_VS_EXPANDS - if(const String *s=value->get_string()) - wcontext_result_size+=s->used_rows()*sizeof(String::Chunk::Row); -#endif - if(op.code==OP_CALL__WRITE) { write_assign_lang(result, last_get_element_name); } else { // OP_CALL @@ -974,15 +962,13 @@ StringPtr Request::execute_method(ValueP WContext *saved_wcontext=wcontext; Junction local_junction(aself, &method, 0,0,0, ArrayOperationPtr(0)); - VMethodFrame local_frame(pool(), method.name, local_junction, method_frame/*caller*/); + VMethodFrame local_frame(pool(), method.name, local_junction, method_frame/*caller*/); local_frame.ref(); if(optional_param && local_frame.can_store_param()) { local_frame.store_param(optional_param); local_frame.fill_unspecified_params(); } local_frame.set_self(aself); rcontext=wcontext=method_frame=&local_frame; - // preventing local object from deletes - local_frame.ref(); // prevent non-string writes for better error reporting if(do_return_string)