stage3/constant_folding.cc
changeset 968 649e03abbfc1
parent 967 544ff4dff04f
child 969 706a152731ab
equal deleted inserted replaced
967:544ff4dff04f 968:649e03abbfc1
  1046 }
  1046 }
  1047 
  1047 
  1048 void *constant_folding_c::handle_var_list_decl(symbol_c *var_list, symbol_c *type_decl) {
  1048 void *constant_folding_c::handle_var_list_decl(symbol_c *var_list, symbol_c *type_decl) {
  1049   type_decl->accept(*this);  // Do constant folding of the initial value, and literals in subranges! (we will probably be doing this multiple times for the same init value, but this is safe as the cvalue is idem-potent)
  1049   type_decl->accept(*this);  // Do constant folding of the initial value, and literals in subranges! (we will probably be doing this multiple times for the same init value, but this is safe as the cvalue is idem-potent)
  1050   symbol_c *init_value = type_initial_value_c::get(type_decl);  
  1050   symbol_c *init_value = type_initial_value_c::get(type_decl);  
  1051   if (NULL == init_value)   return NULL; // this is probably a FB datatype, for which no initial value exists! Do nothing and return.
  1051   if (NULL == init_value)   {debug_c::print(type_decl); return NULL;} // this is probably a FB datatype, for which no initial value exists! Do nothing and return.
  1052 
  1052   init_value->accept(*this); // necessary when handling default initial values, that were not constant folded in the call type_decl->accept(*this)
       
  1053   
  1053   list_c *list = dynamic_cast<list_c *>(var_list);
  1054   list_c *list = dynamic_cast<list_c *>(var_list);
  1054   if (NULL == list) ERROR;
  1055   if (NULL == list) ERROR;
  1055   for (int i = 0; i < list->n; i++) {
  1056   for (int i = 0; i < list->n; i++) {
  1056     token_c *var_name = dynamic_cast<token_c *>(list->elements[i]);
  1057     token_c *var_name = dynamic_cast<token_c *>(list->elements[i]);
  1057     if (NULL == var_name) {
  1058     if (NULL == var_name) {