Diff for /parser3/src/main/execute.C between versions 1.403 and 1.407

version 1.403, 2017/01/13 13:50:28 version 1.407, 2020/10/27 10:10:08
Line 1 Line 1
 /** @file  /** @file
         Parser: executor part of request class.          Parser: executor part of request class.
   
         Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)          Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com)
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
 */  */
   
Line 450  void Request::execute(ArrayOperation& op Line 450  void Request::execute(ArrayOperation& op
                                 const String& name=stack.pop().string();  debug_name=&name;                                  const String& name=stack.pop().string();  debug_name=&name;
                                 Value& ncontext=stack.pop().value();                                  Value& ncontext=stack.pop().value();
                                 if(const VJunction* vjunction=ncontext.put_element(name, &value))                                  if(const VJunction* vjunction=ncontext.put_element(name, &value))
                                         if(vjunction!=PUT_ELEMENT_REPLACED_ELEMENT)  
                                                 throw Exception(PARSER_RUNTIME, 0, "property value can not be code, use [] or () brackets");                                                  throw Exception(PARSER_RUNTIME, 0, "property value can not be code, use [] or () brackets");
   
                                 break;                                  break;
Line 672  void Request::execute(ArrayOperation& op Line 671  void Request::execute(ArrayOperation& op
   
                 case OP::OP_OBJECT_POOL:                  case OP::OP_OBJECT_POOL:
                         {                          {
                                   debug_name=0;
   
                                 ArrayOperation& local_ops=*i.next().ops;                                  ArrayOperation& local_ops=*i.next().ops;
                                                                   
                                 WContext *saved_wcontext=wcontext;                                  WContext *saved_wcontext=wcontext;
Line 1250  Value& Request::get_element4call(Value& Line 1251  Value& Request::get_element4call(Value&
   
 void Request::put_element(Value& ncontext, const String& name, Value* value) {  void Request::put_element(Value& ncontext, const String& name, Value* value) {
         // put_element can return property-setting-junction          // put_element can return property-setting-junction
         if(const VJunction* vjunction=ncontext.put_element(name, value))          if(const VJunction* vjunction=ncontext.put_element(name, value)) {
                 if(vjunction!=PUT_ELEMENT_REPLACED_ELEMENT) {                  const Junction& junction = vjunction->junction();
                         const Junction& junction = vjunction->junction();                  int param_count=junction.method->params_count;
                         int param_count=junction.method->params_count;  
                   if(junction.auto_name) {
                         if(junction.auto_name){                          // default setter
                                 // default setter                          if(param_count!=2)
                                 if(param_count!=2)                                  throw Exception(PARSER_RUNTIME, 0, "default setter method must have TWO parameters (has %d parameters)", param_count);
                                         throw Exception(PARSER_RUNTIME, 0, "default setter method must have TWO parameters (has %d parameters)", param_count);  
                           Value* params[2] = { new VString(*junction.auto_name), value };
                                 Value* params[2] = { new VString(*junction.auto_name), value };  
                           CONSTRUCTOR_FRAME_ACTION(*junction.method, method_frame /*caller*/, junction.self, {
                                 CONSTRUCTOR_FRAME_ACTION(*junction.method, method_frame /*caller*/, junction.self, {                                  frame.store_params(params, 2);
                                         frame.store_params(params, 2);                                  Temp_disable_default_setter temp(junction.self);
                                         Temp_disable_default_setter temp(junction.self);                                  call(frame);
                                         call(frame);                          });
                                 });                  } else {
                         } else {                          // setter
                                 // setter                          if(param_count!=1)
                                 if(param_count!=1)                                  throw Exception(PARSER_RUNTIME, 0, "setter method must have ONE parameter (has %d parameters)", param_count);
                                         throw Exception(PARSER_RUNTIME, 0, "setter method must have ONE parameter (has %d parameters)", param_count);  
                           CONSTRUCTOR_FRAME_ACTION(*junction.method, method_frame /*caller*/, junction.self, {
                                 CONSTRUCTOR_FRAME_ACTION(*junction.method, method_frame /*caller*/, junction.self, {                                  frame.store_params(&value, 1);
                                         frame.store_params(&value, 1);                                  call(frame);
                                         call(frame);                          });
                                 });  
                         }  
                 }                  }
           }
 }  }
   
 Value& Request::process_getter(Junction& junction) {  Value& Request::process_getter(Junction& junction) {
Line 1470  const String* Request::execute_virtual_m Line 1470  const String* Request::execute_virtual_m
 }  }
   
 const String* Request::get_method_filespec(const Method* method){  const String* Request::get_method_filespec(const Method* method){
           Operation::Origin origin=get_method_origin(method);
           return origin.file_no ? get_used_filespec(origin.file_no) : NULL;
   }
   
   const Operation::Origin Request::get_method_origin(const Method* method){
           Operation::Origin origin={0, 0, 0};
   
         if(ArrayOperation* code=method->parser_code)          if(ArrayOperation* code=method->parser_code)
                 if(code){                  if(code){
                         Operation::Origin origin={0, 0, 0};  
                         Array_iterator<Operation> i(*code);                          Array_iterator<Operation> i(*code);
                         while( i.has_next() ){                          while( i.has_next() ){
                                 switch( i.next().code ){                                  switch( i.next().code ){
Line 1539  const String* Request::get_method_filesp Line 1545  const String* Request::get_method_filesp
                                         default: break;                                          default: break;
                                 }                                  }
                                 if(origin.file_no)                                  if(origin.file_no)
                                         return get_used_filespec(origin.file_no);                                          return origin;
                         }                          }
                 }                  }
         return 0;          return origin;
 }  }
   

Removed from v.1.403  
changed lines
  Added in v.1.407


E-mail: