--- parser3/src/main/Attic/core.C 2001/02/12 11:34:12 1.2 +++ parser3/src/main/Attic/core.C 2001/02/13 11:24:25 1.5 @@ -1,19 +1,23 @@ void process(Pool& pool, Value& self, RContext& rcontext, WContext& wcontext, - StringIterator& code, char char_to_stop_before) { + String_iterator& code, char char_to_stop_before) { // $ on code? process_dollar(pool, rcontext, wcontext, code, char_to_stop_before); // ^ on code? process_bird(pool, rcontext, wcontext, code, char_to_stop_before); + + // TODO + // 1. случаи :: и this. в начале + // 2. вызовы статических методов } void process_dollar(Pool& pool, - Value& THIS, + Value& self, RContext& rcontext, WContext& wcontext, - StringIterator& iter, char char_to_stop_before) { + String_iterator& iter, char char_to_stop_before) { // $name.field.subfield -- read // $name.field.subfield(constructor code) -- construct @@ -29,6 +33,7 @@ void process_dollar(Pool& pool, Value *context=read_mode?rcontext:wcontext; if(read_mode) { + // 'context' dive into dotted path for(int i=0; iget_element(static_cast(names.get[i])); if(!context) // no such object field, nothing bad, just ignore that @@ -40,7 +45,9 @@ void process_dollar(Pool& pool, bool construct_mode=names_ended_before=='('; + // 'context' dive into dotted path, int steps=names.count(); + // if constructing then "excluding last .name" if(construct_mode) steps--; for(int i=0; i(names.get[steps]); WContext local_wcontext(pool /* empty */); process(pool, rcontext, local_wcontext, iter, ')'); context->put_element(name, local_wcontext.value()); } else { // =='[' + // .name[with-code], processing on 'context' WContext local_context(pool, context); process(pool, local_context, local_context, iter, ']'); wcontext.write(local_context); @@ -70,7 +80,7 @@ void process_dollar(Pool& pool, void process_bird(Pool& pool, Value& self, RContext& rcontext, WContext& wcontext, - StringIterator& iter, char char_to_stop_before) { + String_iterator& iter, char char_to_stop_before) { // ^name.field.subfield.method[..] -- plain call // ^name.field.subfield.method_ref[..] -- method ref call, when .get_method()!=0 @@ -84,6 +94,7 @@ void process_bird(Pool& pool, Value *context=rcontext; iter++; // skip '[' + // 'context' dive into dotted path, excluding last .name Value *local_self=context; int steps=names.count()-1; for(int i=0; i(names.get[steps]); // first we're trying to locate method with that 'name' Method *method=context.get_method(name); @@ -100,10 +112,11 @@ void process_bird(Pool& pool, Value *value=context.get_element(name); if(!value) // failed: no element of that 'name' pool.exception().raise(name, "call: no method field found"); - method=value->get_method(); - if(!method) // failed: that field wasn't method_ref + Method_ref *method_ref=value->get_method_ref(); + if(!method_ref) // failed: that field wasn't method_ref pool.exception().raise(name, "call: this field is not a method reference"); - local_self=value->get_self(); + method=method_ref->method; + local_self=method_ref->self; }