38 //#include <string> |
38 //#include <string> |
39 //#include <iostream> |
39 //#include <iostream> |
40 |
40 |
41 //#include "../../util/symtable.hh" |
41 //#include "../../util/symtable.hh" |
42 |
42 |
43 |
43 class initialization_analyzer_c: public null_visitor_c { |
44 |
44 public: |
|
45 typedef enum { |
|
46 simple_it, |
|
47 array_it, |
|
48 struct_it |
|
49 } initialization_type_t; |
|
50 |
|
51 private: |
|
52 |
|
53 initialization_type_t current_type; |
|
54 |
|
55 public: |
|
56 initialization_analyzer_c(symbol_c* symbol) { |
|
57 current_type = simple_it; |
|
58 symbol->accept(*this); |
|
59 } |
|
60 ~initialization_analyzer_c(void) {} |
|
61 |
|
62 initialization_type_t get_initialization_type(void) { |
|
63 return current_type; |
|
64 } |
|
65 |
|
66 void *visit(array_initial_elements_list_c *symbol) { |
|
67 current_type = array_it; |
|
68 return NULL; |
|
69 } |
|
70 |
|
71 void *visit(structure_element_initialization_list_c *symbol) { |
|
72 current_type = struct_it; |
|
73 return NULL; |
|
74 } |
|
75 }; |
45 |
76 |
46 class generate_c_array_initialization_c: public generate_c_typedecl_c { |
77 class generate_c_array_initialization_c: public generate_c_typedecl_c { |
47 |
78 |
48 public: |
79 public: |
49 typedef enum { |
80 typedef enum { |
94 s4o.indent_right(); |
125 s4o.indent_right(); |
95 s4o.print(s4o.indent_spaces + "int index["); |
126 s4o.print(s4o.indent_spaces + "int index["); |
96 print_integer(dimension_number); |
127 print_integer(dimension_number); |
97 s4o.print("];\n"); |
128 s4o.print("];\n"); |
98 s4o.print(s4o.indent_spaces); |
129 s4o.print(s4o.indent_spaces); |
|
130 s4o.print("static const "); |
99 array_specification->accept(*this); |
131 array_specification->accept(*this); |
100 s4o.print(" temp = "); |
132 s4o.print(" temp = "); |
101 init_array_values(array_initialization); |
133 init_array_values(array_initialization); |
102 s4o.print(";\n"); |
134 s4o.print(";\n"); |
103 |
135 |
122 if (array_default_initialization != NULL && defined_values_count < array_size) |
154 if (array_default_initialization != NULL && defined_values_count < array_size) |
123 array_default_initialization->accept(*this); |
155 array_default_initialization->accept(*this); |
124 if (defined_values_count < array_size) { |
156 if (defined_values_count < array_size) { |
125 for (int i = defined_values_count; i < array_size; i++) { |
157 for (int i = defined_values_count; i < array_size; i++) { |
126 if (defined_values_count > 0) |
158 if (defined_values_count > 0) |
127 s4o.print(", "); |
159 s4o.print(","); |
128 array_default_value->accept(*this); |
160 array_default_value->accept(*this); |
129 defined_values_count++; |
161 defined_values_count++; |
130 } |
162 } |
131 } |
163 } |
132 s4o.print("}"); |
164 s4o.print("}"); |
154 void *visit(var1_list_c *symbol) { |
186 void *visit(var1_list_c *symbol) { |
155 int i, j; |
187 int i, j; |
156 |
188 |
157 for (i = 0; i < symbol->n; i++) { |
189 for (i = 0; i < symbol->n; i++) { |
158 s4o.print(s4o.indent_spaces); |
190 s4o.print(s4o.indent_spaces); |
|
191 s4o.print(SET_VAR); |
|
192 s4o.print("("); |
159 print_variable_prefix(); |
193 print_variable_prefix(); |
160 symbol->elements[i]->accept(*this); |
194 symbol->elements[i]->accept(*this); |
|
195 s4o.print(",temp"); |
161 for (j = 0; j < dimension_number; j++) { |
196 for (j = 0; j < dimension_number; j++) { |
162 s4o.print("[index["); |
197 s4o.print("[index["); |
163 print_integer(j); |
198 print_integer(j); |
164 s4o.print("]]"); |
199 s4o.print("]]"); |
165 } |
200 } |
166 s4o.print(" = temp"); |
201 s4o.print(","); |
167 for (j = 0; j < dimension_number; j++) { |
202 for (j = 0; j < dimension_number; j++) { |
168 s4o.print("[index["); |
203 s4o.print("[index["); |
169 print_integer(j); |
204 print_integer(j); |
170 s4o.print("]]"); |
205 s4o.print("]]"); |
171 } |
206 } |
172 s4o.print(";\n"); |
207 s4o.print(");\n"); |
173 } |
208 } |
174 return NULL; |
209 return NULL; |
175 } |
210 } |
176 |
211 |
177 /********************************/ |
212 /********************************/ |
243 for (int i = 0; i < symbol->n; i++) { |
278 for (int i = 0; i < symbol->n; i++) { |
244 if (current_initialization_count >= defined_values_count) { |
279 if (current_initialization_count >= defined_values_count) { |
245 if (defined_values_count >= array_size) |
280 if (defined_values_count >= array_size) |
246 ERROR; |
281 ERROR; |
247 if (defined_values_count > 0) |
282 if (defined_values_count > 0) |
248 s4o.print(", "); |
283 s4o.print(","); |
249 symbol->elements[i]->accept(*this); |
284 symbol->elements[i]->accept(*this); |
250 defined_values_count++; |
285 defined_values_count++; |
251 } |
286 } |
252 else { |
287 else { |
253 array_initial_elements_c *array_initial_element = dynamic_cast<array_initial_elements_c *>(symbol->elements[i]); |
288 array_initial_elements_c *array_initial_element = dynamic_cast<array_initial_elements_c *>(symbol->elements[i]); |
254 |
289 |
255 if (array_initial_element != NULL) |
290 if (array_initial_element != NULL) { |
256 symbol->elements[i]->accept(*this); |
291 symbol->elements[i]->accept(*this); |
|
292 } |
257 } |
293 } |
258 current_initialization_count++; |
294 current_initialization_count++; |
259 } |
295 } |
260 break; |
296 break; |
261 default: |
297 default: |
279 temp_element_number = initial_element_number - diff; |
315 temp_element_number = initial_element_number - diff; |
280 current_initialization_count += initial_element_number - 1; |
316 current_initialization_count += initial_element_number - 1; |
281 initial_element_number = temp_element_number; |
317 initial_element_number = temp_element_number; |
282 if (initial_element_number > 0) { |
318 if (initial_element_number > 0) { |
283 defined_values_count++; |
319 defined_values_count++; |
284 s4o.print(", "); |
320 s4o.print(","); |
285 } |
321 } |
286 } |
322 } |
287 else |
323 else |
288 current_initialization_count += initial_element_number - 1; |
324 current_initialization_count += initial_element_number - 1; |
289 if (defined_values_count + initial_element_number > array_size) |
325 if (defined_values_count + initial_element_number > array_size) |
290 ERROR; |
326 ERROR; |
291 for (int i = 0; i < initial_element_number; i++) { |
327 for (int i = 0; i < initial_element_number; i++) { |
292 if (i > 0) |
328 if (i > 0) |
293 s4o.print(", "); |
329 s4o.print(","); |
294 if (symbol->array_initial_element != NULL) |
330 if (symbol->array_initial_element != NULL) { |
295 symbol->array_initial_element->accept(*this); |
331 symbol->array_initial_element->accept(*this); |
296 else |
332 } |
|
333 else { |
297 array_default_value->accept(*this); |
334 array_default_value->accept(*this); |
|
335 } |
298 } |
336 } |
299 if (initial_element_number > 1) |
337 if (initial_element_number > 1) |
300 defined_values_count += initial_element_number - 1; |
338 defined_values_count += initial_element_number - 1; |
301 break; |
339 break; |
302 default: |
340 default: |
512 current_mode = initializationvalue_sm; |
550 current_mode = initializationvalue_sm; |
513 s4o.print("\n"); |
551 s4o.print("\n"); |
514 s4o.print(s4o.indent_spaces + "{\n"); |
552 s4o.print(s4o.indent_spaces + "{\n"); |
515 s4o.indent_right(); |
553 s4o.indent_right(); |
516 s4o.print(s4o.indent_spaces); |
554 s4o.print(s4o.indent_spaces); |
|
555 s4o.print("static const "); |
517 structure_type_name->accept(*this); |
556 structure_type_name->accept(*this); |
518 s4o.print(" temp = "); |
557 s4o.print(" temp = "); |
519 structure_initialization->accept(*this); |
558 structure_initialization->accept(*this); |
520 s4o.print(";\n"); |
559 s4o.print(";\n"); |
521 |
560 |
548 int i, j; |
587 int i, j; |
549 |
588 |
550 for (i = 0; i < symbol->n; i++) { |
589 for (i = 0; i < symbol->n; i++) { |
551 s4o.print(s4o.indent_spaces); |
590 s4o.print(s4o.indent_spaces); |
552 print_variable_prefix(); |
591 print_variable_prefix(); |
|
592 s4o.print(SET_VAR); |
|
593 s4o.print("("); |
553 symbol->elements[i]->accept(*this); |
594 symbol->elements[i]->accept(*this); |
554 s4o.print(" = temp;\n"); |
595 s4o.print(",temp);\n"); |
555 } |
596 } |
556 return NULL; |
597 return NULL; |
557 } |
598 } |
558 |
599 |
559 /********************************/ |
600 /********************************/ |
581 |
622 |
582 identifier_c *element_name; |
623 identifier_c *element_name; |
583 structure_init_element_iterator_c structure_init_element_iterator(symbol); |
624 structure_init_element_iterator_c structure_init_element_iterator(symbol); |
584 for(int i = 1; (element_name = structure_iterator.next()) != NULL; i++) { |
625 for(int i = 1; (element_name = structure_iterator.next()) != NULL; i++) { |
585 if (i > 1) |
626 if (i > 1) |
586 s4o.print(", "); |
627 s4o.print(","); |
587 |
628 |
588 /* Get the value from an initialization */ |
629 /* Get the value from an initialization */ |
589 symbol_c *element_value = structure_init_element_iterator.search(element_name); |
630 symbol_c *element_value = structure_init_element_iterator.search(element_name); |
590 |
631 |
591 if (element_value == NULL) { |
632 if (element_value == NULL) { |
602 element_value = (symbol_c *)current_element_type->accept(*type_initial_value_c::instance()); |
643 element_value = (symbol_c *)current_element_type->accept(*type_initial_value_c::instance()); |
603 } |
644 } |
604 |
645 |
605 if (element_value == NULL) ERROR; |
646 if (element_value == NULL) ERROR; |
606 |
647 |
607 structure_element_initialization_list_c *structure_element_initialization_list = dynamic_cast<structure_element_initialization_list_c *>(element_value); |
648 initialization_analyzer_c initialization_analyzer(element_value); |
608 |
649 |
609 if (structure_element_initialization_list != NULL) { |
650 if (initialization_analyzer.get_initialization_type() == initialization_analyzer_c::struct_it) { |
610 generate_c_structure_initialization_c *structure_initialization = new generate_c_structure_initialization_c(&s4o); |
651 generate_c_structure_initialization_c *structure_initialization = new generate_c_structure_initialization_c(&s4o); |
611 structure_initialization->set_variable_prefix(get_variable_prefix()); |
652 structure_initialization->set_variable_prefix(get_variable_prefix()); |
612 structure_initialization->init_structure_default(current_element_type); |
653 structure_initialization->init_structure_default(current_element_type); |
613 structure_initialization->current_mode = generate_c_structure_initialization_c::initializationvalue_sm; |
654 structure_initialization->current_mode = generate_c_structure_initialization_c::initializationvalue_sm; |
614 element_value->accept(*structure_initialization); |
655 element_value->accept(*structure_initialization); |
615 delete structure_initialization; |
656 delete structure_initialization; |
616 } |
657 } |
617 else |
658 else { |
618 element_value->accept(*this); |
659 element_value->accept(*this); |
|
660 } |
619 } |
661 } |
620 s4o.print("}"); |
662 s4o.print("}"); |
621 return NULL; |
663 return NULL; |
622 } |
664 } |
623 |
665 |
744 static const unsigned int en_vt = 0x0200; // EN declaration |
786 static const unsigned int en_vt = 0x0200; // EN declaration |
745 static const unsigned int eno_vt = 0x0400; // ENO declaration |
787 static const unsigned int eno_vt = 0x0400; // ENO declaration |
746 static const unsigned int resource_vt = 0x8000; // RESOURCE (inside a configuration!) |
788 static const unsigned int resource_vt = 0x8000; // RESOURCE (inside a configuration!) |
747 // This, just of itself, will not print out any declarations!! |
789 // This, just of itself, will not print out any declarations!! |
748 // It must be acompanied by either program_vt and/or global_vt |
790 // It must be acompanied by either program_vt and/or global_vt |
|
791 |
|
792 /* the qualifier of variables that need to be processed... */ |
|
793 static const unsigned int none_vq = 0x0000; |
|
794 static const unsigned int constant_vq = 0x0001; // CONSTANT |
|
795 static const unsigned int retain_vq = 0x0002; // RETAIN |
|
796 static const unsigned int non_retain_vq = 0x0004; // NON_RETAIN |
|
797 |
749 |
798 |
750 /* How variables should be declared: as local variables or |
799 /* How variables should be declared: as local variables or |
751 * variables within a function call interface. |
800 * variables within a function call interface. |
752 * |
801 * |
753 * This will define the format of the output generated |
802 * This will define the format of the output generated |
811 private: |
860 private: |
812 /* variable used to store the types of variables that need to be processed... */ |
861 /* variable used to store the types of variables that need to be processed... */ |
813 /* Only set in the constructor...! */ |
862 /* Only set in the constructor...! */ |
814 /* Will contain a set of values of generate_c_vardecl_c::XXXX_vt */ |
863 /* Will contain a set of values of generate_c_vardecl_c::XXXX_vt */ |
815 unsigned int wanted_vartype; |
864 unsigned int wanted_vartype; |
|
865 |
816 /* variable used to store the type of variable currently being processed... */ |
866 /* variable used to store the type of variable currently being processed... */ |
817 /* Will contain a single value of generate_c_vardecl_c::XXXX_vt */ |
867 /* Will contain a single value of generate_c_vardecl_c::XXXX_vt */ |
818 unsigned int current_vartype; |
868 unsigned int current_vartype; |
|
869 |
|
870 /* variable used to store the qualifier of variable currently being processed... */ |
|
871 /* Will contain a single value of generate_c_vardecl_c::XXXX_vq */ |
|
872 unsigned int current_varqualifier; |
819 |
873 |
820 /* How variables should be declared: as local variables or |
874 /* How variables should be declared: as local variables or |
821 * variables within a function interface... |
875 * variables within a function interface... |
822 */ |
876 */ |
823 /* Only set in the constructor...! */ |
877 /* Only set in the constructor...! */ |
870 * the identifier of the scope within which the static member was |
924 * the identifier of the scope within which the static member was |
871 * declared. |
925 * declared. |
872 */ |
926 */ |
873 symbol_c *globalnamespace; |
927 symbol_c *globalnamespace; |
874 |
928 |
|
929 void *print_retain(void) { |
|
930 s4o.print(","); |
|
931 switch (current_varqualifier) { |
|
932 case retain_vq: |
|
933 s4o.print("1"); |
|
934 break; |
|
935 case non_retain_vq: |
|
936 s4o.print("0"); |
|
937 break; |
|
938 default: |
|
939 s4o.print("retain"); |
|
940 break; |
|
941 } |
|
942 return NULL; |
|
943 } |
|
944 |
875 /* Actually produce the output where variables are declared... */ |
945 /* Actually produce the output where variables are declared... */ |
876 /* Note that located variables and EN/ENO are the exception, they |
946 /* Note that located variables and EN/ENO are the exception, they |
877 * being declared in the located_var_decl_c, |
947 * being declared in the located_var_decl_c, |
878 * en_param_declaration_c and eno_param_declaration_c visitors... |
948 * en_param_declaration_c and eno_param_declaration_c visitors... |
879 */ |
949 */ |
887 (wanted_varformat == init_vf) || |
957 (wanted_varformat == init_vf) || |
888 (wanted_varformat == localinit_vf)) { |
958 (wanted_varformat == localinit_vf)) { |
889 for(int i = 0; i < list->n; i++) { |
959 for(int i = 0; i < list->n; i++) { |
890 s4o.print(s4o.indent_spaces); |
960 s4o.print(s4o.indent_spaces); |
891 if (wanted_varformat == local_vf) { |
961 if (wanted_varformat == local_vf) { |
892 s4o.print(DECLARE_VAR); |
962 if (!is_fb) { |
893 s4o.print("("); |
963 s4o.print(DECLARE_VAR); |
|
964 s4o.print("("); |
|
965 } |
894 this->current_var_type_symbol->accept(*this); |
966 this->current_var_type_symbol->accept(*this); |
895 s4o.print(","); |
967 if (is_fb) |
|
968 s4o.print(" "); |
|
969 else |
|
970 s4o.print(","); |
896 } |
971 } |
897 else if (wanted_varformat == localinit_vf) { |
972 else if (wanted_varformat == localinit_vf) { |
898 this->current_var_type_symbol->accept(*this); |
973 this->current_var_type_symbol->accept(*this); |
899 s4o.print(" "); |
974 s4o.print(" "); |
900 } |
975 } |
958 this->current_var_type_symbol->accept(*this); |
1035 this->current_var_type_symbol->accept(*this); |
959 s4o.print(FB_INIT_SUFFIX); |
1036 s4o.print(FB_INIT_SUFFIX); |
960 s4o.print("(&"); |
1037 s4o.print("(&"); |
961 this->print_variable_prefix(); |
1038 this->print_variable_prefix(); |
962 list->elements[i]->accept(*this); |
1039 list->elements[i]->accept(*this); |
|
1040 print_retain(); |
963 s4o.print(");"); |
1041 s4o.print(");"); |
964 } |
1042 } |
965 else if (this->current_var_init_symbol != NULL) { |
1043 else if (this->current_var_init_symbol != NULL) { |
966 s4o.print(nv->get()); |
1044 s4o.print(nv->get()); |
967 s4o.print(INIT_VAR); |
1045 s4o.print(INIT_VAR); |
968 s4o.print("("); |
1046 s4o.print("("); |
969 this->print_variable_prefix(); |
1047 this->print_variable_prefix(); |
970 list->elements[i]->accept(*this); |
1048 list->elements[i]->accept(*this); |
971 s4o.print(","); |
1049 s4o.print(","); |
972 this->current_var_init_symbol->accept(*this); |
1050 this->current_var_init_symbol->accept(*this); |
|
1051 print_retain(); |
973 s4o.print(")"); |
1052 s4o.print(")"); |
974 } |
1053 } |
975 } |
1054 } |
976 } |
1055 } |
977 |
1056 |
985 generate_c_vardecl_c(stage4out_c *s4o_ptr, varformat_t varformat, unsigned int vartype, symbol_c* res_name = NULL) |
1064 generate_c_vardecl_c(stage4out_c *s4o_ptr, varformat_t varformat, unsigned int vartype, symbol_c* res_name = NULL) |
986 : generate_c_typedecl_c(s4o_ptr) { |
1065 : generate_c_typedecl_c(s4o_ptr) { |
987 wanted_varformat = varformat; |
1066 wanted_varformat = varformat; |
988 wanted_vartype = vartype; |
1067 wanted_vartype = vartype; |
989 current_vartype = none_vt; |
1068 current_vartype = none_vt; |
|
1069 current_varqualifier = none_vq; |
990 current_var_type_symbol = NULL; |
1070 current_var_type_symbol = NULL; |
991 current_var_init_symbol = NULL; |
1071 current_var_init_symbol = NULL; |
992 globalnamespace = NULL; |
1072 globalnamespace = NULL; |
993 nv = NULL; |
1073 nv = NULL; |
994 resource_name = res_name; |
1074 resource_name = res_name; |
1094 /* done in base class(es) */ |
1174 /* done in base class(es) */ |
1095 |
1175 |
1096 /******************************************/ |
1176 /******************************************/ |
1097 /* B 1.4.3 - Declaration & Initialisation */ |
1177 /* B 1.4.3 - Declaration & Initialisation */ |
1098 /******************************************/ |
1178 /******************************************/ |
1099 void *visit(constant_option_c *symbol) {s4o.print("CONSTANT"); return NULL;} |
1179 |
1100 void *visit(retain_option_c *symbol) {s4o.print("RETAIN"); return NULL;} |
1180 void *visit(constant_option_c *symbol) { |
1101 void *visit(non_retain_option_c *symbol) {s4o.print("NON_RETAIN"); return NULL;} |
1181 current_varqualifier = constant_vq; |
|
1182 return NULL; |
|
1183 } |
|
1184 |
|
1185 void *visit(retain_option_c *symbol) { |
|
1186 current_varqualifier = retain_vq; |
|
1187 return NULL; |
|
1188 } |
|
1189 |
|
1190 void *visit(non_retain_option_c *symbol) { |
|
1191 current_varqualifier = non_retain_vq; |
|
1192 return NULL; |
|
1193 } |
1102 |
1194 |
1103 void *visit(input_declarations_c *symbol) { |
1195 void *visit(input_declarations_c *symbol) { |
1104 TRACE("input_declarations_c"); |
1196 TRACE("input_declarations_c"); |
1105 if ((wanted_vartype & input_vt) != 0) { |
1197 if ((wanted_vartype & input_vt) != 0) { |
1106 /* |
1198 /* |
1108 if (symbol->option != NULL) |
1200 if (symbol->option != NULL) |
1109 symbol->option->accept(*this); |
1201 symbol->option->accept(*this); |
1110 */ |
1202 */ |
1111 //s4o.indent_right(); |
1203 //s4o.indent_right(); |
1112 current_vartype = input_vt; |
1204 current_vartype = input_vt; |
|
1205 if (symbol->option != NULL) |
|
1206 symbol->option->accept(*this); |
1113 symbol->input_declaration_list->accept(*this); |
1207 symbol->input_declaration_list->accept(*this); |
1114 current_vartype = none_vt; |
1208 current_vartype = none_vt; |
|
1209 current_varqualifier = none_vt; |
1115 //s4o.indent_left(); |
1210 //s4o.indent_left(); |
1116 } |
1211 } |
1117 return NULL; |
1212 return NULL; |
1118 } |
1213 } |
1119 |
1214 |
1246 s4o.print(INIT_VAR); |
1342 s4o.print(INIT_VAR); |
1247 s4o.print("("); |
1343 s4o.print("("); |
1248 this->print_variable_prefix(); |
1344 this->print_variable_prefix(); |
1249 // s4o.print("ENO = __BOOL_LITERAL(TRUE);"); |
1345 // s4o.print("ENO = __BOOL_LITERAL(TRUE);"); |
1250 symbol->name->accept(*this); |
1346 symbol->name->accept(*this); |
1251 s4o.print(",__BOOL_LITERAL(TRUE))"); |
1347 s4o.print(",__BOOL_LITERAL(TRUE)"); |
|
1348 print_retain(); |
|
1349 s4o.print(")"); |
1252 } |
1350 } |
1253 } |
1351 } |
1254 return NULL; |
1352 return NULL; |
1255 } |
1353 } |
1256 |
1354 |
1368 if (symbol->option != NULL) |
1466 if (symbol->option != NULL) |
1369 symbol->option->accept(*this); |
1467 symbol->option->accept(*this); |
1370 */ |
1468 */ |
1371 //s4o.indent_right(); |
1469 //s4o.indent_right(); |
1372 current_vartype = output_vt; |
1470 current_vartype = output_vt; |
|
1471 if (symbol->option != NULL) |
|
1472 symbol->option->accept(*this); |
1373 symbol->var_init_decl_list->accept(*this); |
1473 symbol->var_init_decl_list->accept(*this); |
1374 current_vartype = none_vt; |
1474 current_vartype = none_vt; |
|
1475 current_varqualifier = none_vq; |
1375 //s4o.indent_left(); |
1476 //s4o.indent_left(); |
1376 } |
1477 } |
1377 return NULL; |
1478 return NULL; |
1378 } |
1479 } |
1379 |
1480 |
1452 // TO DO ... |
1553 // TO DO ... |
1453 if (symbol->option != NULL) |
1554 if (symbol->option != NULL) |
1454 symbol->option->accept(*this); |
1555 symbol->option->accept(*this); |
1455 */ |
1556 */ |
1456 current_vartype = private_vt; |
1557 current_vartype = private_vt; |
|
1558 if (symbol->option != NULL) |
|
1559 symbol->option->accept(*this); |
1457 symbol->var_init_decl_list->accept(*this); |
1560 symbol->var_init_decl_list->accept(*this); |
1458 current_vartype = none_vt; |
1561 current_vartype = none_vt; |
|
1562 current_varqualifier = none_vq; |
1459 } |
1563 } |
1460 return NULL; |
1564 return NULL; |
1461 } |
1565 } |
1462 |
1566 |
1463 /* VAR RETAIN var_init_decl_list END_VAR */ |
1567 /* VAR RETAIN var_init_decl_list END_VAR */ |
1464 void *visit(retentive_var_declarations_c *symbol) { |
1568 void *visit(retentive_var_declarations_c *symbol) { |
1465 TRACE("retentive_var_declarations_c"); |
1569 TRACE("retentive_var_declarations_c"); |
1466 if ((wanted_vartype & private_vt) != 0) { |
1570 if ((wanted_vartype & private_vt) != 0) { |
1467 current_vartype = private_vt; |
1571 current_vartype = private_vt; |
|
1572 current_varqualifier = retain_vq; |
1468 symbol->var_init_decl_list->accept(*this); |
1573 symbol->var_init_decl_list->accept(*this); |
1469 current_vartype = none_vt; |
1574 current_vartype = none_vt; |
|
1575 current_varqualifier = none_vq; |
1470 } |
1576 } |
1471 return NULL; |
1577 return NULL; |
1472 } |
1578 } |
1473 |
1579 |
1474 /* VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */ |
1580 /* VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */ |
1481 // TO DO ... |
1587 // TO DO ... |
1482 if (symbol->option != NULL) |
1588 if (symbol->option != NULL) |
1483 symbol->option->accept(*this); |
1589 symbol->option->accept(*this); |
1484 */ |
1590 */ |
1485 current_vartype = located_vt; |
1591 current_vartype = located_vt; |
|
1592 if (symbol->option != NULL) |
|
1593 symbol->option->accept(*this); |
1486 symbol->located_var_decl_list->accept(*this); |
1594 symbol->located_var_decl_list->accept(*this); |
1487 current_vartype = none_vt; |
1595 current_vartype = none_vt; |
|
1596 current_varqualifier = none_vq; |
1488 } |
1597 } |
1489 return NULL; |
1598 return NULL; |
1490 } |
1599 } |
1491 |
1600 |
1492 /* helper symbol for located_var_declarations */ |
1601 /* helper symbol for located_var_declarations */ |
1540 symbol->variable_name->accept(*this); |
1649 symbol->variable_name->accept(*this); |
1541 else |
1650 else |
1542 symbol->location->accept(*this); |
1651 symbol->location->accept(*this); |
1543 s4o.print(","); |
1652 s4o.print(","); |
1544 print_variable_prefix(); |
1653 print_variable_prefix(); |
|
1654 print_retain(); |
1545 s4o.print(")\n"); |
1655 s4o.print(")\n"); |
1546 if (this->current_var_init_symbol != NULL) { |
1656 if (this->current_var_init_symbol != NULL) { |
1547 s4o.print(INIT_LOCATED_VALUE); |
1657 s4o.print(INIT_LOCATED_VALUE); |
1548 s4o.print("("); |
1658 s4o.print("("); |
1549 if (symbol->variable_name != NULL) |
1659 if (symbol->variable_name != NULL) |
1614 if (symbol->option != NULL) |
1724 if (symbol->option != NULL) |
1615 symbol->option->accept(*this); |
1725 symbol->option->accept(*this); |
1616 */ |
1726 */ |
1617 //s4o.indent_right(); |
1727 //s4o.indent_right(); |
1618 current_vartype = external_vt; |
1728 current_vartype = external_vt; |
|
1729 if (symbol->option != NULL) |
|
1730 symbol->option->accept(*this); |
1619 symbol->external_declaration_list->accept(*this); |
1731 symbol->external_declaration_list->accept(*this); |
1620 current_vartype = none_vt; |
1732 current_vartype = none_vt; |
|
1733 current_varqualifier = none_vq; |
1621 //s4o.indent_left(); |
1734 //s4o.indent_left(); |
1622 } |
1735 } |
1623 return NULL; |
1736 return NULL; |
1624 } |
1737 } |
1625 |
1738 |
1710 */ |
1824 */ |
1711 //s4o.indent_right(); |
1825 //s4o.indent_right(); |
1712 unsigned int previous_vartype = current_vartype; |
1826 unsigned int previous_vartype = current_vartype; |
1713 // previous_vartype will be either none_vt, or resource_vt |
1827 // previous_vartype will be either none_vt, or resource_vt |
1714 current_vartype = global_vt; |
1828 current_vartype = global_vt; |
|
1829 if (symbol->option != NULL) |
|
1830 symbol->option->accept(*this); |
1715 symbol->global_var_decl_list->accept(*this); |
1831 symbol->global_var_decl_list->accept(*this); |
1716 current_vartype = previous_vartype; |
1832 current_vartype = previous_vartype; |
|
1833 current_varqualifier = none_vq; |
1717 //s4o.indent_left(); |
1834 //s4o.indent_left(); |
1718 } |
1835 } |
1719 return NULL; |
1836 return NULL; |
1720 } |
1837 } |
1721 |
1838 |
1797 } |
1914 } |
1798 s4o.print(","); |
1915 s4o.print(","); |
1799 symbol->global_var_name->accept(*this); |
1916 symbol->global_var_name->accept(*this); |
1800 s4o.print(","); |
1917 s4o.print(","); |
1801 symbol->location->accept(*this); |
1918 symbol->location->accept(*this); |
|
1919 print_retain(); |
1802 s4o.print(")"); |
1920 s4o.print(")"); |
1803 } |
1921 } |
1804 if (this->current_var_init_symbol != NULL) { |
1922 if (this->current_var_init_symbol != NULL) { |
1805 s4o.print(nv->get()); |
1923 s4o.print(nv->get()); |
1806 s4o.print(s4o.indent_spaces); |
1924 s4o.print(s4o.indent_spaces); |
1867 s4o.print(INIT_GLOBAL); |
1986 s4o.print(INIT_GLOBAL); |
1868 s4o.print("("); |
1987 s4o.print("("); |
1869 list->elements[i]->accept(*this); |
1988 list->elements[i]->accept(*this); |
1870 s4o.print(","); |
1989 s4o.print(","); |
1871 this->current_var_init_symbol->accept(*this); |
1990 this->current_var_init_symbol->accept(*this); |
|
1991 print_retain(); |
1872 s4o.print(")"); |
1992 s4o.print(")"); |
1873 #if 0 |
1993 #if 0 |
1874 /* The following code would be for globalinit_vf !! |
1994 /* The following code would be for globalinit_vf !! |
1875 * But it is not currently required... |
1995 * But it is not currently required... |
1876 */ |
1996 */ |