--- parser3/src/classes/op.C 2002/08/13 13:02:39 1.102 +++ parser3/src/classes/op.C 2002/09/17 16:46:25 1.110 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_OP_C="$Date: 2002/08/13 13:02:39 $"; +static const char* IDENT_OP_C="$Date: 2002/09/17 16:46:25 $"; #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 @@ -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.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); @@ -580,7 +581,9 @@ static void _try_operator(Request& r, co // 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; + Value *sself=r.self; + VMethodFrame *smethod_frame=r.method_frame; + Value *srcontext=r.rcontext; WContext *swcontext=r.wcontext; try { result=r.process(body_code); @@ -588,20 +591,20 @@ static void _try_operator(Request& r, co // 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; + r.self=sself; r.method_frame=smethod_frame, 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); - 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 @@ -713,8 +716,8 @@ void MOP::configure_user(Request& r) { Pool& pool=r.pool(); // $MAIN:SQL.drivers - if(Value *sql=r.main_class->get_element(main_sql_name, r.main_class)) - if(Value *element=sql->get_element(main_sql_drivers_name, sql)) + if(Value *sql=r.main_class->get_element(main_sql_name, r.main_class, false)) + if(Value *element=sql->get_element(main_sql_drivers_name, sql, false)) if(Table *protocol2library=element->get_table()) r.classes_conf.put(name(), protocol2library); }