--- parser3/src/main/execute.C 2001/03/08 13:42:32 1.71 +++ parser3/src/main/execute.C 2001/03/09 04:47:29 1.79 @@ -1,5 +1,5 @@ /* - $Id: execute.C,v 1.71 2001/03/08 13:42:32 paf Exp $ + $Id: execute.C,v 1.79 2001/03/09 04:47:29 paf Exp $ */ #include "pa_array.h" @@ -92,7 +92,7 @@ void Request::execute(const Array& ops) for(int i=0; i(stack[stack.top()]); + VMethodFrame *frame=static_cast(stack.top_value()); // code const Array *local_ops=reinterpret_cast(ops.quick_get(++i)); fprintf(stderr, " (%d)\n", local_ops->size()); @@ -215,7 +215,7 @@ void Request::execute(const Array& ops) case OP_REDUCE_RWPOOL: { String *string=wcontext->get_string(); - Value *value=string?NEW VString(*string):NEW VString(pool()); + Value *value=string?NEW VString(*string):NEW VString(); wcontext=static_cast(POP()); rcontext=POP(); PUSH(value); @@ -232,7 +232,7 @@ void Request::execute(const Array& ops) // from "$a $b" part of expression taking only string value, // ignoring any other content of wcontext String *string=wcontext->get_string(); - Value *value=string?NEW VString(*string):NEW VString(pool()); + Value *value=string?NEW VString(*string):NEW VString(); wcontext=static_cast(POP()); PUSH(value); break; @@ -258,7 +258,7 @@ void Request::execute(const Array& ops) case OP_STORE_PARAM: { Value *value=POP(); - VMethodFrame *frame=static_cast(stack[0]); + VMethodFrame *frame=static_cast(stack.top_value()); frame->store_param(value); break; } @@ -274,19 +274,18 @@ void Request::execute(const Array& ops) PUSH(wcontext); VClass *called_class=frame->junction.self.get_class(); - // constructing? - if(wcontext->constructing()) { // yes - // constructor call: $some(^class:method(..)) - self=NEW VObject(pool(), *called_class); - frame->write(*self); - } else { // no - // context is object or class & is it my class or my parent's class? - VClass *read_class=rcontext->get_class(); - if(read_class && read_class->is_or_derived_from(*called_class)) // yes - self=rcontext; // class dynamic call - else // no - self=&frame->junction.self; // static or simple dynamic call - } + // is context object or class & is it my class or my parent's class? + VClass *read_class=rcontext->get_class(); + if(read_class && read_class->is_or_derived_from(*called_class)) // yes + self=rcontext; // class dynamic call + else // no, not me or relative of mine (total stranger) + if(wcontext->constructing()) { // constructing? + // yes, constructor call: $some(^class:method(..)) + self=NEW VObject(*called_class); + frame->write(*self); + } else + self=&frame->junction.self; // no, static or simple dynamic call + frame->set_self(*self); root=rcontext=wcontext=frame; { @@ -317,7 +316,8 @@ void Request::execute(const Array& ops) case OP_NEG: { Value *operand=POP(); - Value *value=NEW VDouble(pool(), -operand->get_double()); + Value *value=NEW VDouble(pool(), + -operand->get_double()); PUSH(value); break; } @@ -362,28 +362,32 @@ void Request::execute(const Array& ops) case OP_SUB: { Value *b=POP(); Value *a=POP(); - Value *value=NEW VDouble(pool(), a->get_double() - b->get_double()); + Value *value=NEW VDouble(pool(), + a->get_double() - b->get_double()); PUSH(value); break; } case OP_ADD: { Value *b=POP(); Value *a=POP(); - Value *value=NEW VDouble(pool(), a->get_double() + b->get_double()); + Value *value=NEW VDouble(pool(), + a->get_double() + b->get_double()); PUSH(value); break; } case OP_MUL: { Value *b=POP(); Value *a=POP(); - Value *value=NEW VDouble(pool(), a->get_double() * b->get_double()); + Value *value=NEW VDouble(pool(), + a->get_double() * b->get_double()); PUSH(value); break; } case OP_DIV: { Value *b=POP(); Value *a=POP(); - Value *value=NEW VDouble(pool(), a->get_double() / b->get_double()); + Value *value=NEW VDouble(pool(), + a->get_double() / b->get_double()); PUSH(value); break; } @@ -543,10 +547,13 @@ Value *Request::get_element() { Value *ncontext=POP(); Value *value=ncontext->get_element(name); - // autocalc possible code-junction - value=value?&autocalc(*value, true/*make_string*/):NEW VUnknown(pool()); + if(value) + value=&autocalc(*value); // autocalc possible code-junction + else { + value=NEW VUnknown(pool()); + value->set_name(name); + } - value->set_name(name); return value; } @@ -594,7 +601,3 @@ Value& Request::autocalc(Value& value, b } else return value; } - -void Request::write(Value& avalue) { - wcontext->write(avalue); -} \ No newline at end of file