stage4/generate_c/generate_c_base.cc
changeset 966 cd7fa00ad774
parent 958 7474d2cd1d6e
child 1011 76175defb87b
equal deleted inserted replaced
965:c9eeb67ba939 966:cd7fa00ad774
   661   this->print_variable_prefix();
   661   this->print_variable_prefix();
   662   symbol->var_name->accept(*this);
   662   symbol->var_name->accept(*this);
   663   return NULL;
   663   return NULL;
   664 }
   664 }
   665 
   665 
       
   666 /* symbolic_constant_c is used only when a variable is used inside the subrange of an array declaration
       
   667  *    e.g.: ARRAY [1 .. maxval] OF INT
       
   668  *  where maxval is a CONSTANT variable. 
       
   669  *  When maxval shows up in the POU body,          it will be stored as a standard symbolic_variable_c in the AST.
       
   670  *  When maxval shows up in the ARRAY declaration, it will be stored as a          symbolic_constant_c in the AST.
       
   671  *  This will allow us to more easily handle this special case, without affecting the remaining working code.
       
   672  */ 
       
   673 // a non-standard extension!!
       
   674 void *visit(symbolic_constant_c *symbol) {
       
   675   TRACE("symbolic_variable_c");
       
   676   if      (symbol->const_value. _int64.is_valid()) s4o.print(symbol->const_value. _int64.get());
       
   677   else if (symbol->const_value._uint64.is_valid()) s4o.print(symbol->const_value._uint64.get());
       
   678   else ERROR;
       
   679   return NULL;
       
   680 }
   666 
   681 
   667 /********************************************/
   682 /********************************************/
   668 /* B.1.4.1   Directly Represented Variables */
   683 /* B.1.4.1   Directly Represented Variables */
   669 /********************************************/
   684 /********************************************/
   670 void *visit(direct_variable_c *symbol) {
   685 void *visit(direct_variable_c *symbol) {