|
|
| version 1.36, 2001/02/24 15:35:28 | version 1.49, 2001/03/10 11:18:15 |
|---|---|
| Line 8 $Id$ | Line 8 $Id$ |
| #include "pa_vclass.h" | #include "pa_vclass.h" |
| #include <stdio.h> | #include <stdio.h> |
| #include "classes/_root.h" | |
| #include "classes/_env.h" | |
| #include "classes/_string.h" | |
| #include "classes/_double.h" | |
| #include "classes/_int.h" | |
| void core() { | void core() { |
| Pool pool; | 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 request(pool); |
| request.core(); | request.core(); |
| } | } |
| Request::Request(Pool& apool) : Pooled(apool), | |
| stack(apool), | |
| root_class(apool), | |
| env_class(apool), | |
| fclasses(apool), | |
| fclasses_array(apool), | |
| lang(String::Untaint_lang::HTML_TYPO) | |
| { | |
| // 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); | |
| // env class | |
| initialize_env_class(pool(), env_class); | |
| String ENV(pool()); ENV.APPEND_CONST(ENV_NAME); | |
| classes().put(ENV, &env_class); | |
| } | |
| void Request::core() { | void Request::core() { |
| TRY { | TRY { |
| char *file="Y:\\parser3\\src\\test.p"; | 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); | use(file, &RUN); |
| char *result=execute_MAIN(); | char *result=execute_MAIN(); |
| Line 49 void Request::core() { | Line 79 void Request::core() { |
| } | } |
| void Request::use(char *file, String *name) { | void Request::use(char *file, String *name) { |
| // TODO: обнаружить|решить cyclic dependences | |
| char *source=file_read(pool(), file); | char *source=file_read(pool(), file); |
| VClass& vclass=COMPILE(source, file); | if(!source) |
| if(name) // they forced some name? | THROW(0,0, |
| vclass.set_name(*name); | 0, |
| name=vclass.name(); | "use: can not read '%s' file", file); |
| if(!name) | |
| return; //TODO: add operators | COMPILE(source, name, file); |
| classes_array()+=&vclass; | // TODO: запустить @STATIC[], если есть |
| classes().put(*name, &vclass); | |
| // if(alias) | |
| //classes().put(*alias, &vclass); | |
| } | } |
| char *Request::execute_MAIN() { | char *Request::execute_MAIN() { |
| Line 75 char *Request::execute_MAIN() { | Line 108 char *Request::execute_MAIN() { |
| const Method *method=junction->method; | const Method *method=junction->method; |
| if(method) { // and junction is method-junction! call it | if(method) { // and junction is method-junction! call it |
| // initialize contexts | // initialize contexts |
| self=root=rcontext=vclass; | root=rcontext=self=vclass; |
| wcontext=NEW WWrapper(pool(), vclass); | wcontext=NEW WWrapper(pool(), vclass, false /* not constructing */); |
| // execute! | // execute! |
| execute(method->code); | execute(*method->parser_code); |
| // return chars | // return chars |
| return wcontext->get_string()->cstr(); | return wcontext->get_string()->cstr(); |