--- parser3/src/main/Attic/core.C 2001/02/24 15:26:03 1.35 +++ parser3/src/main/Attic/core.C 2001/02/25 16:36:12 1.41 @@ -1,5 +1,5 @@ /* -$Id: core.C,v 1.35 2001/02/24 15:26:03 paf Exp $ +$Id: core.C,v 1.41 2001/02/25 16:36:12 paf Exp $ */ #include "pa_request.h" @@ -48,16 +48,21 @@ void Request::core() { END_CATCH } -void Request::use(char *file, String *name) { +void Request::use(char *file, String *alias) { 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 + if(!source) + THROW(0,0, + 0, + "use: can not read '%s' file", file); + + VClass& vclass=COMPILE(source, alias, file); + String& vclass_name=vclass.name(); + //TODO: обнаружить, что грузят не объект, а операторы. + // загрузить операторы classes_array()+=&vclass; - classes().put(*name, &vclass); + classes().put(vclass_name, &vclass); + if(alias) + classes().put(*alias, &vclass); } char *Request::execute_MAIN() { @@ -71,17 +76,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->code); + + // return chars + return wcontext->get_string()->cstr(); + } } } }