160 if ((PARAM_DIRECTION == function_param_iterator_c::direction_out || |
164 if ((PARAM_DIRECTION == function_param_iterator_c::direction_out || |
161 PARAM_DIRECTION == function_param_iterator_c::direction_inout) && |
165 PARAM_DIRECTION == function_param_iterator_c::direction_inout) && |
162 PARAM_VALUE != NULL) { |
166 PARAM_VALUE != NULL) { |
163 |
167 |
164 s4o.print(s4o.indent_spaces); |
168 s4o.print(s4o.indent_spaces); |
165 |
169 print_setter(PARAM_VALUE, PARAM_TYPE, PARAM_NAME); |
166 unsigned int vartype = search_varfb_instance_type->get_vartype(PARAM_VALUE); |
170 s4o.print(";\n"); |
167 if (vartype == search_var_instance_decl_c::external_vt) |
|
168 s4o.print(SET_EXTERNAL); |
|
169 else if (vartype == search_var_instance_decl_c::located_vt) |
|
170 s4o.print(SET_LOCATED); |
|
171 else |
|
172 s4o.print(SET_VAR); |
|
173 s4o.print("("); |
|
174 wanted_variablegeneration = assignment_vg; |
|
175 PARAM_VALUE->accept(*this); |
|
176 wanted_variablegeneration = expression_vg; |
|
177 s4o.print(", "); |
|
178 print_check_function(PARAM_TYPE, PARAM_NAME, NULL, true); |
|
179 s4o.print(");\n"); |
|
180 } |
171 } |
181 } |
172 } |
182 s4o.print(s4o.indent_spaces + "return "); |
173 s4o.print(s4o.indent_spaces + "return "); |
183 s4o.print(INLINE_RESULT_TEMP_VAR); |
174 s4o.print(INLINE_RESULT_TEMP_VAR); |
184 s4o.print(";\n"); |
175 s4o.print(";\n"); |
189 return NULL; |
180 return NULL; |
190 } |
181 } |
191 |
182 |
192 private: |
183 private: |
193 |
184 |
|
185 void *print_getter(symbol_c *symbol) { |
|
186 unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); |
|
187 if (vartype == search_var_instance_decl_c::external_vt) |
|
188 s4o.print(GET_EXTERNAL); |
|
189 else if (vartype == search_var_instance_decl_c::located_vt) |
|
190 s4o.print(GET_LOCATED); |
|
191 else |
|
192 s4o.print(GET_VAR); |
|
193 s4o.print("("); |
|
194 |
|
195 wanted_variablegeneration = complextype_base_vg; |
|
196 symbol->accept(*this); |
|
197 if (search_varfb_instance_type->type_is_complex()) |
|
198 s4o.print(","); |
|
199 wanted_variablegeneration = complextype_suffix_vg; |
|
200 symbol->accept(*this); |
|
201 s4o.print(")"); |
|
202 wanted_variablegeneration = expression_vg; |
|
203 return NULL; |
|
204 } |
|
205 |
|
206 void *print_setter(symbol_c* symbol, |
|
207 symbol_c* type, |
|
208 symbol_c* value) { |
|
209 unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); |
|
210 if (vartype == search_var_instance_decl_c::external_vt) |
|
211 s4o.print(SET_EXTERNAL); |
|
212 else if (vartype == search_var_instance_decl_c::located_vt) |
|
213 s4o.print(SET_LOCATED); |
|
214 else |
|
215 s4o.print(SET_VAR); |
|
216 s4o.print("("); |
|
217 |
|
218 wanted_variablegeneration = complextype_base_vg; |
|
219 symbol->accept(*this); |
|
220 s4o.print(","); |
|
221 wanted_variablegeneration = expression_vg; |
|
222 print_check_function(type, value, NULL, true); |
|
223 if (search_varfb_instance_type->type_is_complex()) { |
|
224 s4o.print(","); |
|
225 wanted_variablegeneration = complextype_suffix_vg; |
|
226 symbol->accept(*this); |
|
227 } |
|
228 s4o.print(")"); |
|
229 wanted_variablegeneration = expression_vg; |
|
230 return NULL; |
|
231 } |
|
232 |
194 /*********************/ |
233 /*********************/ |
195 /* B 1.4 - Variables */ |
234 /* B 1.4 - Variables */ |
196 /*********************/ |
235 /*********************/ |
197 void *visit(symbolic_variable_c *symbol) { |
236 void *visit(symbolic_variable_c *symbol) { |
198 if (wanted_variablegeneration == expression_vg) { |
237 unsigned int vartype; |
199 unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); |
238 if (wanted_variablegeneration == complextype_base_vg) |
|
239 generate_c_base_c::visit(symbol); |
|
240 else if (wanted_variablegeneration == complextype_suffix_vg) |
|
241 return NULL; |
|
242 else if (wanted_variablegeneration == expression_vg) { |
|
243 vartype = search_varfb_instance_type->get_vartype(symbol); |
200 if (vartype == search_var_instance_decl_c::external_vt) { |
244 if (vartype == search_var_instance_decl_c::external_vt) { |
201 s4o.print(GET_EXTERNAL); |
245 s4o.print(GET_EXTERNAL); |
202 s4o.print("("); |
246 s4o.print("("); |
203 symbol->var_name->accept(*this); |
247 symbol->var_name->accept(*this); |
204 } |
248 } |
231 s4o.printlocation(symbol->value + 1); |
275 s4o.printlocation(symbol->value + 1); |
232 s4o.print(")"); |
276 s4o.print(")"); |
233 return NULL; |
277 return NULL; |
234 } |
278 } |
235 |
279 |
|
280 /*************************************/ |
|
281 /* B.1.4.2 Multi-element Variables */ |
|
282 /*************************************/ |
|
283 |
|
284 // SYM_REF2(structured_variable_c, record_variable, field_selector) |
|
285 void *visit(structured_variable_c *symbol) { |
|
286 TRACE("structured_variable_c"); |
|
287 switch (wanted_variablegeneration) { |
|
288 case complextype_base_vg: |
|
289 symbol->record_variable->accept(*this); |
|
290 break; |
|
291 case complextype_suffix_vg: |
|
292 symbol->record_variable->accept(*this); |
|
293 s4o.print("."); |
|
294 symbol->field_selector->accept(*this); |
|
295 break; |
|
296 default: |
|
297 if (this->is_variable_prefix_null()) { |
|
298 symbol->record_variable->accept(*this); |
|
299 s4o.print("."); |
|
300 symbol->field_selector->accept(*this); |
|
301 } |
|
302 else |
|
303 print_getter(symbol); |
|
304 break; |
|
305 } |
|
306 return NULL; |
|
307 } |
|
308 |
|
309 /* subscripted_variable '[' subscript_list ']' */ |
|
310 //SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
|
311 void *visit(array_variable_c *symbol) { |
|
312 switch (wanted_variablegeneration) { |
|
313 case complextype_base_vg: |
|
314 symbol->subscripted_variable->accept(*this); |
|
315 break; |
|
316 case complextype_suffix_vg: |
|
317 current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable); |
|
318 symbol->subscripted_variable->accept(*this); |
|
319 if (current_array_type != NULL) { |
|
320 symbol->subscript_list->accept(*this); |
|
321 current_array_type = NULL; |
|
322 } |
|
323 break; |
|
324 default: |
|
325 if (this->is_variable_prefix_null()) { |
|
326 current_array_type = search_varfb_instance_type->get_rawtype(symbol->subscripted_variable); |
|
327 symbol->subscripted_variable->accept(*this); |
|
328 if (current_array_type != NULL) { |
|
329 symbol->subscript_list->accept(*this); |
|
330 current_array_type = NULL; |
|
331 } |
|
332 } |
|
333 else |
|
334 print_getter(symbol); |
|
335 break; |
|
336 } |
|
337 return NULL; |
|
338 } |
|
339 |
236 /****************************************/ |
340 /****************************************/ |
237 /* B.2 - Language IL (Instruction List) */ |
341 /* B.2 - Language IL (Instruction List) */ |
238 /****************************************/ |
342 /****************************************/ |
239 |
343 |
240 /***********************************/ |
344 /***********************************/ |