equal
deleted
inserted
replaced
56 current_type = struct_it; |
56 current_type = struct_it; |
57 return NULL; |
57 return NULL; |
58 } |
58 } |
59 }; |
59 }; |
60 |
60 |
|
61 |
|
62 // Does this class really need to derive from generate_c_typedecl_c ??? |
61 class generate_c_array_initialization_c: public generate_c_typedecl_c { |
63 class generate_c_array_initialization_c: public generate_c_typedecl_c { |
62 |
64 |
63 public: |
65 public: |
64 typedef enum { |
66 typedef enum { |
65 none_am, |
67 none_am, |
200 symbol->array_subrange_list->accept(*this); |
202 symbol->array_subrange_list->accept(*this); |
201 array_base_type = symbol->non_generic_type_name; |
203 array_base_type = symbol->non_generic_type_name; |
202 array_default_value = type_initial_value_c::get(symbol->non_generic_type_name); |
204 array_default_value = type_initial_value_c::get(symbol->non_generic_type_name); |
203 if (array_default_value == NULL) ERROR; |
205 if (array_default_value == NULL) ERROR; |
204 break; |
206 break; |
205 case typedecl_am: |
207 case typedecl_am: { |
206 s4o.print("__"); |
208 int implicit_id_count = symbol->anotations_map.count("generate_c_annotaton__implicit_type_id"); |
207 symbol->non_generic_type_name->accept(*this); |
209 if (implicit_id_count > 1) ERROR; |
208 symbol->array_subrange_list->accept(*this); |
210 if (implicit_id_count == 1) |
209 break; |
211 /* this is part of an implicitly declared datatype (i.e. inside a variable decaration), for which an equivalent C datatype |
|
212 * has already been defined. So, we simly print out the id of that C datatpe... |
|
213 */ |
|
214 symbol->anotations_map["generate_c_annotaton__implicit_type_id"]->accept(*this); |
|
215 else |
|
216 symbol->non_generic_type_name->accept(*this); |
|
217 break; |
|
218 } |
210 default: |
219 default: |
211 symbol->array_subrange_list->accept(*this); |
220 symbol->array_subrange_list->accept(*this); |
212 break; |
221 break; |
213 } |
222 } |
214 return NULL; |
223 return NULL; |
222 /* res = a * b; ---> Check for overflow by pre-condition: If (UINT_MAX / a) < b => overflow! */ |
231 /* res = a * b; ---> Check for overflow by pre-condition: If (UINT_MAX / a) < b => overflow! */ |
223 if ((std::numeric_limits< unsigned long long int >::max() / array_size) < symbol->dimension) |
232 if ((std::numeric_limits< unsigned long long int >::max() / array_size) < symbol->dimension) |
224 STAGE4_ERROR(symbol, symbol, "The array containing this subrange has a total number of elements larger than the maximum currently supported (%llu).", |
233 STAGE4_ERROR(symbol, symbol, "The array containing this subrange has a total number of elements larger than the maximum currently supported (%llu).", |
225 std::numeric_limits< unsigned long long int >::max()); |
234 std::numeric_limits< unsigned long long int >::max()); |
226 array_size *= symbol->dimension; |
235 array_size *= symbol->dimension; |
227 break; |
|
228 case typedecl_am: |
|
229 s4o.print("_"); |
|
230 s4o.print(symbol->dimension); |
|
231 break; |
236 break; |
232 default: |
237 default: |
233 break; |
238 break; |
234 } |
239 } |
235 return NULL; |
240 return NULL; |
1422 void_type_init(); |
1427 void_type_init(); |
1423 |
1428 |
1424 return NULL; |
1429 return NULL; |
1425 } |
1430 } |
1426 |
1431 |
1427 /* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
|
1428 void *visit(array_specification_c *symbol) { |
|
1429 s4o.print("__"); |
|
1430 symbol->non_generic_type_name->accept(*this); |
|
1431 symbol->array_subrange_list->accept(*this); |
|
1432 return NULL; |
|
1433 } |
|
1434 |
|
1435 /* signed_integer DOTDOT signed_integer */ |
|
1436 //SYM_REF2(subrange_c, lower_limit, upper_limit) |
|
1437 void *visit(subrange_c *symbol) { |
|
1438 s4o.print("_"); |
|
1439 s4o.print(symbol->dimension); |
|
1440 return NULL; |
|
1441 } |
|
1442 |
1432 |
1443 /* var1_list ':' initialized_structure */ |
1433 /* var1_list ':' initialized_structure */ |
1444 // SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) |
1434 // SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) |
1445 void *visit(structured_var_init_decl_c *symbol) { |
1435 void *visit(structured_var_init_decl_c *symbol) { |
1446 TRACE("structured_var_init_decl_c"); |
1436 TRACE("structured_var_init_decl_c"); |