117 /*********************/ |
117 /*********************/ |
118 void *visit(symbolic_variable_c *symbol) { |
118 void *visit(symbolic_variable_c *symbol) { |
119 unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); |
119 unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); |
120 if (this->is_variable_prefix_null()) { |
120 if (this->is_variable_prefix_null()) { |
121 if (wanted_variablegeneration == fparam_output_vg) { |
121 if (wanted_variablegeneration == fparam_output_vg) { |
122 if (vartype == search_var_instance_decl_c::external_vt) { |
122 if (vartype == search_var_instance_decl_c::external_vt) |
123 s4o.print(GET_EXTERNAL); |
123 s4o.print(GET_EXTERNAL); |
124 s4o.print("("); |
124 else |
125 symbol->var_name->accept(*this); |
125 s4o.print("&"); |
126 } |
126 s4o.print("("); |
127 else { |
127 generate_c_base_c::visit(symbol); |
128 s4o.print("&("); |
|
129 generate_c_base_c::visit(symbol); |
|
130 } |
|
131 s4o.print(")"); |
128 s4o.print(")"); |
132 } |
129 } |
133 else { |
130 else { |
134 if (vartype == search_var_instance_decl_c::external_vt) { |
131 if (vartype == search_var_instance_decl_c::external_vt) { |
135 s4o.print(GET_EXTERNAL); |
132 s4o.print(GET_EXTERNAL); |
136 s4o.print("("); |
133 s4o.print("("); |
137 symbol->var_name->accept(*this); |
134 generate_c_base_c::visit(symbol); |
138 s4o.print(")"); |
135 s4o.print(")"); |
139 } |
136 } |
140 else |
137 else |
141 generate_c_base_c::visit(symbol); |
138 generate_c_base_c::visit(symbol); |
142 } |
139 } |
143 } |
140 } |
144 else { |
141 else { |
145 switch (wanted_variablegeneration) { |
142 switch (wanted_variablegeneration) { |
146 case expression_vg: |
143 case expression_vg: |
147 if (vartype == search_var_instance_decl_c::external_vt) { |
144 if (vartype == search_var_instance_decl_c::external_vt) |
148 s4o.print(GET_EXTERNAL); |
145 s4o.print(GET_EXTERNAL); |
149 s4o.print("("); |
146 else if (vartype == search_var_instance_decl_c::located_vt) |
150 symbol->var_name->accept(*this); |
147 s4o.print(GET_LOCATED); |
151 } |
148 else |
152 else { |
149 s4o.print(GET_VAR); |
153 if (vartype == search_var_instance_decl_c::located_vt) |
150 s4o.print("("); |
154 s4o.print(GET_LOCATED); |
151 generate_c_base_c::visit(symbol); |
155 else |
|
156 s4o.print(GET_VAR); |
|
157 s4o.print("("); |
|
158 generate_c_base_c::visit(symbol); |
|
159 } |
|
160 s4o.print(")"); |
152 s4o.print(")"); |
161 break; |
153 break; |
162 case fparam_output_vg: |
154 case fparam_output_vg: |
163 if (vartype == search_var_instance_decl_c::external_vt) { |
155 if (vartype == search_var_instance_decl_c::external_vt) |
164 s4o.print(GET_EXTERNAL_BY_REF); |
156 s4o.print(GET_EXTERNAL_BY_REF); |
165 s4o.print("("); |
157 else if (vartype == search_var_instance_decl_c::located_vt) |
166 symbol->var_name->accept(*this); |
158 s4o.print(GET_LOCATED_BY_REF); |
167 } |
159 else |
168 else { |
160 s4o.print(GET_VAR_BY_REF); |
169 if (vartype == search_var_instance_decl_c::located_vt) |
161 s4o.print("("); |
170 s4o.print(GET_LOCATED_BY_REF); |
162 generate_c_base_c::visit(symbol); |
171 else |
|
172 s4o.print(GET_VAR_BY_REF); |
|
173 s4o.print("("); |
|
174 generate_c_base_c::visit(symbol); |
|
175 } |
|
176 s4o.print(")"); |
163 s4o.print(")"); |
177 break; |
164 break; |
178 default: |
165 default: |
179 if (vartype == search_var_instance_decl_c::external_vt) |
166 generate_c_base_c::visit(symbol); |
180 symbol->var_name->accept(*this); |
|
181 else |
|
182 generate_c_base_c::visit(symbol); |
|
183 break; |
167 break; |
184 } |
168 } |
185 } |
169 } |
186 return NULL; |
170 return NULL; |
187 } |
171 } |
221 } |
205 } |
222 |
206 |
223 /*************************************/ |
207 /*************************************/ |
224 /* B.1.4.2 Multi-element Variables */ |
208 /* B.1.4.2 Multi-element Variables */ |
225 /*************************************/ |
209 /*************************************/ |
|
210 |
|
211 // SYM_REF2(structured_variable_c, record_variable, field_selector) |
|
212 void *visit(structured_variable_c *symbol) { |
|
213 TRACE("structured_variable_c"); |
|
214 |
|
215 unsigned int vartype = search_varfb_instance_type->get_vartype(symbol->record_variable); |
|
216 if (this->is_variable_prefix_null()) { |
|
217 symbol->record_variable->accept(*this); |
|
218 s4o.print("."); |
|
219 symbol->field_selector->accept(*this); |
|
220 } |
|
221 else { |
|
222 variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration; |
|
223 switch (wanted_variablegeneration) { |
|
224 case expression_vg: |
|
225 wanted_variablegeneration = assignment_vg; |
|
226 if (vartype == search_var_instance_decl_c::external_vt) { |
|
227 s4o.print(GET_EXTERNAL); |
|
228 s4o.print("("); |
|
229 symbol->record_variable->accept(*this); |
|
230 s4o.print(")."); |
|
231 symbol->field_selector->accept(*this); |
|
232 } |
|
233 else { |
|
234 if (vartype == search_var_instance_decl_c::located_vt) |
|
235 s4o.print(GET_LOCATED); |
|
236 else |
|
237 s4o.print(GET_VAR); |
|
238 s4o.print("("); |
|
239 symbol->record_variable->accept(*this); |
|
240 s4o.print("."); |
|
241 symbol->field_selector->accept(*this); |
|
242 s4o.print(")"); |
|
243 } |
|
244 wanted_variablegeneration = old_wanted_variablegeneration; |
|
245 break; |
|
246 case fparam_output_vg: |
|
247 wanted_variablegeneration = assignment_vg; |
|
248 s4o.print("&("); |
|
249 if (vartype == search_var_instance_decl_c::external_vt) |
|
250 s4o.print(GET_EXTERNAL); |
|
251 else if (vartype == search_var_instance_decl_c::located_vt) |
|
252 s4o.print(GET_LOCATED); |
|
253 else |
|
254 s4o.print(GET_VAR); |
|
255 s4o.print("("); |
|
256 symbol->record_variable->accept(*this); |
|
257 s4o.print(")."); |
|
258 symbol->field_selector->accept(*this); |
|
259 s4o.print("))"); |
|
260 wanted_variablegeneration = old_wanted_variablegeneration; |
|
261 break; |
|
262 default: |
|
263 symbol->record_variable->accept(*this); |
|
264 s4o.print("."); |
|
265 symbol->field_selector->accept(*this); |
|
266 break; |
|
267 } |
|
268 } |
|
269 return NULL; |
|
270 } |
226 |
271 |
227 /* subscripted_variable '[' subscript_list ']' */ |
272 /* subscripted_variable '[' subscript_list ']' */ |
228 //SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
273 //SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
229 void *visit(array_variable_c *symbol) { |
274 void *visit(array_variable_c *symbol) { |
230 current_array_type = search_varfb_instance_type->get_type(symbol->subscripted_variable, false); |
275 current_array_type = search_varfb_instance_type->get_type(symbol->subscripted_variable, false); |