Diff for /parser3/src/main/execute.C between versions 1.159 and 1.180

version 1.159, 2001/05/17 15:20:15 version 1.180, 2001/07/20 09:40:46
Line 4 Line 4
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
   
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
   
         $Id$  
 */  */
   static const char *RCSId="$Id$"; 
   
 #include "pa_config_includes.h"  
 #include "pa_opcode.h"  #include "pa_opcode.h"
 #include "pa_array.h"   #include "pa_array.h" 
 #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 "pa_vvoid.h"
 #include "pa_vcode_frame.h"  #include "pa_vcode_frame.h"
 #include "pa_vmethod_frame.h"  #include "pa_vmethod_frame.h"
 #include "pa_vobject.h"  #include "pa_vobject.h"
Line 255  void Request::execute(const Array& ops) Line 253  void Request::execute(const Array& ops)
                                 // maybe they do ^object.method[] call, remember the fact                                  // maybe they do ^object.method[] call, remember the fact
                                 wcontext->inc_somebody_entered_some_object();                                  wcontext->inc_somebody_entered_some_object();
   
                                   //_asm int 3;
                                 Value *value=get_element();                                  Value *value=get_element();
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
Line 301  void Request::execute(const Array& ops) Line 300  void Request::execute(const Array& ops)
                                 if(string)                                  if(string)
                                         value=NEW VString(*string);                                          value=NEW VString(*string);
                                 else                                  else
                                         value=NEW VUnknown(pool());                                          value=NEW VVoid(pool());
                                 wcontext=static_cast<WContext *>(POP());                                  wcontext=static_cast<WContext *>(POP());
                                 rcontext=POP();                                  rcontext=POP();
                                 PUSH(value);                                  PUSH(value);
Line 322  void Request::execute(const Array& ops) Line 321  void Request::execute(const Array& ops)
                                 if(string)                                  if(string)
                                         value=NEW VString(*string);                                          value=NEW VString(*string);
                                 else                                  else
                                         NEW VUnknown(pool());                                          NEW VVoid(pool());
                                 wcontext=static_cast<WContext *>(POP());                                  wcontext=static_cast<WContext *>(POP());
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
Line 374  void Request::execute(const Array& ops) Line 373  void Request::execute(const Array& ops)
                                 PUSH(wcontext);                                   PUSH(wcontext); 
                                                                   
                                 VStateless_class *called_class=frame->junction.self.get_class();                                  VStateless_class *called_class=frame->junction.self.get_class();
                                 // not ^name.method call and                                  // not ^name.method call, name:method call; and
                                 // is context object or class & is it my class or my parent's class and?                                  // is context object or class & is it my class or my parent's class and?
                                 VStateless_class *read_class=rcontext->get_class();                                  VStateless_class *read_class=rcontext->get_class();
                                 if(!wcontext->somebody_entered_some_object() &&                                   if(
                                           !(wcontext->somebody_entered_some_object() &&
                                           !wcontext->somebody_entered_some_class()) && 
                                         read_class && read_class->is_or_derived_from(*called_class)) // yes                                          read_class && read_class->is_or_derived_from(*called_class)) // yes
                                         self=rcontext; // class dynamic call                                          self=rcontext; // class dynamic call
                                 else // no, not me or relative of mine (total stranger)                                  else // no, not me or relative of mine (total stranger)
Line 416  void Request::execute(const Array& ops) Line 417  void Request::execute(const Array& ops)
                                                         method.check_actual_numbered_params(pool(),                                                          method.check_actual_numbered_params(pool(),
                                                                 frame->junction.self,                                                                   frame->junction.self, 
                                                                 frame->name(), frame->numbered_params());                                                                  frame->name(), frame->numbered_params());
                                                         (*method.native_code)(                                                          method.native_code(
                                                                 *this,                                                                   *this, 
                                                                 frame->name(), frame->numbered_params()); // execute it                                                                  frame->name(), frame->numbered_params()); // execute it
                                                 } else { // parser code                                                  } else { // parser code
                                                         if(++anti_endless_execute_recoursion==ANTI_ENDLESS_EXECUTE_RECOURSION) {                                                          if(++anti_endless_execute_recoursion==ANTI_ENDLESS_EXECUTE_RECOURSION) {
                                                                 anti_endless_execute_recoursion=0; // give @exception a chance                                                                  anti_endless_execute_recoursion=0; // give @exception a chance
                                                                 THROW(0, 0,                                                                  THROW(0, 0,
                                                                         &method.name,                                                                          &frame->name(),
                                                                         "endless recursion detected");                                                                          "endless recursion detected");
                                                         }                                                          }
                                                                                                                   
Line 531  void Request::execute(const Array& ops) Line 532  void Request::execute(const Array& ops)
                 case OP_DIV:                   case OP_DIV: 
                         {                          {
                                 Value *b=POP();  Value *a=POP();                                  Value *b=POP();  Value *a=POP();
                                 Value *value=NEW VDouble(pool(), a->as_double() / b->as_double());  
                                   double a_double=a->as_double();
                                   double b_double=b->as_double();
   
                                   if(b_double == 0) {
                                           const String *problem_source=&b->as_string();
   #ifndef NO_STRING_ORIGIN
                                           if(!problem_source->origin().file)
                                                   problem_source=&b->name();
   #endif
                                           THROW(0, 0,
                                                   problem_source,
                                                   "Division by zero");
                                   }
   
                                   Value *value=NEW VDouble(pool(), a_double / b_double);
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
                 case OP_MOD:                   case OP_MOD: 
                         {                          {
                                 Value *b=POP();  Value *a=POP();                                  Value *b=POP();  Value *a=POP();
                                 Value *value=NEW VDouble(pool(),   
                                         a->as_int() %                                  double a_double=a->as_double();
                                         b->as_int());                                  double b_double=b->as_double();
   
                                   if(b_double == 0) {
                                           const String *problem_source=&b->as_string();
   #ifndef NO_STRING_ORIGIN
                                           if(!problem_source->origin().file)
                                                   problem_source=&b->name();
   #endif
                                           THROW(0, 0,
                                                   problem_source,
                                                   "Modulus by zero");
                                   }
   
                                   Value *value=NEW VDouble(pool(), fmod(a_double, b_double));
                                 PUSH(value);                                  PUSH(value);
                                 break;                                  break;
                         }                          }
Line 706  Value *Request::get_element() { Line 735  Value *Request::get_element() {
         if(value)          if(value)
                 value=&process(*value, &name); // process possible code-junction                  value=&process(*value, &name); // process possible code-junction
         else {          else {
                 value=NEW VUnknown(pool());                  value=NEW VVoid(pool());
                 value->set_name(name);                  value->set_name(name);
         }          }
   
         return value;          return value;
 }  }
   
 /**     intercept_string:  /**     @param intercept_string
         - true:          - true:
                 they want result=string value,                   they want result=string value, 
                 possible object result goes to wcontext                  possible object result goes to wcontext
Line 778  Value& Request::process(Value& value, co Line 807  Value& Request::process(Value& value, co
         return *result;          return *result;
 }  }
   
 const String *Request::execute_method(Value& aself, const Method& method, bool return_cstr) {  const String *Request::execute_method(Value& aself, const Method& method, 
                                                                             bool return_cstr) {
         PUSH(self);            PUSH(self);  
         PUSH(root);            PUSH(root);  
         PUSH(rcontext);            PUSH(rcontext);  
Line 807  const String *Request::execute_method(Va Line 837  const String *Request::execute_method(Va
         return result;          return result;
 }  }
   
 const String *Request::execute_method(Value& aself,   const String *Request::execute_virtual_method(Value& aself, 
                                                           const String& method_name, bool return_cstr) {                                                                                            const String& method_name, 
                                                                                             bool return_cstr) {
         if(Value *value=aself.get_element(method_name))          if(Value *value=aself.get_element(method_name))
                 if(Junction *junction=value->get_junction())                  if(Junction *junction=value->get_junction())
                         if(const Method *method=junction->method)                           if(const Method *method=junction->method) 
Line 816  const String *Request::execute_method(Va Line 847  const String *Request::execute_method(Va
   
         return 0;          return 0;
 }  }
   
   const String *Request::execute_nonvirtual_method(VStateless_class& aclass, 
                                                                                                    const String& method_name, 
                                                                                                    bool return_cstr) {
           if(const Method *method=aclass.get_method(method_name))
                   return execute_method(aclass, *method, return_cstr);
   
           return 0;
   }

Removed from v.1.159  
changed lines
  Added in v.1.180


E-mail: