--- parser3/src/main/pa_request.C 2010/05/23 01:06:47 1.320 +++ parser3/src/main/pa_request.C 2010/09/16 23:35:11 1.324 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_REQUEST_C="$Date: 2010/05/23 01:06:47 $"; +static const char * const IDENT_REQUEST_C="$Date: 2010/09/16 23:35:11 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -100,6 +100,7 @@ Request::Request(SAPI_Info& asapi_info, String::Language adefault_lang, bool status_allowed): // private anti_endless_execute_recoursion(0), + anti_endless_json_string_recoursion(0), // public method_frame(0), @@ -205,12 +206,11 @@ Value* Request::get_class(const String& if(Junction* junction=value->get_junction()) if(const Method *method=junction->method) { Value *vname=new VString(name); - VMethodFrame frame(*junction, 0/*no parent*/); + VMethodFrame frame(*method, 0 /*no parent*/, main_class); - frame.set_self(main_class); frame.store_params(&vname, 1); // we don't need the result - execute_method(frame, *method); + execute_method(frame); result=classes().get(name); } @@ -409,11 +409,12 @@ gettimeofday(&mt[2],NULL); if(const Method *method=junction->method) { // preparing to pass parameters to // @postprocess[data] - VMethodFrame frame(/*method->name, */ *junction, 0/*no parent*/); - frame.set_self(main_class); + VMethodFrame frame(*method, 0 /*no parent*/, main_class); frame.store_params(&body_value, 1); - body_value=&execute_method(frame, *method).as_value(); + execute_method(frame); + + body_value=&frame.result().as_value(); } VFile* body_file=body_value->as_vfile(flang, &charsets); @@ -467,8 +468,6 @@ t[9]-t[3] if(const Method *method=junction->method) { // preparing to pass parameters to // @unhandled_exception[exception;stack] - VMethodFrame frame(/*method->name, */ *junction, 0/*no caller*/); - frame.set_self(main_class); // $stack[^table::create{name file lineno colno}] Table::columns_type stack_trace_columns(new ArrayString); @@ -492,13 +491,17 @@ t[9]-t[3] stack_trace+=row; } - Value *params[]={&details.vhash, new VTable(&stack_trace)}; - frame.store_params(params, 2); - // future $response:body= // execute ^unhandled_exception[exception;stack] exception_trace.clear(); // forget all about previous life, in case there would be error inside of this method, error handled would not be mislead by old stack contents (see extract_origin) - body_string=&execute_method(frame, *method).as_string(); + + VMethodFrame frame(*method, 0 /*no caller*/, main_class); + Value *params[]={&details.vhash, new VTable(&stack_trace)}; + + frame.store_params(params, 2); + execute_method(frame); + + body_string=&frame.result().as_string(); } } } @@ -926,68 +929,6 @@ const String& Request::mime_type_of(cons return *new String("application/octet-stream"); } -const String* Request::get_method_filename(const Method* method){ - if(ArrayOperation* code=method->parser_code) - if(code){ - Operation::Origin origin={0, 0, 0}; - Array_iterator i(*code); - while( i.has_next() ){ - switch( i.next().code ){ - case OP::OP_CURLY_CODE__STORE_PARAM: - case OP::OP_EXPR_CODE__STORE_PARAM: - case OP::OP_CURLY_CODE__CONSTRUCT: - case OP::OP_NESTED_CODE: - case OP::OP_OBJECT_POOL: - case OP::OP_STRING_POOL: - case OP::OP_CALL: - case OP::OP_CALL__WRITE: - { - i.next(); // skip local ops - i.next(); // skip next opcode - } - case OP::OP_CONSTRUCT_OBJECT: - case OP::OP_CONSTRUCT_OBJECT__WRITE: - case OP::OP_VALUE: - case OP::OP_STRING__WRITE: - case OP::OP_VALUE__GET_CLASS: -#ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT - case OP::OP_GET_OBJECT_ELEMENT: - case OP::OP_GET_OBJECT_ELEMENT__WRITE: -#endif -#ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT - case OP::OP_GET_OBJECT_VAR_ELEMENT: - case OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE: -#endif -#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT - case OP::OP_VALUE__GET_ELEMENT: - case OP::OP_VALUE__GET_ELEMENT__WRITE: - case OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR: - case OP::OP_WITH_ROOT__VALUE__GET_ELEMENT: -#endif -#ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT - case OP::OP_WITH_SELF__VALUE__GET_ELEMENT: - case OP::OP_WITH_SELF__VALUE__GET_ELEMENT__WRITE: -#endif -#ifdef OPTIMIZE_BYTECODE_CONSTRUCT - case OP::OP_WITH_ROOT__VALUE__CONSTRUCT_EXPR: - case OP::OP_WITH_ROOT__VALUE__CONSTRUCT_VALUE: - case OP::OP_WITH_WRITE__VALUE__CONSTRUCT_EXPR: - case OP::OP_WITH_WRITE__VALUE__CONSTRUCT_VALUE: - case OP::OP_WITH_SELF__VALUE__CONSTRUCT_EXPR: - case OP::OP_WITH_SELF__VALUE__CONSTRUCT_VALUE: -#endif - { - origin=i.next().origin; - break; - } - } - if(origin.file_no) - return get_used_filename(origin.file_no); - } - } - return 0; -} - const String* Request::get_used_filename(uint file_no){ if(file_no < file_list.count()) return new String(file_list[file_no], String::L_TAINTED);