Diff for /parser3/src/main/execute.C between versions 1.48 and 1.52

version 1.48, 2001/02/25 18:02:12 version 1.52, 2001/03/06 14:32:19
Line 11 Line 11
 #include "pa_vcframe.h"  #include "pa_vcframe.h"
 #include "pa_vmframe.h"  #include "pa_vmframe.h"
 #include "pa_vobject.h"  #include "pa_vobject.h"
   #include "pa_vdouble.h"
   
 #include <stdio.h>  #include <stdio.h>
   
Line 20 Line 21
   
   
 char *opcode_name[]={  char *opcode_name[]={
         "STRING",  "CODE",  "CLASS",          // literals
         "WITH_ROOT",    "WITH_SELF",    "WITH_READ",    "WITH_WRITE",          "VALUE",  "CODE",  "CLASS",
   
           // actions
           "WITH_SELF",    "WITH_ROOT",    "WITH_READ",    "WITH_WRITE",
         "CONSTRUCT",          "CONSTRUCT",
         "EXPRESSION_EVAL",      "MODIFY_EVAL",  
         "WRITE",          "WRITE",
         "GET_ELEMENT",  "GET_ELEMENT__WRITE",          "GET_ELEMENT",  "GET_ELEMENT__WRITE",
         "CREATE_EWPOOL",        "REDUCE_EWPOOL",          "CREATE_EWPOOL",        "REDUCE_EWPOOL",
         "CREATE_RWPOOL",        "REDUCE_RWPOOL",          "CREATE_RWPOOL",        "REDUCE_RWPOOL",
           "CREATE_SWPOOL",        "REDUCE_SWPOOL",
         "GET_METHOD_FRAME",          "GET_METHOD_FRAME",
         "STORE_PARAM",          "STORE_PARAM",
         "CALL"          "CALL",
   
           // expression ops: unary
           "NEG", "INV", "NOT", "DEF", "IN", "FEXISTS",
           // expression ops: binary
           "SUB", "ADD", "MUL", "DIV", "MOD",
           "BIN_AND", "BIN_OR",
           "LOG_AND", "LOG_OR",
           "NUM_LT", "NUM_GT", "NUM_LE", "NUM_GE", "NUM_EQ", "NUM_NE",
           "STR_LT", "STR_GT", "STR_LE", "STR_GE", "STR_EQ", "STR_NE",
           "XOR"
 };  };
   
 void dump(int level, const Array& ops) {  void dump(int level, const Array& ops) {
Line 51  void dump(int level, const Array& ops) { Line 65  void dump(int level, const Array& ops) {
                 op.cast=ops.quick_get(i);                  op.cast=ops.quick_get(i);
                 fprintf(stderr, "%*s%s", level*4, "", opcode_name[op.code]);                  fprintf(stderr, "%*s%s", level*4, "", opcode_name[op.code]);
   
                 if(op.code==OP_STRING) {                  if(op.code==OP_VALUE) {
                         VString *vstring=static_cast<VString *>(ops.quick_get(++i));                          Value *value=static_cast<Value *>(ops.quick_get(++i));
                         fprintf(stderr, " \"%s\"", vstring->get_string()->cstr());                          fprintf(stderr, " \"%s\" %s", value->get_string()->cstr(), value->type());
                 }                  }
                 if(op.code==OP_CLASS) {                  if(op.code==OP_CLASS) {
                         VClass *vclass=static_cast<VClass *>(ops.quick_get(++i));                          VClass *vclass=static_cast<VClass *>(ops.quick_get(++i));
Line 70  void dump(int level, const Array& ops) { Line 84  void dump(int level, const Array& ops) {
   
 void Request::execute(const Array& ops) {  void Request::execute(const Array& ops) {
         if(1) {          if(1) {
                 fputs("source----------------------------", stderr);                  fputs("source----------------------------\n", stderr);
                 dump(0, ops);                  dump(0, ops);
                 fputs("execution-------------------------", stderr);                  fputs("execution-------------------------\n", stderr);
         }          }
   
         int size=ops.size();          int size=ops.size();
Line 83  void Request::execute(const Array& ops) Line 97  void Request::execute(const Array& ops)
                 fprintf(stderr, "%d:%s", stack.top(), opcode_name[op.code]);                  fprintf(stderr, "%d:%s", stack.top(), opcode_name[op.code]);
   
                 switch(op.code) {                  switch(op.code) {
                         // param in next instruction                  // param in next instruction
                 case OP_STRING:                  case OP_VALUE:
                         {                          {
                                 VString *vstring=static_cast<VString *>(ops.quick_get(++i));                                  Value *value=static_cast<Value *>(ops.quick_get(++i));
                                 fprintf(stderr, " \"%s\"", vstring->get_string()->cstr());                                  fprintf(stderr, " \"%s\" %s", value->get_string()->cstr(), value->type());
                                 PUSH(vstring);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
                 case OP_CODE:                  case OP_CODE:
Line 112  void Request::execute(const Array& ops) Line 126  void Request::execute(const Array& ops)
                                 break;                                  break;
                         }                          }
                                                   
                         // OP_WITH                  // OP_WITH
                 case OP_WITH_SELF:                   case OP_WITH_SELF: 
                         {                          {
                                 PUSH(self);                                  PUSH(self);
Line 134  void Request::execute(const Array& ops) Line 148  void Request::execute(const Array& ops)
                                 break;                                  break;
                         }                          }
                                                   
                         // ...                  // OTHER ACTIONS BUT WITHs
                 case OP_CONSTRUCT:                  case OP_CONSTRUCT:
                         {                          {
                                 Value *value=POP();                                  Value *value=POP();
Line 144  void Request::execute(const Array& ops) Line 158  void Request::execute(const Array& ops)
                                 ncontext->put_element(name, value);                                  ncontext->put_element(name, value);
                                 break;                                  break;
                         }                          }
                         // TODO: OP_EXPRESSION_EVAL,    OP_MODIFY_EVAL,  
                 case OP_WRITE:                  case OP_WRITE:
                         {                          {
                                 Value *value=POP();                                  Value *value=POP();
Line 193  void Request::execute(const Array& ops) Line 206  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=NEW VString(*string);                                  Value *value=string?NEW VString(*string):NEW VString(pool());
                                 wcontext=static_cast<WContext *>(POP());                                  wcontext=static_cast<WContext *>(POP());
                                 rcontext=POP();                                  rcontext=POP();
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
                   case OP_CREATE_SWPOOL:
                           {
                                   PUSH(wcontext);
                                   wcontext=NEW WWrapper(pool(), 0 /* empty */, false /* not constructing */);
                                   break;
                           }
                   case OP_REDUCE_SWPOOL:
                           {
                                   // 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());
                                   wcontext=static_cast<WContext *>(POP());
                                   PUSH(value);
                                   break;
                           }
   
                         // CALL                  // CALL
                 case OP_GET_METHOD_FRAME:                  case OP_GET_METHOD_FRAME:
                         {                          {
                                 Value *value=POP();                                  Value *value=POP();
Line 238  void Request::execute(const Array& ops) Line 267  void Request::execute(const Array& ops)
                                 // constructing?                                  // constructing?
                                 if(wcontext->constructing()) {  // yes                                  if(wcontext->constructing()) {  // yes
                                         // constructor call: $some(^class:method(..))                                          // constructor call: $some(^class:method(..))
                                         self=NEW VObject(pool(), *called_class);                                          frame->write(self=NEW VObject(pool(), *called_class));
                                         frame->write(self);  
                                 } else {  // no                                  } else {  // no
                                         // context is object or class & is it my class or my parent's class?                                          // context is object or class & is it my class or my parent's class?
                                         VClass *read_class=rcontext->get_class();                                          VClass *read_class=rcontext->get_class();
Line 268  void Request::execute(const Array& ops) Line 296  void Request::execute(const Array& ops)
                                 break;                                  break;
                         }                          }
   
                   // EXPRESSION
                   case OP_MUL: 
                           {
                                   Value *b=POP();
                                   Value *a=POP();
                                   Value *value=NEW VDouble(pool(), 
                                           a->get_double() *
                                           b->get_double());
                                   PUSH(value);
                                   break;
                           }
   
                 default:                  default:
                         fprintf(stderr, "\tTODO");                          fprintf(stderr, "\tTODO");
                         break;                          break;

Removed from v.1.48  
changed lines
  Added in v.1.52


E-mail: