equal
deleted
inserted
replaced
24 |
24 |
25 |
25 |
26 #define INLINE_RESULT_TEMP_VAR "__res" |
26 #define INLINE_RESULT_TEMP_VAR "__res" |
27 #define INLINE_PARAM_COUNT "__PARAM_COUNT" |
27 #define INLINE_PARAM_COUNT "__PARAM_COUNT" |
28 |
28 |
29 class generate_c_inlinefcall_c: public generate_c_typedecl_c { |
29 class generate_c_inlinefcall_c: public generate_c_base_c { |
30 |
30 |
31 public: |
31 public: |
32 typedef enum { |
32 typedef enum { |
33 expression_vg, |
33 expression_vg, |
34 assignment_vg, |
34 assignment_vg, |
74 |
74 |
75 variablegeneration_t wanted_variablegeneration; |
75 variablegeneration_t wanted_variablegeneration; |
76 |
76 |
77 public: |
77 public: |
78 generate_c_inlinefcall_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL) |
78 generate_c_inlinefcall_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL) |
79 : generate_c_typedecl_c(s4o_ptr), |
79 : generate_c_base_c(s4o_ptr), |
80 implicit_variable_current(IL_DEFVAR, NULL) |
80 implicit_variable_current(IL_DEFVAR, NULL) |
81 { |
81 { |
82 search_varfb_instance_type = new search_varfb_instance_type_c(scope); |
82 search_varfb_instance_type = new search_varfb_instance_type_c(scope); |
83 search_var_instance_decl = new search_var_instance_decl_c (scope); |
83 search_var_instance_decl = new search_var_instance_decl_c (scope); |
84 |
84 |
241 |
241 |
242 |
242 |
243 void *print_getter(symbol_c *symbol) { |
243 void *print_getter(symbol_c *symbol) { |
244 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
244 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
245 if (vartype == search_var_instance_decl_c::external_vt) { |
245 if (vartype == search_var_instance_decl_c::external_vt) { |
246 if (search_var_instance_decl->type_is_fb(symbol)) |
246 if (!get_datatype_info_c::is_type_valid (symbol->datatype)) ERROR; |
|
247 if ( get_datatype_info_c::is_function_block(symbol->datatype)) |
247 s4o.print(GET_EXTERNAL_FB); |
248 s4o.print(GET_EXTERNAL_FB); |
248 else |
249 else |
249 s4o.print(GET_EXTERNAL); |
250 s4o.print(GET_EXTERNAL); |
250 } |
251 } |
251 else if (vartype == search_var_instance_decl_c::located_vt) |
252 else if (vartype == search_var_instance_decl_c::located_vt) |
254 s4o.print(GET_VAR); |
255 s4o.print(GET_VAR); |
255 s4o.print("("); |
256 s4o.print("("); |
256 |
257 |
257 wanted_variablegeneration = complextype_base_vg; |
258 wanted_variablegeneration = complextype_base_vg; |
258 symbol->accept(*this); |
259 symbol->accept(*this); |
259 if (search_var_instance_decl->type_is_complex(symbol)) |
260 s4o.print(","); |
260 s4o.print(","); |
|
261 wanted_variablegeneration = complextype_suffix_vg; |
261 wanted_variablegeneration = complextype_suffix_vg; |
262 symbol->accept(*this); |
262 symbol->accept(*this); |
263 s4o.print(")"); |
263 s4o.print(")"); |
264 wanted_variablegeneration = expression_vg; |
264 wanted_variablegeneration = expression_vg; |
265 return NULL; |
265 return NULL; |
268 void *print_setter(symbol_c* symbol, |
268 void *print_setter(symbol_c* symbol, |
269 symbol_c* type, |
269 symbol_c* type, |
270 symbol_c* value) { |
270 symbol_c* value) { |
271 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
271 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
272 if (vartype == search_var_instance_decl_c::external_vt) { |
272 if (vartype == search_var_instance_decl_c::external_vt) { |
273 if (search_var_instance_decl->type_is_fb(symbol)) |
273 if (!get_datatype_info_c::is_type_valid (symbol->datatype)) ERROR; |
|
274 if ( get_datatype_info_c::is_function_block(symbol->datatype)) |
274 s4o.print(SET_EXTERNAL_FB); |
275 s4o.print(SET_EXTERNAL_FB); |
275 else |
276 else |
276 s4o.print(SET_EXTERNAL); |
277 s4o.print(SET_EXTERNAL); |
277 } |
278 } |
278 else if (vartype == search_var_instance_decl_c::located_vt) |
279 else if (vartype == search_var_instance_decl_c::located_vt) |
284 wanted_variablegeneration = complextype_base_vg; |
285 wanted_variablegeneration = complextype_base_vg; |
285 symbol->accept(*this); |
286 symbol->accept(*this); |
286 s4o.print(","); |
287 s4o.print(","); |
287 wanted_variablegeneration = expression_vg; |
288 wanted_variablegeneration = expression_vg; |
288 print_check_function(type, value, NULL, true); |
289 print_check_function(type, value, NULL, true); |
289 if (search_var_instance_decl->type_is_complex(symbol)) { |
290 if (analyse_variable_c::contains_complex_type(symbol)) { |
290 s4o.print(","); |
291 s4o.print(","); |
291 wanted_variablegeneration = complextype_suffix_vg; |
292 wanted_variablegeneration = complextype_suffix_vg; |
292 symbol->accept(*this); |
293 symbol->accept(*this); |
293 } |
294 } |
294 s4o.print(")"); |
295 s4o.print(")"); |
335 /*************************************/ |
336 /*************************************/ |
336 |
337 |
337 // SYM_REF2(structured_variable_c, record_variable, field_selector) |
338 // SYM_REF2(structured_variable_c, record_variable, field_selector) |
338 void *visit(structured_variable_c *symbol) { |
339 void *visit(structured_variable_c *symbol) { |
339 TRACE("structured_variable_c"); |
340 TRACE("structured_variable_c"); |
340 bool type_is_complex = search_var_instance_decl->type_is_complex(symbol->record_variable); |
341 bool type_is_complex = analyse_variable_c::is_complex_type(symbol->record_variable); |
341 if (generating_inlinefunction) { |
342 if (generating_inlinefunction) { |
342 switch (wanted_variablegeneration) { |
343 switch (wanted_variablegeneration) { |
343 case complextype_base_vg: |
344 case complextype_base_vg: |
344 symbol->record_variable->accept(*this); |
345 symbol->record_variable->accept(*this); |
345 if (!type_is_complex) { |
346 if (!type_is_complex) { |
510 */ |
511 */ |
511 if ((param_value == NULL) && (fp_iterator.is_extensible_param())) { |
512 if ((param_value == NULL) && (fp_iterator.is_extensible_param())) { |
512 break; |
513 break; |
513 } |
514 } |
514 |
515 |
|
516 /* We do not yet support embedded IL lists, so we abort the compiler if we find one */ |
|
517 /* Note that in IL function calls the syntax does not allow embeded IL lists, so this check is not necessary here! */ |
|
518 /* |
|
519 {simple_instr_list_c *instruction_list = dynamic_cast<simple_instr_list_c *>(param_value); |
|
520 if (NULL != instruction_list) STAGE4_ERROR(param_value, param_value, "The compiler does not yet support formal invocations in IL that contain embedded IL lists. Aborting!"); |
|
521 } |
|
522 */ |
|
523 |
515 if ((param_value == NULL) && (param_direction == function_param_iterator_c::direction_in)) { |
524 if ((param_value == NULL) && (param_direction == function_param_iterator_c::direction_in)) { |
516 /* No value given for parameter, so we must use the default... */ |
525 /* No value given for parameter, so we must use the default... */ |
517 /* First check whether default value specified in function declaration...*/ |
526 /* First check whether default value specified in function declaration...*/ |
518 param_value = fp_iterator.default_value(); |
527 param_value = fp_iterator.default_value(); |
519 } |
528 } |
667 * have reached the end, and should simply jump out of the for loop. |
676 * have reached the end, and should simply jump out of the for loop. |
668 */ |
677 */ |
669 if ((param_value == NULL) && (fp_iterator.is_extensible_param())) { |
678 if ((param_value == NULL) && (fp_iterator.is_extensible_param())) { |
670 break; |
679 break; |
671 } |
680 } |
672 |
681 |
|
682 /* We do not yet support embedded IL lists, so we abort the compiler if we find one */ |
|
683 {simple_instr_list_c *instruction_list = dynamic_cast<simple_instr_list_c *>(param_value); |
|
684 if (NULL != instruction_list) STAGE4_ERROR(param_value, param_value, "The compiler does not yet support formal invocations in IL that contain embedded IL lists. Aborting!"); |
|
685 } |
|
686 |
673 if ((param_value == NULL) && (param_direction == function_param_iterator_c::direction_in)) { |
687 if ((param_value == NULL) && (param_direction == function_param_iterator_c::direction_in)) { |
674 /* No value given for parameter, so we must use the default... */ |
688 /* No value given for parameter, so we must use the default... */ |
675 /* First check whether default value specified in function declaration...*/ |
689 /* First check whether default value specified in function declaration...*/ |
676 param_value = fp_iterator.default_value(); |
690 param_value = fp_iterator.default_value(); |
677 } |
691 } |