author | Mario de Sousa <msousa@fe.up.pt> |
Fri, 13 Apr 2012 13:05:44 +0100 | |
changeset 503 | e1e7c7678c44 |
parent 498 | 0637a4490c8c |
child 505 | 21be0f2f242d |
permissions | -rwxr-xr-x |
70 | 1 |
/* |
279
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
70 | 3 |
* |
279
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
4 |
* Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
5 |
* Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant |
70 | 6 |
* |
279
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
7 |
* This program is free software: you can redistribute it and/or modify |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
8 |
* it under the terms of the GNU General Public License as published by |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
9 |
* the Free Software Foundation, either version 3 of the License, or |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
10 |
* (at your option) any later version. |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
11 |
* |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
12 |
* This program is distributed in the hope that it will be useful, |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
15 |
* GNU General Public License for more details. |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
16 |
* |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License |
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
70 | 19 |
* |
20 |
* This code is made available on the understanding that it will not be |
|
21 |
* used in safety-critical situations without a full and competent review. |
|
22 |
* |
|
23 |
* Based on the |
|
24 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
25 |
* |
|
26 |
*/ |
|
27 |
||
28 |
||
29 |
/* |
|
30 |
* Conversion of st statements (i.e. ST code). |
|
31 |
* |
|
32 |
* This is part of the 4th stage that generates |
|
279
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
258
diff
changeset
|
33 |
* a C source program equivalent to the IL and ST, or SFC |
70 | 34 |
* code. |
35 |
*/ |
|
36 |
||
37 |
||
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
38 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
39 |
#include "../../util/strdup.hh" |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
40 |
|
70 | 41 |
/***********************************************************************/ |
42 |
/***********************************************************************/ |
|
43 |
/***********************************************************************/ |
|
44 |
/***********************************************************************/ |
|
45 |
||
46 |
||
47 |
class generate_c_st_c: public generate_c_typedecl_c { |
|
48 |
||
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
49 |
public: |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
50 |
typedef enum { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
51 |
expression_vg, |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
52 |
assignment_vg, |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
53 |
complextype_base_vg, |
392
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
54 |
complextype_base_assignment_vg, |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
55 |
complextype_suffix_vg, |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
56 |
fparam_output_vg |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
57 |
} variablegeneration_t; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
58 |
|
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
59 |
typedef enum { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
60 |
single_cg, |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
61 |
subrange_cg, |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
62 |
none_cg |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
63 |
} casegeneration_t; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
64 |
|
70 | 65 |
private: |
66 |
/* When calling a function block, we must first find it's type, |
|
67 |
* by searching through the declarations of the variables currently |
|
68 |
* in scope. |
|
69 |
* This class does just that... |
|
70 |
* A new class is instantiated whenever we begin generating the code |
|
71 |
* for a function block type declaration, or a program declaration. |
|
72 |
* This object instance will then later be called while the |
|
73 |
* function block's or the program's body is being handled. |
|
74 |
* |
|
75 |
* Note that functions cannot contain calls to function blocks, |
|
76 |
* so we do not create an object instance when handling |
|
77 |
* a function declaration. |
|
78 |
*/ |
|
79 |
search_fb_instance_decl_c *search_fb_instance_decl; |
|
80 |
||
81 |
/* When compiling st code, it becomes necessary to determine the |
|
82 |
* data type of st expressions. To do this, we must first find the |
|
83 |
* st operand's declaration, within the scope of the function block |
|
84 |
* or function currently being processed. |
|
85 |
* The following object does just that... |
|
86 |
* This object instance will then later be called while the |
|
87 |
* remaining st code is being handled. |
|
88 |
*/ |
|
89 |
search_expression_type_c *search_expression_type; |
|
90 |
||
91 |
search_varfb_instance_type_c *search_varfb_instance_type; |
|
92 |
||
98 | 93 |
search_base_type_c search_base_type; |
94 |
||
95 |
symbol_c* current_array_type; |
|
235 | 96 |
symbol_c* current_param_type; |
98 | 97 |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
98 |
int fcall_number; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
99 |
symbol_c *fbname; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
100 |
|
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
101 |
bool first_subrange_case_list; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
102 |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
103 |
variablegeneration_t wanted_variablegeneration; |
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
104 |
casegeneration_t wanted_casegeneration; |
145 | 105 |
|
70 | 106 |
public: |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
107 |
generate_c_st_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL) |
70 | 108 |
: generate_c_typedecl_c(s4o_ptr) { |
109 |
search_fb_instance_decl = new search_fb_instance_decl_c(scope); |
|
110 |
search_expression_type = new search_expression_type_c(scope); |
|
111 |
search_varfb_instance_type = new search_varfb_instance_type_c(scope); |
|
112 |
this->set_variable_prefix(variable_prefix); |
|
98 | 113 |
current_array_type = NULL; |
235 | 114 |
current_param_type = NULL; |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
115 |
fcall_number = 0; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
116 |
fbname = name; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
117 |
wanted_variablegeneration = expression_vg; |
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
118 |
wanted_casegeneration = none_cg; |
70 | 119 |
} |
120 |
||
121 |
virtual ~generate_c_st_c(void) { |
|
122 |
delete search_fb_instance_decl; |
|
123 |
delete search_expression_type; |
|
124 |
delete search_varfb_instance_type; |
|
125 |
} |
|
126 |
||
127 |
||
128 |
public: |
|
129 |
void generate(statement_list_c *stl) { |
|
130 |
stl->accept(*this); |
|
131 |
} |
|
132 |
||
133 |
private: |
|
134 |
||
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
135 |
void *print_getter(symbol_c *symbol) { |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
136 |
unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); |
235 | 137 |
if (wanted_variablegeneration == fparam_output_vg) { |
503
e1e7c7678c44
Edit formating and delete unused code.
Mario de Sousa <msousa@fe.up.pt>
parents:
498
diff
changeset
|
138 |
if (vartype == search_var_instance_decl_c::external_vt) |
235 | 139 |
s4o.print(GET_EXTERNAL_BY_REF); |
140 |
else if (vartype == search_var_instance_decl_c::located_vt) |
|
141 |
s4o.print(GET_LOCATED_BY_REF); |
|
142 |
else |
|
143 |
s4o.print(GET_VAR_BY_REF); |
|
144 |
} |
|
145 |
else { |
|
503
e1e7c7678c44
Edit formating and delete unused code.
Mario de Sousa <msousa@fe.up.pt>
parents:
498
diff
changeset
|
146 |
if (vartype == search_var_instance_decl_c::external_vt) |
e1e7c7678c44
Edit formating and delete unused code.
Mario de Sousa <msousa@fe.up.pt>
parents:
498
diff
changeset
|
147 |
s4o.print(GET_EXTERNAL); |
e1e7c7678c44
Edit formating and delete unused code.
Mario de Sousa <msousa@fe.up.pt>
parents:
498
diff
changeset
|
148 |
else if (vartype == search_var_instance_decl_c::located_vt) |
e1e7c7678c44
Edit formating and delete unused code.
Mario de Sousa <msousa@fe.up.pt>
parents:
498
diff
changeset
|
149 |
s4o.print(GET_LOCATED); |
e1e7c7678c44
Edit formating and delete unused code.
Mario de Sousa <msousa@fe.up.pt>
parents:
498
diff
changeset
|
150 |
else |
e1e7c7678c44
Edit formating and delete unused code.
Mario de Sousa <msousa@fe.up.pt>
parents:
498
diff
changeset
|
151 |
s4o.print(GET_VAR); |
235 | 152 |
} |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
153 |
s4o.print("("); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
154 |
|
235 | 155 |
variablegeneration_t old_wanted_variablegeneration = wanted_variablegeneration; |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
156 |
wanted_variablegeneration = complextype_base_vg; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
157 |
symbol->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
158 |
if (search_varfb_instance_type->type_is_complex()) |
235 | 159 |
s4o.print(","); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
160 |
wanted_variablegeneration = complextype_suffix_vg; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
161 |
symbol->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
162 |
s4o.print(")"); |
235 | 163 |
wanted_variablegeneration = old_wanted_variablegeneration; |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
164 |
return NULL; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
165 |
} |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
166 |
|
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
167 |
void *print_setter(symbol_c* symbol, |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
168 |
symbol_c* type, |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
169 |
symbol_c* value, |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
170 |
symbol_c* fb_symbol = NULL, |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
171 |
symbol_c* fb_value = NULL) { |
302
d120740a6b58
Fixing bug related to setting array variables with values coming from other variables
Mario de Sousa <msousa@fe.up.pt>
parents:
298
diff
changeset
|
172 |
|
405
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
173 |
bool type_is_complex = false; |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
174 |
if (fb_symbol == NULL) { |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
175 |
unsigned int vartype = search_varfb_instance_type->get_vartype(symbol); |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
176 |
type_is_complex = search_varfb_instance_type->type_is_complex(); |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
177 |
if (vartype == search_var_instance_decl_c::external_vt) |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
178 |
s4o.print(SET_EXTERNAL); |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
179 |
else if (vartype == search_var_instance_decl_c::located_vt) |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
180 |
s4o.print(SET_LOCATED); |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
181 |
else |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
182 |
s4o.print(SET_VAR); |
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
183 |
} |
392
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
184 |
else |
405
7b5d67d1aeef
Fix bug wrong code generated when, in a pou, a located variable has the same name than a function block instance input variable
laurent
parents:
399
diff
changeset
|
185 |
s4o.print(SET_VAR); |
392
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
186 |
s4o.print("("); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
187 |
|
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
188 |
if (fb_symbol != NULL) { |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
189 |
print_variable_prefix(); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
190 |
fb_symbol->accept(*this); |
392
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
191 |
s4o.print(".,"); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
192 |
} |
382
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
193 |
else if (type_is_complex) |
392
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
194 |
wanted_variablegeneration = complextype_base_assignment_vg; |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
195 |
else |
382
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
196 |
wanted_variablegeneration = assignment_vg; |
302
d120740a6b58
Fixing bug related to setting array variables with values coming from other variables
Mario de Sousa <msousa@fe.up.pt>
parents:
298
diff
changeset
|
197 |
|
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
198 |
symbol->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
199 |
s4o.print(","); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
200 |
wanted_variablegeneration = expression_vg; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
201 |
print_check_function(type, value, fb_value); |
382
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
202 |
if (type_is_complex) { |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
203 |
s4o.print(","); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
204 |
wanted_variablegeneration = complextype_suffix_vg; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
205 |
symbol->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
206 |
} |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
207 |
s4o.print(")"); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
208 |
wanted_variablegeneration = expression_vg; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
209 |
return NULL; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
210 |
} |
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
211 |
|
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
212 |
/********************************/ |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
213 |
/* B 1.3.3 - Derived data types */ |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
214 |
/********************************/ |
377
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
215 |
|
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
216 |
/* signed_integer DOTDOT signed_integer */ |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
217 |
void *visit(subrange_c *symbol) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
218 |
switch (wanted_casegeneration) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
219 |
case subrange_cg: |
376 | 220 |
s4o.print("__case_expression >= "); |
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
221 |
symbol->lower_limit->accept(*this); |
376 | 222 |
s4o.print(" && __case_expression <= "); |
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
223 |
symbol->upper_limit->accept(*this); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
224 |
break; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
225 |
default: |
377
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
226 |
symbol->lower_limit->accept(*this); |
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
227 |
break; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
228 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
229 |
return NULL; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
230 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
231 |
|
377
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
232 |
/* ARRAY '[' array_subrange_list ']' OF non_generic_type_name */ |
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
233 |
void *visit(array_specification_c *symbol) { |
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
234 |
symbol->non_generic_type_name->accept(*this); |
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
235 |
return NULL; |
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
236 |
} |
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
237 |
|
70 | 238 |
/*********************/ |
239 |
/* B 1.4 - Variables */ |
|
240 |
/*********************/ |
|
241 |
void *visit(symbolic_variable_c *symbol) { |
|
382
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
242 |
switch (wanted_variablegeneration) { |
392
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
243 |
case complextype_base_assignment_vg: |
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
244 |
case assignment_vg: |
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
245 |
this->print_variable_prefix(); |
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
246 |
s4o.print(","); |
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
247 |
symbol->var_name->accept(*this); |
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
248 |
break; |
382
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
249 |
case complextype_base_vg: |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
250 |
generate_c_base_c::visit(symbol); |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
251 |
break; |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
252 |
case complextype_suffix_vg: |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
253 |
break; |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
254 |
default: |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
255 |
if (this->is_variable_prefix_null()) { |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
256 |
if (wanted_variablegeneration == fparam_output_vg) { |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
257 |
s4o.print("&("); |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
258 |
generate_c_base_c::visit(symbol); |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
259 |
s4o.print(")"); |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
260 |
} |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
261 |
else { |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
262 |
generate_c_base_c::visit(symbol); |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
263 |
} |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
264 |
} |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
265 |
else |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
266 |
print_getter(symbol); |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
267 |
break; |
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
268 |
} |
70 | 269 |
return NULL; |
270 |
} |
|
271 |
||
272 |
/********************************************/ |
|
273 |
/* B.1.4.1 Directly Represented Variables */ |
|
274 |
/********************************************/ |
|
275 |
// direct_variable: direct_variable_token {$$ = new direct_variable_c($1);}; |
|
276 |
void *visit(direct_variable_c *symbol) { |
|
277 |
TRACE("direct_variable_c"); |
|
278 |
/* Do not use print_token() as it will change everything into uppercase */ |
|
279 |
if (strlen(symbol->value) == 0) ERROR; |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
280 |
if (this->is_variable_prefix_null()) { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
281 |
if (wanted_variablegeneration != fparam_output_vg) |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
282 |
s4o.print("*("); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
283 |
} |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
284 |
else { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
285 |
switch (wanted_variablegeneration) { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
286 |
case expression_vg: |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
287 |
s4o.print(GET_LOCATED); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
288 |
s4o.print("("); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
289 |
break; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
290 |
case fparam_output_vg: |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
291 |
s4o.print(GET_LOCATED_BY_REF); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
292 |
s4o.print("("); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
293 |
break; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
294 |
default: |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
295 |
break; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
296 |
} |
145 | 297 |
} |
70 | 298 |
this->print_variable_prefix(); |
299 |
s4o.printlocation(symbol->value + 1); |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
300 |
if ((this->is_variable_prefix_null() && wanted_variablegeneration != fparam_output_vg) || |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
301 |
wanted_variablegeneration != assignment_vg) |
145 | 302 |
s4o.print(")"); |
70 | 303 |
return NULL; |
304 |
} |
|
305 |
||
98 | 306 |
/*************************************/ |
307 |
/* B.1.4.2 Multi-element Variables */ |
|
308 |
/*************************************/ |
|
309 |
||
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
310 |
// SYM_REF2(structured_variable_c, record_variable, field_selector) |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
311 |
void *visit(structured_variable_c *symbol) { |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
312 |
TRACE("structured_variable_c"); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
313 |
switch (wanted_variablegeneration) { |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
314 |
case complextype_base_vg: |
392
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
315 |
case complextype_base_assignment_vg: |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
316 |
symbol->record_variable->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
317 |
break; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
318 |
case complextype_suffix_vg: |
382
ac6dfec701c9
Fix bug in parser while trying to use IL operator like S1, R1, etc... as standard function block interface variable in structured_variable syntax and bug in code generator while generating code for assignment of function block interface variable using structured_variable syntax
laurent
parents:
377
diff
changeset
|
319 |
case assignment_vg: |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
320 |
symbol->record_variable->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
321 |
s4o.print("."); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
322 |
symbol->field_selector->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
323 |
break; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
324 |
default: |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
325 |
if (this->is_variable_prefix_null()) { |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
326 |
symbol->record_variable->accept(*this); |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
327 |
s4o.print("."); |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
328 |
symbol->field_selector->accept(*this); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
329 |
} |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
330 |
else |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
331 |
print_getter(symbol); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
332 |
break; |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
333 |
} |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
334 |
return NULL; |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
335 |
} |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
220
diff
changeset
|
336 |
|
98 | 337 |
/* subscripted_variable '[' subscript_list ']' */ |
338 |
//SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
|
339 |
void *visit(array_variable_c *symbol) { |
|
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
340 |
switch (wanted_variablegeneration) { |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
341 |
case complextype_base_vg: |
392
9b88b8b6bccd
Fixing generated code for global variables. Adding support for defining global variables with complex type
laurent
parents:
387
diff
changeset
|
342 |
case complextype_base_assignment_vg: |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
343 |
symbol->subscripted_variable->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
344 |
break; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
345 |
case complextype_suffix_vg: |
238
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
346 |
symbol->subscripted_variable->accept(*this); |
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
347 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
392
diff
changeset
|
348 |
current_array_type = search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable); |
238
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
349 |
if (current_array_type == NULL) ERROR; |
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
350 |
|
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
351 |
s4o.print(".table"); |
298
022a874149ce
Fixing code generation of array indexes in Function Blocks.
Mario de Sousa <msousa@fe.up.pt>
parents:
283
diff
changeset
|
352 |
wanted_variablegeneration = expression_vg; |
238
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
353 |
symbol->subscript_list->accept(*this); |
298
022a874149ce
Fixing code generation of array indexes in Function Blocks.
Mario de Sousa <msousa@fe.up.pt>
parents:
283
diff
changeset
|
354 |
wanted_variablegeneration = complextype_suffix_vg; |
238
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
355 |
|
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
356 |
current_array_type = NULL; |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
357 |
break; |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
358 |
default: |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
359 |
if (this->is_variable_prefix_null()) { |
238
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
360 |
symbol->subscripted_variable->accept(*this); |
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
361 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
392
diff
changeset
|
362 |
current_array_type = search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable); |
238
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
363 |
if (current_array_type == NULL) ERROR; |
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
364 |
|
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
365 |
s4o.print(".table"); |
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
366 |
symbol->subscript_list->accept(*this); |
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
367 |
|
0919986a5c98
Bug when trying to get type of elements in a big complex structure fixed
laurent
parents:
237
diff
changeset
|
368 |
current_array_type = NULL; |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
369 |
} |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
370 |
else |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
371 |
print_getter(symbol); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
372 |
break; |
98 | 373 |
} |
374 |
return NULL; |
|
375 |
} |
|
376 |
||
377 |
/* subscript_list ',' subscript */ |
|
378 |
void *visit(subscript_list_c *symbol) { |
|
377
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
379 |
array_dimension_iterator_c* array_dimension_iterator = new array_dimension_iterator_c(current_array_type); |
98 | 380 |
for (int i = 0; i < symbol->n; i++) { |
377
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
381 |
symbol_c* dimension = array_dimension_iterator->next(); |
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
382 |
if (dimension == NULL) ERROR; |
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
383 |
|
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
384 |
s4o.print("[("); |
98 | 385 |
symbol->elements[i]->accept(*this); |
377
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
386 |
s4o.print(") - ("); |
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
387 |
dimension->accept(*this); |
98 | 388 |
s4o.print(")]"); |
389 |
} |
|
377
60b012b7793f
Adding support for compiling direct array specification inside variable declaration
laurent
parents:
376
diff
changeset
|
390 |
delete array_dimension_iterator; |
98 | 391 |
return NULL; |
392 |
} |
|
393 |
||
235 | 394 |
/******************************************/ |
395 |
/* B 1.4.3 - Declaration & Initialisation */ |
|
396 |
/******************************************/ |
|
237 | 397 |
|
398 |
/* helper symbol for structure_initialization */ |
|
399 |
/* structure_element_initialization_list ',' structure_element_initialization */ |
|
235 | 400 |
void *visit(structure_element_initialization_list_c *symbol) { |
401 |
generate_c_structure_initialization_c *structure_initialization = new generate_c_structure_initialization_c(&s4o); |
|
402 |
structure_initialization->init_structure_default(this->current_param_type); |
|
237 | 403 |
structure_initialization->init_structure_values(symbol); |
235 | 404 |
delete structure_initialization; |
405 |
return NULL; |
|
406 |
} |
|
98 | 407 |
|
237 | 408 |
/* helper symbol for array_initialization */ |
409 |
/* array_initial_elements_list ',' array_initial_elements */ |
|
410 |
void *visit(array_initial_elements_list_c *symbol) { |
|
411 |
generate_c_array_initialization_c *array_initialization = new generate_c_array_initialization_c(&s4o); |
|
412 |
array_initialization->init_array_size(this->current_param_type); |
|
413 |
array_initialization->init_array_values(symbol); |
|
414 |
delete array_initialization; |
|
415 |
return NULL; |
|
416 |
} |
|
417 |
||
70 | 418 |
/***************************************/ |
419 |
/* B.3 - Language ST (Structured Text) */ |
|
420 |
/***************************************/ |
|
421 |
/***********************/ |
|
422 |
/* B 3.1 - Expressions */ |
|
423 |
/***********************/ |
|
424 |
void *visit(or_expression_c *symbol) { |
|
425 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
426 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
427 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
428 |
ERROR; |
|
429 |
if (search_expression_type->is_bool_type(left_type)) |
|
430 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " || "); |
|
431 |
if (search_expression_type->is_binary_type(left_type)) |
|
432 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " | "); |
|
433 |
ERROR; |
|
434 |
return NULL; |
|
435 |
} |
|
436 |
||
437 |
void *visit(xor_expression_c *symbol) { |
|
438 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
439 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
440 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
441 |
ERROR; |
|
442 |
if (search_expression_type->is_bool_type(left_type)) { |
|
443 |
s4o.print("("); |
|
444 |
symbol->l_exp->accept(*this); |
|
445 |
s4o.print(" && !"); |
|
446 |
symbol->r_exp->accept(*this); |
|
447 |
s4o.print(") || (!"); |
|
448 |
symbol->l_exp->accept(*this); |
|
449 |
s4o.print(" && "); |
|
450 |
symbol->r_exp->accept(*this); |
|
451 |
s4o.print(")"); |
|
130 | 452 |
return NULL; |
70 | 453 |
} |
454 |
if (search_expression_type->is_binary_type(left_type)) |
|
455 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " ^ "); |
|
456 |
ERROR; |
|
457 |
return NULL; |
|
458 |
} |
|
459 |
||
460 |
void *visit(and_expression_c *symbol) { |
|
461 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
462 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
463 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
464 |
ERROR; |
|
465 |
if (search_expression_type->is_bool_type(left_type)) |
|
466 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " && "); |
|
467 |
if (search_expression_type->is_binary_type(left_type)) |
|
468 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " & "); |
|
469 |
ERROR; |
|
470 |
return NULL; |
|
471 |
} |
|
472 |
||
473 |
void *visit(equ_expression_c *symbol) { |
|
474 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
475 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
476 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
477 |
ERROR; |
|
123 | 478 |
if (search_expression_type->is_time_type(left_type) || |
479 |
search_expression_type->is_string_type(left_type)) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
480 |
return print_compare_function("EQ_", left_type, symbol->l_exp, symbol->r_exp); |
70 | 481 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " == "); |
482 |
} |
|
483 |
||
484 |
void *visit(notequ_expression_c *symbol) { |
|
485 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
486 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
487 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
488 |
ERROR; |
|
123 | 489 |
if (search_expression_type->is_time_type(left_type) || |
490 |
search_expression_type->is_string_type(left_type)) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
491 |
return print_compare_function("NE_", left_type, symbol->l_exp, symbol->r_exp); |
70 | 492 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " != "); |
493 |
} |
|
494 |
||
495 |
void *visit(lt_expression_c *symbol) { |
|
496 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
497 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
498 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
499 |
ERROR; |
|
123 | 500 |
if (search_expression_type->is_time_type(left_type) || |
501 |
search_expression_type->is_string_type(left_type)) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
502 |
return print_compare_function("LT_", left_type, symbol->l_exp, symbol->r_exp); |
123 | 503 |
if (!search_base_type.type_is_enumerated(left_type)) |
504 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " < "); |
|
505 |
ERROR; |
|
506 |
return NULL; |
|
70 | 507 |
} |
508 |
||
509 |
void *visit(gt_expression_c *symbol) { |
|
510 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
511 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
512 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
513 |
ERROR; |
|
123 | 514 |
if (search_expression_type->is_time_type(left_type) || |
515 |
search_expression_type->is_string_type(left_type)) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
516 |
return print_compare_function("GT_", left_type, symbol->l_exp, symbol->r_exp); |
123 | 517 |
if (!search_base_type.type_is_enumerated(left_type)) |
518 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " > "); |
|
519 |
ERROR; |
|
520 |
return NULL; |
|
70 | 521 |
} |
522 |
||
523 |
void *visit(le_expression_c *symbol) { |
|
524 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
525 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
526 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
527 |
ERROR; |
|
123 | 528 |
if (search_expression_type->is_time_type(left_type) || |
529 |
search_expression_type->is_string_type(left_type)) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
530 |
return print_compare_function("LE_", left_type, symbol->l_exp, symbol->r_exp); |
123 | 531 |
if (!search_base_type.type_is_enumerated(left_type)) |
532 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " <= "); |
|
533 |
ERROR; |
|
534 |
return NULL; |
|
70 | 535 |
} |
536 |
||
537 |
void *visit(ge_expression_c *symbol) { |
|
538 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
539 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
540 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
541 |
ERROR; |
|
123 | 542 |
if (search_expression_type->is_time_type(left_type) || |
543 |
search_expression_type->is_string_type(left_type)) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
544 |
return print_compare_function("GE_", left_type, symbol->l_exp, symbol->r_exp); |
123 | 545 |
if (!search_base_type.type_is_enumerated(left_type)) |
546 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " >= "); |
|
547 |
ERROR; |
|
548 |
return NULL; |
|
70 | 549 |
} |
550 |
||
551 |
void *visit(add_expression_c *symbol) { |
|
552 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
553 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
554 |
if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
|
555 |
(typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
|
556 |
(typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c))) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
557 |
return print_binary_function("__time_add", symbol->l_exp, symbol->r_exp); |
70 | 558 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
559 |
ERROR; |
|
560 |
if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) |
|
561 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " + "); |
|
562 |
ERROR; |
|
563 |
return NULL; |
|
564 |
} |
|
565 |
||
566 |
void *visit(sub_expression_c *symbol) { |
|
567 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
568 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
569 |
if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
|
570 |
(typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) || |
|
571 |
(typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
|
572 |
(typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) || |
|
573 |
(typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) || |
|
574 |
(typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c))) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
575 |
return print_binary_function("__time_sub", symbol->l_exp, symbol->r_exp); |
70 | 576 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
577 |
ERROR; |
|
578 |
if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) |
|
579 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " - "); |
|
580 |
ERROR; |
|
581 |
return NULL; |
|
582 |
} |
|
583 |
||
584 |
void *visit(mul_expression_c *symbol) { |
|
585 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
586 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
587 |
if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) || |
|
588 |
(typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type))) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
589 |
return print_binary_function("__time_mul", symbol->l_exp, symbol->r_exp); |
70 | 590 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
591 |
ERROR; |
|
592 |
if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) |
|
593 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " * "); |
|
594 |
ERROR; |
|
595 |
return NULL; |
|
596 |
} |
|
597 |
||
598 |
void *visit(div_expression_c *symbol) { |
|
599 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
600 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
149 | 601 |
if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) || |
602 |
(typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type))) |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
603 |
return print_binary_function("__time_div", symbol->l_exp, symbol->r_exp); |
70 | 604 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
605 |
ERROR; |
|
606 |
if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) |
|
607 |
return print_binary_expression(symbol->l_exp, symbol->r_exp, " / "); |
|
608 |
ERROR; |
|
609 |
return NULL; |
|
610 |
} |
|
611 |
||
612 |
void *visit(mod_expression_c *symbol) { |
|
613 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
|
614 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
615 |
if (!search_expression_type->is_same_type(left_type, right_type)) |
|
616 |
ERROR; |
|
617 |
if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) { |
|
618 |
s4o.print("(("); |
|
619 |
symbol->r_exp->accept(*this); |
|
620 |
s4o.print(" == 0)?0:"); |
|
621 |
print_binary_expression(symbol->l_exp, symbol->r_exp, " % "); |
|
622 |
s4o.print(")"); |
|
623 |
return NULL; |
|
624 |
} |
|
625 |
ERROR; |
|
626 |
return NULL; |
|
627 |
} |
|
628 |
||
257 | 629 |
void *visit(power_expression_c *symbol) { |
349 | 630 |
symbol_c *left_type = search_expression_type->get_type(symbol->l_exp); |
631 |
symbol_c *right_type = search_expression_type->get_type(symbol->r_exp); |
|
632 |
if (search_expression_type->is_real_type(left_type) && search_expression_type->is_num_type(right_type)) { |
|
375 | 633 |
s4o.print("EXPT__LREAL__LREAL__LREAL((BOOL)__BOOL_LITERAL(TRUE),\n"); |
349 | 634 |
s4o.indent_right(); |
635 |
s4o.print(s4o.indent_spaces + "NULL,\n"); |
|
636 |
s4o.print(s4o.indent_spaces + "(LREAL)("); |
|
637 |
symbol->l_exp->accept(*this); |
|
638 |
s4o.print("),\n"); |
|
639 |
s4o.print(s4o.indent_spaces + "(LREAL)("); |
|
640 |
symbol->r_exp->accept(*this); |
|
641 |
s4o.print("))"); |
|
642 |
return NULL; |
|
643 |
} |
|
644 |
ERROR; |
|
358
a2c4af8f0c18
Add support for '**' (power) operator in ST expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
355
diff
changeset
|
645 |
return NULL; |
257 | 646 |
} |
647 |
||
123 | 648 |
void *visit(neg_expression_c *symbol) { |
257 | 649 |
return print_unary_expression(symbol->exp, " -"); |
123 | 650 |
} |
70 | 651 |
|
652 |
void *visit(not_expression_c *symbol) { |
|
653 |
symbol_c *exp_type = search_expression_type->get_type(symbol->exp); |
|
123 | 654 |
if (search_expression_type->is_binary_type(exp_type)) |
655 |
return print_unary_expression(symbol->exp, search_expression_type->is_bool_type(exp_type)?"!":"~"); |
|
656 |
ERROR; |
|
657 |
return NULL; |
|
70 | 658 |
} |
659 |
||
660 |
void *visit(function_invocation_c *symbol) { |
|
149 | 661 |
symbol_c* function_name = NULL; |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
662 |
DECLARE_PARAM_LIST() |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
663 |
|
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
664 |
symbol_c *parameter_assignment_list = NULL; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
665 |
if (NULL != symbol-> formal_param_list) parameter_assignment_list = symbol-> formal_param_list; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
666 |
if (NULL != symbol->nonformal_param_list) parameter_assignment_list = symbol->nonformal_param_list; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
667 |
if (NULL == parameter_assignment_list) ERROR; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
668 |
|
233
3d23a68183d3
Bug on standard functions called with literals fixed
laurent
parents:
231
diff
changeset
|
669 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
3d23a68183d3
Bug on standard functions called with literals fixed
laurent
parents:
231
diff
changeset
|
670 |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
671 |
function_declaration_c *f_decl = (function_declaration_c *)symbol->called_function_declaration; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
672 |
if (f_decl == NULL) ERROR; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
673 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
674 |
function_name = symbol->function_name; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
675 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
676 |
/* loop through each function parameter, find the value we should pass |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
677 |
* to it, and then output the c equivalent... |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
678 |
*/ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
679 |
function_param_iterator_c fp_iterator(f_decl); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
680 |
identifier_c *param_name; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
681 |
/* flag to cirreclty handle calls to extensible standard functions (i.e. functions with variable number of input parameters) */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
682 |
bool found_first_extensible_parameter = false; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
683 |
for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
684 |
if (fp_iterator.is_extensible_param() && (!found_first_extensible_parameter)) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
685 |
/* We are calling an extensible function. Before passing the extensible |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
686 |
* parameters, we must add a dummy paramater value to tell the called |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
687 |
* function how many extensible parameters we will be passing. |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
688 |
* |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
689 |
* Note that stage 3 has already determined the number of extensible |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
690 |
* paramters, and stored that info in the abstract syntax tree. We simply |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
691 |
* re-use that value. |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
692 |
*/ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
693 |
/* NOTE: we are not freeing the malloc'd memory. This is not really a bug. |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
694 |
* Since we are writing a compiler, which runs to termination quickly, |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
695 |
* we can consider this as just memory required for the compilation process |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
696 |
* that will be free'd when the program terminates. |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
697 |
*/ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
698 |
char *tmp = (char *)malloc(32); /* enough space for a call with 10^31 (larger than 2^64) input parameters! */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
699 |
if (tmp == NULL) ERROR; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
700 |
int res = snprintf(tmp, 32, "%d", symbol->extensible_param_count); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
701 |
if ((res >= 32) || (res < 0)) ERROR; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
702 |
identifier_c *param_value = new identifier_c(tmp); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
703 |
uint_type_name_c *param_type = new uint_type_name_c(); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
704 |
identifier_c *param_name = new identifier_c(""); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
705 |
ADD_PARAM_LIST(param_name, param_value, param_type, function_param_iterator_c::direction_in) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
706 |
found_first_extensible_parameter = true; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
707 |
} |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
708 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
709 |
if (fp_iterator.is_extensible_param()) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
710 |
/* since we are handling an extensible parameter, we must add the index to the |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
711 |
* parameter name so we can go looking for the value passed to the correct |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
712 |
* extended parameter (e.g. IN1, IN2, IN3, IN4, ...) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
713 |
*/ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
714 |
char *tmp = (char *)malloc(32); /* enough space for a call with 10^31 (larger than 2^64) input parameters! */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
715 |
int res = snprintf(tmp, 32, "%d", fp_iterator.extensible_param_index()); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
716 |
if ((res >= 32) || (res < 0)) ERROR; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
717 |
param_name = new identifier_c(strdup2(param_name->value, tmp)); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
718 |
if (param_name->value == NULL) ERROR; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
719 |
} |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
720 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
721 |
symbol_c *param_type = fp_iterator.param_type(); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
722 |
if (param_type == NULL) ERROR; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
723 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
724 |
function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
725 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
726 |
symbol_c *param_value = NULL; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
727 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
728 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
729 |
if (param_value == NULL) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
730 |
param_value = function_call_param_iterator.search_f(param_name); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
731 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
732 |
/* Get the value from a foo(<param_value>) style call */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
733 |
if ((param_value == NULL) && !fp_iterator.is_en_eno_param_implicit()) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
734 |
param_value = function_call_param_iterator.next_nf(); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
735 |
} |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
736 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
737 |
/* if no more parameter values in function call, and the current parameter |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
738 |
* of the function declaration is an extensible parameter, we |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
739 |
* have reached the end, and should simply jump out of the for loop. |
70 | 740 |
*/ |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
741 |
if ((param_value == NULL) && (fp_iterator.is_extensible_param())) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
742 |
break; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
743 |
} |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
744 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
745 |
if ((param_value == NULL) && (param_direction == function_param_iterator_c::direction_in)) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
746 |
/* No value given for parameter, so we must use the default... */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
747 |
/* First check whether default value specified in function declaration...*/ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
748 |
param_value = fp_iterator.default_value(); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
749 |
} |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
750 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
751 |
ADD_PARAM_LIST(param_name, param_value, param_type, param_direction) |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
752 |
} /* for(...) */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
753 |
// symbol->parameter_assignment->accept(*this); |
149 | 754 |
|
233
3d23a68183d3
Bug on standard functions called with literals fixed
laurent
parents:
231
diff
changeset
|
755 |
if (function_call_param_iterator.next_nf() != NULL) ERROR; |
3d23a68183d3
Bug on standard functions called with literals fixed
laurent
parents:
231
diff
changeset
|
756 |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
757 |
bool has_output_params = false; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
758 |
|
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
759 |
if (!this->is_variable_prefix_null()) { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
760 |
PARAM_LIST_ITERATOR() { |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
761 |
if ((PARAM_DIRECTION == function_param_iterator_c::direction_out || |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
762 |
PARAM_DIRECTION == function_param_iterator_c::direction_inout) && |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
763 |
PARAM_VALUE != NULL) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
764 |
has_output_params = true; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
765 |
} |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
766 |
} |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
767 |
} |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
768 |
|
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
769 |
/* Check whether we are calling an overloaded function! */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
770 |
/* (fdecl_mutiplicity==2) => calling overloaded function */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
771 |
int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
772 |
if (fdecl_mutiplicity == 0) ERROR; |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
773 |
|
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
774 |
if (has_output_params) { |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
775 |
fcall_number++; |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
776 |
s4o.print("__"); |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
777 |
fbname->accept(*this); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
778 |
s4o.print("_"); |
149 | 779 |
function_name->accept(*this); |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
780 |
if (fdecl_mutiplicity == 2) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
781 |
/* function being called is overloaded! */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
782 |
s4o.print("__"); |
406
6381589697ff
Fix bug with overloaded function due to literal input values
laurent
parents:
405
diff
changeset
|
783 |
print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
784 |
f_decl->accept(overloaded_func_suf); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
785 |
} |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
786 |
s4o.print_integer(fcall_number); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
787 |
} |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
788 |
else { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
789 |
function_name->accept(*this); |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
790 |
if (fdecl_mutiplicity == 2) { |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
791 |
/* function being called is overloaded! */ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
792 |
s4o.print("__"); |
406
6381589697ff
Fix bug with overloaded function due to literal input values
laurent
parents:
405
diff
changeset
|
793 |
print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
794 |
f_decl->accept(overloaded_func_suf); |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
795 |
} |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
796 |
} |
149 | 797 |
s4o.print("("); |
798 |
s4o.indent_right(); |
|
799 |
||
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
800 |
int nb_param = 0; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
801 |
PARAM_LIST_ITERATOR() { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
802 |
symbol_c *param_value = PARAM_VALUE; |
235 | 803 |
current_param_type = PARAM_TYPE; |
149 | 804 |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
805 |
switch (PARAM_DIRECTION) { |
149 | 806 |
case function_param_iterator_c::direction_in: |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
807 |
if (nb_param > 0) |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
808 |
s4o.print(",\n"+s4o.indent_spaces); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
809 |
if (param_value == NULL) { |
149 | 810 |
/* If not, get the default value of this variable's type */ |
235 | 811 |
param_value = (symbol_c *)current_param_type->accept(*type_initial_value_c::instance()); |
149 | 812 |
} |
813 |
if (param_value == NULL) ERROR; |
|
216
136d6ae70745
Bug with using non explicit literals as standard library functions input parameters fixed
laurent
parents:
208
diff
changeset
|
814 |
s4o.print("("); |
235 | 815 |
if (search_expression_type->is_literal_integer_type(current_param_type)) |
220 | 816 |
search_expression_type->lint_type_name.accept(*this); |
235 | 817 |
else if (search_expression_type->is_literal_real_type(current_param_type)) |
220 | 818 |
search_expression_type->lreal_type_name.accept(*this); |
216
136d6ae70745
Bug with using non explicit literals as standard library functions input parameters fixed
laurent
parents:
208
diff
changeset
|
819 |
else |
235 | 820 |
current_param_type->accept(*this); |
216
136d6ae70745
Bug with using non explicit literals as standard library functions input parameters fixed
laurent
parents:
208
diff
changeset
|
821 |
s4o.print(")"); |
235 | 822 |
print_check_function(current_param_type, param_value); |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
823 |
nb_param++; |
149 | 824 |
break; |
825 |
case function_param_iterator_c::direction_out: |
|
826 |
case function_param_iterator_c::direction_inout: |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
827 |
if (!has_output_params) { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
828 |
if (nb_param > 0) |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
829 |
s4o.print(",\n"+s4o.indent_spaces); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
830 |
if (param_value == NULL) |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
831 |
s4o.print("NULL"); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
832 |
else { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
833 |
wanted_variablegeneration = fparam_output_vg; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
834 |
param_value->accept(*this); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
835 |
wanted_variablegeneration = expression_vg; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
836 |
} |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
837 |
nb_param++; |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
838 |
} |
149 | 839 |
break; |
840 |
case function_param_iterator_c::direction_extref: |
|
841 |
/* TODO! */ |
|
842 |
ERROR; |
|
843 |
break; |
|
844 |
} /* switch */ |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
845 |
} |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
846 |
if (has_output_params) { |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
847 |
if (nb_param > 0) |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
848 |
s4o.print(",\n"+s4o.indent_spaces); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
849 |
s4o.print(FB_FUNCTION_PARAM); |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
850 |
} |
149 | 851 |
s4o.print(")"); |
852 |
s4o.indent_left(); |
|
70 | 853 |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
854 |
CLEAR_PARAM_LIST() |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
855 |
|
70 | 856 |
return NULL; |
857 |
} |
|
858 |
||
859 |
/********************/ |
|
860 |
/* B 3.2 Statements */ |
|
861 |
/********************/ |
|
862 |
void *visit(statement_list_c *symbol) { |
|
863 |
return print_list(symbol, s4o.indent_spaces, ";\n" + s4o.indent_spaces, ";\n"); |
|
864 |
} |
|
865 |
||
866 |
/*********************************/ |
|
867 |
/* B 3.2.1 Assignment Statements */ |
|
868 |
/*********************************/ |
|
869 |
void *visit(assignment_statement_c *symbol) { |
|
321
a96399ab57c2
Add better comments, and change name of functions to clarify what they do.
Mario de Sousa <msousa@fe.up.pt>
parents:
309
diff
changeset
|
870 |
symbol_c *left_type = search_varfb_instance_type->get_type_id(symbol->l_exp); |
98 | 871 |
|
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
872 |
if (this->is_variable_prefix_null()) { |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
873 |
symbol->l_exp->accept(*this); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
874 |
s4o.print(" = "); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
875 |
print_check_function(left_type, symbol->r_exp); |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
876 |
} |
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
877 |
else { |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
878 |
print_setter(symbol->l_exp, left_type, symbol->r_exp); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
879 |
} |
70 | 880 |
return NULL; |
881 |
} |
|
882 |
||
883 |
/*****************************************/ |
|
884 |
/* B 3.2.2 Subprogram Control Statements */ |
|
885 |
/*****************************************/ |
|
886 |
||
283
214d3fdee596
fixing C code generation of return_statement_c and exit_statement_c
Mario de Sousa <msousa@fe.up.pt>
parents:
282
diff
changeset
|
887 |
void *visit(return_statement_c *symbol) { |
214d3fdee596
fixing C code generation of return_statement_c and exit_statement_c
Mario de Sousa <msousa@fe.up.pt>
parents:
282
diff
changeset
|
888 |
s4o.print("goto "); s4o.print(END_LABEL); |
214d3fdee596
fixing C code generation of return_statement_c and exit_statement_c
Mario de Sousa <msousa@fe.up.pt>
parents:
282
diff
changeset
|
889 |
return NULL; |
214d3fdee596
fixing C code generation of return_statement_c and exit_statement_c
Mario de Sousa <msousa@fe.up.pt>
parents:
282
diff
changeset
|
890 |
} |
214d3fdee596
fixing C code generation of return_statement_c and exit_statement_c
Mario de Sousa <msousa@fe.up.pt>
parents:
282
diff
changeset
|
891 |
|
214d3fdee596
fixing C code generation of return_statement_c and exit_statement_c
Mario de Sousa <msousa@fe.up.pt>
parents:
282
diff
changeset
|
892 |
|
70 | 893 |
/* fb_name '(' [param_assignment_list] ')' */ |
894 |
/* param_assignment_list -> may be NULL ! */ |
|
895 |
//SYM_REF2(fb_invocation_c, fb_name, param_assignment_list) |
|
896 |
void *visit(fb_invocation_c *symbol) { |
|
897 |
TRACE("fb_invocation_c"); |
|
898 |
/* first figure out what is the name of the function block type of the function block being called... */ |
|
899 |
symbol_c *function_block_type_name = this->search_fb_instance_decl->get_type_name(symbol->fb_name); |
|
900 |
/* should never occur. The function block instance MUST have been declared... */ |
|
901 |
if (function_block_type_name == NULL) ERROR; |
|
902 |
||
903 |
/* Now find the declaration of the function block type being called... */ |
|
904 |
function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(function_block_type_name); |
|
905 |
/* should never occur. The function block type being called MUST be in the symtable... */ |
|
906 |
if (fb_decl == function_block_type_symtable.end_value()) ERROR; |
|
907 |
||
908 |
/* loop through each function block parameter, find the value we should pass |
|
909 |
* to it, and then output the c equivalent... |
|
910 |
*/ |
|
911 |
function_param_iterator_c fp_iterator(fb_decl); |
|
912 |
identifier_c *param_name; |
|
913 |
function_call_param_iterator_c function_call_param_iterator(symbol); |
|
914 |
for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) { |
|
915 |
function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
|
160 | 916 |
|
162
60a124678842
Fixed typo in EN/ENO parameters handling for std library functions
etisserant
parents:
160
diff
changeset
|
917 |
/*fprintf(stderr, "param : %s\n", param_name->value);*/ |
160 | 918 |
|
70 | 919 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
920 |
symbol_c *param_value = function_call_param_iterator.search_f(param_name); |
70 | 921 |
|
922 |
/* Get the value from a foo(<param_value>) style call */ |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
923 |
/* When using the informal invocation style, user can not pass values to EN or ENO parameters if these |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
924 |
* were implicitly defined! |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
925 |
*/ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
926 |
if ((param_value == NULL) && !fp_iterator.is_en_eno_param_implicit()) |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
927 |
param_value = function_call_param_iterator.next_nf(); |
70 | 928 |
|
98 | 929 |
symbol_c *param_type = fp_iterator.param_type(); |
930 |
if (param_type == NULL) ERROR; |
|
931 |
||
70 | 932 |
/* now output the value assignment */ |
933 |
if (param_value != NULL) |
|
934 |
if ((param_direction == function_param_iterator_c::direction_in) || |
|
935 |
(param_direction == function_param_iterator_c::direction_inout)) { |
|
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
936 |
if (this->is_variable_prefix_null()) { |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
937 |
symbol->fb_name->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
938 |
s4o.print("."); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
939 |
param_name->accept(*this); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
940 |
s4o.print(" = "); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
941 |
print_check_function(param_type, param_value); |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
942 |
} |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
943 |
else { |
228
43831b683764
Adding support for setter and getter on complex datatype in IL
berem
parents:
226
diff
changeset
|
944 |
print_setter(param_name, param_type, param_value, symbol->fb_name); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
945 |
} |
70 | 946 |
s4o.print(";\n" + s4o.indent_spaces); |
947 |
} |
|
948 |
} /* for(...) */ |
|
949 |
||
950 |
/* now call the function... */ |
|
951 |
function_block_type_name->accept(*this); |
|
952 |
s4o.print(FB_FUNCTION_SUFFIX); |
|
953 |
s4o.print("(&"); |
|
954 |
print_variable_prefix(); |
|
955 |
symbol->fb_name->accept(*this); |
|
956 |
s4o.print(")"); |
|
957 |
||
958 |
/* loop through each function parameter, find the variable to which |
|
959 |
* we should atribute the value of all output or inoutput parameters. |
|
960 |
*/ |
|
961 |
fp_iterator.reset(); |
|
962 |
function_call_param_iterator.reset(); |
|
963 |
for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) { |
|
964 |
function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
|
965 |
||
966 |
/* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
967 |
symbol_c *param_value = function_call_param_iterator.search_f(param_name); |
70 | 968 |
|
969 |
/* Get the value from a foo(<param_value>) style call */ |
|
350
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
970 |
/* When using the informal invocation style, user can not pass values to EN or ENO parameters if these |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
971 |
* were implicitly defined! |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
972 |
*/ |
2c3c4dc34979
Support for semantic verification of calls to standard functions.
Mario de Sousa <msousa@fe.up.pt>
parents:
336
diff
changeset
|
973 |
if ((param_value == NULL) && !fp_iterator.is_en_eno_param_implicit()) |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
169
diff
changeset
|
974 |
param_value = function_call_param_iterator.next_nf(); |
70 | 975 |
|
976 |
/* now output the value assignment */ |
|
977 |
if (param_value != NULL) |
|
978 |
if ((param_direction == function_param_iterator_c::direction_out) || |
|
979 |
(param_direction == function_param_iterator_c::direction_inout)) { |
|
321
a96399ab57c2
Add better comments, and change name of functions to clarify what they do.
Mario de Sousa <msousa@fe.up.pt>
parents:
309
diff
changeset
|
980 |
symbol_c *param_type = search_varfb_instance_type->get_type_id(param_value); |
240 | 981 |
s4o.print(";\n" + s4o.indent_spaces); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
982 |
if (this->is_variable_prefix_null()) { |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
983 |
param_value->accept(*this); |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
984 |
s4o.print(" = "); |
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
985 |
print_check_function(param_type, param_name, symbol->fb_name); |
98 | 986 |
} |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
987 |
else { |
226
29f8ffc203c1
Adding support for setter and getter on complex datatype in ST
laurent
parents:
221
diff
changeset
|
988 |
print_setter(param_value, param_type, param_name, NULL, symbol->fb_name); |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
216
diff
changeset
|
989 |
} |
70 | 990 |
} |
991 |
} /* for(...) */ |
|
992 |
||
993 |
return NULL; |
|
994 |
} |
|
995 |
||
996 |
||
997 |
||
998 |
||
999 |
/* helper symbol for fb_invocation */ |
|
1000 |
/* param_assignment_list ',' param_assignment */ |
|
1001 |
void *visit(param_assignment_list_c *symbol) { |
|
1002 |
TRACE("param_assignment_list_c"); |
|
1003 |
/* this should never be called... */ |
|
1004 |
ERROR; |
|
1005 |
return NULL; |
|
1006 |
// return print_list(symbol, "", ", "); |
|
1007 |
} |
|
1008 |
||
1009 |
||
1010 |
void *visit(input_variable_param_assignment_c *symbol) { |
|
1011 |
TRACE("input_variable_param_assignment_c"); |
|
1012 |
/* this should never be called... */ |
|
1013 |
ERROR; |
|
1014 |
return NULL; |
|
1015 |
/* |
|
1016 |
symbol->variable_name->accept(*this); |
|
1017 |
s4o.print(" = "); |
|
1018 |
symbol->expression->accept(*this); |
|
1019 |
return NULL; |
|
1020 |
*/ |
|
1021 |
} |
|
1022 |
||
1023 |
void *visit(output_variable_param_assignment_c *symbol) { |
|
1024 |
TRACE("output_variable_param_assignment_c"); |
|
1025 |
/* this should never be called... */ |
|
1026 |
ERROR; |
|
1027 |
return NULL; |
|
1028 |
/* |
|
1029 |
s4o.print(s4o.indent_spaces); |
|
1030 |
if (symbol->not_param != NULL) |
|
1031 |
symbol->not_param->accept(*this); |
|
1032 |
symbol->variable_name->accept(*this); |
|
1033 |
s4o.print(" => "); |
|
1034 |
symbol->variable->accept(*this); |
|
1035 |
return NULL; |
|
1036 |
*/ |
|
1037 |
} |
|
1038 |
||
1039 |
// TODO: the NOT symbol in function (block) calls... |
|
1040 |
void *visit(not_paramassign_c *symbol) { |
|
1041 |
TRACE("not_paramassign_c"); |
|
1042 |
/* this should never be called... */ |
|
1043 |
ERROR; |
|
1044 |
return NULL; |
|
1045 |
/* |
|
1046 |
s4o.print("NOT "); |
|
1047 |
return NULL; |
|
1048 |
*/ |
|
1049 |
} |
|
1050 |
||
1051 |
||
1052 |
/********************************/ |
|
1053 |
/* B 3.2.3 Selection Statements */ |
|
1054 |
/********************************/ |
|
1055 |
void *visit(if_statement_c *symbol) { |
|
1056 |
s4o.print("if ("); |
|
1057 |
symbol->expression->accept(*this); |
|
1058 |
s4o.print(") {\n"); |
|
1059 |
s4o.indent_right(); |
|
1060 |
symbol->statement_list->accept(*this); |
|
1061 |
s4o.indent_left(); |
|
1062 |
symbol->elseif_statement_list->accept(*this); |
|
1063 |
||
1064 |
if (symbol->else_statement_list != NULL) { |
|
1065 |
s4o.print(s4o.indent_spaces); s4o.print("} else {\n"); |
|
1066 |
s4o.indent_right(); |
|
1067 |
symbol->else_statement_list->accept(*this); |
|
1068 |
s4o.indent_left(); |
|
1069 |
} |
|
1070 |
s4o.print(s4o.indent_spaces); s4o.print("}"); |
|
1071 |
return NULL; |
|
1072 |
} |
|
1073 |
||
1074 |
/* helper symbol for if_statement */ |
|
1075 |
void *visit(elseif_statement_list_c *symbol) {return print_list(symbol);} |
|
1076 |
||
1077 |
/* helper symbol for elseif_statement_list */ |
|
1078 |
void *visit(elseif_statement_c *symbol) { |
|
1079 |
s4o.print(s4o.indent_spaces); s4o.print("} else if ("); |
|
1080 |
symbol->expression->accept(*this); |
|
1081 |
s4o.print(") {\n"); |
|
1082 |
s4o.indent_right(); |
|
1083 |
symbol->statement_list->accept(*this); |
|
1084 |
s4o.indent_left(); |
|
1085 |
return NULL; |
|
1086 |
} |
|
1087 |
||
1088 |
void *visit(case_statement_c *symbol) { |
|
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1089 |
symbol_c *expression_type = search_expression_type->get_type(symbol->expression); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1090 |
s4o.print("{\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1091 |
s4o.indent_right(); |
376 | 1092 |
s4o.print(s4o.indent_spaces); |
1093 |
if (search_expression_type->is_literal_integer_type(expression_type)) |
|
1094 |
search_expression_type->lint_type_name.accept(*this); |
|
1095 |
else if (search_expression_type->is_literal_real_type(expression_type)) |
|
1096 |
search_expression_type->lreal_type_name.accept(*this); |
|
1097 |
else |
|
1098 |
expression_type->accept(*this); |
|
1099 |
s4o.print(" __case_expression = "); |
|
70 | 1100 |
symbol->expression->accept(*this); |
376 | 1101 |
s4o.print(";\n" + s4o.indent_spaces + "switch (__case_expression) {\n"); |
70 | 1102 |
s4o.indent_right(); |
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1103 |
wanted_casegeneration = single_cg; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1104 |
symbol->case_element_list->accept(*this); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1105 |
wanted_casegeneration = subrange_cg; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1106 |
s4o.print(s4o.indent_spaces + "default:\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1107 |
s4o.indent_right(); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1108 |
first_subrange_case_list = true; |
70 | 1109 |
symbol->case_element_list->accept(*this); |
1110 |
if (symbol->statement_list != NULL) { |
|
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1111 |
if (!first_subrange_case_list) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1112 |
s4o.print(s4o.indent_spaces + "else {\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1113 |
s4o.indent_right(); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1114 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1115 |
symbol->statement_list->accept(*this); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1116 |
if (!first_subrange_case_list) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1117 |
s4o.indent_left(); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1118 |
s4o.print(s4o.indent_spaces + "}\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1119 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1120 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1121 |
s4o.print(s4o.indent_spaces + "break;\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1122 |
s4o.indent_left(); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1123 |
wanted_casegeneration = none_cg; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1124 |
s4o.indent_left(); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1125 |
s4o.print(s4o.indent_spaces + "}\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1126 |
s4o.indent_left(); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1127 |
s4o.print(s4o.indent_spaces + "}"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1128 |
return NULL; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1129 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1130 |
|
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1131 |
/* helper symbol for case_statement */ |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1132 |
void *visit(case_element_list_c *symbol) {return print_list(symbol);} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1133 |
|
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1134 |
void *visit(case_element_c *symbol) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1135 |
case_element_iterator_c *case_element_iterator; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1136 |
symbol_c* element = NULL; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1137 |
bool first_element = true; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1138 |
|
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1139 |
switch (wanted_casegeneration) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1140 |
case single_cg: |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1141 |
case_element_iterator = new case_element_iterator_c(symbol->case_list, case_element_iterator_c::element_single); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1142 |
for (element = case_element_iterator->next(); element != NULL; element = case_element_iterator->next()) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1143 |
if (first_element) first_element = false; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1144 |
s4o.print(s4o.indent_spaces + "case "); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1145 |
element->accept(*this); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1146 |
s4o.print(":\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1147 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1148 |
delete case_element_iterator; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1149 |
break; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1150 |
|
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1151 |
case subrange_cg: |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1152 |
case_element_iterator = new case_element_iterator_c(symbol->case_list, case_element_iterator_c::element_subrange); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1153 |
for (element = case_element_iterator->next(); element != NULL; element = case_element_iterator->next()) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1154 |
if (first_element) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1155 |
if (first_subrange_case_list) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1156 |
s4o.print(s4o.indent_spaces + "if ("); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1157 |
first_subrange_case_list = false; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1158 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1159 |
else { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1160 |
s4o.print(s4o.indent_spaces + "else if ("); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1161 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1162 |
first_element = false; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1163 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1164 |
else { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1165 |
s4o.print(" && "); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1166 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1167 |
element->accept(*this); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1168 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1169 |
delete case_element_iterator; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1170 |
if (!first_element) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1171 |
s4o.print(") {\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1172 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1173 |
break; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1174 |
|
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1175 |
default: |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1176 |
break; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1177 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1178 |
|
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1179 |
if (!first_element) { |
70 | 1180 |
s4o.indent_right(); |
1181 |
symbol->statement_list->accept(*this); |
|
347
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1182 |
switch (wanted_casegeneration) { |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1183 |
case single_cg: |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1184 |
s4o.print(s4o.indent_spaces + "break;\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1185 |
s4o.indent_left(); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1186 |
break; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1187 |
case subrange_cg: |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1188 |
s4o.indent_left(); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1189 |
s4o.print(s4o.indent_spaces + "}\n"); |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1190 |
break; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1191 |
default: |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1192 |
break; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1193 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1194 |
} |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1195 |
return NULL; |
44ff2a6fcadc
Fix case statement in ST, adding support for enumerated types
laurent
parents:
344
diff
changeset
|
1196 |
} |
70 | 1197 |
|
1198 |
/********************************/ |
|
1199 |
/* B 3.2.4 Iteration Statements */ |
|
1200 |
/********************************/ |
|
1201 |
void *visit(for_statement_c *symbol) { |
|
1202 |
s4o.print("for("); |
|
1203 |
symbol->control_variable->accept(*this); |
|
1204 |
s4o.print(" = "); |
|
1205 |
symbol->beg_expression->accept(*this); |
|
1206 |
s4o.print("; "); |
|
387
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1207 |
if (symbol->by_expression == NULL) { |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1208 |
/* increment by 1 */ |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1209 |
symbol->control_variable->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1210 |
s4o.print(" <= "); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1211 |
symbol->end_expression->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1212 |
s4o.print("; "); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1213 |
symbol->control_variable->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1214 |
s4o.print("++"); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1215 |
} else { |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1216 |
/* increment by user defined value */ |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1217 |
/* The user defined increment value may be negative, in which case |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1218 |
* the expression to determine whether we have reached the end of the loop |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1219 |
* changes from a '<=' to a '>='. |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1220 |
* Since the increment value may change during runtime (remember, it is |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1221 |
* an expression, so may contain variables), choosing which test |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1222 |
* to use has to be done at runtime. |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1223 |
*/ |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1224 |
s4o.print("(("); |
70 | 1225 |
symbol->by_expression->accept(*this); |
387
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1226 |
s4o.print(") > 0)? ("); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1227 |
symbol->control_variable->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1228 |
s4o.print(" <= ("); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1229 |
symbol->end_expression->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1230 |
s4o.print(")) : ("); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1231 |
symbol->control_variable->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1232 |
s4o.print(" >= ("); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1233 |
symbol->end_expression->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1234 |
s4o.print(")); "); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1235 |
symbol->control_variable->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1236 |
s4o.print(" += ("); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1237 |
symbol->by_expression->accept(*this); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1238 |
s4o.print(")"); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1239 |
} |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1240 |
s4o.print(")"); |
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1241 |
|
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1242 |
s4o.print(" {\n"); |
70 | 1243 |
s4o.indent_right(); |
1244 |
symbol->statement_list->accept(*this); |
|
1245 |
s4o.indent_left(); |
|
1246 |
s4o.print(s4o.indent_spaces); s4o.print("}"); |
|
1247 |
return NULL; |
|
1248 |
} |
|
387
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1249 |
|
70 | 1250 |
void *visit(while_statement_c *symbol) { |
1251 |
s4o.print("while ("); |
|
1252 |
symbol->expression->accept(*this); |
|
1253 |
s4o.print(") {\n"); |
|
1254 |
s4o.indent_right(); |
|
1255 |
symbol->statement_list->accept(*this); |
|
1256 |
s4o.indent_left(); |
|
1257 |
s4o.print(s4o.indent_spaces); s4o.print("}"); |
|
1258 |
return NULL; |
|
1259 |
} |
|
387
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1260 |
|
70 | 1261 |
void *visit(repeat_statement_c *symbol) { |
1262 |
s4o.print("do {\n"); |
|
1263 |
s4o.indent_right(); |
|
1264 |
symbol->statement_list->accept(*this); |
|
1265 |
s4o.indent_left(); |
|
1266 |
s4o.print(s4o.indent_spaces); s4o.print("} while("); |
|
1267 |
symbol->expression->accept(*this); |
|
1268 |
s4o.print(")"); |
|
1269 |
return NULL; |
|
1270 |
} |
|
387
db368e53133c
Fix code generation of FOR loops. Now handles negative values of BY correctly.
Mario de Sousa <msousa@fe.up.pt>
parents:
382
diff
changeset
|
1271 |
|
70 | 1272 |
void *visit(exit_statement_c *symbol) { |
281
686fa44e3832
fixing exit_statement_c: produce 'break' instead of 'exit(0); (Thanks to Manuele)
Mario de Sousa <msousa@fe.up.pt>
parents:
258
diff
changeset
|
1273 |
s4o.print("break"); |
70 | 1274 |
return NULL; |
1275 |
} |
|
1276 |
||
1277 |
||
1278 |
||
1279 |
}; /* generate_c_st_c */ |
|
1280 |
||
1281 |
||
1282 |
||
1283 |
||
1284 |
||
1285 |
||
1286 |
||
1287 |
||
1288 |