--- parser3/src/main/Attic/core.C 2001/02/24 15:26:03 1.35 +++ parser3/src/main/Attic/core.C 2001/03/10 11:03:49 1.48 @@ -1,5 +1,5 @@ /* -$Id: core.C,v 1.35 2001/02/24 15:26:03 paf Exp $ +$Id: core.C,v 1.48 2001/03/10 11:03:49 paf Exp $ */ #include "pa_request.h" @@ -8,17 +8,42 @@ $Id: core.C,v 1.35 2001/02/24 15:26:03 p #include "pa_vclass.h" #include +#include "classes/_root.h" +#include "classes/_string.h" +#include "classes/_double.h" +#include "classes/_int.h" void core() { Pool pool; + initialize_string_class(pool, *(string_class=new(pool) VClass(pool))); + initialize_double_class(pool, *(double_class=new(pool) VClass(pool))); + initialize_int_class(pool, *(int_class=new(pool) VClass(pool))); Request request(pool); request.core(); } +Request::Request(Pool& apool) : Pooled(apool), + stack(apool), + root_class(apool), + fclasses(apool), + fclasses_array(apool), + lang(String::Untaint_lang::HTML_TYPO) +{ + // construct_root_class + initialize_root_class(pool(), root_class); + + + // adding root superclass, + // parent of all classes, + // operators holder + String ROOT(pool()); ROOT.APPEND_CONST(ROOT_NAME); + classes().put(ROOT, &root_class); +} + void Request::core() { TRY { char *file="Y:\\parser3\\src\\test.p"; - String RUN(pool()); RUN.APPEND_CONST(NAME_RUN); + String RUN(pool()); RUN.APPEND_CONST(RUN_NAME); use(file, &RUN); char *result=execute_MAIN(); @@ -49,15 +74,18 @@ void Request::core() { } void Request::use(char *file, String *name) { + // TODO: обнаружить|решить cyclic dependences char *source=file_read(pool(), file); - VClass& vclass=COMPILE(source, file); - if(name) // they forced some name? - vclass.set_name(*name); - name=vclass.name(); - if(!name) - return; //TODO: add operators - classes_array()+=&vclass; - classes().put(*name, &vclass); + if(!source) + THROW(0,0, + 0, + "use: can not read '%s' file", file); + + COMPILE(source, name, file); + // TODO: запустить @STATIC[], если есть + +// if(alias) + //classes().put(*alias, &vclass); } char *Request::execute_MAIN() { @@ -71,17 +99,19 @@ char *Request::execute_MAIN() { Value *main=vclass->get_element(name_main); if(main) { // found some 'main' element Junction *junction=main->get_junction(); - const Method *method=junction->method; - if(method) { // that element is a method, call it - // initialize contexts - self=root=rcontext=vclass; - wcontext=NEW WWrapper(pool(), vclass); - - // execute! - execute(method->code); - - // return chars - return wcontext->get_string()->cstr(); + if(junction) {// it even has junction! + const Method *method=junction->method; + if(method) { // and junction is method-junction! call it + // initialize contexts + root=rcontext=self=vclass; + wcontext=NEW WWrapper(pool(), vclass, false /* not constructing */); + + // execute! + execute(*method->parser_code); + + // return chars + return wcontext->get_string()->cstr(); + } } } }