Diff for /parser3/src/main/execute.C between versions 1.22 and 1.26

version 1.22, 2001/02/22 16:21:49 version 1.26, 2001/02/23 11:53:06
Line 7 Line 7
 #include "pa_request.h"  #include "pa_request.h"
 #include "pa_vstring.h"  #include "pa_vstring.h"
 #include "pa_vhash.h"  #include "pa_vhash.h"
   #include "pa_vunknown.h"
   
 #include <stdio.h>  #include <stdio.h>
   
   #define PUSH(value) stack.push(value)
   #define POP() static_cast<Value *>(stack.pop())
   
   
 char *opcode_name[]={  char *opcode_name[]={
         "STRING",  "CODE_ARRAY",          "STRING",  "CODE_ARRAY",
Line 27  char *opcode_name[]={ Line 31  char *opcode_name[]={
 };  };
   
 void dump(int level, const Array& ops) {  void dump(int level, const Array& ops) {
           if(0){
                   int size=ops.size();
                   printf("size=%d\n", size);
                   for(int i=0; i<size; i++) {
                           Operation op;
                           op.cast=ops.quick_get(i);
                           printf("%8X\n", op.cast);
                   }
           }
   
         int size=ops.size();          int size=ops.size();
           printf("size=%d\n", size);
         for(int i=0; i<size; i++) {          for(int i=0; i<size; i++) {
                 int code=reinterpret_cast<int>(ops.quick_get(i));                  Operation op;
                 printf("%*s%s", level*4, "", opcode_name[code]);                  op.cast=ops.quick_get(i);
                   printf("%*s%s", level*4, "", opcode_name[op.code]);
   
                 if(code==OP_STRING) {                  if(op.code==OP_STRING) {
                         VString *vstring=static_cast<VString *>(ops.quick_get(++i));                          VString *vstring=static_cast<VString *>(ops.quick_get(++i));
                         printf(" \"%s\"", vstring->get_string()->cstr());                          printf(" \"%s\"", vstring->get_string()->cstr());
                 }                  }
                 printf("\n");                  printf("\n");
   
                 if(code==OP_CODE_ARRAY) {                  if(op.code==OP_CODE_ARRAY) {
                         const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));                          const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));
                         dump(level+1, *local_ops);                          dump(level+1, *local_ops);
                 }                  }
Line 53  void Request::execute(Array& ops) { Line 69  void Request::execute(Array& ops) {
         }          }
   
         int size=ops.size();          int size=ops.size();
           printf("size=%d\n", size);
         for(int i=0; i<size; i++) {          for(int i=0; i<size; i++) {
                 int code=reinterpret_cast<int>(ops.quick_get(i));                  Operation op;
                 printf("%d:%s", stack.top(), opcode_name[code]);                  op.cast=ops.quick_get(i);
                   printf("%d:%s", stack.top(), opcode_name[op.code]);
   
                 if(code==OP_CODE_ARRAY) {                  if(op.code==OP_CODE_ARRAY) {
                         const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));                          const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i));
                         //dump(level+1, *local_ops);                          //dump(level+1, *local_ops);
                 }                  }
                                   
                 switch(code) {                  switch(op.code) {
                 case OP_WITH_WRITE:                   case OP_WITH_WRITE: 
                         {                          {
                                 stack.push(wcontext);                                  PUSH(wcontext);
                                 break;                                  break;
                         }                          }
                 case OP_WITH_READ:                   case OP_WITH_READ: 
                         {                          {
                                 stack.push(rcontext);                                  PUSH(rcontext);
                                 break;                                  break;
                         }                          }
                 case OP_WITH_ROOT:                   case OP_WITH_ROOT: 
                         {                          {
                                 stack.push(root);                                  PUSH(root);
                                 break;                                  break;
                         }                          }
                 case OP_WITH_SELF:                   case OP_WITH_SELF: 
                         {                          {
                                 stack.push(self);                                  PUSH(self);
                                 break;                                  break;
                         }                          }
                                                   
Line 88  void Request::execute(Array& ops) { Line 106  void Request::execute(Array& ops) {
                         {                          {
                                 VString *vstring=static_cast<VString *>(ops.quick_get(++i));                                  VString *vstring=static_cast<VString *>(ops.quick_get(++i));
                                 printf(" \"%s\"", vstring->get_string()->cstr());                                  printf(" \"%s\"", vstring->get_string()->cstr());
                                 stack.push(vstring);                                  PUSH(vstring);
                                 break;                                  break;
                         }                          }
                                                   
                 case OP_CONSTRUCT:                  case OP_CONSTRUCT:
                         {                          {
                                 Value *value=static_cast<Value *>(stack.pop());                                  Value *value=POP();
                                 VString *name=static_cast<VString *>(stack.pop());                                  String& name=POP()->as_string();
                                 Value *ncontext=static_cast<Value *>(stack.pop());                                  Value *ncontext=POP();
                                 ncontext->put_element(*name, value);                                  value->set_name(name);
                                   ncontext->put_element(name, value);
                                 break;                                  break;
                         }                          }
                                                   
                 case OP_WRITE:                  case OP_WRITE:
                         {                          {
                                 Value *value=static_cast<Value *>(stack.pop());                                  Value *value=POP();
                                 wcontext->write(value);                                  wcontext->write(value);
                                 break;                                  break;
                         }                          }
Line 111  void Request::execute(Array& ops) { Line 130  void Request::execute(Array& ops) {
                 case OP_GET_ELEMENT:                  case OP_GET_ELEMENT:
                         {                          {
                                 Value *value=get_element();                                  Value *value=get_element();
                                 stack.push(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
   
Line 124  void Request::execute(Array& ops) { Line 143  void Request::execute(Array& ops) {
   
                 case OP_CREATE_EWPOOL:                  case OP_CREATE_EWPOOL:
                         {                          {
                                 stack.push(wcontext);                                  PUSH(wcontext);
                                 wcontext=NEW WContext(pool(), 0 /* empty */);                                  wcontext=NEW WContext(pool(), 0 /* empty */);
                                 break;                                  break;
                         }                          }
                 case OP_REDUCE_EWPOOL:                  case OP_REDUCE_EWPOOL:
                         {                          {
                                 Value *value=wcontext->value();                                  Value *value=wcontext->value();
                                 wcontext=static_cast<WContext *>(stack.pop());                                  wcontext=static_cast<WContext *>(POP());
                                 stack.push(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
                                                   
                   case OP_CREATE_RWPOOL:
                           {
                                   Value *ncontext=POP();
                                   PUSH(rcontext);
                                   rcontext=ncontext;
                                   PUSH(wcontext);
                                   wcontext=NEW WContext(pool(), ncontext);
                                   break;
                           }
                   case OP_REDUCE_RWPOOL:
                           {
                                   String *string=wcontext->get_string();
                                   Value *value=NEW VString(string);
                                   wcontext=static_cast<WContext *>(POP());
                                   rcontext=POP();
                                   PUSH(value);
                                   break;
                           }
   
                 default:                  default:
                         printf("\tTODO");                          printf("\tTODO");
                         break;                          break;
Line 145  void Request::execute(Array& ops) { Line 183  void Request::execute(Array& ops) {
 }  }
   
 Value *Request::get_element() {  Value *Request::get_element() {
         VString *name=static_cast<VString *>(stack.pop());          String& name=POP()->as_string();
         Value *ncontext=static_cast<Value *>(stack.pop());          Value *ncontext=POP();
         Value *value=ncontext->get_element(*name); // name áûâàåò method, òîãäà âûäà¸ò new junction(ÀÂÒÎÂÛ×ÈÑËßÒÜ=false, root,self,rcontext,wcontext,code)          Value *value=ncontext->get_element(name); // name áûâàåò method, òîãäà âûäà¸ò new junction(ÀÂÒÎÂÛ×ÈÑËßÒÜ=false, root,self,rcontext,wcontext,code)
         // name áûâàåò èìÿ junction, òîãäà èëè îñòàâëÿåò â ïîêîå, èëè âû÷èñëÿåò â çàâèñèìîñòè îò ôëàãà ÀÂÒÎÂÛ×ÈÑËßÒÜ          // name áûâàåò èìÿ junction, òîãäà èëè îñòàâëÿåò â ïîêîå, èëè âû÷èñëÿåò â çàâèñèìîñòè îò ôëàãà ÀÂÒÎÂÛ×ÈÑËßÒÜ
   
         if(!value) {          if(!value) {
                 value=NEW VHash(pool());                  value=NEW VUnknown(pool());
                 ncontext->put_element(*name, value);                  value->set_name(name);
         }          }
         return value;          return value;
 }  }
   

Removed from v.1.22  
changed lines
  Added in v.1.26


E-mail: