Diff for /parser3/src/main/compile_tools.C between versions 1.76 and 1.82

version 1.76, 2016/05/24 16:38:40 version 1.82, 2023/09/26 20:49:09
Line 1 Line 1
 /** @file  /** @file
         Parser: compiler support helper functions.          Parser: compiler support helper functions.
   
         Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)          Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com)
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
 */  */
   
 #include "compile_tools.h"  #include "compile_tools.h"
Line 43  bool change_first(ArrayOperation& opcode Line 43  bool change_first(ArrayOperation& opcode
   
   
 // OP_VALUE+origin+self+OP_GET_ELEMENT+OP_VALUE+origin+value+OP_GET_ELEMENT => OP_WITH_SELF__VALUE__GET_ELEMENT+origin+value  // OP_VALUE+origin+self+OP_GET_ELEMENT+OP_VALUE+origin+value+OP_GET_ELEMENT => OP_WITH_SELF__VALUE__GET_ELEMENT+origin+value
 bool maybe_make_self(ArrayOperation& opcodes, ArrayOperation& diving_code, size_t divine_count){  bool maybe_make_self(ArrayOperation& opcodes, ArrayOperation& diving_code, size_t diving_count){
         const String* first_name=LA2S(diving_code);          const String* first_name=LA2S(diving_code);
   
         if(first_name && SYMBOLS_EQ(*first_name,SELF_SYMBOL)){          if(first_name && SYMBOLS_EQ(*first_name,SELF_SYMBOL)){
 #ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT  #ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT
                 if(                  if(
                         divine_count>=8                          diving_count>=8
                         && diving_code[3].code==OP::OP_GET_ELEMENT                          && diving_code[3].code==OP::OP_GET_ELEMENT
                         && diving_code[4].code==OP::OP_VALUE                          && diving_code[4].code==OP::OP_VALUE
                         && diving_code[7].code==OP::OP_GET_ELEMENT                          && diving_code[7].code==OP::OP_GET_ELEMENT
                 ){                  ){
                         // optimization for $self.field and ^self.method                          // optimization for $self.field and ^self.method
                         O(opcodes, OP::OP_WITH_SELF__VALUE__GET_ELEMENT);                          O(opcodes, OP::OP_WITH_SELF__VALUE__GET_ELEMENT);
                         P(opcodes, diving_code, 5/*offset*/, 2/*limit*/); // copy second origin+value. we know that the first one is "self"                          P(opcodes, diving_code, 5 /*offset*/, 2 /*limit*/); // copy second origin+value. we know that the first one is "self"
                         if(divine_count>8)                          if(diving_count>8)
                                 P(opcodes, diving_code, 8/*offset*/); // copy tail                                  P(opcodes, diving_code, 8 /*offset*/); // copy tail
                 } else                  } else
 #endif  #endif
                 {                  {
                         // self.xxx... => xxx...                          // self.xxx... => xxx...
                         // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+...                          // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+...
                         O(opcodes, OP::OP_WITH_SELF); /* stack: starting context */                          O(opcodes, OP::OP_WITH_SELF); /* stack: starting context */
                         P(opcodes, diving_code, divine_count>=4?4/*OP::OP_VALUE+origin+string+OP::OP_GET_ELEMENTx*/:3/*OP::OP_+origin+string*/);                          P(opcodes, diving_code, diving_count >=4 ? 4 /*OP::OP_VALUE+origin+string+OP::OP_GET_ELEMENTx*/ : 3 /*OP::OP_+origin+string*/);
                 }                  }
                 return true;                  return true;
         }          }
Line 88  bool maybe_append_simple_diving_code(Arr Line 88  bool maybe_append_simple_diving_code(Arr
   
 bool is_special_element(ArrayOperation& opcodes){  bool is_special_element(ArrayOperation& opcodes){
         const String* name=LA2S(opcodes);          const String* name=LA2S(opcodes);
         return ( name && ( SYMBOLS_EQ(*name,CLASS_SYMBOL) || SYMBOLS_EQ(*name,CLASS_NAME_SYMBOL) ) );          return name && ( SYMBOLS_EQ(*name,CLASS_SYMBOL) || SYMBOLS_EQ(*name,CLASS_NAME_SYMBOL) );
 }  }
 #endif  #endif
   
Line 112  void push_LS(Parse_control& pc, lexical_ Line 112  void push_LS(Parse_control& pc, lexical_
                 pc.ls_stack[pc.ls_sp++]=pc.ls;                    pc.ls_stack[pc.ls_sp++]=pc.ls;  
                 pc.ls=new_state;                  pc.ls=new_state;
         } else          } else
                 throw Exception(0, 0,                   throw Exception(0, 0, "push_LS: ls_stack overflow");
                         "push_LS: ls_stack overflow");  
 }  }
 void pop_LS(Parse_control& pc) {  void pop_LS(Parse_control& pc) {
         if(--pc.ls_sp>=0)          if(--pc.ls_sp>=0)
                 pc.ls=pc.ls_stack[pc.ls_sp];                  pc.ls=pc.ls_stack[pc.ls_sp];
         else          else
                 throw Exception(0, 0,                   throw Exception(0, 0, "pop_LS: ls_stack underflow");
                         "pop_LS: ls_stack underflow");  
 }  }
   
 const String& Parse_control::alias_method(const String& name) {  const String& Parse_control::alias_method(const String& name) {

Removed from v.1.76  
changed lines
  Added in v.1.82


E-mail: