--- parser3/src/main/execute.C 2009/08/08 13:30:21 1.354 +++ parser3/src/main/execute.C 2010/04/19 19:39:54 1.360 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_EXECUTE_C="$Date: 2009/08/08 13:30:21 $"; +static const char * const IDENT_EXECUTE_C="$Date: 2010/04/19 19:39:54 $"; #include "pa_opcode.h" #include "pa_array.h" @@ -272,11 +272,11 @@ void Request::execute(ArrayOperation& op debug_origin=i.next().origin; Value& value=*i.next().value; - const String& name=*value.get_string(); + const String& name=*value.get_string(); debug_name=&name; DEBUG_PRINT_STRING(name) - Value* class_value=classes().get(name); + Value* class_value=get_class(name); if(!class_value) throw Exception(PARSER_RUNTIME, &name, @@ -291,8 +291,8 @@ void Request::execute(ArrayOperation& op // maybe they do ^class:method[] call, remember the fact wcontext->set_somebody_entered_some_class(); - const String& name=stack.pop().string(); - Value* value=classes().get(name); + const String& name=stack.pop().string(); debug_name=&name; + Value* value=get_class(name); if(!value) throw Exception(PARSER_RUNTIME, &name, @@ -543,7 +543,7 @@ void Request::execute(ArrayOperation& op DEBUG_PRINT_STRING(var_name) - const String* field=get_element(*rcontext, var_name).get_string(); + const String* field=&get_element(*rcontext, var_name).as_string(); Value& value=get_element(object, *field); @@ -834,11 +834,11 @@ void Request::execute(ArrayOperation& op { debug_origin=i.next().origin; Value& vclass_name=*i.next().value; - const String& class_name=*vclass_name.get_string(); + const String& class_name=*vclass_name.get_string(); debug_name=&class_name; DEBUG_PRINT_STRING(class_name) - Value* class_value=classes().get(class_name); + Value* class_value=get_class(class_name); if(!class_value) throw Exception(PARSER_RUNTIME, &class_name, @@ -853,7 +853,7 @@ void Request::execute(ArrayOperation& op Value& constructor_value=get_element(*class_value, constructor_name); Junction* junction=constructor_value.get_junction(); - if(!junction || junction->self.get_class()!=class_value) + if(!junction) throw Exception(PARSER_RUNTIME, &constructor_name, "constructor must be declared in class '%s'", @@ -863,7 +863,9 @@ void Request::execute(ArrayOperation& op DEBUG_PRINT_OPS(local_ops) DEBUG_PRINT_STR("->\n") - VMethodFrame frame(*junction, method_frame); + Junction casted=Junction(*class_value, junction->method); + VConstructorFrame frame(casted, method_frame); + METHOD_FRAME_ACTION(op_call(frame, true /* constructing */)); if(opcode==OP::OP_CONSTRUCT_OBJECT) stack.push(frame.result().as_value()); @@ -1221,9 +1223,7 @@ void Request::op_call(VMethodFrame& fram "is not a constructor, system class '%s' can be constructed only implicitly", called_class.name().cstr()); - frame.write(*new_self, - String::L_CLEAN // not used, always an object, not string - ); + frame.write(*new_self); } else throw Exception(PARSER_RUNTIME, 0, //&frame.name(), @@ -1351,11 +1351,12 @@ StringOrValue Request::process(Value& in if(junction) { if(junction->is_getter) { // is it a getter-junction? VMethodFrame frame(*junction, method_frame/*caller*/); + Value *param; if(size_t param_count=frame.method_params_count()){ if(junction->auto_name){ // default getter if(param_count==1){ - Value *param=new VString(*junction->auto_name); + param=new VString(*junction->auto_name); frame.store_params(¶m, 1); } else throw Exception(PARSER_RUNTIME, @@ -1375,11 +1376,10 @@ StringOrValue Request::process(Value& in method_frame=&frame; recoursion_checked_execute(*frame.junction.method->parser_code); // parser code, execute it - StringOrValue result=wcontext->result(); RESTORE_CONTEXT - return result; + return frame.result(); } if(junction->code) { // is it a code-junction? @@ -1443,11 +1443,12 @@ void Request::process_write(Value& input if(junction) { if(junction->is_getter) { // is it a getter-junction? VMethodFrame frame(*junction, method_frame/*caller*/); + Value *param; if(size_t param_count=frame.method_params_count()){ if(junction->auto_name){ // default getter if(param_count==1){ - Value *param=new VString(*junction->auto_name); + param=new VString(*junction->auto_name); frame.store_params(¶m, 1); } else throw Exception(PARSER_RUNTIME, @@ -1568,15 +1569,13 @@ const String* Request::execute_method(Va // prevent non-string writes for better error reporting if(do_return_string) - wcontext->write(local_frame); + local_frame.write(local_frame); // execute! execute(*method.parser_code); // result - const String* result=0; - if(do_return_string) - result=&wcontext->result().as_string(); + const String* result=do_return_string ? local_frame.get_string() : 0; RESTORE_CONTEXT