author | laurent |
Sat, 12 Mar 2011 18:43:02 +0100 | |
changeset 249 | d58a45824531 |
parent 244 | 3a478229db8b |
child 279 | c0453b7f99df |
permissions | -rw-r--r-- |
70 | 1 |
/* |
2 |
* (c) 2007 Mario de Sousa, Laurent Bessard |
|
3 |
* |
|
4 |
* Offered to the public under the terms of the GNU General Public License |
|
5 |
* as published by the Free Software Foundation; either version 2 of the |
|
6 |
* License, or (at your option) any later version. |
|
7 |
* |
|
8 |
* This program is distributed in the hope that it will be useful, but |
|
9 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|
11 |
* Public License for more details. |
|
12 |
* |
|
13 |
* This code is made available on the understanding that it will not be |
|
14 |
* used in safety-critical situations without a full and competent review. |
|
15 |
*/ |
|
16 |
||
17 |
/* |
|
18 |
* An IEC 61131-3 IL and ST compiler. |
|
19 |
* |
|
20 |
* Based on the |
|
21 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
||
26 |
/* |
|
27 |
* Conversion of sfc networks (i.e. SFC code). |
|
28 |
* |
|
29 |
* This is part of the 4th stage that generates |
|
30 |
* a c++ source program equivalent to the SFC, IL and ST |
|
31 |
* code. |
|
32 |
*/ |
|
33 |
||
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
34 |
typedef struct |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
35 |
{ |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
36 |
identifier_c *symbol; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
37 |
} VARIABLE; |
70 | 38 |
|
39 |
/***********************************************************************/ |
|
40 |
/***********************************************************************/ |
|
41 |
/***********************************************************************/ |
|
42 |
/***********************************************************************/ |
|
43 |
||
44 |
class generate_c_sfcdecl_c: protected generate_c_typedecl_c { |
|
45 |
||
46 |
public: |
|
47 |
typedef enum { |
|
48 |
sfcdecl_sd, |
|
49 |
sfcinit_sd, |
|
50 |
stepcount_sd, |
|
51 |
stepdef_sd, |
|
52 |
stepundef_sd, |
|
53 |
actiondef_sd, |
|
54 |
actionundef_sd, |
|
229 | 55 |
actioncount_sd, |
56 |
transitioncount_sd |
|
70 | 57 |
} sfcdeclaration_t; |
58 |
||
59 |
private: |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
60 |
int step_number; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
61 |
int action_number; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
62 |
int transition_number; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
63 |
std::list<VARIABLE> variable_list; |
70 | 64 |
|
65 |
sfcdeclaration_t wanted_sfcdeclaration; |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
66 |
|
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
67 |
search_var_instance_decl_c *search_var_instance_decl; |
70 | 68 |
|
69 |
public: |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
70 |
generate_c_sfcdecl_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL) |
70 | 71 |
: generate_c_typedecl_c(s4o_ptr) { |
72 |
this->set_variable_prefix(variable_prefix); |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
73 |
search_var_instance_decl = new search_var_instance_decl_c(scope); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
74 |
} |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
75 |
~generate_c_sfcdecl_c(void) { |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
76 |
variable_list.clear(); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
77 |
delete search_var_instance_decl; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
78 |
} |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
79 |
|
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
80 |
void generate(symbol_c *symbol, sfcdeclaration_t declaration_type) { |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
81 |
wanted_sfcdeclaration = declaration_type; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
82 |
|
70 | 83 |
symbol->accept(*this); |
84 |
} |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
85 |
|
70 | 86 |
/*********************************************/ |
87 |
/* B.1.6 Sequential function chart elements */ |
|
88 |
/*********************************************/ |
|
89 |
||
90 |
void *visit(sequential_function_chart_c *symbol) { |
|
91 |
step_number = 0; |
|
92 |
action_number = 0; |
|
93 |
transition_number = 0; |
|
94 |
switch (wanted_sfcdeclaration) { |
|
95 |
case sfcdecl_sd: |
|
96 |
for(int i = 0; i < symbol->n; i++) |
|
97 |
symbol->elements[i]->accept(*this); |
|
98 |
||
99 |
/* steps table declaration */ |
|
141 | 100 |
s4o.print(s4o.indent_spaces + "STEP __step_list["); |
70 | 101 |
s4o.print_integer(step_number); |
102 |
s4o.print("];\n"); |
|
141 | 103 |
s4o.print(s4o.indent_spaces + "UINT __nb_steps;\n"); |
70 | 104 |
|
105 |
/* actions table declaration */ |
|
141 | 106 |
s4o.print(s4o.indent_spaces + "ACTION __action_list["); |
70 | 107 |
s4o.print_integer(action_number); |
108 |
s4o.print("];\n"); |
|
141 | 109 |
s4o.print(s4o.indent_spaces + "UINT __nb_actions;\n"); |
70 | 110 |
|
111 |
/* transitions table declaration */ |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
160
diff
changeset
|
112 |
s4o.print(s4o.indent_spaces + "__IEC_BOOL_t __transition_list["); |
70 | 113 |
s4o.print_integer(transition_number); |
114 |
s4o.print("];\n"); |
|
115 |
||
141 | 116 |
/* transitions debug table declaration */ |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
160
diff
changeset
|
117 |
s4o.print(s4o.indent_spaces + "__IEC_BOOL_t __debug_transition_list["); |
141 | 118 |
s4o.print_integer(transition_number); |
119 |
s4o.print("];\n"); |
|
229 | 120 |
s4o.print(s4o.indent_spaces + "UINT __nb_transitions;\n"); |
141 | 121 |
|
125
7ec16536bc87
Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
lbessard
parents:
120
diff
changeset
|
122 |
/* last_ticktime declaration */ |
141 | 123 |
s4o.print(s4o.indent_spaces + "TIME __lasttick_time;\n"); |
70 | 124 |
break; |
125 |
case sfcinit_sd: |
|
126 |
s4o.print(s4o.indent_spaces); |
|
127 |
s4o.print("UINT i;\n"); |
|
128 |
||
129 |
/* steps table count */ |
|
130 |
wanted_sfcdeclaration = stepcount_sd; |
|
131 |
for(int i = 0; i < symbol->n; i++) |
|
132 |
symbol->elements[i]->accept(*this); |
|
133 |
s4o.print(s4o.indent_spaces); |
|
134 |
print_variable_prefix(); |
|
141 | 135 |
s4o.print("__nb_steps = "); |
70 | 136 |
s4o.print_integer(step_number); |
137 |
s4o.print(";\n"); |
|
138 |
step_number = 0; |
|
139 |
wanted_sfcdeclaration = sfcinit_sd; |
|
140 |
||
141 |
/* steps table initialisation */ |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
160
diff
changeset
|
142 |
s4o.print(s4o.indent_spaces + "static const STEP temp_step = {{0, 0}, 0, 0};\n"); |
70 | 143 |
s4o.print(s4o.indent_spaces + "for(i = 0; i < "); |
144 |
print_variable_prefix(); |
|
141 | 145 |
s4o.print("__nb_steps; i++) {\n"); |
70 | 146 |
s4o.indent_right(); |
147 |
s4o.print(s4o.indent_spaces); |
|
148 |
print_variable_prefix(); |
|
141 | 149 |
s4o.print("__step_list[i] = temp_step;\n"); |
70 | 150 |
s4o.indent_left(); |
151 |
s4o.print(s4o.indent_spaces + "}\n"); |
|
152 |
for(int i = 0; i < symbol->n; i++) |
|
153 |
symbol->elements[i]->accept(*this); |
|
154 |
||
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
155 |
/* actions table count */ |
70 | 156 |
wanted_sfcdeclaration = actioncount_sd; |
157 |
for(int i = 0; i < symbol->n; i++) |
|
158 |
symbol->elements[i]->accept(*this); |
|
159 |
s4o.print(s4o.indent_spaces); |
|
160 |
print_variable_prefix(); |
|
141 | 161 |
s4o.print("__nb_actions = "); |
70 | 162 |
s4o.print_integer(action_number); |
163 |
s4o.print(";\n"); |
|
164 |
action_number = 0; |
|
165 |
wanted_sfcdeclaration = sfcinit_sd; |
|
166 |
||
167 |
/* actions table initialisation */ |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
160
diff
changeset
|
168 |
s4o.print(s4o.indent_spaces + "static const ACTION temp_action = {0, 0, 0, 0, 0, 0};\n"); |
70 | 169 |
s4o.print(s4o.indent_spaces + "for(i = 0; i < "); |
170 |
print_variable_prefix(); |
|
141 | 171 |
s4o.print("__nb_actions; i++) {\n"); |
70 | 172 |
s4o.indent_right(); |
173 |
s4o.print(s4o.indent_spaces); |
|
174 |
print_variable_prefix(); |
|
141 | 175 |
s4o.print("__action_list[i] = temp_action;\n"); |
70 | 176 |
s4o.indent_left(); |
177 |
s4o.print(s4o.indent_spaces + "}\n"); |
|
125
7ec16536bc87
Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
lbessard
parents:
120
diff
changeset
|
178 |
|
229 | 179 |
/* transitions table count */ |
180 |
wanted_sfcdeclaration = transitioncount_sd; |
|
181 |
for(int i = 0; i < symbol->n; i++) |
|
182 |
symbol->elements[i]->accept(*this); |
|
183 |
s4o.print(s4o.indent_spaces); |
|
184 |
print_variable_prefix(); |
|
185 |
s4o.print("__nb_transitions = "); |
|
186 |
s4o.print_integer(transition_number); |
|
187 |
s4o.print(";\n"); |
|
188 |
transition_number = 0; |
|
189 |
wanted_sfcdeclaration = sfcinit_sd; |
|
190 |
||
125
7ec16536bc87
Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
lbessard
parents:
120
diff
changeset
|
191 |
/* last_ticktime initialisation */ |
160 | 192 |
s4o.print(s4o.indent_spaces); |
125
7ec16536bc87
Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
lbessard
parents:
120
diff
changeset
|
193 |
print_variable_prefix(); |
141 | 194 |
s4o.print("__lasttick_time = __CURRENT_TIME;\n"); |
70 | 195 |
break; |
196 |
case stepdef_sd: |
|
197 |
s4o.print("// Steps definitions\n"); |
|
198 |
for(int i = 0; i < symbol->n; i++) |
|
199 |
symbol->elements[i]->accept(*this); |
|
200 |
s4o.print("\n"); |
|
201 |
break; |
|
202 |
case actiondef_sd: |
|
203 |
s4o.print("// Actions definitions\n"); |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
204 |
{ |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
205 |
std::list<VARIABLE>::iterator pt; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
206 |
for(pt = variable_list.begin(); pt != variable_list.end(); pt++) { |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
207 |
s4o.print("#define "); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
208 |
s4o.print(SFC_STEP_ACTION_PREFIX); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
209 |
pt->symbol->accept(*this); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
210 |
s4o.print(" "); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
211 |
s4o.print_integer(action_number); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
212 |
s4o.print("\n"); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
213 |
action_number++; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
214 |
} |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
215 |
} |
70 | 216 |
for(int i = 0; i < symbol->n; i++) |
217 |
symbol->elements[i]->accept(*this); |
|
218 |
s4o.print("\n"); |
|
219 |
break; |
|
220 |
case stepundef_sd: |
|
221 |
s4o.print("// Steps undefinitions\n"); |
|
222 |
for(int i = 0; i < symbol->n; i++) |
|
223 |
symbol->elements[i]->accept(*this); |
|
224 |
s4o.print("\n"); |
|
225 |
break; |
|
226 |
case actionundef_sd: |
|
227 |
s4o.print("// Actions undefinitions\n"); |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
228 |
{ |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
229 |
std::list<VARIABLE>::iterator pt; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
230 |
for(pt = variable_list.begin(); pt != variable_list.end(); pt++) { |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
231 |
s4o.print("#undef "); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
232 |
s4o.print(SFC_STEP_ACTION_PREFIX); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
233 |
pt->symbol->accept(*this); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
234 |
s4o.print("\n"); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
235 |
} |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
236 |
} |
70 | 237 |
for(int i = 0; i < symbol->n; i++) |
238 |
symbol->elements[i]->accept(*this); |
|
239 |
s4o.print("\n"); |
|
240 |
break; |
|
241 |
default: |
|
242 |
break; |
|
243 |
} |
|
244 |
return NULL; |
|
245 |
} |
|
246 |
||
247 |
void *visit(initial_step_c *symbol) { |
|
248 |
switch (wanted_sfcdeclaration) { |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
249 |
case actioncount_sd: |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
250 |
symbol->action_association_list->accept(*this); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
251 |
break; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
252 |
case sfcdecl_sd: |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
253 |
symbol->action_association_list->accept(*this); |
70 | 254 |
case stepcount_sd: |
255 |
step_number++; |
|
256 |
break; |
|
257 |
case sfcinit_sd: |
|
258 |
s4o.print(s4o.indent_spaces); |
|
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
160
diff
changeset
|
259 |
s4o.print(SET_VAR); |
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
160
diff
changeset
|
260 |
s4o.print("("); |
70 | 261 |
print_variable_prefix(); |
141 | 262 |
s4o.print("__step_list["); |
70 | 263 |
s4o.print_integer(step_number); |
221
c6aed7e5f070
Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents:
160
diff
changeset
|
264 |
s4o.print("].state,1);\n"); |
70 | 265 |
step_number++; |
266 |
break; |
|
267 |
case stepdef_sd: |
|
268 |
s4o.print("#define "); |
|
269 |
s4o.print(SFC_STEP_ACTION_PREFIX); |
|
270 |
symbol->step_name->accept(*this); |
|
271 |
s4o.print(" "); |
|
272 |
s4o.print_integer(step_number); |
|
273 |
s4o.print("\n"); |
|
274 |
step_number++; |
|
275 |
break; |
|
276 |
case stepundef_sd: |
|
277 |
s4o.print("#undef "); |
|
278 |
s4o.print(SFC_STEP_ACTION_PREFIX); |
|
279 |
symbol->step_name->accept(*this); |
|
280 |
s4o.print("\n"); |
|
281 |
break; |
|
282 |
default: |
|
283 |
break; |
|
284 |
} |
|
285 |
return NULL; |
|
286 |
} |
|
287 |
||
288 |
void *visit(step_c *symbol) { |
|
289 |
switch (wanted_sfcdeclaration) { |
|
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
290 |
case actioncount_sd: |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
291 |
symbol->action_association_list->accept(*this); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
292 |
break; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
293 |
case sfcdecl_sd: |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
294 |
symbol->action_association_list->accept(*this); |
70 | 295 |
case stepcount_sd: |
119
4cbf71106b66
Bug with C code generation for SFC when more than one sfc_network in one sequential_function_chart fixed
lbessard
parents:
116
diff
changeset
|
296 |
case sfcinit_sd: |
70 | 297 |
step_number++; |
298 |
break; |
|
299 |
case stepdef_sd: |
|
300 |
s4o.print("#define "); |
|
301 |
s4o.print(SFC_STEP_ACTION_PREFIX); |
|
302 |
symbol->step_name->accept(*this); |
|
303 |
s4o.print(" "); |
|
304 |
s4o.print_integer(step_number); |
|
305 |
s4o.print("\n"); |
|
306 |
step_number++; |
|
307 |
break; |
|
308 |
case stepundef_sd: |
|
309 |
s4o.print("#undef "); |
|
310 |
s4o.print(SFC_STEP_ACTION_PREFIX); |
|
311 |
symbol->step_name->accept(*this); |
|
312 |
s4o.print("\n"); |
|
313 |
break; |
|
314 |
default: |
|
315 |
break; |
|
316 |
} |
|
317 |
return NULL; |
|
318 |
} |
|
319 |
||
244
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
320 |
void *visit(action_association_c *symbol) { |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
321 |
/* we try to find the variable instance declaration, to determine if symbol is variable... */ |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
322 |
symbol_c *var_decl = search_var_instance_decl->get_decl(symbol->action_name); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
323 |
|
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
324 |
if (var_decl != NULL) { |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
325 |
std::list<VARIABLE>::iterator pt; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
326 |
for(pt = variable_list.begin(); pt != variable_list.end(); pt++) { |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
327 |
if (!compare_identifiers(pt->symbol, symbol->action_name)) |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
328 |
return NULL; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
329 |
} |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
330 |
VARIABLE *variable; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
331 |
variable = new VARIABLE; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
332 |
variable->symbol = (identifier_c*)(symbol->action_name); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
333 |
variable_list.push_back(*variable); |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
334 |
action_number++; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
335 |
} |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
336 |
return NULL; |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
337 |
} |
3a478229db8b
Adding support for generating code for variable in step action association instead of action
laurent
parents:
229
diff
changeset
|
338 |
|
70 | 339 |
void *visit(transition_c *symbol) { |
340 |
switch (wanted_sfcdeclaration) { |
|
341 |
case sfcdecl_sd: |
|
229 | 342 |
case transitioncount_sd: |
70 | 343 |
transition_number++; |
344 |
break; |
|
345 |
default: |
|
346 |
break; |
|
347 |
} |
|
348 |
return NULL; |
|
349 |
} |
|
350 |
||
351 |
void *visit(action_c *symbol) { |
|
352 |
switch (wanted_sfcdeclaration) { |
|
353 |
case actiondef_sd: |
|
354 |
s4o.print("#define "); |
|
355 |
s4o.print(SFC_STEP_ACTION_PREFIX); |
|
356 |
symbol->action_name->accept(*this); |
|
357 |
s4o.print(" "); |
|
358 |
s4o.print_integer(action_number); |
|
359 |
s4o.print("\n"); |
|
360 |
action_number++; |
|
361 |
break; |
|
362 |
case actionundef_sd: |
|
363 |
s4o.print("#undef "); |
|
364 |
s4o.print(SFC_STEP_ACTION_PREFIX); |
|
365 |
symbol->action_name->accept(*this); |
|
366 |
s4o.print("\n"); |
|
367 |
break; |
|
368 |
case actioncount_sd: |
|
369 |
case sfcdecl_sd: |
|
370 |
action_number++; |
|
371 |
break; |
|
372 |
default: |
|
373 |
break; |
|
374 |
} |
|
375 |
return NULL; |
|
376 |
} |
|
377 |
||
378 |
void *visit(instruction_list_c *symbol) { |
|
379 |
return NULL; |
|
380 |
} |
|
381 |
||
382 |
void *visit(statement_list_c *symbol) { |
|
383 |
return NULL; |
|
384 |
} |
|
385 |
||
386 |
}; /* generate_c_sfcdecl_c */ |
|
387 |