--- parser3/src/main/execute.C 2001/11/01 16:27:20 1.202 +++ parser3/src/main/execute.C 2001/12/21 11:17:25 1.207 @@ -2,9 +2,9 @@ Parser: executor part of request class. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + Author: Alexander Petrosyan (http://paf.design.ru) - $Id: execute.C,v 1.202 2001/11/01 16:27:20 paf Exp $ + $Id: execute.C,v 1.207 2001/12/21 11:17:25 paf Exp $ */ #include "pa_opcode.h" @@ -25,7 +25,7 @@ //#define DEBUG_EXECUTE -const uint ANTI_ENDLESS_EXECUTE_RECOURSION=200; +const uint ANTI_ENDLESS_EXECUTE_RECOURSION=500; #ifdef DEBUG_EXECUTE char *opcode_name[]={ @@ -371,12 +371,14 @@ void Request::execute(const Array& ops) // this is a constructor call if(Value *value=called_class->create_new_value(pool())) { - // some stateless_object creatable derivates + // some stateless_class creatable derivates self=value; - } else { - // stateful object - self=NEW VObject(pool(), *called_class); - } + } else + throw Exception(0, 0, + &frame->name(), + "is not a constructor, system class '%s' can be constructed only implicitly", + called_class->name().cstr()); + frame->write(*self, String::UL_CLEAN // not used, always an object, not string ); @@ -423,15 +425,16 @@ void Request::execute(const Array& ops) frame->name(), frame->numbered_params()); // execute it } else { // parser code root=frame; - if(++anti_endless_execute_recoursion==ANTI_ENDLESS_EXECUTE_RECOURSION) { - anti_endless_execute_recoursion=0; // give @exception a chance - throw Exception(0, 0, - &frame->name(), - "endless recursion detected"); + { // anti_endless_execute_recoursion + if(++anti_endless_execute_recoursion==ANTI_ENDLESS_EXECUTE_RECOURSION) { + anti_endless_execute_recoursion=0; // give @exception a chance + throw Exception(0, 0, + &frame->name(), + "call canceled - endless recursion detected"); + } + execute(*method.parser_code); // execute it + anti_endless_execute_recoursion--; } - - execute(*method.parser_code); // execute it - anti_endless_execute_recoursion--; } } catch(...) { // record it to stack trace @@ -814,7 +817,18 @@ Value& Request::process(Value& value, co self=&junction->self; root=junction->root; rcontext=junction->rcontext; - execute(*junction->code); + + { // anti_endless_execute_recoursion + if(++anti_endless_execute_recoursion==ANTI_ENDLESS_EXECUTE_RECOURSION) { + anti_endless_execute_recoursion=0; // give @exception a chance + throw Exception(0, 0, + name, + "junction evaluation canceled - endless recursion detected"); + } + execute(*junction->code); + anti_endless_execute_recoursion--; + } + if(using_code_frame) { // CodeFrame soul: // string writes were intercepted