--- parser3/src/classes/op.C 2002/08/13 15:55:41 1.103 +++ parser3/src/classes/op.C 2002/10/14 13:53:20 1.112 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_OP_C="$Date: 2002/08/13 15:55:41 $"; +static const char* IDENT_OP_C="$Date: 2002/10/14 13:53:20 $"; #include "classes.h" #include "pa_common.h" @@ -13,6 +13,7 @@ static const char* IDENT_OP_C="$Date: 20 #include "pa_vint.h" #include "pa_sql_connection.h" #include "pa_vdate.h" +#include "pa_vmethod_frame.h" // limits @@ -101,7 +102,7 @@ static void _taint(Request& r, const Str static void _process(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - VStateless_class& self_class=*r.self->get_class(); + VStateless_class& self_class=*r.get_self()->get_class(); const Method *main_method; { // temporary remove language change @@ -202,18 +203,18 @@ static void _for(Request& r, const Strin bool need_delim=false; VInt *vint=new(pool) VInt(pool, 0); - r.root->put_element(var_name, vint, false); + r.get_method_frame()->put_element(var_name, vint, false); for(int i=from; i<=to; i++) { vint->set_int(i); - StringOrValue processed_body=r.process(body_code); - if(delim_maybe_code) { // delimiter set? - const String *string=processed_body.get_string(); - if(need_delim && string && string->size()) // need delim & iteration produced string? + StringOrValue sv_processed=r.process(body_code); + const String *s_processed=sv_processed.get_string(); + if(delim_maybe_code && s_processed && s_processed->size()) { // delimiter set and we have body + if(need_delim) // need delim & iteration produced string? r.write_pass_lang(r.process(*delim_maybe_code)); need_delim=true; } - r.write_pass_lang(processed_body); + r.write_pass_lang(sv_processed); } } @@ -291,7 +292,7 @@ static void _switch(Request& r, const St r.process(cases_code, true/*intercept_string*/); if(Value *selected_code=data.found ? data.found : data._default) { // setting code context, would execute in ^switch[...]{>>context<<} - selected_code->get_junction()->change_context(cases_code.get_junction()); + //selected_code->get_junction()->change_context(cases_code.get_junction()); r.write_pass_lang(r.process(*selected_code)); } } @@ -310,7 +311,7 @@ static void _case(Request& r, const Stri // killing context for safety, would execute in ^switch[...]{>>context<<} // reason: context is stacked, and it would become invalid afterwards - code->get_junction()->change_context(0); + //code->get_junction()->change_context(0); for(int i=0; iget(i)); @@ -441,8 +442,8 @@ static time_t as_expires(Request& r, con int index, time_t now) { time_t result; Value& vlifespan_or_expires=params->get(index); - if(strcmp(vlifespan_or_expires.type(), VDATE_TYPE)==0) - result=static_cast(vlifespan_or_expires).get_time(); + if(Value *vdate=vlifespan_or_expires.as(VDATE_TYPE, false)) + result=static_cast(vdate)->get_time(); else result=now+(time_t)params->as_double(index, "lifespan must be date or number", r); @@ -576,32 +577,22 @@ static void _try_operator(Request& r, co Value& catch_code=params->as_junction(1, "catch_code must be code"); StringOrValue result; - - // taking snapshot of request processing status - //int ssexception_trace=r.exception_trace.top_index(); - int sstack=r.stack.top_index(); - Value *sself=r.self, *sroot=r.root, *srcontext=r.rcontext; - WContext *swcontext=r.wcontext; try { + Request_context_saver context_saved(r); // taking snapshot of request processing status, restoring it at } result=r.process(body_code); + context_saved.restore(); // manually restoring context } catch(const Exception& e) { - // restoring request processing status - //r.exception_trace.top_index(ssexception_trace); - r.stack.top_index(sstack); - r.self=sself; r.root=sroot, r.rcontext=srcontext; r.wcontext=swcontext; - - VHash& vhash=exception2vhash(pool, e); Junction *junction=catch_code.get_junction(); - Value *root=junction->root; - Value *saved_exception_var_value=root->get_element(*exception_var_name, root, false); - junction->root->put_element(*exception_var_name, &vhash, false); + Value *method_frame=junction->method_frame; + Value *saved_exception_var_value=method_frame->get_element(*exception_var_name, method_frame, false); + junction->method_frame->put_element(*exception_var_name, &vhash, false); result=r.process(catch_code); bool handled=false; if(Value *value=static_cast(vhash.hash(0).get(*exception_handled_part_name))) handled=value->as_bool(); - junction->root->put_element(*exception_var_name, saved_exception_var_value, false); + junction->method_frame->put_element(*exception_var_name, saved_exception_var_value, false); if(!handled) throw(e); // rethrow