24 |
24 |
25 #include <limits> // required for std::numeric_limits<XXX> |
25 #include <limits> // required for std::numeric_limits<XXX> |
26 |
26 |
27 class initialization_analyzer_c: public null_visitor_c { |
27 class initialization_analyzer_c: public null_visitor_c { |
28 public: |
28 public: |
29 typedef enum { |
29 typedef enum { |
30 simple_it, |
30 simple_it, |
31 array_it, |
31 array_it, |
32 struct_it |
32 struct_it |
33 } initialization_type_t; |
33 } initialization_type_t; |
34 |
34 |
35 private: |
35 private: |
36 |
36 |
37 initialization_type_t current_type; |
37 initialization_type_t current_type; |
38 |
38 |
39 public: |
39 public: |
40 initialization_analyzer_c(symbol_c* symbol) { |
40 initialization_analyzer_c(symbol_c* symbol) { |
41 current_type = simple_it; |
41 current_type = simple_it; |
42 symbol->accept(*this); |
42 symbol->accept(*this); |
43 } |
43 } |
44 ~initialization_analyzer_c(void) {} |
44 ~initialization_analyzer_c(void) {} |
45 |
45 |
46 initialization_type_t get_initialization_type(void) { |
46 initialization_type_t get_initialization_type(void) { |
47 return current_type; |
47 return current_type; |
48 } |
48 } |
49 |
49 |
50 void *visit(array_initial_elements_list_c *symbol) { |
50 void *visit(array_initial_elements_list_c *symbol) { |
51 current_type = array_it; |
51 current_type = array_it; |
52 return NULL; |
52 return NULL; |
53 } |
53 } |
54 |
54 |
55 void *visit(structure_element_initialization_list_c *symbol) { |
55 void *visit(structure_element_initialization_list_c *symbol) { |
56 current_type = struct_it; |
56 current_type = struct_it; |
57 return NULL; |
57 return NULL; |
58 } |
58 } |
271 void *visit(array_initial_elements_c *symbol) { |
271 void *visit(array_initial_elements_c *symbol) { |
272 unsigned long long int initial_element_count; |
272 unsigned long long int initial_element_count; |
273 |
273 |
274 /* This code assumes that unsigned long long int is >= uint64_t */ |
274 /* This code assumes that unsigned long long int is >= uint64_t */ |
275 if (std::numeric_limits< uint64_t >::max() > std::numeric_limits< unsigned long long int >::max()) |
275 if (std::numeric_limits< uint64_t >::max() > std::numeric_limits< unsigned long long int >::max()) |
276 ERROR_MSG("Assertion (sizeof(uint64_t) > sizeof(unsigned long long int)) failed! Compiler cannot execute correctly on the current platform!"); |
276 ERROR_MSG("Assertion (sizeof(uint64_t) > sizeof(unsigned long long int)) failed! Compiler cannot execute correctly on the current platform!"); |
277 |
277 |
278 switch (current_mode) { |
278 switch (current_mode) { |
279 case initializationvalue_am: |
279 case initializationvalue_am: |
280 if (VALID_CVALUE( int64, symbol->integer) && (GET_CVALUE( int64, symbol->integer) >= 0)) |
280 if (VALID_CVALUE( int64, symbol->integer) && (GET_CVALUE( int64, symbol->integer) >= 0)) |
281 initial_element_count = GET_CVALUE( int64, symbol->integer); |
281 initial_element_count = GET_CVALUE( int64, symbol->integer); |
652 /* array_initial_elements_list ',' array_initial_elements */ |
652 /* array_initial_elements_list ',' array_initial_elements */ |
653 void *visit(array_initial_elements_list_c *symbol) { |
653 void *visit(array_initial_elements_list_c *symbol) { |
654 generate_c_array_initialization_c *array_initialization = new generate_c_array_initialization_c(&s4o); |
654 generate_c_array_initialization_c *array_initialization = new generate_c_array_initialization_c(&s4o); |
655 array_initialization->init_array_size(current_element_type); |
655 array_initialization->init_array_size(current_element_type); |
656 if (current_element_default_value != NULL) |
656 if (current_element_default_value != NULL) |
657 array_initialization->set_array_default_initialisation(current_element_default_value); |
657 array_initialization->set_array_default_initialisation(current_element_default_value); |
658 array_initialization->init_array_values(symbol); |
658 array_initialization->init_array_values(symbol); |
659 delete array_initialization; |
659 delete array_initialization; |
660 return NULL; |
660 return NULL; |
661 } |
661 } |
662 |
662 |
941 (wanted_varformat == init_vf) || |
941 (wanted_varformat == init_vf) || |
942 (wanted_varformat == localinit_vf)) { |
942 (wanted_varformat == localinit_vf)) { |
943 for(int i = 0; i < list->n; i++) { |
943 for(int i = 0; i < list->n; i++) { |
944 s4o.print(s4o.indent_spaces); |
944 s4o.print(s4o.indent_spaces); |
945 if (wanted_varformat == local_vf) { |
945 if (wanted_varformat == local_vf) { |
946 if (!is_fb) { |
946 if (!is_fb) { |
947 s4o.print(DECLARE_VAR); |
947 s4o.print(DECLARE_VAR); |
948 s4o.print("("); |
948 s4o.print("("); |
949 } |
949 } |
950 this->current_var_type_symbol->accept(*this); |
950 this->current_var_type_symbol->accept(*this); |
951 if (is_fb) |
951 if (is_fb) |
952 s4o.print(" "); |
952 s4o.print(" "); |
953 else |
953 else |
954 s4o.print(","); |
954 s4o.print(","); |
955 print_variable_prefix(); |
955 print_variable_prefix(); |
956 } |
956 } |
957 else if (wanted_varformat == localinit_vf) { |
957 else if (wanted_varformat == localinit_vf) { |
958 this->current_var_type_symbol->accept(*this); |
958 this->current_var_type_symbol->accept(*this); |
959 s4o.print(" "); |
959 s4o.print(" "); |
960 print_variable_prefix(); |
960 print_variable_prefix(); |
961 } |
961 } |
962 else if (wanted_varformat == init_vf) { |
962 else if (wanted_varformat == init_vf) { |
963 s4o.print(SET_VAR); |
963 s4o.print(SET_VAR); |
964 s4o.print("("); |
964 s4o.print("("); |
965 print_variable_prefix(); |
965 print_variable_prefix(); |
966 s4o.print(","); |
966 s4o.print(","); |
967 } |
967 } |
968 list->elements[i]->accept(*this); |
968 list->elements[i]->accept(*this); |
969 if (wanted_varformat != local_vf) { |
969 if (wanted_varformat != local_vf) { |
970 if (wanted_varformat == localinit_vf && |
970 if (wanted_varformat == localinit_vf && |
971 (current_vartype & inoutput_vt) != 0) { |
971 (current_vartype & inoutput_vt) != 0) { |
972 s4o.print(";\n"); |
972 s4o.print(";\n"); |
973 s4o.print(s4o.indent_spaces); |
973 s4o.print(s4o.indent_spaces); |
974 s4o.print("if (__"); |
974 s4o.print("if (__"); |
975 list->elements[i]->accept(*this); |
975 list->elements[i]->accept(*this); |
976 s4o.print(" != NULL) {\n"); |
976 s4o.print(" != NULL) {\n"); |
997 s4o.print(" = temp;\n"); |
997 s4o.print(" = temp;\n"); |
998 s4o.indent_left(); |
998 s4o.indent_left(); |
999 s4o.print(s4o.indent_spaces); |
999 s4o.print(s4o.indent_spaces); |
1000 s4o.print("}\n"); |
1000 s4o.print("}\n"); |
1001 } |
1001 } |
1002 else if (wanted_varformat == init_vf) { |
1002 else if (wanted_varformat == init_vf) { |
1003 s4o.print(","); |
1003 s4o.print(","); |
1004 this->current_var_init_symbol->accept(*this); |
1004 this->current_var_init_symbol->accept(*this); |
1005 s4o.print(");\n"); |
1005 s4o.print(");\n"); |
1006 } |
1006 } |
1007 else { |
1007 else { |
1008 if (this->current_var_init_symbol != NULL) { |
1008 if (this->current_var_init_symbol != NULL) { |
1009 s4o.print(" = "); |
1009 s4o.print(" = "); |
1010 this->current_var_init_symbol->accept(*this); |
1010 this->current_var_init_symbol->accept(*this); |
1011 } |
1011 } |
1012 s4o.print(";\n"); |
1012 s4o.print(";\n"); |
1013 } |
1013 } |
1014 } |
1014 } |
1015 else if (is_fb) |
1015 else if (is_fb) |
1016 s4o.print(";\n"); |
1016 s4o.print(";\n"); |
1017 else |
1017 else |
1018 s4o.print(")\n"); |
1018 s4o.print(")\n"); |
1019 } |
1019 } |
1020 } |
1020 } |
1021 |
1021 |
1275 if ((wanted_varformat == local_vf) || |
1275 if ((wanted_varformat == local_vf) || |
1276 (wanted_varformat == init_vf) || |
1276 (wanted_varformat == init_vf) || |
1277 (wanted_varformat == localinit_vf)) { |
1277 (wanted_varformat == localinit_vf)) { |
1278 s4o.print(s4o.indent_spaces); |
1278 s4o.print(s4o.indent_spaces); |
1279 if (wanted_varformat == local_vf) { |
1279 if (wanted_varformat == local_vf) { |
1280 s4o.print(DECLARE_VAR); |
1280 s4o.print(DECLARE_VAR); |
1281 s4o.print("("); |
1281 s4o.print("("); |
1282 symbol->type->accept(*this); |
1282 symbol->type->accept(*this); |
1283 s4o.print(","); |
1283 s4o.print(","); |
1284 } |
1284 } |
1285 else if (wanted_varformat == localinit_vf) { |
1285 else if (wanted_varformat == localinit_vf) { |
1286 symbol->type->accept(*this); |
1286 symbol->type->accept(*this); |
1287 s4o.print(" "); |
1287 s4o.print(" "); |
1288 } |
1288 } |
1289 print_variable_prefix(); |
1289 print_variable_prefix(); |
1290 symbol->name->accept(*this); |
1290 symbol->name->accept(*this); |
1291 if (wanted_varformat == local_vf) |
1291 if (wanted_varformat == local_vf) |
1292 s4o.print(")\n"); |
1292 s4o.print(")\n"); |
1293 else { |
1293 else { |
1294 s4o.print(" = "); |
1294 s4o.print(" = "); |
1295 symbol->value->accept(*this); |
1295 symbol->value->accept(*this); |
1296 s4o.print(";\n"); |
1296 s4o.print(";\n"); |
1297 } |
1297 } |
1333 if ((wanted_varformat == local_vf) || |
1333 if ((wanted_varformat == local_vf) || |
1334 (wanted_varformat == init_vf) || |
1334 (wanted_varformat == init_vf) || |
1335 (wanted_varformat == localinit_vf)) { |
1335 (wanted_varformat == localinit_vf)) { |
1336 s4o.print(s4o.indent_spaces); |
1336 s4o.print(s4o.indent_spaces); |
1337 if (wanted_varformat == local_vf) { |
1337 if (wanted_varformat == local_vf) { |
1338 s4o.print(DECLARE_VAR); |
1338 s4o.print(DECLARE_VAR); |
1339 s4o.print("("); |
1339 s4o.print("("); |
1340 symbol->type->accept(*this); |
1340 symbol->type->accept(*this); |
1341 s4o.print(","); |
1341 s4o.print(","); |
1342 } |
1342 } |
1343 else if (wanted_varformat == localinit_vf) { |
1343 else if (wanted_varformat == localinit_vf) { |
1344 symbol->type->accept(*this); |
1344 symbol->type->accept(*this); |
1345 s4o.print(" "); |
1345 s4o.print(" "); |
1346 } |
1346 } |
1347 print_variable_prefix(); |
1347 print_variable_prefix(); |
1348 symbol->name->accept(*this); |
1348 symbol->name->accept(*this); |
1349 if (wanted_varformat == local_vf) |
1349 if (wanted_varformat == local_vf) |
1350 s4o.print(")\n"); |
1350 s4o.print(")\n"); |
1351 else |
1351 else |
1352 s4o.print(" = __BOOL_LITERAL(TRUE);\n"); |
1352 s4o.print(" = __BOOL_LITERAL(TRUE);\n"); |
1353 } |
1353 } |
1354 |
1354 |
1355 if (wanted_varformat == foutputassign_vf) { |
1355 if (wanted_varformat == foutputassign_vf) { |
1356 s4o.print(s4o.indent_spaces + "if (__"); |
1356 s4o.print(s4o.indent_spaces + "if (__"); |
1357 symbol->name->accept(*this); |
1357 symbol->name->accept(*this); |
1578 return NULL; |
1578 return NULL; |
1579 } |
1579 } |
1580 |
1580 |
1581 void *visit(array_initial_elements_list_c *symbol) { |
1581 void *visit(array_initial_elements_list_c *symbol) { |
1582 if (wanted_varformat == localinit_vf || wanted_varformat == constructorinit_vf) { |
1582 if (wanted_varformat == localinit_vf || wanted_varformat == constructorinit_vf) { |
1583 generate_c_array_initialization_c *array_initialization = new generate_c_array_initialization_c(&s4o); |
1583 generate_c_array_initialization_c *array_initialization = new generate_c_array_initialization_c(&s4o); |
1584 array_initialization->init_array_size(this->current_var_type_symbol); |
1584 array_initialization->init_array_size(this->current_var_type_symbol); |
1585 array_initialization->init_array_values(this->current_var_init_symbol); |
1585 array_initialization->init_array_values(this->current_var_init_symbol); |
1586 delete array_initialization; |
1586 delete array_initialization; |
1587 } |
1587 } |
1588 return NULL; |
1588 return NULL; |
1589 } |
1589 } |
1590 |
1590 |
1591 /* var1_list ':' structure_type_name */ |
1591 /* var1_list ':' structure_type_name */ |
1623 void *visit(structure_element_initialization_list_c *symbol) { |
1623 void *visit(structure_element_initialization_list_c *symbol) { |
1624 if (wanted_varformat == localinit_vf || wanted_varformat == constructorinit_vf) { |
1624 if (wanted_varformat == localinit_vf || wanted_varformat == constructorinit_vf) { |
1625 generate_c_structure_initialization_c *structure_initialization = new generate_c_structure_initialization_c(&s4o); |
1625 generate_c_structure_initialization_c *structure_initialization = new generate_c_structure_initialization_c(&s4o); |
1626 structure_initialization->init_structure_default(this->current_var_type_symbol); |
1626 structure_initialization->init_structure_default(this->current_var_type_symbol); |
1627 structure_initialization->init_structure_values(this->current_var_init_symbol); |
1627 structure_initialization->init_structure_values(this->current_var_init_symbol); |
1628 delete structure_initialization; |
1628 delete structure_initialization; |
1629 } |
1629 } |
1630 return NULL; |
1630 return NULL; |
1631 } |
1631 } |
1632 |
1632 |
1633 /* VAR [CONSTANT] var_init_decl_list END_VAR */ |
1633 /* VAR [CONSTANT] var_init_decl_list END_VAR */ |
1738 else |
1738 else |
1739 symbol->location->accept(*this); |
1739 symbol->location->accept(*this); |
1740 print_retain(); |
1740 print_retain(); |
1741 s4o.print(")\n"); |
1741 s4o.print(")\n"); |
1742 if (this->current_var_init_symbol != NULL) { |
1742 if (this->current_var_init_symbol != NULL) { |
1743 s4o.print(s4o.indent_spaces); |
1743 s4o.print(s4o.indent_spaces); |
1744 s4o.print(INIT_LOCATED_VALUE); |
1744 s4o.print(INIT_LOCATED_VALUE); |
1745 s4o.print("("); |
1745 s4o.print("("); |
1746 print_variable_prefix(); |
1746 print_variable_prefix(); |
1747 if (symbol->variable_name != NULL) |
1747 if (symbol->variable_name != NULL) |
1748 symbol->variable_name->accept(*this); |
1748 symbol->variable_name->accept(*this); |
1749 else |
1749 else |
1750 symbol->location->accept(*this); |
1750 symbol->location->accept(*this); |
1751 s4o.print(","); |
1751 s4o.print(","); |
1752 this->current_var_init_symbol->accept(*this); |
1752 this->current_var_init_symbol->accept(*this); |
1753 s4o.print(")"); |
1753 s4o.print(")"); |
1754 } |
1754 } |
1755 break; |
1755 break; |
1756 |
1756 |
1846 /* Start off by setting the current_var_type_symbol and |
1846 /* Start off by setting the current_var_type_symbol and |
1847 * current_var_init_symbol private variables... |
1847 * current_var_init_symbol private variables... |
1848 */ |
1848 */ |
1849 this->current_var_type_symbol = symbol->specification; |
1849 this->current_var_type_symbol = symbol->specification; |
1850 this->current_var_init_symbol = NULL; |
1850 this->current_var_init_symbol = NULL; |
|
1851 bool is_fb = type_is_fb(this->current_var_type_symbol); |
1851 |
1852 |
1852 /* now to produce the c equivalent... */ |
1853 /* now to produce the c equivalent... */ |
1853 switch (wanted_varformat) { |
1854 switch (wanted_varformat) { |
1854 case local_vf: |
1855 case local_vf: |
1855 case localinit_vf: |
1856 case localinit_vf: |
1856 s4o.print(s4o.indent_spaces); |
1857 s4o.print(s4o.indent_spaces); |
1857 s4o.print(DECLARE_EXTERNAL); |
1858 if (is_fb) |
|
1859 s4o.print(DECLARE_EXTERNAL_FB); |
|
1860 else |
|
1861 s4o.print(DECLARE_EXTERNAL); |
1858 s4o.print("("); |
1862 s4o.print("("); |
1859 this->current_var_type_symbol->accept(*this); |
1863 this->current_var_type_symbol->accept(*this); |
1860 s4o.print(","); |
1864 s4o.print(","); |
1861 symbol->global_var_name->accept(*this); |
1865 symbol->global_var_name->accept(*this); |
1862 s4o.print(")\n"); |
1866 s4o.print(")\n"); |
1863 break; |
1867 break; |
1864 |
1868 |
1865 case constructorinit_vf: |
1869 case constructorinit_vf: |
1866 s4o.print(nv->get()); |
1870 s4o.print(nv->get()); |
1867 s4o.print(INIT_EXTERNAL); |
1871 if (is_fb) |
|
1872 s4o.print(INIT_EXTERNAL_FB); |
|
1873 else |
|
1874 s4o.print(INIT_EXTERNAL); |
1868 s4o.print("("); |
1875 s4o.print("("); |
1869 this->current_var_type_symbol->accept(*this); |
1876 this->current_var_type_symbol->accept(*this); |
1870 s4o.print(","); |
1877 s4o.print(","); |
1871 symbol->global_var_name->accept(*this); |
1878 symbol->global_var_name->accept(*this); |
1872 s4o.print(","); |
1879 s4o.print(","); |
1991 } |
1998 } |
1992 break; |
1999 break; |
1993 |
2000 |
1994 case constructorinit_vf: |
2001 case constructorinit_vf: |
1995 if (symbol->global_var_name != NULL) { |
2002 if (symbol->global_var_name != NULL) { |
1996 s4o.print(nv->get()); |
2003 s4o.print(nv->get()); |
1997 s4o.print(INIT_GLOBAL_LOCATED); |
2004 s4o.print(INIT_GLOBAL_LOCATED); |
1998 s4o.print("("); |
2005 s4o.print("("); |
1999 if (this->resource_name != NULL) { |
2006 if (this->resource_name != NULL) { |
2000 this->resource_name->accept(*this); |
2007 this->resource_name->accept(*this); |
2001 } |
2008 } |
2002 s4o.print(","); |
2009 s4o.print(","); |
2003 symbol->global_var_name->accept(*this); |
2010 symbol->global_var_name->accept(*this); |
2004 s4o.print(","); |
2011 s4o.print(","); |
2005 symbol->location->accept(*this); |
2012 symbol->location->accept(*this); |
2006 print_retain(); |
2013 print_retain(); |
2007 s4o.print(")"); |
2014 s4o.print(")"); |
2008 } |
2015 } |
2009 if (this->current_var_init_symbol != NULL) { |
2016 if (this->current_var_init_symbol != NULL) { |
2010 s4o.print(nv->get()); |
2017 s4o.print(nv->get()); |
2011 s4o.print(INIT_GLOBAL); |
2018 s4o.print(INIT_GLOBAL); |
2012 s4o.print("("); |
2019 s4o.print("("); |
2013 this->current_var_type_symbol->accept(*this); |
2020 this->current_var_type_symbol->accept(*this); |
2014 s4o.print(","); |
2021 s4o.print(","); |
2015 if (symbol->global_var_name != NULL) |
2022 if (symbol->global_var_name != NULL) |
2016 symbol->global_var_name->accept(*this); |
2023 symbol->global_var_name->accept(*this); |
2017 else |
2024 else |
2018 symbol->location->accept(*this); |
2025 symbol->location->accept(*this); |
2019 s4o.print(","); |
2026 s4o.print(","); |
2020 s4o.print(INITIAL_VALUE); |
2027 s4o.print(INITIAL_VALUE); |
2021 s4o.print("("); |
2028 s4o.print("("); |
2022 this->current_var_init_symbol->accept(*this); |
2029 this->current_var_init_symbol->accept(*this); |
2023 s4o.print(")"); |
2030 s4o.print(")"); |
2024 print_retain(); |
2031 print_retain(); |
2025 s4o.print(")"); |
2032 s4o.print(")"); |
2026 } |
2033 } |
2027 break; |
2034 break; |
2028 |
2035 |
2029 case globalprototype_vf: |
2036 case globalprototype_vf: |
2030 s4o.print(s4o.indent_spaces); |
2037 s4o.print(s4o.indent_spaces); |
2031 s4o.print(DECLARE_GLOBAL_PROTOTYPE); |
2038 s4o.print(DECLARE_GLOBAL_PROTOTYPE); |
2032 s4o.print("("); |
2039 s4o.print("("); |
2033 this->current_var_type_symbol->accept(*this); |
2040 this->current_var_type_symbol->accept(*this); |
2034 s4o.print(","); |
2041 s4o.print(","); |
2035 if (symbol->global_var_name != NULL) |
2042 if (symbol->global_var_name != NULL) |
2036 symbol->global_var_name->accept(*this); |
2043 symbol->global_var_name->accept(*this); |
2037 else |
2044 else |
2038 symbol->location->accept(*this); |
2045 symbol->location->accept(*this); |
2039 s4o.print(")\n"); |
2046 s4o.print(")\n"); |
2040 break; |
2047 break; |
2041 |
2048 |
2042 default: |
2049 default: |
2043 ERROR; |
2050 ERROR; |
2044 } /* switch() */ |
2051 } /* switch() */ |
2059 /*| global_var_list ',' global_var_name */ |
2066 /*| global_var_list ',' global_var_name */ |
2060 //SYM_LIST(global_var_list_c) |
2067 //SYM_LIST(global_var_list_c) |
2061 void *visit(global_var_list_c *symbol) { |
2068 void *visit(global_var_list_c *symbol) { |
2062 TRACE("global_var_list_c"); |
2069 TRACE("global_var_list_c"); |
2063 list_c *list = dynamic_cast<list_c *>(symbol); |
2070 list_c *list = dynamic_cast<list_c *>(symbol); |
|
2071 bool is_fb = type_is_fb(this->current_var_type_symbol); |
2064 /* should NEVER EVER occur!! */ |
2072 /* should NEVER EVER occur!! */ |
2065 if (list == NULL) ERROR; |
2073 if (list == NULL) ERROR; |
2066 |
2074 |
2067 /* now to produce the c equivalent... */ |
2075 /* now to produce the c equivalent... */ |
2068 switch (wanted_varformat) { |
2076 switch (wanted_varformat) { |
2069 case local_vf: |
2077 case local_vf: |
2070 case localinit_vf: |
2078 case localinit_vf: |
2071 for(int i = 0; i < list->n; i++) { |
2079 for(int i = 0; i < list->n; i++) { |
2072 s4o.print(s4o.indent_spaces); |
2080 s4o.print(s4o.indent_spaces); |
2073 s4o.print(DECLARE_GLOBAL); |
2081 if (is_fb) |
2074 s4o.print("("); |
2082 s4o.print(DECLARE_GLOBAL_FB); |
|
2083 else |
|
2084 s4o.print(DECLARE_GLOBAL); |
|
2085 s4o.print("("); |
2075 this->current_var_type_symbol->accept(*this); |
2086 this->current_var_type_symbol->accept(*this); |
2076 s4o.print(","); |
2087 s4o.print(","); |
2077 if(this->resource_name != NULL) |
2088 if(this->resource_name != NULL) |
2078 this->resource_name->accept(*this); |
2089 this->resource_name->accept(*this); |
2079 s4o.print(","); |
2090 s4o.print(","); |
2081 s4o.print(")\n"); |
2092 s4o.print(")\n"); |
2082 } |
2093 } |
2083 break; |
2094 break; |
2084 |
2095 |
2085 case constructorinit_vf: |
2096 case constructorinit_vf: |
2086 if (this->current_var_init_symbol != NULL) { |
2097 if (this->current_var_init_symbol != NULL || is_fb) { |
2087 for(int i = 0; i < list->n; i++) { |
2098 for(int i = 0; i < list->n; i++) { |
2088 s4o.print(nv->get()); |
2099 s4o.print(nv->get()); |
2089 |
2100 |
2090 s4o.print(INIT_GLOBAL); |
2101 if (is_fb) |
|
2102 s4o.print(INIT_GLOBAL_FB); |
|
2103 else |
|
2104 s4o.print(INIT_GLOBAL); |
2091 s4o.print("("); |
2105 s4o.print("("); |
2092 this->current_var_type_symbol->accept(*this); |
2106 this->current_var_type_symbol->accept(*this); |
2093 s4o.print(","); |
2107 s4o.print(","); |
2094 list->elements[i]->accept(*this); |
2108 list->elements[i]->accept(*this); |
2095 s4o.print(","); |
2109 if (this->current_var_init_symbol != NULL) { |
2096 s4o.print(INITIAL_VALUE); |
2110 s4o.print(","); |
2097 s4o.print("("); |
2111 s4o.print(INITIAL_VALUE); |
2098 this->current_var_init_symbol->accept(*this); |
2112 s4o.print("("); |
2099 s4o.print(")"); |
2113 this->current_var_init_symbol->accept(*this); |
|
2114 s4o.print(")"); |
|
2115 } |
2100 print_retain(); |
2116 print_retain(); |
2101 s4o.print(")"); |
2117 s4o.print(")"); |
2102 #if 0 |
2118 #if 0 |
2103 /* The following code would be for globalinit_vf !! |
2119 /* The following code would be for globalinit_vf !! |
2104 * But it is not currently required... |
2120 * But it is not currently required... |
2105 */ |
2121 */ |
2106 s4o.print(s4o.indent_spaces + "__ext_element_c<"); |
2122 s4o.print(s4o.indent_spaces + "__ext_element_c<"); |
2107 this->current_var_type_symbol->accept(*this); |
2123 this->current_var_type_symbol->accept(*this); |
2108 s4o.print("> "); |
2124 s4o.print("> "); |
2109 if (this->globalnamespace != NULL) { |
2125 if (this->globalnamespace != NULL) { |
2110 this->globalnamespace->accept(*this); |
2126 this->globalnamespace->accept(*this); |
2111 s4o.print("::"); |
2127 s4o.print("::"); |
2524 break; |
2540 break; |
2525 |
2541 |
2526 case function_param_iterator_c::direction_extref: |
2542 case function_param_iterator_c::direction_extref: |
2527 #if 0 |
2543 #if 0 |
2528 if (param_value == NULL) |
2544 if (param_value == NULL) |
2529 /* This is illegal in ST and IL languages. |
2545 /* This is illegal in ST and IL languages. |
2530 * All variables declared in a VAR_EXTERNAL __must__ |
2546 * All variables declared in a VAR_EXTERNAL __must__ |
2531 * be initialised to reference a specific VAR_GLOBAL variable!! |
2547 * be initialised to reference a specific VAR_GLOBAL variable!! |
2532 * |
2548 * |
2533 * The semantic checker should have caught this, we check again just the |
2549 * The semantic checker should have caught this, we check again just the |
2534 * same (especially since the semantic checker has not yet been written!). |
2550 * same (especially since the semantic checker has not yet been written!). |
2535 */ |
2551 */ |
2536 ERROR; |
2552 ERROR; |
2537 s4o.print(nv->get()); |
2553 s4o.print(nv->get()); |
2538 s4o.print("&"); |
2554 s4o.print("&"); |
2539 param_value->accept(*this); |
2555 param_value->accept(*this); |
2540 #endif |
2556 #endif |
2541 break; |
2557 break; |
2542 } /* switch */ |
2558 } /* switch */ |
2543 } /* for(...) */ |
2559 } /* for(...) */ |
2544 |
2560 |
2545 // symbol->parameter_assignment->accept(*this); |
2561 // symbol->parameter_assignment->accept(*this); |
2546 s4o.print(")"); |
2562 s4o.print(")"); |