Diff for /parser3/src/main/execute.C between versions 1.78 and 1.80

version 1.78, 2001/03/08 17:14:53 version 1.80, 2001/03/09 08:19:51
Line 28  char *opcode_name[]={ Line 28  char *opcode_name[]={
         // actions          // actions
         "WITH_SELF",    "WITH_ROOT",    "WITH_READ",    "WITH_WRITE",          "WITH_SELF",    "WITH_ROOT",    "WITH_READ",    "WITH_WRITE",
         "GET_CLASS",          "GET_CLASS",
         "CONSTRUCT",          "CONSTRUCT_VALUE",  "CONSTRUCT_DOUBLE",
         "WRITE",          "WRITE",
         "GET_ELEMENT",  "GET_ELEMENT__WRITE",          "GET_ELEMENT",  "GET_ELEMENT__WRITE",
         "CREATE_EWPOOL",        "REDUCE_EWPOOL",          "CREATE_EWPOOL",        "REDUCE_EWPOOL",
Line 92  void Request::execute(const Array& ops) Line 92  void Request::execute(const Array& ops)
         for(int i=0; i<size; i++) {          for(int i=0; i<size; i++) {
                 Operation op;                  Operation op;
                 op.cast=ops.quick_get(i);                  op.cast=ops.quick_get(i);
                 fprintf(stderr, "%d:%s", stack.top_index(), opcode_name[op.code]); fflush(stderr);                  fprintf(stderr, "%d:%s", stack.top_index()+1, opcode_name[op.code]); fflush(stderr);
   
                 switch(op.code) {                  switch(op.code) {
                 // param in next instruction                  // param in next instruction
Line 158  void Request::execute(const Array& ops) Line 158  void Request::execute(const Array& ops)
                         }                          }
                                                   
                 // OTHER ACTIONS BUT WITHs                  // OTHER ACTIONS BUT WITHs
                 case OP_CONSTRUCT:                  case OP_CONSTRUCT_VALUE:
                         {                          {
                                 Value *value=POP();                                  Value *value=POP();
                                 String& name=POP_NAME();                                  String& name=POP_NAME();
Line 167  void Request::execute(const Array& ops) Line 167  void Request::execute(const Array& ops)
                                 ncontext->put_element(name, value);                                  ncontext->put_element(name, value);
                                 break;                                  break;
                         }                          }
                   case OP_CONSTRUCT_EXPR:
                           {
                                   Value *value=POP();
                                   String& name=POP_NAME();
                                   Value *ncontext=POP();
                                   value->set_name(name);
                                   ncontext->put_element(name, value->get_expr_result());
                                   break;
                           }
                 case OP_WRITE:                  case OP_WRITE:
                         {                          {
                                 Value *value=POP();                                  Value *value=POP();
Line 215  void Request::execute(const Array& ops) Line 224  void Request::execute(const Array& ops)
                 case OP_REDUCE_RWPOOL:                  case OP_REDUCE_RWPOOL:
                         {                          {
                                 String *string=wcontext->get_string();                                  String *string=wcontext->get_string();
                                 Value *value=string?NEW VString(*string):NEW VString(pool());                                  Value *value;
                                   if(string)
                                           value=NEW VString(*string);
                                   else
                                           value=NEW VUnknown(pool());
                                 wcontext=static_cast<WContext *>(POP());                                  wcontext=static_cast<WContext *>(POP());
                                 rcontext=POP();                                  rcontext=POP();
                                 PUSH(value);                                  PUSH(value);
Line 232  void Request::execute(const Array& ops) Line 245  void Request::execute(const Array& ops)
                                 // from "$a $b" part of expression taking only string value,                                  // from "$a $b" part of expression taking only string value,
                                 // ignoring any other content of wcontext                                  // ignoring any other content of wcontext
                                 String *string=wcontext->get_string();                                  String *string=wcontext->get_string();
                                 Value *value=string?NEW VString(*string):NEW VString(pool());                                  Value *value;
                                   if(string)
                                           value=NEW VString(*string);
                                   else
                                           NEW VUnknown(pool());
                                 wcontext=static_cast<WContext *>(POP());                                  wcontext=static_cast<WContext *>(POP());
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
Line 281  void Request::execute(const Array& ops) Line 298  void Request::execute(const Array& ops)
                                 else // no, not me or relative of mine (total stranger)                                  else // no, not me or relative of mine (total stranger)
                                         if(wcontext->constructing()) {  // constructing?                                          if(wcontext->constructing()) {  // constructing?
                                                 // yes, constructor call: $some(^class:method(..))                                                  // yes, constructor call: $some(^class:method(..))
                                                 self=NEW VObject(*called_class);                                                  self=NEW VObject(pool(), *called_class);
                                                 frame->write(*self);                                                  frame->write(*self);
                                         } else                                           } else 
                                                 self=&frame->junction.self; // no, static or simple dynamic call                                                  self=&frame->junction.self; // no, static or simple dynamic call
Line 295  void Request::execute(const Array& ops) Line 312  void Request::execute(const Array& ops)
                                         Temp_alias temp_alias(*aliased, *frame->junction.vclass);                                          Temp_alias temp_alias(*aliased, *frame->junction.vclass);
   
                                         Method& method=*frame->junction.method;                                          Method& method=*frame->junction.method;
                                         if(method.native_code) // native code?                                          if(method.native_code) { // native code?
                                                   method.check_actual_numbered_params(frame->numbered_params());
                                                 (*method.native_code)(*this, frame->numbered_params()); // execute it                                                  (*method.native_code)(*this, frame->numbered_params()); // execute it
                                         else // parser code                                          } else // parser code
                                                 execute(*method.parser_code); // execute it                                                  execute(*method.parser_code); // execute it
                                 }                                  }
                                 Value *value=wcontext->result();                                  Value *value=wcontext->result();
Line 316  void Request::execute(const Array& ops) Line 334  void Request::execute(const Array& ops)
                 case OP_NEG:                  case OP_NEG:
                         {                          {
                                 Value *operand=POP();                                  Value *operand=POP();
                                 Value *value=NEW VDouble(pool(),                                   Value *value=NEW VDouble(pool(), -operand->get_double());
                                         -operand->get_double());  
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
                 case OP_INV:                  case OP_INV:
                         {                          {
                                 Value *operand=POP();                                  Value *operand=POP();
                                 Value *value=NEW VDouble(pool(),                                   Value *value=NEW VDouble(pool(), ~static_cast<int>(operand->get_double()));
                                         ~static_cast<int>(operand->get_double()));  
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
Line 362  void Request::execute(const Array& ops) Line 378  void Request::execute(const Array& ops)
                 case OP_SUB:                   case OP_SUB: 
                         {                          {
                                 Value *b=POP();  Value *a=POP();                                  Value *b=POP();  Value *a=POP();
                                 Value *value=NEW VDouble(pool(),                                   Value *value=NEW VDouble(pool(), a->get_double() - b->get_double());
                                         a->get_double() - b->get_double());  
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
                 case OP_ADD:                   case OP_ADD: 
                         {                          {
                                 Value *b=POP();  Value *a=POP();                                  Value *b=POP();  Value *a=POP();
                                 Value *value=NEW VDouble(pool(),                                   Value *value=NEW VDouble(pool(), a->get_double() + b->get_double());
                                         a->get_double() + b->get_double());  
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
                 case OP_MUL:                   case OP_MUL: 
                         {                          {
                                 Value *b=POP();  Value *a=POP();                                  Value *b=POP();  Value *a=POP();
                                 Value *value=NEW VDouble(pool(),                                   Value *value=NEW VDouble(pool(), a->get_double() * b->get_double());
                                         a->get_double() * b->get_double());  
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
                 case OP_DIV:                   case OP_DIV: 
                         {                          {
                                 Value *b=POP();  Value *a=POP();                                  Value *b=POP();  Value *a=POP();
                                 Value *value=NEW VDouble(pool(),                                   Value *value=NEW VDouble(pool(), a->get_double() / b->get_double());
                                         a->get_double() / b->get_double());  
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
Line 601  Value& Request::autocalc(Value& value, b Line 613  Value& Request::autocalc(Value& value, b
         } else          } else
                 return value;                  return value;
 }  }
   
 void Request::write(Value& avalue) {  
         wcontext->write(avalue);  
 }  
   

Removed from v.1.78  
changed lines
  Added in v.1.80


E-mail: