--- parser3/src/classes/op.C 2003/04/03 10:48:24 1.127.2.22.2.27 +++ parser3/src/classes/op.C 2003/04/08 12:47:29 1.127.2.22.2.31 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_OP_C="$Date: 2003/04/03 10:48:24 $"; +static const char* IDENT_OP_C="$Date: 2003/04/08 12:47:29 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -134,13 +134,18 @@ static void _taint(Request& r, MethodPar static void _process(Request& r, MethodParams& params) { Method* main_method; - Value& value=*params[0]; - Value& target_self=params.count()>1? - params.as_no_junction(0, "target must not be code") - :r.get_method_frame()->caller()->self(); + size_t index=0; + Value* target_self; + Value& maybe_target_self=params[index]; + if(maybe_target_self.get_string() || maybe_target_self.get_junction()) + target_self=&r.get_method_frame()->caller()->self(); + else { + target_self=&maybe_target_self; index++; + } + { - VStateless_class *target_class=target_self.get_last_derived_class(); + VStateless_class *target_class=target_self->get_last_derived_class(); if(!target_class) throw Exception("parser.runtime", 0, @@ -153,14 +158,20 @@ static void _process(Request& r, MethodP // temporary zero @auto so it wouldn't be auto-called in Request::use_buf Temp_method temp_method_auto(*target_class, auto_method_name, 0); - if(const String* file_name=params.last().get_string()) { // ^process...[file] - r.use_file(*target_class, r.absolute(*file_name), true/*ignore_class_path*/); + size_t main_alias_index=index+1; + const String* main_alias=0; + if(main_alias_indexparser_code); } @@ -214,7 +225,7 @@ static void _for(Request& r, MethodParam int from=params.as_int(1, "from must be int", r); int to=params.as_int(2, "to must be int", r); Value& body_code=params.as_junction(3, "body must be code"); - Value* delim_maybe_code=params.count()>4?params[4]:0; + Value* delim_maybe_code=params.count()>4?¶ms[4]:0; if(to-from>=MAX_LOOPS) // too long loop? throw Exception("parser.runtime", @@ -306,7 +317,7 @@ public: }; #endif static void _switch(Request& r, MethodParams& params) { - Switch_data* data=new Switch_data(r, r.process_to_value(*params[0])); + Switch_data* data=new Switch_data(r, r.process_to_value(params[0])); Temp_hash_value switch_data_setter(r.classes_conf, switch_data_name, data); @@ -336,7 +347,7 @@ static void _case(Request& r, MethodPara //code->get_junction()->change_context(0); for(int i=0; i_default=&code; @@ -405,7 +416,7 @@ static void locked_process_and_cache_put // expiration time not spoiled by ^cache(0) or something? if(info.data->expires > time(0)) { // string -serialize> buffer - String::C serialized=info.evaluated_body->serialize( + String::Cm serialized=info.evaluated_body->serialize( sizeof(Data_string_serialized_prolog)); Data_string_serialized_prolog& prolog= *reinterpret_cast(serialized.str); @@ -463,7 +474,7 @@ const String* cache_get(Charset& charset static time_t as_expires(Request& r, MethodParams& params, int index, time_t now) { time_t result; - if(Value* vdate=params[index]->as(VDATE_TYPE, false)) + if(Value* vdate=params[index].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); @@ -478,7 +489,7 @@ static void _cache(Request& r, MethodPar // ^cache[filename] ^cache(seconds) ^cache[expires date] if(params.count()==1) { - if(params[0]->is_string()) { // filename? + if(params[0].is_string()) { // filename? cache_delete(as_file_spec(r, params, 0)); return; } @@ -573,11 +584,11 @@ static void _try_operator(Request& r, Me try { result=r.process(body_code); } catch(const Exception& e) { + Request::Exception_details details=r.get_details(e); + Request_context_saver throw_context(r); // taking snapshot of throw-context [stack trace contains error] try_context.restore(); // restoring try-context to perform catch-code - Request::Exception_details details=r.get_details(e); - Junction* junction=catch_code.get_junction(); Value* method_frame=junction->method_frame; Value* saved_exception_var_value=method_frame->get_element(exception_var_name, *method_frame, false); @@ -600,8 +611,7 @@ static void _try_operator(Request& r, Me static void _throw_operator(Request& r, MethodParams& params) { if(params.count()==1) { - Value* param0=params[0]; - if(HashStringValue *hash=param0->get_hash()) { + if(HashStringValue *hash=params[0].get_hash()) { const char* type=0; if(Value* value=hash->get(exception_type_part_name)) type=value->as_string().cstr();