--- parser3/src/main/execute.C 2001/03/16 11:10:20 1.111 +++ parser3/src/main/execute.C 2001/03/21 14:06:45 1.122 @@ -1,13 +1,15 @@ -/* - Parser +/** @file + Parser: executor part of request class. + Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan (http://design.ru/paf) - $Id: execute.C,v 1.111 2001/03/16 11:10:20 paf Exp $ + $Id: execute.C,v 1.122 2001/03/21 14:06:45 paf Exp $ */ -#include "pa_array.h" #include "code.h" +#include "pa_array.h" #include "pa_request.h" #include "pa_vstring.h" #include "pa_vhash.h" @@ -56,6 +58,7 @@ char *opcode_name[]={ }; void va_log_printf(const char *fmt,va_list args) { + return; vfprintf(stderr, fmt, args); } @@ -153,13 +156,13 @@ void Request::execute(const Array& ops) wcontext->set_somebody_entered_some_class(); const String& name=POP_NAME(); - VClass *vclass=static_cast(classes().get(name)); - if(!vclass) + Value *value=static_cast(classes().get(name)); + if(!value) THROW(0,0, &name, ": undefined class"); - PUSH(vclass); + PUSH(value); break; } @@ -220,7 +223,7 @@ void Request::execute(const Array& ops) { VString *vstring=static_cast(ops.quick_get(++i)); log_printf(" \"%s\"", vstring->string().cstr()); - write(vstring->string()); + write_no_lang(vstring->string()); break; } @@ -343,14 +346,13 @@ void Request::execute(const Array& ops) wcontext->constructing() && // constructing? wcontext->somebody_entered_some_class()) { // ^class:method[..]? // yes, this is a constructor call - if(called_class->name()==TABLE_CLASS_NAME) + // some stateless_object derivates with constructors + if(called_class==table_class)///called_class->name()==TABLE_CLASS_NAME) self=NEW VTable(pool()); - else if(called_class->name()==ENV_CLASS_NAME) - self=NEW VEnv(pool()); - else + else // stateful object self=NEW VObject(pool(), *called_class); frame->write(*self, - String::Untaint_lang::NO // not used, always an object, not string + String::UL_NO // not used, always an object, not string ); } else self=&frame->junction.self; // no, static or simple dynamic call @@ -365,8 +367,10 @@ void Request::execute(const Array& ops) const Method& method=*frame->junction.method; if(method.native_code) { // native code? method.check_actual_numbered_params( + frame->junction.self, frame->name(), frame->numbered_params()); - (*method.native_code)(*this, + (*method.native_code)( + *this, frame->name(), frame->numbered_params()); // execute it } else // parser code execute(*method.parser_code); // execute it @@ -416,7 +420,7 @@ void Request::execute(const Array& ops) { Value *operand=POP(); const char *path=operand->as_string().cstr(); - Value *value=NEW VBool(pool(), strcmp(path, info.request_uri)<=0); + Value *value=NEW VBool(pool(), strcmp(path, info.uri)<=0); PUSH(value); break; } @@ -630,16 +634,17 @@ Value *Request::get_element() { return value; } +/** + intercept_string: + - true: + they want result=string value, + possible object result goes to wcontext + - false: + they want any result[string|object] + nothing goes to wcontext. + used in (expression) params evaluation +*/ Value& Request::process(Value& value, const String *name, bool intercept_string) { - // intercept_string: - // true: - // they want result=string value, - // possible object result goes to wcontext - // false: - // they want any result[string|object] - // nothing goes to wcontext. - // used in (expression) params evaluation - Value *result; Junction *junction=value.get_junction(); if(junction && junction->code) { // is it a code-junction? @@ -691,7 +696,7 @@ Value& Request::process(Value& value, co return *result; } -char *Request::execute_method(Value& aself, const Method& method, bool return_cstr) { +const String *Request::execute_method(Value& aself, const Method& method, bool return_cstr) { PUSH(self); PUSH(root); PUSH(rcontext); @@ -705,9 +710,9 @@ char *Request::execute_method(Value& ase execute(*method.parser_code); // result - char *result; + const String *result; if(return_cstr) - result=wcontext->get_string()->cstr(); // chars + result=&wcontext->as_string(); else result=0; // ignore result @@ -720,7 +725,7 @@ char *Request::execute_method(Value& ase return result; } -char *Request::execute_method(Value& aself, +const String *Request::execute_method(Value& aself, const String& method_name, bool return_cstr) { if(Value *value=aself.get_element(method_name)) if(Junction *junction=value->get_junction())