--- parser3/src/main/execute.C 2012/03/16 09:24:12 1.368 +++ parser3/src/main/execute.C 2015/05/08 14:30:44 1.375 @@ -21,7 +21,7 @@ #include "pa_vimage.h" #include "pa_wwrapper.h" -volatile const char * IDENT_EXECUTE_C="$Id: execute.C,v 1.368 2012/03/16 09:24:12 moko Exp $" IDENT_PA_VCODE_FRAME_H IDENT_PA_WWRAPPER_H; +volatile const char * IDENT_EXECUTE_C="$Id: execute.C,v 1.375 2015/05/08 14:30:44 moko Exp $" IDENT_PA_OPCODE_H IDENT_PA_OPERATION_H IDENT_PA_VCODE_FRAME_H IDENT_PA_WWRAPPER_H; //#define DEBUG_EXECUTE @@ -76,6 +76,10 @@ char *opcode_name[]={ "WITH_SELF__VALUE__CONSTRUCT_VALUE", #endif +#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL + "GET_ELEMENT__SPECIAL", + "GET_ELEMENT__SPECIAL__WRITE", +#endif // expression ops: unary "NEG", "INV", "NOT", "DEF", "IN", "FEXISTS", "DEXISTS", // expression ops: binary @@ -263,8 +267,7 @@ void Request::execute(ArrayOperation& op wcontext->set_somebody_entered_some_class(); debug_origin=i.next().origin; - Value& value=*i.next().value; - const String& name=*value.get_string(); debug_name=&name; + const String& name=*i.next().value->get_string(); debug_name=&name; DEBUG_PRINT_STRING(name) @@ -277,6 +280,38 @@ void Request::execute(ArrayOperation& op stack.push(*class_value); break; } + +#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL + case OP::OP_GET_ELEMENT__SPECIAL: + case OP::OP_GET_ELEMENT__SPECIAL__WRITE: + { + const String& name=stack.pop().string(); debug_name=&name; + Value& ncontext=stack.pop().value(); + + Value* value=0; + if(VStateless_class* vclass=ncontext.get_class()){ + if(name==class_element_name){ + value=vclass; + } else if(name==class_name_element_name){ + value=new VString(vclass->name()); + } + } else { + // Value + if(name==class_element_name){ + value=&ncontext; + }else if(name==class_name_element_name){ + value=new VString(*new String(ncontext.type())); + } + }; + if(opcode==OP::OP_GET_ELEMENT__SPECIAL){ + stack.push(*value); + } else { + write_assign_lang(*value); + } + break; + } +#endif + // OP_WITH case OP::OP_WITH_ROOT: { @@ -397,7 +432,7 @@ void Request::execute(ArrayOperation& op const String& name=stack.pop().string(); debug_name=&name; Value& ncontext=stack.pop().value(); - if(const VJunction* vjunction=ncontext.put_element(name, &value, false)) + if(const VJunction* vjunction=ncontext.put_element(name, &value)) if(vjunction!=PUT_ELEMENT_REPLACED_ELEMENT) throw Exception(PARSER_RUNTIME, 0, @@ -720,9 +755,14 @@ void Request::execute(ArrayOperation& op value.type()); } - VMethodFrame frame(*junction->method, method_frame, junction->self); - METHOD_FRAME_ACTION(op_call(frame)); - stack.push(frame.result().as_value()); + Value *result; + { + VMethodFrame frame(*junction->method, method_frame, junction->self); + METHOD_FRAME_ACTION(op_call(frame)); + result=&frame.result().as_value(); + // VMethodFrame desctructor deletes junctions in stack params here + } + stack.push(*result); DEBUG_PRINT_STR("<-returned") @@ -833,15 +873,20 @@ void Request::execute(ArrayOperation& op DEBUG_PRINT_OPS(local_ops) DEBUG_PRINT_STR("->\n") - Value &object=construct(*class_value, *constructor_junction->method); - VConstructorFrame frame(*constructor_junction->method, method_frame, object); - METHOD_FRAME_ACTION(op_call(frame)); - object.enable_default_setter(); + Value *result; + { + Value& object=construct(*class_value, *constructor_junction->method); + VConstructorFrame frame(*constructor_junction->method, method_frame, object); + METHOD_FRAME_ACTION(op_call(frame)); + object.enable_default_setter(); + result=&frame.result().as_value(); + // VMethodFrame desctructor deletes junctions in stack params here + } if(opcode==OP::OP_CONSTRUCT_OBJECT) - stack.push(frame.result().as_value()); + stack.push(*result); else - write_pass_lang(frame.result()); + write_pass_lang(*result); DEBUG_PRINT_STR("<-returned") break; @@ -1268,7 +1313,7 @@ Value& Request::get_element(Value& ncont void Request::put_element(Value& ncontext, const String& name, Value* value) { // put_element can return property-setting-junction - if(const VJunction* vjunction=ncontext.put_element(name, value, false)) + if(const VJunction* vjunction=ncontext.put_element(name, value)) if(vjunction!=PUT_ELEMENT_REPLACED_ELEMENT) { const Junction& junction = vjunction->junction(); VConstructorFrame frame(*junction.method, method_frame /*caller*/, junction.self); @@ -1349,7 +1394,7 @@ StringOrValue Request::process(Value& in Junction* junction=input_value.get_junction(); if(junction) { if(junction->is_getter) { // is it a getter-junction? - return process_getter(*junction); + return process(process_getter(*junction).as_value(), intercept_string); } if(junction->code) { // is it a code-junction? @@ -1411,10 +1456,8 @@ StringOrValue Request::process(Value& in void Request::process_write(Value& input_value) { Junction* junction=input_value.get_junction(); if(junction) { - if(junction->is_getter) { // is it a getter-junction? - write_pass_lang(process_getter(*junction)); - return; - } + // no getter-junction check as process_write is called + // to process method arguments, not from get_element if(junction->code) { // is it a code-junction? // process it @@ -1584,6 +1627,7 @@ const String* Request::get_method_filena origin=i.next().origin; break; } + default: break; } if(origin.file_no) return get_used_filename(origin.file_no);