--- parser3/src/main/execute.C 2002/10/14 12:16:06 1.280 +++ parser3/src/main/execute.C 2002/10/15 14:28:57 1.284 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_EXECUTE_C="$Date: 2002/10/14 12:16:06 $"; +static const char* IDENT_EXECUTE_C="$Date: 2002/10/15 14:28:57 $"; #include "pa_opcode.h" #include "pa_array.h" @@ -44,8 +44,7 @@ char *opcode_name[]={ "GET_CLASS", "CONSTRUCT_VALUE", "CONSTRUCT_EXPR", "CURLY_CODE__CONSTRUCT", "WRITE_VALUE", "WRITE_EXPR_RESULT", "STRING__WRITE", - "GET_ELEMENT_OR_OPERATOR", "OP_GET_ELEMENT_OR_JUNCTION_EXPAND", - "GET_ELEMENT", "GET_ELEMENT__WRITE", + "GET_ELEMENT_OR_OPERATOR", "GET_ELEMENT", "GET_ELEMENT__WRITE", "OBJECT_POOL", "STRING_POOL", "STORE_PARAM", "PREPARE_TO_CONSTRUCT_OBJECT", "PREPARE_TO_EXPRESSION", @@ -264,12 +263,6 @@ void Request::execute(const Array& ops) PUSH(value); break; } - case OP_GET_ELEMENT_OR_JUNCTION_EXPAND: - { - value=get_element(last_get_element_name, false, true/* the only user */); - PUSH(value); - break; - } case OP_GET_ELEMENT: { value=get_element(last_get_element_name, false); @@ -398,6 +391,7 @@ void Request::execute(const Array& ops) last_get_element_name, "(%s) not a method or junction, can not call it", value->type()); + /* no check needed, code compiled the way that that's impossible // check: // that this is method-junction, not a code-junction // [disabling these contstructions:] @@ -408,8 +402,9 @@ void Request::execute(const Array& ops) last_get_element_name, "(%s) is code junction, can not call it", value->type()); + */ - VMethodFrame frame(pool(), *last_get_element_name, *junction); + VMethodFrame frame(pool(), *last_get_element_name, *junction, method_frame/*caller*/); if(local_ops){ // store param code goes here PUSH(&frame); // argument for *STORE_PARAM ops execute(*local_ops); @@ -460,19 +455,16 @@ void Request::execute(const Array& ops) method.call_type==Method::CT_ANY || method.call_type==call_type) { // allowed call type? try { + method_frame=&frame; if(method.native_code) { // native code? - // method_frame unchanged, so that ^for ^foreach & co may write to locals method.check_actual_numbered_params( frame.junction.self, frame.name(), frame.numbered_params()); method.native_code( *this, frame.name(), frame.numbered_params()); // execute it - } else { // parser code - method_frame=&frame; - // execute it + } else // parser code, execute it recoursion_checked_execute(&frame.name(), *method.parser_code); - } } catch(...) { // record it to stack trace exception_trace.push((void *)&frame.name()); @@ -829,16 +821,15 @@ void Request::execute(const Array& ops) } /// @test cache|prepare junctions -Value *Request::get_element(const String *& remember_name, - bool can_call_operator, bool should_explode_junction) { +Value *Request::get_element(const String *& remember_name, bool can_call_operator) { const String& name=POP_NAME(); remember_name=&name; Value *ncontext=POP(); Value *value=0; if(can_call_operator) { - if(Method* method=OP.get_method(name)) { // looking operator of that name FIRST + if(Method* method=main_class.get_method(name)) { // looking operator of that name FIRST // as if that method were in self and we have normal dynamic method here Junction& junction=*NEW Junction(pool(), - *main_class, method, 0,0,0,0); + main_class, method, 0,0,0,0); value=NEW VJunction(junction); } } @@ -858,10 +849,9 @@ Value *Request::get_element(const String value=ncontext->get_element(name, ncontext, false); _void: - if(value) { - if(should_explode_junction) // process $junction, but leave $junction.xxx as is + if(value) value=&process_to_value(*value); // process possible code-junction - } else + else value=NEW VVoid(pool()); return value; @@ -981,7 +971,7 @@ void Request::execute_method(Value& asel // WWrapper local(pool(), &aself, wcontext); // wcontext=&local; Junction local_junction(pool(), *self, &method, 0,0,0,0); - VMethodFrame local_frame(pool(), method.name, local_junction); + VMethodFrame local_frame(pool(), method.name, local_junction, method_frame/*caller*/); if(optional_param && local_frame.can_store_param()) { local_frame.store_param(optional_param); local_frame.fill_unspecified_params(); @@ -1008,10 +998,11 @@ void Request::execute_method(Value& asel } void Request::execute_nonvirtual_method(VStateless_class& aclass, - const Method *method, VString *optional_param, + const String& method_name, VString *optional_param, const String **return_string, const Method **return_method) { + const Method *method=aclass.get_method(method_name); if(return_string) *return_string=0; if(return_method)