--- parser3/src/main/execute.C 2002/10/31 15:01:54 1.290 +++ parser3/src/main/execute.C 2003/03/18 09:53:01 1.295.4.2 @@ -1,11 +1,11 @@ /** @file Parser: executor part of request class. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_EXECUTE_C="$Date: 2002/10/31 15:01:54 $"; +static const char* IDENT_EXECUTE_C="$Date: 2003/03/18 09:53:01 $"; #include "pa_opcode.h" #include "pa_array.h" @@ -100,6 +100,7 @@ void debug_dump(Pool& pool, int level, c case OP_OBJECT_POOL: case OP_STRING_POOL: case OP_CALL: + case OP_CALL__WRITE: const Array *local_ops=reinterpret_cast(i.next()); debug_dump(pool, level+1, *local_ops); } @@ -123,6 +124,11 @@ void Request::execute(const Array& ops) Array_iter i(ops); while(i.has_next()) { + if(interrupted()) + throw Exception("parser.interrupted", + 0, + "execution stopped"); + Operation op; op.cast=i.next(); #ifdef DEBUG_EXECUTE @@ -381,6 +387,8 @@ void Request::execute(const Array& ops) case OP_CALL: case OP_CALL__WRITE: { +// pool().collect_garbage(); + Array *local_ops=static_cast(i.next()); #ifdef DEBUG_EXECUTE debug_printf(pool(), " (%d)\n", local_ops->size()); @@ -460,6 +468,16 @@ void Request::execute(const Array& ops) method.call_type==Method::CT_ANY || method.call_type==call_type) { // allowed call type? try { + { + char buf[MAX_STRING]; + const String& name=frame.name(); + snprintf(buf, MAX_STRING, "%s(%d): %s", + name.origin().file?name.origin().file:"unknown", + name.origin().line, + name.cstr()); + pool().log_high_watermark(buf); + } + method_frame=&frame; if(method.native_code) { // native code? method.check_actual_numbered_params( @@ -824,14 +842,16 @@ void Request::execute(const Array& ops) } } -/// @todo cache|prepare junctions +/** + @todo cache|prepare junctions + @bug ^superbase:method would dynamically call ^base:method if there is any +*/ 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=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); value=NEW VJunction(junction); @@ -852,9 +872,17 @@ Value *Request::get_element(const String if(!value) value=ncontext->get_element(name, *ncontext, false); + if(value && wcontext->get_constructing()) + if(Junction *junction=value->get_junction()) { + if(junction->self.get_class()!=ncontext) + throw Exception("parser.runtime", + &name, + "constructor must be declared in class %s", ncontext->get_class()->name_cstr()); + } + value_ready: if(value) - value=&process_to_value(*value); // process possible code-junction + value=&process_to_value(*value); // process possible code-junction else value=NEW VVoid(pool());