--- parser3/src/classes/op.C 2005/11/18 11:44:04 1.152.4.4 +++ parser3/src/classes/op.C 2005/07/28 11:23:01 1.154 @@ -1,11 +1,11 @@ /** @file Parser: parser @b operators. - Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_OP_C="$Date: 2005/11/18 11:44:04 $"; +static const char * const IDENT_OP_C="$Date: 2005/07/28 11:23:01 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -83,11 +83,14 @@ public: // methods static void _if(Request& r, MethodParams& params) { - bool condition=params.as_bool(0, "condition must be expression", r); + Value& condition_code=params.as_junction(0, "condition must be expression"); + + bool condition=r.process_to_value(condition_code, + false/*don't intercept string*/).as_bool(); if(condition) - r.write_pass_lang(r.process(*params.get(1))); + r.write_pass_lang(r.process(params.as_junction(1, "'then' parameter must be code"))); else if(params.count()>2) - r.write_pass_lang(r.process(*params.get(2))); + r.write_pass_lang(r.process(params.as_junction(2, "'else' parameter must be code"))); } static void _untaint(Request& r, MethodParams& params) { @@ -268,7 +271,9 @@ static void _for(Request& r, MethodParam bool need_delim=false; VInt* vint=new VInt(0); - r.get_method_frame()->caller()->put_element(var_name, vint, false); + + VMethodFrame& caller=*r.get_method_frame()->caller(); + caller.put_element(caller, var_name, vint, false); for(int i=from; i<=to; i++) { vint->set_int(i); @@ -379,7 +384,7 @@ static void _case(Request& r, MethodPara for(int i=0; i_default=&code; break; } @@ -434,12 +439,13 @@ static Try_catch_result try_catch(Reques 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); - junction->method_frame->put_element(exception_var_name, &details.vhash, false); + VMethodFrame& frame=*junction->method_frame; + frame.put_element(frame, exception_var_name, &details.vhash, false); result.processed_code=r.process(*catch_code); // retriving $exception.handled, restoring $exception var Value* vhandled=details.vhash.hash().get(exception_handled_part_name); - junction->method_frame->put_element(exception_var_name, saved_exception_var_value, false); + frame.put_element(frame, exception_var_name, saved_exception_var_value, false); bool bhandled=false; if(vhandled) { @@ -495,7 +501,7 @@ struct Locked_process_and_cache_put_acti static StringOrValue process_cache_body_code(Request& r, Value* body_code) { - return StringOrValue(&r.process_to_string(*body_code), 0); + return StringOrValue(r.process_to_string(*body_code)); } /* @todo maybe network order worth spending some effort? @@ -608,18 +614,6 @@ static const String& as_file_spec(Reques return r.absolute(params.as_string(index, "filespec must be string")); } static void _cache(Request& r, MethodParams& params) { - if(params.count()==0) - { - // return current expiration time - Cache_scope* scope=static_cast(r.classes_conf.get(cache_data_name)); - if(!scope) - throw Exception("parser.runtime", - 0, - "expire-time get without cache"); - r.write_no_lang(*new VDate(scope->expires)); - return; - } - time_t now=time(0); // ^cache[filename] ^cache(seconds) ^cache[expires date] @@ -823,8 +817,7 @@ VClassMAIN::VClassMAIN(): VClass() { // ^cache[file_spec](time){code}[{catch code}] time=0 no cache // ^cache[file_spec] delete cache - // ^cache[] get current expiration time - add_native_method("cache", Method::CT_ANY, _cache, 0, 4); + add_native_method("cache", Method::CT_ANY, _cache, 1, 4); // switch