absyntax_utils/decompose_var_instance_name.cc
changeset 238 0919986a5c98
parent 202 da1a8186f86f
child 265 4d222f46f8cc
equal deleted inserted replaced
237:cece842c7417 238:0919986a5c98
    44   next_variable_name = NULL;
    44   next_variable_name = NULL;
    45   current_recursive_variable_name = NULL;
    45   current_recursive_variable_name = NULL;
    46   previously_returned_variable_name = NULL;
    46   previously_returned_variable_name = NULL;
    47 }
    47 }
    48 
    48 
    49 symbol_c *decompose_var_instance_name_c::next_part(void) {
    49 symbol_c *decompose_var_instance_name_c::next_part(bool increment) {
    50   /* We must always start from the top!
    50   /* We must always start from the top!
    51    * See note in the structured_variable_c visitor
    51    * See note in the structured_variable_c visitor
    52    * to understand why...
    52    * to understand why...
    53    */
    53    */
    54   symbol_c *res = (symbol_c *)variable_name->accept(*this);
    54   symbol_c *res = (symbol_c *)variable_name->accept(*this);
    55   next_variable_name = current_recursive_variable_name;
    55   if (increment)
       
    56     next_variable_name = current_recursive_variable_name;
    56 
    57 
    57   if (previously_returned_variable_name == res)
    58   if (previously_returned_variable_name == res)
    58     return NULL;
    59 	  return NULL;
    59   previously_returned_variable_name = res;
    60   if (increment)
       
    61     previously_returned_variable_name = res;
    60   return res;
    62   return res;
    61 }
    63 }
    62 
       
    63 
    64 
    64 /*************************/
    65 /*************************/
    65 /* B.1 - Common elements */
    66 /* B.1 - Common elements */
    66 /*************************/
    67 /*************************/
    67 /*******************************************/
    68 /*******************************************/
   121   if (next_variable_name == symbol) {
   122   if (next_variable_name == symbol) {
   122     /* NOTE: field_selector is always an identifier_c,
   123     /* NOTE: field_selector is always an identifier_c,
   123      * so we do not have to recursevily visit it again...
   124      * so we do not have to recursevily visit it again...
   124      * return (void *)symbol->field_selector->accept(*this);  -> NOT REQUIRED!!
   125      * return (void *)symbol->field_selector->accept(*this);  -> NOT REQUIRED!!
   125      */
   126      */
   126      return (void *)symbol->field_selector;
   127 	 return (void *)symbol->field_selector;
   127   }
   128   }
   128 
   129 
   129   current_recursive_variable_name = symbol;
   130   current_recursive_variable_name = symbol;
   130   return symbol->record_variable->accept(*this);
   131   return symbol->record_variable->accept(*this);
   131 }
   132 }