--- parser3/src/main/execute.C 2002/01/31 12:40:35 1.211 +++ parser3/src/main/execute.C 2002/02/18 15:21:01 1.219 @@ -1,10 +1,10 @@ /** @file Parser: executor part of request class. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) + Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) - $Id: execute.C,v 1.211 2002/01/31 12:40:35 paf Exp $ + $Id: execute.C,v 1.219 2002/02/18 15:21:01 paf Exp $ */ #include "pa_opcode.h" @@ -38,12 +38,12 @@ char *opcode_name[]={ "GET_CLASS", "CONSTRUCT_VALUE", "CONSTRUCT_EXPR", "CURLY_CODE__CONSTRUCT", "WRITE_VALUE", "WRITE_EXPR_RESULT", "STRING__WRITE", - "GET_ELEMENT", "GET_ELEMENT__WRITE", + "GET_ELEMENT_OR_OPERATOR", "GET_ELEMENT", "GET_ELEMENT__WRITE", "CREATE_EWPOOL", "REDUCE_EWPOOL", "CREATE_SWPOOL", "REDUCE_SWPOOL", "GET_METHOD_FRAME", "STORE_PARAM", - "PREPARE_TO_CONSTRUCT_OBJECT", "CALL", + "PREPARE_TO_CONSTRUCT_OBJECT", "PREPARE_TO_EXPRESSION", "CALL", // expression ops: unary "NEG", "INV", "NOT", "DEF", "IN", "FEXISTS", "DEXISTS", @@ -166,7 +166,7 @@ void Request::execute(const Array& ops) case OP_GET_CLASS: { // maybe they do ^class:method[] call, remember the fact - wcontext->set_somebody_entered_some_class(true); + wcontext->set_somebody_entered_some_class(); const String& name=POP_NAME(); value=static_cast(classes().get(name)); @@ -209,15 +209,13 @@ void Request::execute(const Array& ops) Value *ncontext=POP(); ncontext->put_element(name, value); value->set_name(name); - - // forget the fact they've entered some $class/object.xxx - // see OP_GET_ELEMENT - wcontext->set_somebody_entered_some_object(false); - wcontext->set_somebody_entered_some_class(false); break; } case OP_CONSTRUCT_EXPR: { + // see OP_PREPARE_TO_EXPRESSION + wcontext->set_in_expression(false); + value=POP(); const String& name=POP_NAME(); Value *ncontext=POP(); @@ -261,14 +259,16 @@ void Request::execute(const Array& ops) value=POP(); write_assign_lang(*value); - // forget the fact they've entered some ^object/class.xxx or $object/class.xxx + // forget the fact they've entered some ^object.method[]. // see OP_GET_ELEMENT wcontext->set_somebody_entered_some_object(false); - wcontext->set_somebody_entered_some_class(false); break; } case OP_WRITE_EXPR_RESULT: { + // see OP_PREPARE_TO_EXPRESSION + wcontext->set_in_expression(false); + value=POP(); write_expr_result(*value->as_expr_result()); break; @@ -283,23 +283,30 @@ void Request::execute(const Array& ops) break; } - case OP_GET_ELEMENT: + case OP_GET_ELEMENT_OR_OPERATOR: { - //_asm int 3; - // uses entered object/class flags to plug in operators - value=get_element(); + // maybe they do ^object.method[] call, remember the fact + wcontext->set_somebody_entered_some_object(true); + //_asm int 3; + value=get_element(true); + PUSH(value); + break; + } + case OP_GET_ELEMENT: + { // maybe they do ^object.method[] call, remember the fact - // must be below get_element() call, it checks it wcontext->set_somebody_entered_some_object(true); + //_asm int 3; + value=get_element(false); PUSH(value); break; } case OP_GET_ELEMENT__WRITE: { - value=get_element(); + value=get_element(false); write_assign_lang(*value); break; } @@ -375,6 +382,13 @@ void Request::execute(const Array& ops) wcontext->set_constructing(true); break; } + + case OP_PREPARE_TO_EXPRESSION: + { + wcontext->set_in_expression(true); + break; + } + case OP_CALL: { #ifdef DEBUG_EXECUTE @@ -425,6 +439,10 @@ void Request::execute(const Array& ops) } frame->set_self(*self); + + // see OP_PREPARE_TO_EXPRESSION + frame->set_in_expression(wcontext->get_in_expression()); + rcontext=wcontext=frame; { // take object or class from any wrappers @@ -793,21 +811,19 @@ void Request::execute(const Array& ops) } } -Value *Request::get_element() { +Value *Request::get_element(bool can_call_operator) { const String& name=POP_NAME(); Value *ncontext=POP(); - Value *value=ncontext->get_element(name); - // operators can not be in form... - if(!value && - !wcontext->get_somebody_entered_some_class () && // $class:xxx - !wcontext->get_somebody_entered_some_object()) // $object.xxx - // they can only be in form ^xxx or $xxx - if(Method* method=OP.get_method(name)) { // maybe operator? + Value *value=0; + if(can_call_operator) + if(Method* method=OP.get_method(name)) { // looking operator of that name FIRST // as if that method were in self and we have normal dynamic method here Junction& junction=*NEW Junction(pool(), *root, self->get_class(), method, 0,0,0,0); value=NEW VJunction(junction); } + if(!value) + value=ncontext->get_element(name); if(value) value=&process(*value, &name); // process possible code-junction else {