stage4/generate_c/generate_c_st.cc
changeset 377 60b012b7793f
parent 376 7dcbd8418771
child 382 ac6dfec701c9
equal deleted inserted replaced
376:7dcbd8418771 377:60b012b7793f
   221 }
   221 }
   222 
   222 
   223 /********************************/
   223 /********************************/
   224 /* B 1.3.3 - Derived data types */
   224 /* B 1.3.3 - Derived data types */
   225 /********************************/
   225 /********************************/
       
   226 
   226 /*  signed_integer DOTDOT signed_integer */
   227 /*  signed_integer DOTDOT signed_integer */
   227 void *visit(subrange_c *symbol) {
   228 void *visit(subrange_c *symbol) {
   228   switch (wanted_casegeneration) {
   229   switch (wanted_casegeneration) {
   229     case subrange_cg:
   230     case subrange_cg:
   230       s4o.print("__case_expression >= ");
   231       s4o.print("__case_expression >= ");
   231       symbol->lower_limit->accept(*this);
   232       symbol->lower_limit->accept(*this);
   232       s4o.print(" && __case_expression <= ");
   233       s4o.print(" && __case_expression <= ");
   233       symbol->upper_limit->accept(*this);
   234       symbol->upper_limit->accept(*this);
   234       break;
   235       break;
   235     default:
   236     default:
       
   237       symbol->lower_limit->accept(*this);
   236       break;
   238       break;
   237   }
   239   }
       
   240   return NULL;
       
   241 }
       
   242 
       
   243 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */
       
   244 void *visit(array_specification_c *symbol) {
       
   245   symbol->non_generic_type_name->accept(*this);
   238   return NULL;
   246   return NULL;
   239 }
   247 }
   240 
   248 
   241 /*********************/
   249 /*********************/
   242 /* B 1.4 - Variables */
   250 /* B 1.4 - Variables */
   365   return NULL;
   373   return NULL;
   366 }
   374 }
   367 
   375 
   368 /* subscript_list ',' subscript */
   376 /* subscript_list ',' subscript */
   369 void *visit(subscript_list_c *symbol) {
   377 void *visit(subscript_list_c *symbol) {
       
   378   array_dimension_iterator_c* array_dimension_iterator = new array_dimension_iterator_c(current_array_type);
   370   for (int i =  0; i < symbol->n; i++) {
   379   for (int i =  0; i < symbol->n; i++) {
   371     s4o.print("[__");
   380     symbol_c* dimension = array_dimension_iterator->next();
   372     current_array_type->accept(*this);
   381 	if (dimension == NULL) ERROR;
   373     s4o.print("_TRANSIDX(");
   382 
   374     print_integer(i);
   383 	s4o.print("[(");
   375     s4o.print(",");
       
   376     symbol->elements[i]->accept(*this);
   384     symbol->elements[i]->accept(*this);
       
   385     s4o.print(") - (");
       
   386     dimension->accept(*this);
   377     s4o.print(")]");
   387     s4o.print(")]");
   378   }
   388   }
       
   389   delete array_dimension_iterator;
   379   return NULL;
   390   return NULL;
   380 }
   391 }
   381 
   392 
   382 /******************************************/
   393 /******************************************/
   383 /* B 1.4.3 - Declaration & Initialisation */
   394 /* B 1.4.3 - Declaration & Initialisation */