35 complextype_base_vg, |
35 complextype_base_vg, |
36 complextype_suffix_vg |
36 complextype_suffix_vg |
37 } variablegeneration_t; |
37 } variablegeneration_t; |
38 |
38 |
39 private: |
39 private: |
40 /* The result of the comparison IL operations (GT, EQ, LT, ...) |
40 /* The result of the comparison IL operations (GT, EQ, LT, ...) |
41 * is a boolean variable. |
41 * is a boolean variable. |
42 * This class keeps track of the current data type stored in the |
42 * This class keeps track of the current data type stored in the |
43 * il default variable. This is usually done by keeping a reference |
43 * il default variable. This is usually done by keeping a reference |
44 * to the data type of the last operand. Nevertheless, in the case of |
44 * to the data type of the last operand. Nevertheless, in the case of |
45 * the comparison IL operators, the data type of the result (a boolean) |
45 * the comparison IL operators, the data type of the result (a boolean) |
46 * is not the data type of the operand. We therefore need an object |
46 * is not the data type of the operand. We therefore need an object |
47 * of the boolean data type to keep as a reference of the current |
47 * of the boolean data type to keep as a reference of the current |
48 * data type. |
48 * data type. |
49 * The following object is it... |
49 * The following object is it... |
50 */ |
50 */ |
51 bool_type_name_c bool_type; |
51 bool_type_name_c bool_type; |
52 lint_type_name_c lint_type; |
52 lint_type_name_c lint_type; |
53 lword_type_name_c lword_type; |
53 lword_type_name_c lword_type; |
54 lreal_type_name_c lreal_type; |
54 lreal_type_name_c lreal_type; |
55 |
55 |
56 /* The name of the IL default variable... */ |
56 /* The name of the IL default variable... */ |
57 #define IL_DEFVAR VAR_LEADER "IL_DEFVAR" |
57 #define IL_DEFVAR VAR_LEADER "IL_DEFVAR" |
58 |
58 |
59 /* The name of the variable used to pass the result of a |
59 /* The name of the variable used to pass the result of a |
60 * parenthesised instruction list to the immediately preceding |
60 * parenthesised instruction list to the immediately preceding |
61 * scope ... |
61 * scope ... |
62 */ |
62 */ |
63 #define IL_DEFVAR_BACK VAR_LEADER "IL_DEFVAR_BACK" |
63 #define IL_DEFVAR_BACK VAR_LEADER "IL_DEFVAR_BACK" |
64 il_default_variable_c implicit_variable_current; |
64 il_default_variable_c implicit_variable_current; |
65 |
65 |
66 symbol_c* current_array_type; |
66 symbol_c* current_array_type; |
67 |
67 |
129 if (f_decl != NULL) { |
129 if (f_decl != NULL) { |
130 /* function being called is overloaded! */ |
130 /* function being called is overloaded! */ |
131 s4o.print("__"); |
131 s4o.print("__"); |
132 print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
132 print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
133 f_decl->accept(overloaded_func_suf); |
133 f_decl->accept(overloaded_func_suf); |
134 } |
134 } |
135 if (function_type_suffix) { |
135 if (function_type_suffix) { |
136 function_type_suffix->accept(*this); |
136 function_type_suffix->accept(*this); |
137 } |
137 } |
138 s4o.print(fcall_number); |
138 s4o.print(fcall_number); |
139 s4o.print("("); |
139 s4o.print("("); |
178 |
178 |
179 s4o.print(s4o.indent_spaces + INLINE_RESULT_TEMP_VAR), |
179 s4o.print(s4o.indent_spaces + INLINE_RESULT_TEMP_VAR), |
180 s4o.print(" = "); |
180 s4o.print(" = "); |
181 function_name->accept(*this); |
181 function_name->accept(*this); |
182 if (f_decl != NULL) { |
182 if (f_decl != NULL) { |
183 /* function being called is overloaded! */ |
183 /* function being called is overloaded! */ |
184 s4o.print("__"); |
184 s4o.print("__"); |
185 print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
185 print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
186 f_decl->accept(overloaded_func_suf); |
186 f_decl->accept(overloaded_func_suf); |
187 } |
187 } |
188 |
188 |
189 if (function_type_suffix) |
189 if (function_type_suffix) |
240 |
240 |
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 s4o.print(GET_EXTERNAL); |
246 if (search_var_instance_decl->type_is_fb(symbol)) |
|
247 s4o.print(GET_EXTERNAL_FB); |
|
248 else |
|
249 s4o.print(GET_EXTERNAL); |
|
250 } |
247 else if (vartype == search_var_instance_decl_c::located_vt) |
251 else if (vartype == search_var_instance_decl_c::located_vt) |
248 s4o.print(GET_LOCATED); |
252 s4o.print(GET_LOCATED); |
249 else |
253 else |
250 s4o.print(GET_VAR); |
254 s4o.print(GET_VAR); |
251 s4o.print("("); |
255 s4o.print("("); |
263 |
267 |
264 void *print_setter(symbol_c* symbol, |
268 void *print_setter(symbol_c* symbol, |
265 symbol_c* type, |
269 symbol_c* type, |
266 symbol_c* value) { |
270 symbol_c* value) { |
267 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
271 unsigned int vartype = search_var_instance_decl->get_vartype(symbol); |
268 if (vartype == search_var_instance_decl_c::external_vt) |
272 if (vartype == search_var_instance_decl_c::external_vt) { |
269 s4o.print(SET_EXTERNAL); |
273 if (search_var_instance_decl->type_is_fb(symbol)) |
|
274 s4o.print(SET_EXTERNAL_FB); |
|
275 else |
|
276 s4o.print(SET_EXTERNAL); |
|
277 } |
270 else if (vartype == search_var_instance_decl_c::located_vt) |
278 else if (vartype == search_var_instance_decl_c::located_vt) |
271 s4o.print(SET_LOCATED); |
279 s4o.print(SET_LOCATED); |
272 else |
280 else |
273 s4o.print(SET_VAR); |
281 s4o.print(SET_VAR); |
274 s4o.print("(,"); |
282 s4o.print("(,"); |
333 if (generating_inlinefunction) { |
341 if (generating_inlinefunction) { |
334 switch (wanted_variablegeneration) { |
342 switch (wanted_variablegeneration) { |
335 case complextype_base_vg: |
343 case complextype_base_vg: |
336 symbol->record_variable->accept(*this); |
344 symbol->record_variable->accept(*this); |
337 if (!type_is_complex) { |
345 if (!type_is_complex) { |
338 s4o.print("."); |
346 s4o.print("."); |
339 symbol->field_selector->accept(*this); |
347 symbol->field_selector->accept(*this); |
340 } |
348 } |
341 break; |
349 break; |
342 case complextype_suffix_vg: |
350 case complextype_suffix_vg: |
343 symbol->record_variable->accept(*this); |
351 symbol->record_variable->accept(*this); |
344 if (type_is_complex) { |
352 if (type_is_complex) { |
704 // SYM_LIST(simple_instr_list_c) |
712 // SYM_LIST(simple_instr_list_c) |
705 void *visit(simple_instr_list_c *symbol) {return iterator_visitor_c::visit(symbol);} |
713 void *visit(simple_instr_list_c *symbol) {return iterator_visitor_c::visit(symbol);} |
706 |
714 |
707 |
715 |
708 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;) |
716 // SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;) |
709 void *visit(il_simple_instruction_c *symbol) { |
717 void *visit(il_simple_instruction_c *symbol) { |
710 /* all previous IL instructions should have the same datatype (checked in stage3), so we get the datatype from the first previous IL instruction we find */ |
718 /* all previous IL instructions should have the same datatype (checked in stage3), so we get the datatype from the first previous IL instruction we find */ |
711 implicit_variable_current.datatype = (symbol->prev_il_instruction.empty())? NULL : symbol->prev_il_instruction[0]->datatype; |
719 implicit_variable_current.datatype = (symbol->prev_il_instruction.empty())? NULL : symbol->prev_il_instruction[0]->datatype; |
712 symbol->il_simple_instruction->accept(*this); |
720 symbol->il_simple_instruction->accept(*this); |
713 implicit_variable_current.datatype = NULL; |
721 implicit_variable_current.datatype = NULL; |
714 return NULL; |
722 return NULL; |
722 /***********************/ |
730 /***********************/ |
723 /* B 3.1 - Expressions */ |
731 /* B 3.1 - Expressions */ |
724 /***********************/ |
732 /***********************/ |
725 |
733 |
726 void *visit(statement_list_c *symbol) { |
734 void *visit(statement_list_c *symbol) { |
727 function_call_iterator_c fc_iterator(symbol); |
735 function_call_iterator_c fc_iterator(symbol); |
728 symbol_c* function_call; |
736 symbol_c* function_call; |
729 while ((function_call = fc_iterator.next()) != NULL) { |
737 while ((function_call = fc_iterator.next()) != NULL) { |
730 function_call->accept(*this); |
738 function_call->accept(*this); |
731 } |
739 } |
732 return NULL; |
740 return NULL; |
733 } |
741 } |
734 |
742 |
735 void *visit(function_invocation_c *symbol) { |
743 void *visit(function_invocation_c *symbol) { |
736 symbol_c* function_type_prefix = NULL; |
744 symbol_c* function_type_prefix = NULL; |
737 symbol_c* function_name = NULL; |
745 symbol_c* function_name = NULL; |
738 symbol_c* function_type_suffix = NULL; |
746 symbol_c* function_type_suffix = NULL; |
859 CLEAR_PARAM_LIST() |
867 CLEAR_PARAM_LIST() |
860 |
868 |
861 return NULL; |
869 return NULL; |
862 } |
870 } |
863 |
871 |
864 /*********************************************/ |
872 /*********************************************/ |
865 /* B.1.6 Sequential function chart elements */ |
873 /* B.1.6 Sequential function chart elements */ |
866 /*********************************************/ |
874 /*********************************************/ |
867 |
875 |
868 void *visit(initial_step_c *symbol) { |
876 void *visit(initial_step_c *symbol) { |
869 return NULL; |
877 return NULL; |
870 } |
878 } |
871 |
879 |
872 void *visit(step_c *symbol) { |
880 void *visit(step_c *symbol) { |
873 return NULL; |
881 return NULL; |
874 } |
882 } |
875 |
883 |
876 void *visit(transition_c *symbol) { |
884 void *visit(transition_c *symbol) { |
877 return symbol->transition_condition->accept(*this); |
885 return symbol->transition_condition->accept(*this); |
878 } |
886 } |
879 |
887 |
880 void *visit(transition_condition_c *symbol) { |
888 void *visit(transition_condition_c *symbol) { |
881 // Transition condition is in IL |
889 // Transition condition is in IL |
882 if (symbol->transition_condition_il != NULL) { |
890 if (symbol->transition_condition_il != NULL) { |
883 symbol->transition_condition_il->accept(*this); |
891 symbol->transition_condition_il->accept(*this); |
884 } |
892 } |
885 |
893 |
886 // Transition condition is in ST |
894 // Transition condition is in ST |
887 if (symbol->transition_condition_st != NULL) { |
895 if (symbol->transition_condition_st != NULL) { |
888 function_call_iterator_c fc_iterator(symbol->transition_condition_st); |
896 function_call_iterator_c fc_iterator(symbol->transition_condition_st); |
889 symbol_c* function_call; |
897 symbol_c* function_call; |
890 while ((function_call = fc_iterator.next()) != NULL) { |
898 while ((function_call = fc_iterator.next()) != NULL) { |
891 function_call->accept(*this); |
899 function_call->accept(*this); |
892 } |
900 } |
893 } |
901 } |
894 |
902 |
895 return NULL; |
903 return NULL; |
896 } |
904 } |
897 |
905 |
898 void *visit(action_c *symbol) { |
906 void *visit(action_c *symbol) { |
899 return symbol->function_block_body->accept(*this); |
907 return symbol->function_block_body->accept(*this); |
900 } |
908 } |
901 |
909 |
902 }; /* generate_c_inlinefcall_c */ |
910 }; /* generate_c_inlinefcall_c */ |
903 |
911 |