author | Mario de Sousa <msousa@fe.up.pt> |
Wed, 30 Mar 2011 19:53:32 +0100 | |
changeset 257 | 90782e241346 |
parent 202 | da1a8186f86f |
child 258 | d7d92b2f87e9 |
permissions | -rwxr-xr-x |
70 | 1 |
/* |
2 |
* (c) 2003 Mario de Sousa |
|
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 |
* This is one of the versions available for the 4th stage. |
|
28 |
* |
|
29 |
* This 4th stage generates a c++ source program equivalent |
|
30 |
* to the IL and ST code. |
|
31 |
*/ |
|
32 |
||
33 |
||
34 |
||
35 |
||
36 |
||
37 |
||
38 |
// #include <stdio.h> /* required for NULL */ |
|
39 |
#include <string> |
|
40 |
#include <iostream> |
|
41 |
#include <sstream> |
|
42 |
#include <typeinfo> |
|
111 | 43 |
#include <list> |
139
668a54686827
added missing includes on some platform (gentoo/gcc-4.3.1)
etisserant
parents:
138
diff
changeset
|
44 |
#include <strings.h> |
70 | 45 |
|
46 |
#include "../../util/symtable.hh" |
|
47 |
#include "../../util/dsymtable.hh" |
|
48 |
#include "../../absyntax/visitor.hh" |
|
181
38d6eb056260
Moving absyntax utility files out from stage4/generate_c
mario
parents:
178
diff
changeset
|
49 |
#include "../../absyntax_utils/absyntax_utils.hh" |
70 | 50 |
|
51 |
#include "../stage4.hh" |
|
52 |
||
53 |
||
54 |
||
55 |
||
56 |
||
57 |
||
58 |
||
59 |
//#define DEBUG |
|
60 |
#ifdef DEBUG |
|
61 |
#define TRACE(classname) printf("\n____%s____\n",classname); |
|
62 |
#else |
|
63 |
#define TRACE(classname) |
|
64 |
#endif |
|
65 |
||
66 |
||
67 |
||
68 |
#define ERROR error_exit(__FILE__,__LINE__) |
|
69 |
/* function defined in main.cc */ |
|
70 |
extern void error_exit(const char *file_name, int line_no); |
|
71 |
||
72 |
||
73 |
||
74 |
||
75 |
/***********************************************************************/ |
|
76 |
/***********************************************************************/ |
|
77 |
/***********************************************************************/ |
|
78 |
/***********************************************************************/ |
|
79 |
||
80 |
/* Unlike Programs and Configurations which get mapped onto C++ classes, |
|
81 |
* Function Blocks are mapped onto a C structure containing the variables, and |
|
82 |
* a C function containing the code in the FB's body. This is to allow direct allocation |
|
83 |
* of a FB variable (which is really an instance of the C data structure) to |
|
84 |
* a member of a union variable (note that classes with constructors cannot |
|
85 |
* be mebers of a union), which is done in IL when loading a FB onto IL's |
|
86 |
* default variable. |
|
87 |
* |
|
88 |
* So as not to clash the names of the C data structure and the C function, |
|
89 |
* the C structure is given a name identical to that of the FB name, whereas |
|
90 |
* the name of the function is the FB name with a constant string appended. |
|
91 |
* The value of that constant string which is appended is defined in the following |
|
92 |
* constant. |
|
93 |
* In order not to clash with any variable in the IL and ST source codem the |
|
94 |
* following constant should contain a double underscore, which is not allowed |
|
95 |
* in IL and ST. |
|
96 |
* |
|
97 |
* e.g.: FUNTION_BLOCK TEST |
|
98 |
* is mapped onto a TEST data structure, and a TEST_body__ function. |
|
99 |
*/ |
|
100 |
||
101 |
#define FB_FUNCTION_SUFFIX "_body__" |
|
102 |
||
103 |
/* Idem as body, but for initializer FB function */ |
|
104 |
#define FB_INIT_SUFFIX "_init__" |
|
105 |
||
106 |
/* Idem as body, but for run CONFIG and RESOURCE function */ |
|
107 |
#define FB_RUN_SUFFIX "_run__" |
|
108 |
||
109 |
/* The FB body function is passed as the only parameter a pointer to the FB data |
|
110 |
* structure instance. The name of this parameter is given by the following constant. |
|
111 |
* In order not to clash with any variable in the IL and ST source codem the |
|
112 |
* following constant should contain a double underscore, which is not allowed |
|
113 |
* in IL and ST. |
|
114 |
* |
|
115 |
* e.g.: the body of FUNTION_BLOCK TEST |
|
116 |
* is mapped onto the C function |
|
117 |
* TEST_body__(TEST *data__) |
|
118 |
*/ |
|
119 |
||
120 |
#define FB_FUNCTION_PARAM "data__" |
|
121 |
||
122 |
||
123 |
#define SFC_STEP_ACTION_PREFIX "__SFC_" |
|
124 |
||
125 |
/***********************************************************************/ |
|
126 |
/***********************************************************************/ |
|
127 |
/***********************************************************************/ |
|
128 |
/***********************************************************************/ |
|
129 |
||
130 |
#include "generate_c_base.cc" |
|
131 |
#include "generate_c_typedecl.cc" |
|
132 |
#include "generate_c_sfcdecl.cc" |
|
133 |
#include "generate_c_vardecl.cc" |
|
134 |
#include "generate_c_configbody.cc" |
|
135 |
#include "generate_location_list.cc" |
|
111 | 136 |
#include "generate_var_list.cc" |
70 | 137 |
|
138 |
/***********************************************************************/ |
|
139 |
/***********************************************************************/ |
|
140 |
/***********************************************************************/ |
|
141 |
/***********************************************************************/ |
|
142 |
||
143 |
/* Generate a name for a temporary variable. |
|
144 |
* Each new name generated is appended a different number, |
|
145 |
* starting off from 0. |
|
146 |
* After calling reset(), the names will start off again from 0. |
|
147 |
*/ |
|
148 |
#define VAR_LEADER "__" |
|
149 |
#define TEMP_VAR VAR_LEADER "TMP_" |
|
150 |
#define SOURCE_VAR VAR_LEADER "SRC_" |
|
151 |
||
152 |
#include "generate_c_st.cc" |
|
153 |
#include "generate_c_il.cc" |
|
154 |
||
155 |
#include "generate_c.hh" |
|
156 |
||
157 |
/***********************************************************************/ |
|
158 |
/***********************************************************************/ |
|
159 |
/***********************************************************************/ |
|
160 |
/***********************************************************************/ |
|
161 |
||
162 |
#define MILLISECOND 1000000 |
|
163 |
#define SECOND 1000 * MILLISECOND |
|
164 |
||
165 |
/* A helper class that knows how to generate code for both the IL and ST languages... */ |
|
166 |
class calculate_time_c: public iterator_visitor_c { |
|
167 |
private: |
|
168 |
unsigned long time; |
|
169 |
float current_value; |
|
170 |
||
171 |
public: |
|
172 |
calculate_time_c(void){time = 0;}; |
|
173 |
||
174 |
unsigned long get_time(void) {return time;}; |
|
175 |
||
176 |
void *get_integer_value(token_c *token) { |
|
177 |
std::string str = ""; |
|
178 |
for (unsigned int i = 0; i < strlen(token->value); i++) |
|
179 |
if (token->value[i] != '_') |
|
180 |
str += token->value[i]; |
|
181 |
current_value = atof(str.c_str()); |
|
182 |
return NULL; |
|
183 |
} |
|
184 |
||
185 |
void *get_float_value(token_c *token) { |
|
186 |
current_value = atof(token->value); |
|
187 |
return NULL; |
|
188 |
} |
|
189 |
||
190 |
/******************************/ |
|
191 |
/* B 1.2.1 - Numeric Literals */ |
|
192 |
/******************************/ |
|
193 |
||
194 |
void *visit(integer_c *symbol) {return get_integer_value(symbol);} |
|
195 |
||
196 |
/************************/ |
|
197 |
/* B 1.2.3.1 - Duration */ |
|
198 |
/************************/ |
|
199 |
||
200 |
/* SYM_REF2(duration_c, neg, interval) */ |
|
201 |
void *visit(duration_c *symbol) { |
|
202 |
if (symbol->neg != NULL) |
|
203 |
ERROR; |
|
204 |
symbol->interval->accept(*this); |
|
205 |
return NULL; |
|
206 |
} |
|
207 |
||
208 |
/* SYM_TOKEN(fixed_point_c) */ |
|
209 |
void *visit(fixed_point_c *symbol) {return get_float_value(symbol);} |
|
210 |
||
211 |
/* SYM_REF2(days_c, days, hours) */ |
|
212 |
void *visit(days_c *symbol) { |
|
213 |
if (symbol->hours) |
|
214 |
symbol->hours->accept(*this); |
|
215 |
symbol->days->accept(*this); |
|
216 |
time += (unsigned long)(current_value * 24 * 3600 * SECOND); |
|
217 |
return NULL; |
|
218 |
} |
|
219 |
||
220 |
/* SYM_REF2(hours_c, hours, minutes) */ |
|
221 |
void *visit(hours_c *symbol) { |
|
222 |
if (symbol->minutes) |
|
223 |
symbol->minutes->accept(*this); |
|
224 |
symbol->hours->accept(*this); |
|
225 |
time += (unsigned long)(current_value * 3600 * SECOND); |
|
226 |
return NULL; |
|
227 |
} |
|
228 |
||
229 |
/* SYM_REF2(minutes_c, minutes, seconds) */ |
|
230 |
void *visit(minutes_c *symbol) { |
|
231 |
if (symbol->seconds) |
|
232 |
symbol->seconds->accept(*this); |
|
233 |
symbol->minutes->accept(*this); |
|
234 |
time += (unsigned long)(current_value * 60 * SECOND); |
|
235 |
return NULL; |
|
236 |
} |
|
237 |
||
238 |
/* SYM_REF2(seconds_c, seconds, milliseconds) */ |
|
239 |
void *visit(seconds_c *symbol) { |
|
240 |
if (symbol->milliseconds) |
|
241 |
symbol->milliseconds->accept(*this); |
|
242 |
symbol->seconds->accept(*this); |
|
243 |
time += (unsigned long)(current_value * SECOND); |
|
244 |
return NULL; |
|
245 |
} |
|
246 |
||
247 |
/* SYM_REF2(milliseconds_c, milliseconds, unused) */ |
|
248 |
void *visit(milliseconds_c *symbol) { |
|
249 |
symbol->milliseconds->accept(*this); |
|
250 |
time += (unsigned long)(current_value * MILLISECOND); |
|
251 |
return NULL; |
|
252 |
} |
|
253 |
}; |
|
254 |
||
255 |
/***********************************************************************/ |
|
256 |
/***********************************************************************/ |
|
257 |
/***********************************************************************/ |
|
258 |
/***********************************************************************/ |
|
259 |
||
260 |
class calculate_common_ticktime_c: public iterator_visitor_c { |
|
261 |
private: |
|
262 |
unsigned long common_ticktime; |
|
263 |
||
264 |
public: |
|
265 |
calculate_common_ticktime_c(void){common_ticktime = 0;} |
|
266 |
||
267 |
unsigned long euclide(unsigned long a, unsigned long b) { |
|
268 |
unsigned long c = a % b; |
|
269 |
if (c == 0) |
|
270 |
return b; |
|
271 |
else |
|
272 |
return euclide(b, c); |
|
273 |
} |
|
274 |
||
275 |
void update_ticktime(unsigned long time) { |
|
276 |
if (common_ticktime == 0) |
|
277 |
common_ticktime = time; |
|
278 |
else if (time > common_ticktime) |
|
279 |
common_ticktime = euclide(time, common_ticktime); |
|
280 |
else |
|
281 |
common_ticktime = euclide(common_ticktime, time); |
|
282 |
} |
|
283 |
||
284 |
unsigned long get_ticktime(void) { |
|
285 |
return common_ticktime; |
|
286 |
} |
|
287 |
||
288 |
/* TASK task_name task_initialization */ |
|
289 |
//SYM_REF2(task_configuration_c, task_name, task_initialization) |
|
290 |
void *visit(task_initialization_c *symbol) { |
|
291 |
calculate_time_c calculate_time; |
|
292 |
unsigned long time = 0; |
|
293 |
if (symbol->interval_data_source != NULL) { |
|
294 |
symbol->interval_data_source->accept(calculate_time); |
|
295 |
time = calculate_time.get_time(); |
|
296 |
} |
|
297 |
if (time > 0) |
|
298 |
update_ticktime(time); |
|
299 |
return NULL; |
|
300 |
} |
|
301 |
}; |
|
302 |
||
303 |
/***********************************************************************/ |
|
304 |
/***********************************************************************/ |
|
305 |
/***********************************************************************/ |
|
306 |
/***********************************************************************/ |
|
307 |
||
308 |
/* A helper class that knows how to generate code for both the IL and ST languages... */ |
|
309 |
class generate_c_SFC_IL_ST_c: public null_visitor_c { |
|
310 |
private: |
|
311 |
stage4out_c *s4o_ptr; |
|
312 |
symbol_c *scope; |
|
313 |
const char *variable_prefix; |
|
314 |
||
315 |
public: |
|
316 |
generate_c_SFC_IL_ST_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL); |
|
317 |
/*********************************************/ |
|
318 |
/* B.1.6 Sequential function chart elements */ |
|
319 |
/*********************************************/ |
|
320 |
||
321 |
/*| sequential_function_chart sfc_network*/ |
|
322 |
void *visit(sequential_function_chart_c * symbol); |
|
323 |
||
324 |
/****************************************/ |
|
325 |
/* B.2 - Language IL (Instruction List) */ |
|
326 |
/****************************************/ |
|
327 |
||
328 |
/***********************************/ |
|
329 |
/* B 2.1 Instructions and Operands */ |
|
330 |
/***********************************/ |
|
331 |
/*| instruction_list il_instruction */ |
|
332 |
void *visit(instruction_list_c *symbol); |
|
333 |
||
334 |
/* Remainder implemented in generate_c_il_c... */ |
|
335 |
||
336 |
/***************************************/ |
|
337 |
/* B.3 - Language ST (Structured Text) */ |
|
338 |
/***************************************/ |
|
339 |
/***********************/ |
|
340 |
/* B 3.1 - Expressions */ |
|
341 |
/***********************/ |
|
342 |
/* Implemented in generate_c_st_c */ |
|
343 |
||
344 |
/********************/ |
|
345 |
/* B 3.2 Statements */ |
|
346 |
/********************/ |
|
347 |
void *visit(statement_list_c *symbol); |
|
348 |
||
349 |
/* Remainder implemented in generate_c_st_c... */ |
|
350 |
}; |
|
351 |
||
352 |
#include "generate_c_sfc.cc" |
|
353 |
||
354 |
generate_c_SFC_IL_ST_c::generate_c_SFC_IL_ST_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix) { |
|
355 |
if (NULL == scope) ERROR; |
|
356 |
this->s4o_ptr = s4o_ptr; |
|
357 |
this->scope = scope; |
|
358 |
this->variable_prefix = variable_prefix; |
|
359 |
} |
|
360 |
||
361 |
void *generate_c_SFC_IL_ST_c::visit(sequential_function_chart_c * symbol) { |
|
362 |
generate_c_sfc_c generate_c_sfc(s4o_ptr, scope, variable_prefix); |
|
363 |
generate_c_sfc.generate(symbol); |
|
364 |
return NULL; |
|
365 |
} |
|
366 |
||
367 |
void *generate_c_SFC_IL_ST_c::visit(instruction_list_c *symbol) { |
|
368 |
generate_c_il_c generate_c_il(s4o_ptr, scope, variable_prefix); |
|
369 |
generate_c_il.generate(symbol); |
|
370 |
return NULL; |
|
371 |
} |
|
372 |
||
373 |
void *generate_c_SFC_IL_ST_c::visit(statement_list_c *symbol) { |
|
374 |
generate_c_st_c generate_c_st(s4o_ptr, scope, variable_prefix); |
|
375 |
generate_c_st.generate(symbol); |
|
376 |
return NULL; |
|
377 |
} |
|
378 |
||
379 |
||
380 |
||
381 |
||
382 |
/***********************************************************************/ |
|
383 |
/***********************************************************************/ |
|
384 |
/***********************************************************************/ |
|
385 |
/***********************************************************************/ |
|
386 |
/***********************************************************************/ |
|
387 |
||
388 |
||
389 |
class generate_c_pous_c: public generate_c_typedecl_c { |
|
390 |
||
391 |
public: |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
392 |
generate_c_pous_c(stage4out_c *s4o_ptr, stage4out_c *s4o_incl_ptr) |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
393 |
: generate_c_typedecl_c(s4o_ptr, s4o_incl_ptr) {}; |
70 | 394 |
virtual ~generate_c_pous_c(void) {} |
395 |
||
396 |
||
397 |
public: |
|
398 |
||
399 |
/*************************/ |
|
400 |
/* B.1 - Common elements */ |
|
401 |
/*************************/ |
|
402 |
/*******************************************/ |
|
403 |
/* B 1.1 - Letters, digits and identifiers */ |
|
404 |
/*******************************************/ |
|
405 |
/* done in base class(es) */ |
|
406 |
||
407 |
/*********************/ |
|
408 |
/* B 1.2 - Constants */ |
|
409 |
/*********************/ |
|
410 |
/* originally empty... */ |
|
411 |
||
412 |
/******************************/ |
|
413 |
/* B 1.2.1 - Numeric Literals */ |
|
414 |
/******************************/ |
|
415 |
/* done in base class(es) */ |
|
416 |
||
417 |
/*******************************/ |
|
418 |
/* B.1.2.2 Character Strings */ |
|
419 |
/*******************************/ |
|
420 |
/* done in base class(es) */ |
|
421 |
||
422 |
/***************************/ |
|
423 |
/* B 1.2.3 - Time Literals */ |
|
424 |
/***************************/ |
|
425 |
/************************/ |
|
426 |
/* B 1.2.3.1 - Duration */ |
|
427 |
/************************/ |
|
428 |
/* done in base class(es) */ |
|
429 |
||
430 |
/************************************/ |
|
431 |
/* B 1.2.3.2 - Time of day and Date */ |
|
432 |
/************************************/ |
|
433 |
/* done in base class(es) */ |
|
434 |
||
435 |
/**********************/ |
|
436 |
/* B.1.3 - Data types */ |
|
437 |
/**********************/ |
|
438 |
/***********************************/ |
|
439 |
/* B 1.3.1 - Elementary Data Types */ |
|
440 |
/***********************************/ |
|
441 |
/* done in base class(es) */ |
|
442 |
||
443 |
/********************************/ |
|
444 |
/* B.1.3.2 - Generic data types */ |
|
445 |
/********************************/ |
|
446 |
/* originally empty... */ |
|
447 |
||
448 |
/********************************/ |
|
449 |
/* B 1.3.3 - Derived data types */ |
|
450 |
/********************************/ |
|
451 |
/* done in base class(es) */ |
|
452 |
||
453 |
/*********************/ |
|
454 |
/* B 1.4 - Variables */ |
|
455 |
/*********************/ |
|
456 |
/* done in base class(es) */ |
|
457 |
||
458 |
/********************************************/ |
|
459 |
/* B.1.4.1 Directly Represented Variables */ |
|
460 |
/********************************************/ |
|
461 |
/* done in base class(es) */ |
|
462 |
||
463 |
/*************************************/ |
|
464 |
/* B.1.4.2 Multi-element Variables */ |
|
465 |
/*************************************/ |
|
466 |
/* done in base class(es) */ |
|
467 |
||
468 |
/******************************************/ |
|
469 |
/* B 1.4.3 - Declaration & Initialisation */ |
|
470 |
/******************************************/ |
|
471 |
/* done in base class(es) */ |
|
472 |
||
473 |
/**************************************/ |
|
474 |
/* B.1.5 - Program organization units */ |
|
475 |
/**************************************/ |
|
476 |
/***********************/ |
|
477 |
/* B 1.5.1 - Functions */ |
|
478 |
/***********************/ |
|
479 |
||
480 |
public: |
|
481 |
/* FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ |
|
482 |
/* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */ |
|
483 |
void *visit(function_declaration_c *symbol) { |
|
484 |
generate_c_vardecl_c *vardecl; |
|
485 |
TRACE("function_declaration_c"); |
|
486 |
||
487 |
/* (A) Function declaration... */ |
|
488 |
/* (A.1) Function return type */ |
|
489 |
s4o.print("// FUNCTION\n"); |
|
490 |
symbol->type_name->accept(*this); /* return type */ |
|
491 |
s4o.print(" "); |
|
492 |
/* (A.2) Function name */ |
|
493 |
symbol->derived_function_name->accept(*this); |
|
494 |
s4o.print("("); |
|
495 |
||
496 |
/* (A.3) Function parameters */ |
|
497 |
s4o.indent_right(); |
|
498 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
499 |
generate_c_vardecl_c::finterface_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
500 |
generate_c_vardecl_c::input_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
501 |
generate_c_vardecl_c::output_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
502 |
generate_c_vardecl_c::inoutput_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
503 |
generate_c_vardecl_c::en_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
504 |
generate_c_vardecl_c::eno_vt); |
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
505 |
vardecl->print(symbol->var_declarations_list); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
506 |
delete vardecl; |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
507 |
|
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
508 |
s4o.indent_left(); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
509 |
|
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
510 |
s4o.print(")\n" + s4o.indent_spaces + "{\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
511 |
|
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
512 |
/* (B) Function local variable declaration */ |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
513 |
/* (B.1) Variables declared in ST source code */ |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
514 |
s4o.indent_right(); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
515 |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
516 |
vardecl = new generate_c_vardecl_c(&s4o, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
517 |
generate_c_vardecl_c::localinit_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
518 |
generate_c_vardecl_c::output_vt | |
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
519 |
generate_c_vardecl_c::inoutput_vt | |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
520 |
generate_c_vardecl_c::private_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
521 |
generate_c_vardecl_c::eno_vt); |
70 | 522 |
vardecl->print(symbol->var_declarations_list); |
523 |
delete vardecl; |
|
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
524 |
|
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
525 |
/* (B.2) Temporary variable for function's return value */ |
70 | 526 |
/* It will have the same name as the function itself! */ |
527 |
s4o.print(s4o.indent_spaces); |
|
528 |
symbol->type_name->accept(*this); /* return type */ |
|
529 |
s4o.print(" "); |
|
530 |
symbol->derived_function_name->accept(*this); |
|
531 |
s4o.print(" = "); |
|
532 |
{ |
|
533 |
/* get the default value of this variable's type */ |
|
534 |
symbol_c *default_value = (symbol_c *)symbol->type_name->accept(*type_initial_value_c::instance()); |
|
535 |
if (default_value == NULL) ERROR; |
|
536 |
default_value->accept(*this); |
|
537 |
} |
|
538 |
s4o.print(";\n\n"); |
|
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
539 |
|
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
540 |
s4o.print(s4o.indent_spaces + "// Control execution\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
541 |
s4o.print(s4o.indent_spaces + "if (!EN) {\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
542 |
s4o.indent_right(); |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
543 |
s4o.print(s4o.indent_spaces + "if (__ENO != NULL) {\n"); |
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
544 |
s4o.indent_right(); |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
545 |
s4o.print(s4o.indent_spaces + "*__ENO = __BOOL_LITERAL(FALSE);\n"); |
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
546 |
s4o.indent_left(); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
547 |
s4o.print(s4o.indent_spaces + "}\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
548 |
s4o.print(s4o.indent_spaces + "return "); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
549 |
symbol->derived_function_name->accept(*this); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
550 |
s4o.print(";\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
551 |
s4o.indent_left(); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
552 |
s4o.print(s4o.indent_spaces + "}\n"); |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
553 |
|
70 | 554 |
/* (C) Function body */ |
555 |
generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol); |
|
556 |
symbol->function_body->accept(generate_c_code); |
|
145 | 557 |
|
558 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
559 |
generate_c_vardecl_c::foutputassign_vf, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
560 |
generate_c_vardecl_c::output_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
561 |
generate_c_vardecl_c::inoutput_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
562 |
generate_c_vardecl_c::eno_vt); |
145 | 563 |
vardecl->print(symbol->var_declarations_list); |
564 |
delete vardecl; |
|
565 |
||
70 | 566 |
s4o.print(s4o.indent_spaces + "return "); |
567 |
symbol->derived_function_name->accept(*this); |
|
568 |
s4o.print(";\n"); |
|
569 |
s4o.indent_left(); |
|
570 |
s4o.print(s4o.indent_spaces + "}\n\n\n"); |
|
571 |
||
572 |
return NULL; |
|
573 |
} |
|
574 |
||
575 |
||
576 |
/* The remaining var_declarations_list_c, function_var_decls_c |
|
577 |
* and var2_init_decl_list_c are handled in the generate_c_vardecl_c class |
|
578 |
*/ |
|
579 |
||
580 |
||
581 |
/*****************************/ |
|
582 |
/* B 1.5.2 - Function Blocks */ |
|
583 |
/*****************************/ |
|
584 |
public: |
|
585 |
/* FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */ |
|
586 |
//SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused) |
|
587 |
void *visit(function_block_declaration_c *symbol) { |
|
588 |
generate_c_vardecl_c *vardecl; |
|
589 |
generate_c_sfcdecl_c *sfcdecl; |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
590 |
generate_c_typedecl_c *typedecl; |
70 | 591 |
TRACE("function_block_declaration_c"); |
592 |
||
593 |
/* (A) Function Block data structure declaration... */ |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
594 |
typedecl = new generate_c_typedecl_c(&s4o_incl); |
70 | 595 |
/* (A.1) Data structure declaration */ |
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
596 |
s4o_incl.print("// FUNCTION_BLOCK "); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
597 |
symbol->fblock_name->accept(*typedecl); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
598 |
s4o_incl.print("\n// Data part\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
599 |
s4o_incl.print("typedef struct {\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
600 |
s4o_incl.indent_right(); |
70 | 601 |
/* (A.2) Public variables: i.e. the function parameters... */ |
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
602 |
s4o_incl.print(s4o_incl.indent_spaces + "// FB Interface - IN, OUT, IN_OUT variables\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
603 |
vardecl = new generate_c_vardecl_c(&s4o_incl, |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
604 |
generate_c_vardecl_c::local_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
605 |
generate_c_vardecl_c::input_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
606 |
generate_c_vardecl_c::output_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
607 |
generate_c_vardecl_c::inoutput_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
608 |
generate_c_vardecl_c::en_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
609 |
generate_c_vardecl_c::eno_vt); |
70 | 610 |
vardecl->print(symbol->var_declarations); |
611 |
delete vardecl; |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
612 |
s4o_incl.print("\n"); |
70 | 613 |
/* (A.3) Private internal variables */ |
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
614 |
s4o_incl.print(s4o_incl.indent_spaces + "// FB private variables - TEMP, private and located variables\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
615 |
vardecl = new generate_c_vardecl_c(&s4o_incl, |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
616 |
generate_c_vardecl_c::local_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
617 |
generate_c_vardecl_c::temp_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
618 |
generate_c_vardecl_c::private_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
619 |
generate_c_vardecl_c::located_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
620 |
generate_c_vardecl_c::external_vt); |
70 | 621 |
vardecl->print(symbol->var_declarations); |
622 |
delete vardecl; |
|
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
623 |
|
70 | 624 |
/* (A.4) Generate private internal variables for SFC */ |
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
625 |
sfcdecl = new generate_c_sfcdecl_c(&s4o_incl, generate_c_sfcdecl_c::sfcdecl_sd); |
70 | 626 |
sfcdecl->print(symbol->fblock_body); |
627 |
delete sfcdecl; |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
628 |
s4o_incl.print("\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
629 |
|
70 | 630 |
/* (A.5) Function Block data structure type name. */ |
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
631 |
s4o_incl.indent_left(); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
632 |
s4o_incl.print("} "); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
633 |
symbol->fblock_name->accept(*typedecl); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
634 |
s4o_incl.print(";\n\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
635 |
delete typedecl; |
70 | 636 |
|
637 |
/* (B) Constructor */ |
|
638 |
/* (B.1) Constructor name... */ |
|
639 |
s4o.print(s4o.indent_spaces + "void "); |
|
640 |
symbol->fblock_name->accept(*this); |
|
641 |
s4o.print(FB_INIT_SUFFIX); |
|
642 |
s4o.print("("); |
|
643 |
||
644 |
/* first and only parameter is a pointer to the data */ |
|
645 |
symbol->fblock_name->accept(*this); |
|
646 |
s4o.print(" *"); |
|
647 |
s4o.print(FB_FUNCTION_PARAM); |
|
648 |
s4o.print(") {\n"); |
|
649 |
s4o.indent_right(); |
|
650 |
||
651 |
/* (B.2) Member initializations... */ |
|
652 |
s4o.print(s4o.indent_spaces); |
|
653 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
654 |
generate_c_vardecl_c::constructorinit_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
655 |
generate_c_vardecl_c::input_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
656 |
generate_c_vardecl_c::output_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
657 |
generate_c_vardecl_c::inoutput_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
658 |
generate_c_vardecl_c::private_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
659 |
generate_c_vardecl_c::located_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
660 |
generate_c_vardecl_c::external_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
661 |
generate_c_vardecl_c::en_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
662 |
generate_c_vardecl_c::eno_vt); |
70 | 663 |
vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
664 |
delete vardecl; |
|
665 |
s4o.print("\n"); |
|
666 |
/* (B.3) Generate private internal variables for SFC */ |
|
667 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::sfcinit_sd); |
|
668 |
sfcdecl->print(symbol->fblock_body, FB_FUNCTION_PARAM"->"); |
|
669 |
delete sfcdecl; |
|
670 |
s4o.indent_left(); |
|
671 |
s4o.print(s4o.indent_spaces + "}\n\n"); |
|
672 |
||
673 |
||
674 |
/* (C) Function with FB body */ |
|
675 |
/* (C.1) Step definitions */ |
|
676 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::stepdef_sd); |
|
677 |
sfcdecl->print(symbol->fblock_body); |
|
678 |
delete sfcdecl; |
|
679 |
||
680 |
/* (C.2) Action definitions */ |
|
681 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::actiondef_sd); |
|
682 |
sfcdecl->print(symbol->fblock_body); |
|
683 |
delete sfcdecl; |
|
684 |
||
685 |
/* (C.3) Function declaration */ |
|
686 |
s4o.print("// Code part\n"); |
|
687 |
/* function interface */ |
|
688 |
s4o.print("void "); |
|
689 |
symbol->fblock_name->accept(*this); |
|
690 |
s4o.print(FB_FUNCTION_SUFFIX); |
|
691 |
s4o.print("("); |
|
692 |
/* first and only parameter is a pointer to the data */ |
|
693 |
symbol->fblock_name->accept(*this); |
|
694 |
s4o.print(" *"); |
|
695 |
s4o.print(FB_FUNCTION_PARAM); |
|
696 |
s4o.print(") {\n"); |
|
697 |
s4o.indent_right(); |
|
698 |
||
146
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
699 |
s4o.print(s4o.indent_spaces + "// Control execution\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
700 |
s4o.print(s4o.indent_spaces + "if (!"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
701 |
s4o.print(FB_FUNCTION_PARAM); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
702 |
s4o.print("->EN) {\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
703 |
s4o.indent_right(); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
704 |
s4o.print(s4o.indent_spaces); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
705 |
s4o.print(FB_FUNCTION_PARAM); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
706 |
s4o.print("->ENO = __BOOL_LITERAL(FALSE);\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
707 |
s4o.print(s4o.indent_spaces + "return;\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
708 |
s4o.indent_left(); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
709 |
s4o.print(s4o.indent_spaces + "}\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
710 |
s4o.print(s4o.indent_spaces + "else {\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
711 |
s4o.indent_right(); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
712 |
s4o.print(s4o.indent_spaces); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
713 |
s4o.print(FB_FUNCTION_PARAM); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
714 |
s4o.print("->ENO = __BOOL_LITERAL(TRUE);\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
715 |
s4o.indent_left(); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
716 |
s4o.print(s4o.indent_spaces + "}\n"); |
eef5e62048c7
Adding support for EN/ENO params in function and function blocks (standard function not supported yet)
lbessard
parents:
145
diff
changeset
|
717 |
|
70 | 718 |
/* (C.4) Initialize TEMP variables */ |
719 |
/* function body */ |
|
720 |
s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
|
721 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
722 |
generate_c_vardecl_c::init_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
723 |
generate_c_vardecl_c::temp_vt); |
70 | 724 |
vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
725 |
delete vardecl; |
|
726 |
s4o.print("\n"); |
|
727 |
||
728 |
/* (C.5) Function code */ |
|
729 |
generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol, FB_FUNCTION_PARAM"->"); |
|
730 |
symbol->fblock_body->accept(generate_c_code); |
|
731 |
s4o.indent_left(); |
|
732 |
s4o.print(s4o.indent_spaces + "} // "); |
|
733 |
symbol->fblock_name->accept(*this); |
|
734 |
s4o.print(FB_FUNCTION_SUFFIX); |
|
735 |
s4o.print(s4o.indent_spaces + "() \n\n"); |
|
736 |
||
737 |
/* (C.6) Step undefinitions */ |
|
738 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::stepundef_sd); |
|
739 |
sfcdecl->print(symbol->fblock_body); |
|
740 |
delete sfcdecl; |
|
741 |
||
742 |
/* (C.7) Action undefinitions */ |
|
743 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::actionundef_sd); |
|
744 |
sfcdecl->print(symbol->fblock_body); |
|
745 |
delete sfcdecl; |
|
746 |
||
747 |
s4o.indent_left(); |
|
748 |
s4o.print("\n\n\n\n"); |
|
749 |
||
750 |
return NULL; |
|
751 |
} |
|
752 |
||
753 |
||
754 |
/* The remaining temp_var_decls_c, temp_var_decls_list_c |
|
755 |
* and non_retentive_var_decls_c are handled in the generate_c_vardecl_c class |
|
756 |
*/ |
|
757 |
||
758 |
||
759 |
/**********************/ |
|
760 |
/* B 1.5.3 - Programs */ |
|
761 |
/**********************/ |
|
762 |
||
763 |
||
764 |
||
765 |
public: |
|
766 |
/* PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */ |
|
767 |
//SYM_REF4(program_declaration_c, program_type_name, var_declarations, function_block_body, unused) |
|
768 |
void *visit(program_declaration_c *symbol) { |
|
769 |
generate_c_vardecl_c *vardecl; |
|
770 |
generate_c_sfcdecl_c *sfcdecl; |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
771 |
generate_c_typedecl_c *typedecl; |
70 | 772 |
TRACE("program_declaration_c"); |
773 |
||
774 |
/* (A) Program data structure declaration... */ |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
775 |
typedecl = new generate_c_typedecl_c(&s4o_incl); |
70 | 776 |
/* (A.1) Data structure declaration */ |
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
777 |
s4o_incl.print("// PROGRAM "); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
778 |
symbol->program_type_name->accept(*typedecl); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
779 |
s4o_incl.print("\n// Data part\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
780 |
s4o_incl.print("typedef struct {\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
781 |
s4o_incl.indent_right(); |
70 | 782 |
|
783 |
/* (A.2) Public variables: i.e. the program parameters... */ |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
784 |
s4o_incl.print(s4o_incl.indent_spaces + "// PROGRAM Interface - IN, OUT, IN_OUT variables\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
785 |
vardecl = new generate_c_vardecl_c(&s4o_incl, |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
786 |
generate_c_vardecl_c::local_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
787 |
generate_c_vardecl_c::input_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
788 |
generate_c_vardecl_c::output_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
789 |
generate_c_vardecl_c::inoutput_vt); |
70 | 790 |
vardecl->print(symbol->var_declarations); |
791 |
delete vardecl; |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
792 |
s4o_incl.print("\n"); |
70 | 793 |
/* (A.3) Private internal variables */ |
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
794 |
s4o_incl.print(s4o_incl.indent_spaces + "// PROGRAM private variables - TEMP, private and located variables\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
795 |
vardecl = new generate_c_vardecl_c(&s4o_incl, |
70 | 796 |
generate_c_vardecl_c::local_vf, |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
797 |
generate_c_vardecl_c::temp_vt | |
70 | 798 |
generate_c_vardecl_c::private_vt | |
799 |
generate_c_vardecl_c::located_vt | |
|
800 |
generate_c_vardecl_c::external_vt); |
|
801 |
vardecl->print(symbol->var_declarations); |
|
802 |
delete vardecl; |
|
803 |
/* (A.4) Generate private internal variables for SFC */ |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
804 |
sfcdecl = new generate_c_sfcdecl_c(&s4o_incl, generate_c_sfcdecl_c::sfcdecl_sd); |
70 | 805 |
sfcdecl->print(symbol->function_block_body); |
806 |
delete sfcdecl; |
|
807 |
||
808 |
/* (A.5) Program data structure type name. */ |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
809 |
s4o_incl.indent_left(); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
810 |
s4o_incl.print("} "); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
811 |
symbol->program_type_name->accept(*typedecl); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
812 |
s4o_incl.print(";\n\n"); |
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
813 |
delete typedecl; |
70 | 814 |
|
815 |
/* (B) Constructor */ |
|
816 |
/* (B.1) Constructor name... */ |
|
817 |
s4o.print(s4o.indent_spaces + "void "); |
|
818 |
symbol->program_type_name->accept(*this); |
|
819 |
s4o.print(FB_INIT_SUFFIX); |
|
820 |
s4o.print("("); |
|
821 |
||
822 |
/* first and only parameter is a pointer to the data */ |
|
823 |
symbol->program_type_name->accept(*this); |
|
824 |
s4o.print(" *"); |
|
825 |
s4o.print(FB_FUNCTION_PARAM); |
|
826 |
s4o.print(") {\n"); |
|
827 |
s4o.indent_right(); |
|
828 |
||
829 |
/* (B.2) Member initializations... */ |
|
830 |
s4o.print(s4o.indent_spaces); |
|
831 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
832 |
generate_c_vardecl_c::constructorinit_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
833 |
generate_c_vardecl_c::input_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
834 |
generate_c_vardecl_c::output_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
835 |
generate_c_vardecl_c::inoutput_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
836 |
generate_c_vardecl_c::private_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
837 |
generate_c_vardecl_c::located_vt | |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
838 |
generate_c_vardecl_c::external_vt); |
70 | 839 |
vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
840 |
delete vardecl; |
|
841 |
s4o.print("\n"); |
|
842 |
/* (B.3) Generate private internal variables for SFC */ |
|
843 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::sfcinit_sd); |
|
844 |
sfcdecl->print(symbol->function_block_body,FB_FUNCTION_PARAM"->"); |
|
845 |
delete sfcdecl; |
|
846 |
||
847 |
s4o.indent_left(); |
|
848 |
s4o.print(s4o.indent_spaces + "}\n\n"); |
|
849 |
||
850 |
/* (C) Function with PROGRAM body */ |
|
851 |
/* (C.1) Step definitions */ |
|
852 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::stepdef_sd); |
|
853 |
sfcdecl->print(symbol->function_block_body); |
|
854 |
delete sfcdecl; |
|
855 |
||
856 |
/* (C.2) Action definitions */ |
|
857 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::actiondef_sd); |
|
858 |
sfcdecl->print(symbol->function_block_body); |
|
859 |
delete sfcdecl; |
|
860 |
||
861 |
/* (C.3) Function declaration */ |
|
862 |
s4o.print("// Code part\n"); |
|
863 |
/* function interface */ |
|
864 |
s4o.print("void "); |
|
865 |
symbol->program_type_name->accept(*this); |
|
866 |
s4o.print(FB_FUNCTION_SUFFIX); |
|
867 |
s4o.print("("); |
|
868 |
/* first and only parameter is a pointer to the data */ |
|
869 |
symbol->program_type_name->accept(*this); |
|
870 |
s4o.print(" *"); |
|
871 |
s4o.print(FB_FUNCTION_PARAM); |
|
872 |
s4o.print(") {\n"); |
|
873 |
s4o.indent_right(); |
|
874 |
||
875 |
/* (C.4) Initialize TEMP variables */ |
|
876 |
/* function body */ |
|
877 |
s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n"); |
|
878 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
879 |
generate_c_vardecl_c::init_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
880 |
generate_c_vardecl_c::temp_vt); |
70 | 881 |
vardecl->print(symbol->var_declarations, NULL, FB_FUNCTION_PARAM"->"); |
882 |
delete vardecl; |
|
883 |
s4o.print("\n"); |
|
884 |
||
885 |
/* (C.5) Function code */ |
|
886 |
generate_c_SFC_IL_ST_c generate_c_code(&s4o, symbol, FB_FUNCTION_PARAM"->"); |
|
887 |
symbol->function_block_body->accept(generate_c_code); |
|
888 |
s4o.indent_left(); |
|
889 |
s4o.print(s4o.indent_spaces + "} // "); |
|
890 |
symbol->program_type_name->accept(*this); |
|
891 |
s4o.print(FB_FUNCTION_SUFFIX); |
|
892 |
s4o.print(s4o.indent_spaces + "() \n\n"); |
|
893 |
||
894 |
/* (C.6) Step undefinitions */ |
|
895 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::stepundef_sd); |
|
896 |
sfcdecl->print(symbol->function_block_body); |
|
897 |
delete sfcdecl; |
|
898 |
||
899 |
/* (C.7) Action undefinitions */ |
|
900 |
sfcdecl = new generate_c_sfcdecl_c(&s4o, generate_c_sfcdecl_c::actionundef_sd); |
|
901 |
sfcdecl->print(symbol->function_block_body); |
|
902 |
delete sfcdecl; |
|
903 |
||
904 |
s4o.indent_left(); |
|
905 |
s4o.print("\n\n\n\n"); |
|
906 |
||
907 |
return NULL; |
|
908 |
} |
|
909 |
||
910 |
}; /* generate_c_pous_c */ |
|
911 |
||
912 |
/***********************************************************************/ |
|
913 |
/***********************************************************************/ |
|
914 |
/***********************************************************************/ |
|
915 |
/***********************************************************************/ |
|
916 |
/***********************************************************************/ |
|
917 |
/***********************************************************************/ |
|
918 |
/***********************************************************************/ |
|
919 |
/***********************************************************************/ |
|
920 |
||
921 |
class generate_c_config_c: public generate_c_typedecl_c { |
|
922 |
||
923 |
public: |
|
924 |
generate_c_config_c(stage4out_c *s4o_ptr) |
|
925 |
: generate_c_typedecl_c(s4o_ptr) {}; |
|
926 |
virtual ~generate_c_config_c(void) {} |
|
927 |
||
928 |
typedef enum { |
|
929 |
initprotos_dt, |
|
930 |
initdeclare_dt, |
|
931 |
runprotos_dt, |
|
932 |
rundeclare_dt |
|
933 |
} declaretype_t; |
|
934 |
||
935 |
declaretype_t wanted_declaretype; |
|
936 |
||
937 |
/********************************/ |
|
938 |
/* B 1.7 Configuration elements */ |
|
939 |
/********************************/ |
|
940 |
||
941 |
||
942 |
public: |
|
943 |
/* |
|
944 |
CONFIGURATION configuration_name |
|
945 |
optional_global_var_declarations |
|
946 |
(resource_declaration_list | single_resource_declaration) |
|
947 |
optional_access_declarations |
|
948 |
optional_instance_specific_initializations |
|
949 |
END_CONFIGURATION |
|
950 |
*/ |
|
951 |
/* |
|
952 |
SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused) |
|
953 |
*/ |
|
954 |
void *visit(configuration_declaration_c *symbol) { |
|
955 |
generate_c_vardecl_c *vardecl; |
|
956 |
||
957 |
/* Insert the header... */ |
|
958 |
s4o.print("/*******************************************/\n"); |
|
959 |
s4o.print("/* FILE GENERATED BY iec2c */\n"); |
|
960 |
s4o.print("/* Editing this file is not recommended... */\n"); |
|
961 |
s4o.print("/*******************************************/\n\n"); |
|
962 |
s4o.print("#include \"iec_std_lib.h\"\n\n"); |
|
257 | 963 |
s4o.print("#include \"accessor.h\"\n\n"); |
70 | 964 |
|
965 |
/* (A) configuration declaration... */ |
|
966 |
/* (A.1) configuration name in comment */ |
|
967 |
s4o.print("// CONFIGURATION "); |
|
968 |
symbol->configuration_name->accept(*this); |
|
969 |
s4o.print("\n"); |
|
970 |
||
971 |
/* (A.2) Global variables */ |
|
972 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
973 |
generate_c_vardecl_c::local_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
974 |
generate_c_vardecl_c::global_vt); |
70 | 975 |
vardecl->print(symbol); |
976 |
delete vardecl; |
|
977 |
s4o.print("\n"); |
|
978 |
||
979 |
/* (B) Initialisation Function */ |
|
980 |
/* (B.1) Ressources initialisation protos... */ |
|
981 |
wanted_declaretype = initprotos_dt; |
|
982 |
symbol->resource_declarations->accept(*this); |
|
983 |
s4o.print("\n"); |
|
984 |
||
985 |
/* (B.2) Initialisation function name... */ |
|
986 |
s4o.print(s4o.indent_spaces + "void config"); |
|
987 |
s4o.print(FB_INIT_SUFFIX); |
|
988 |
s4o.print("(void) {\n"); |
|
989 |
s4o.indent_right(); |
|
990 |
||
991 |
/* (B.3) Global variables initializations... */ |
|
992 |
s4o.print(s4o.indent_spaces); |
|
993 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
994 |
generate_c_vardecl_c::constructorinit_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
995 |
generate_c_vardecl_c::global_vt); |
70 | 996 |
vardecl->print(symbol); |
997 |
delete vardecl; |
|
998 |
s4o.print("\n"); |
|
999 |
||
1000 |
/* (B.3) Resources initializations... */ |
|
1001 |
wanted_declaretype = initdeclare_dt; |
|
1002 |
symbol->resource_declarations->accept(*this); |
|
1003 |
||
1004 |
s4o.indent_left(); |
|
1005 |
s4o.print(s4o.indent_spaces + "}\n\n"); |
|
1006 |
||
1007 |
||
1008 |
/* (C) Run Function*/ |
|
1009 |
/* (C.1) Resources run functions protos... */ |
|
1010 |
wanted_declaretype = runprotos_dt; |
|
1011 |
symbol->resource_declarations->accept(*this); |
|
1012 |
s4o.print("\n"); |
|
1013 |
||
1014 |
/* (C.2) Run function name... */ |
|
1015 |
s4o.print(s4o.indent_spaces + "void config"); |
|
1016 |
s4o.print(FB_RUN_SUFFIX); |
|
1017 |
s4o.print("(int tick) {\n"); |
|
1018 |
s4o.indent_right(); |
|
1019 |
||
1020 |
/* (C.3) Resources initializations... */ |
|
1021 |
wanted_declaretype = rundeclare_dt; |
|
1022 |
symbol->resource_declarations->accept(*this); |
|
1023 |
||
1024 |
/* (C.3) Close Public Function body */ |
|
1025 |
s4o.indent_left(); |
|
1026 |
s4o.print(s4o.indent_spaces + "}\n"); |
|
1027 |
||
1028 |
return NULL; |
|
1029 |
} |
|
1030 |
||
1031 |
void *visit(resource_declaration_c *symbol) { |
|
1032 |
if (wanted_declaretype == initprotos_dt || wanted_declaretype == runprotos_dt) { |
|
1033 |
s4o.print(s4o.indent_spaces + "void "); |
|
1034 |
symbol->resource_name->accept(*this); |
|
1035 |
if (wanted_declaretype == initprotos_dt) { |
|
1036 |
s4o.print(FB_INIT_SUFFIX); |
|
1037 |
s4o.print("(void);\n"); |
|
1038 |
} |
|
1039 |
else { |
|
1040 |
s4o.print(FB_RUN_SUFFIX); |
|
1041 |
s4o.print("(int tick);\n"); |
|
1042 |
} |
|
1043 |
} |
|
1044 |
if (wanted_declaretype == initdeclare_dt || wanted_declaretype == rundeclare_dt) { |
|
1045 |
s4o.print(s4o.indent_spaces); |
|
1046 |
symbol->resource_name->accept(*this); |
|
1047 |
if (wanted_declaretype == initdeclare_dt) { |
|
1048 |
s4o.print(FB_INIT_SUFFIX); |
|
1049 |
s4o.print("();\n"); |
|
1050 |
} |
|
1051 |
else { |
|
1052 |
s4o.print(FB_RUN_SUFFIX); |
|
1053 |
s4o.print("(tick);\n"); |
|
1054 |
} |
|
1055 |
} |
|
1056 |
return NULL; |
|
1057 |
} |
|
1058 |
||
1059 |
void *visit(single_resource_declaration_c *symbol) { |
|
1060 |
if (wanted_declaretype == initprotos_dt || wanted_declaretype == runprotos_dt) { |
|
1061 |
s4o.print(s4o.indent_spaces + "void RESOURCE"); |
|
1062 |
if (wanted_declaretype == initprotos_dt) { |
|
1063 |
s4o.print(FB_INIT_SUFFIX); |
|
1064 |
s4o.print("(void);\n"); |
|
1065 |
} |
|
1066 |
else { |
|
1067 |
s4o.print(FB_RUN_SUFFIX); |
|
1068 |
s4o.print("(int tick);\n"); |
|
1069 |
} |
|
1070 |
} |
|
1071 |
if (wanted_declaretype == initdeclare_dt || wanted_declaretype == rundeclare_dt) { |
|
1072 |
s4o.print(s4o.indent_spaces + "RESOURCE"); |
|
1073 |
if (wanted_declaretype == initdeclare_dt) { |
|
1074 |
s4o.print(FB_INIT_SUFFIX); |
|
1075 |
s4o.print("();\n"); |
|
1076 |
} |
|
1077 |
else { |
|
1078 |
s4o.print(FB_RUN_SUFFIX); |
|
1079 |
s4o.print("(tick);\n"); |
|
1080 |
} |
|
1081 |
} |
|
1082 |
return NULL; |
|
1083 |
} |
|
1084 |
||
1085 |
}; |
|
1086 |
||
1087 |
/***********************************************************************/ |
|
1088 |
/***********************************************************************/ |
|
1089 |
/***********************************************************************/ |
|
1090 |
/***********************************************************************/ |
|
1091 |
/***********************************************************************/ |
|
1092 |
/***********************************************************************/ |
|
1093 |
/***********************************************************************/ |
|
1094 |
/***********************************************************************/ |
|
1095 |
||
1096 |
||
1097 |
class generate_c_resources_c: public generate_c_typedecl_c { |
|
1098 |
||
1099 |
search_var_instance_decl_c *search_config_instance; |
|
1100 |
search_var_instance_decl_c *search_resource_instance; |
|
1101 |
||
1102 |
private: |
|
1103 |
/* The name of the resource curretnly being processed... */ |
|
1104 |
symbol_c *current_resource_name; |
|
184 | 1105 |
symbol_c *current_task_name; |
70 | 1106 |
symbol_c *current_global_vars; |
1107 |
||
1108 |
public: |
|
1109 |
generate_c_resources_c(stage4out_c *s4o_ptr, symbol_c *config_scope, symbol_c *resource_scope, unsigned long time) |
|
1110 |
: generate_c_typedecl_c(s4o_ptr) { |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1111 |
search_config_instance = new search_var_instance_decl_c(config_scope); |
70 | 1112 |
search_resource_instance = new search_var_instance_decl_c(resource_scope); |
1113 |
common_ticktime = time; |
|
1114 |
current_resource_name = NULL; |
|
184 | 1115 |
current_task_name = NULL; |
70 | 1116 |
current_global_vars = NULL; |
1117 |
}; |
|
1118 |
virtual ~generate_c_resources_c(void) { |
|
1119 |
delete search_config_instance; |
|
1120 |
delete search_resource_instance; |
|
1121 |
} |
|
1122 |
||
1123 |
typedef enum { |
|
1124 |
declare_dt, |
|
1125 |
init_dt, |
|
1126 |
run_dt |
|
1127 |
} declaretype_t; |
|
1128 |
||
1129 |
declaretype_t wanted_declaretype; |
|
1130 |
||
1131 |
unsigned long common_ticktime; |
|
1132 |
||
1133 |
const char *current_program_name; |
|
1134 |
||
1135 |
typedef enum { |
|
1136 |
assign_at, |
|
1137 |
send_at |
|
1138 |
} assigntype_t; |
|
1139 |
||
1140 |
assigntype_t wanted_assigntype; |
|
1141 |
||
1142 |
/********************************/ |
|
1143 |
/* B 1.7 Configuration elements */ |
|
1144 |
/********************************/ |
|
1145 |
||
1146 |
/* |
|
1147 |
RESOURCE resource_name ON resource_type_name |
|
1148 |
optional_global_var_declarations |
|
1149 |
single_resource_declaration |
|
1150 |
END_RESOURCE |
|
1151 |
*/ |
|
1152 |
// SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration) |
|
1153 |
void *visit(resource_declaration_c *symbol) { |
|
1154 |
current_resource_name = symbol->resource_name; |
|
1155 |
current_global_vars = symbol->global_var_declarations; |
|
1156 |
||
1157 |
symbol->resource_declaration->accept(*this); |
|
1158 |
||
1159 |
current_resource_name = NULL; |
|
1160 |
current_global_vars = NULL; |
|
1161 |
return NULL; |
|
1162 |
} |
|
1163 |
||
1164 |
/* task_configuration_list program_configuration_list */ |
|
1165 |
// SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list) |
|
1166 |
void *visit(single_resource_declaration_c *symbol) { |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1167 |
bool single_resource = current_resource_name == NULL; |
70 | 1168 |
if (single_resource) |
1169 |
current_resource_name = new identifier_c("RESOURCE"); |
|
1170 |
generate_c_vardecl_c *vardecl; |
|
1171 |
||
1172 |
/* Insert the header... */ |
|
1173 |
s4o.print("/*******************************************/\n"); |
|
1174 |
s4o.print("/* FILE GENERATED BY iec2c */\n"); |
|
1175 |
s4o.print("/* Editing this file is not recommended... */\n"); |
|
1176 |
s4o.print("/*******************************************/\n\n"); |
|
1177 |
s4o.print("#include \"iec_std_lib.h\"\n\n"); |
|
1178 |
||
1179 |
/* (A) resource declaration... */ |
|
1180 |
/* (A.1) resource name in comment */ |
|
1181 |
s4o.print("// RESOURCE "); |
|
1182 |
current_resource_name->accept(*this); |
|
120
74640e3c7f53
Bug with D and L action qualifier and timing management in SFC generated fixed
lbessard
parents:
112
diff
changeset
|
1183 |
s4o.print("\n\n"); |
74640e3c7f53
Bug with D and L action qualifier and timing management in SFC generated fixed
lbessard
parents:
112
diff
changeset
|
1184 |
|
74640e3c7f53
Bug with D and L action qualifier and timing management in SFC generated fixed
lbessard
parents:
112
diff
changeset
|
1185 |
s4o.print("extern int common_ticktime__;\n\n"); |
70 | 1186 |
|
1187 |
/* (A.2) Global variables... */ |
|
1188 |
if (current_global_vars != NULL) { |
|
1189 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1190 |
generate_c_vardecl_c::local_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1191 |
generate_c_vardecl_c::global_vt, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1192 |
current_resource_name); |
70 | 1193 |
vardecl->print(current_global_vars); |
1194 |
delete vardecl; |
|
120
74640e3c7f53
Bug with D and L action qualifier and timing management in SFC generated fixed
lbessard
parents:
112
diff
changeset
|
1195 |
s4o.print("\n"); |
70 | 1196 |
} |
1197 |
||
1198 |
/* (A.3) POUs inclusion */ |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
1199 |
s4o.print("#include \"POUS.h\"\n\n"); |
70 | 1200 |
s4o.print("#include \"POUS.c\"\n\n"); |
1201 |
||
184 | 1202 |
wanted_declaretype = declare_dt; |
1203 |
||
70 | 1204 |
/* (A.4) Resource programs declaration... */ |
184 | 1205 |
symbol->task_configuration_list->accept(*this); |
1206 |
||
1207 |
/* (A.5) Resource programs declaration... */ |
|
70 | 1208 |
symbol->program_configuration_list->accept(*this); |
184 | 1209 |
|
70 | 1210 |
s4o.print("\n"); |
1211 |
||
1212 |
/* (B) resource initialisation function... */ |
|
1213 |
/* (B.1) initialisation function name... */ |
|
1214 |
s4o.print("void "); |
|
1215 |
current_resource_name->accept(*this); |
|
1216 |
s4o.print(FB_INIT_SUFFIX); |
|
1217 |
s4o.print("(void) {\n"); |
|
1218 |
s4o.indent_right(); |
|
1219 |
||
1220 |
/* (B.2) Global variables initialisations... */ |
|
1221 |
if (current_global_vars != NULL) { |
|
1222 |
s4o.print(s4o.indent_spaces); |
|
1223 |
vardecl = new generate_c_vardecl_c(&s4o, |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1224 |
generate_c_vardecl_c::constructorinit_vf, |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1225 |
generate_c_vardecl_c::global_vt); |
70 | 1226 |
vardecl->print(current_global_vars); |
1227 |
delete vardecl; |
|
1228 |
} |
|
1229 |
s4o.print("\n"); |
|
1230 |
||
1231 |
wanted_declaretype = init_dt; |
|
184 | 1232 |
|
1233 |
/* (B.3) Tasks initialisations... */ |
|
1234 |
symbol->task_configuration_list->accept(*this); |
|
1235 |
||
1236 |
/* (B.4) Resource programs initialisations... */ |
|
70 | 1237 |
symbol->program_configuration_list->accept(*this); |
1238 |
||
1239 |
s4o.indent_left(); |
|
1240 |
s4o.print("}\n\n"); |
|
1241 |
||
1242 |
/* (C) Resource run function... */ |
|
1243 |
/* (C.1) Run function name... */ |
|
1244 |
s4o.print("void "); |
|
1245 |
current_resource_name->accept(*this); |
|
1246 |
s4o.print(FB_RUN_SUFFIX); |
|
1247 |
s4o.print("(int tick) {\n"); |
|
1248 |
s4o.indent_right(); |
|
1249 |
||
184 | 1250 |
wanted_declaretype = run_dt; |
1251 |
||
70 | 1252 |
/* (C.2) Task management... */ |
1253 |
symbol->task_configuration_list->accept(*this); |
|
1254 |
||
1255 |
/* (C.3) Program run declaration... */ |
|
1256 |
symbol->program_configuration_list->accept(*this); |
|
1257 |
||
1258 |
s4o.indent_left(); |
|
1259 |
s4o.print("}\n\n"); |
|
1260 |
||
1261 |
if (single_resource) { |
|
1262 |
delete current_resource_name; |
|
1263 |
current_resource_name = NULL; |
|
1264 |
} |
|
1265 |
return NULL; |
|
1266 |
} |
|
1267 |
||
1268 |
/* PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */ |
|
1269 |
//SYM_REF6(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements, unused) |
|
1270 |
void *visit(program_configuration_c *symbol) { |
|
184 | 1271 |
switch (wanted_declaretype) { |
1272 |
case declare_dt: |
|
70 | 1273 |
s4o.print(s4o.indent_spaces); |
184 | 1274 |
symbol->program_type_name->accept(*this); |
1275 |
s4o.print(" "); |
|
1276 |
current_resource_name->accept(*this); |
|
1277 |
s4o.print("__"); |
|
1278 |
symbol->program_name->accept(*this); |
|
1279 |
s4o.print(";\n#define "); |
|
1280 |
symbol->program_name->accept(*this); |
|
1281 |
s4o.print(" "); |
|
1282 |
current_resource_name->accept(*this); |
|
1283 |
s4o.print("__"); |
|
1284 |
symbol->program_name->accept(*this); |
|
1285 |
s4o.print("\n"); |
|
1286 |
break; |
|
1287 |
case init_dt: |
|
1288 |
s4o.print(s4o.indent_spaces); |
|
1289 |
symbol->program_type_name->accept(*this); |
|
1290 |
s4o.print(FB_INIT_SUFFIX); |
|
1291 |
s4o.print("(&"); |
|
1292 |
symbol->program_name->accept(*this); |
|
1293 |
s4o.print(");\n"); |
|
1294 |
break; |
|
1295 |
case run_dt: |
|
1296 |
current_program_name = ((identifier_c*)(symbol->program_name))->value; |
|
1297 |
if (symbol->task_name != NULL) { |
|
1298 |
s4o.print(s4o.indent_spaces); |
|
1299 |
s4o.print("if ("); |
|
1300 |
symbol->task_name->accept(*this); |
|
1301 |
s4o.print(") {\n"); |
|
1302 |
s4o.indent_right(); |
|
1303 |
} |
|
70 | 1304 |
|
184 | 1305 |
wanted_assigntype = assign_at; |
1306 |
if (symbol->prog_conf_elements != NULL) |
|
1307 |
symbol->prog_conf_elements->accept(*this); |
|
1308 |
||
1309 |
s4o.print(s4o.indent_spaces); |
|
1310 |
symbol->program_type_name->accept(*this); |
|
1311 |
s4o.print(FB_FUNCTION_SUFFIX); |
|
1312 |
s4o.print("(&"); |
|
1313 |
symbol->program_name->accept(*this); |
|
1314 |
s4o.print(");\n"); |
|
1315 |
||
1316 |
wanted_assigntype = send_at; |
|
1317 |
if (symbol->prog_conf_elements != NULL) |
|
1318 |
symbol->prog_conf_elements->accept(*this); |
|
1319 |
||
1320 |
if (symbol->task_name != NULL) { |
|
1321 |
s4o.indent_left(); |
|
1322 |
s4o.print(s4o.indent_spaces + "}\n"); |
|
1323 |
} |
|
1324 |
break; |
|
1325 |
default: |
|
1326 |
break; |
|
70 | 1327 |
} |
1328 |
return NULL; |
|
1329 |
} |
|
1330 |
||
1331 |
/* TASK task_name task_initialization */ |
|
1332 |
//SYM_REF2(task_configuration_c, task_name, task_initialization) |
|
1333 |
void *visit(task_configuration_c *symbol) { |
|
184 | 1334 |
current_task_name = symbol->task_name; |
1335 |
switch (wanted_declaretype) { |
|
1336 |
case declare_dt: |
|
1337 |
s4o.print(s4o.indent_spaces + "BOOL "); |
|
1338 |
current_task_name->accept(*this); |
|
1339 |
s4o.print(";\n"); |
|
1340 |
symbol->task_initialization->accept(*this); |
|
1341 |
break; |
|
1342 |
case init_dt: |
|
1343 |
s4o.print(s4o.indent_spaces); |
|
1344 |
current_task_name->accept(*this); |
|
1345 |
s4o.print(" = __BOOL_LITERAL(FALSE);\n"); |
|
1346 |
symbol->task_initialization->accept(*this); |
|
1347 |
break; |
|
1348 |
case run_dt: |
|
1349 |
symbol->task_initialization->accept(*this); |
|
1350 |
break; |
|
1351 |
default: |
|
1352 |
break; |
|
1353 |
} |
|
1354 |
current_task_name = NULL; |
|
70 | 1355 |
return NULL; |
1356 |
} |
|
1357 |
||
1358 |
/* '(' [SINGLE ASSIGN data_source ','] [INTERVAL ASSIGN data_source ','] PRIORITY ASSIGN integer ')' */ |
|
1359 |
//SYM_REF4(task_initialization_c, single_data_source, interval_data_source, priority_data_source, unused) |
|
1360 |
void *visit(task_initialization_c *symbol) { |
|
184 | 1361 |
switch (wanted_declaretype) { |
1362 |
case declare_dt: |
|
1363 |
if (symbol->single_data_source != NULL) { |
|
1364 |
s4o.print(s4o.indent_spaces + "R_TRIG "); |
|
1365 |
current_task_name->accept(*this); |
|
1366 |
s4o.print("_R_TRIG;\n"); |
|
1367 |
} |
|
1368 |
break; |
|
1369 |
case init_dt: |
|
1370 |
if (symbol->single_data_source != NULL) { |
|
1371 |
s4o.print(s4o.indent_spaces + "R_TRIG"); |
|
1372 |
s4o.print(FB_INIT_SUFFIX); |
|
1373 |
s4o.print("(&"); |
|
1374 |
current_task_name->accept(*this); |
|
1375 |
s4o.print("_R_TRIG);\n"); |
|
1376 |
} |
|
1377 |
break; |
|
1378 |
case run_dt: |
|
1379 |
if (symbol->single_data_source != NULL) { |
|
1380 |
symbol_c *config_var_decl = NULL; |
|
1381 |
symbol_c *res_var_decl = NULL; |
|
1382 |
symbol_c *current_var_reference = ((global_var_reference_c *)(symbol->single_data_source))->global_var_name; |
|
1383 |
res_var_decl = search_resource_instance->get_decl(current_var_reference); |
|
1384 |
if (res_var_decl == NULL) { |
|
1385 |
config_var_decl = search_config_instance->get_decl(current_var_reference); |
|
1386 |
if (config_var_decl == NULL) |
|
1387 |
ERROR; |
|
1388 |
s4o.print(s4o.indent_spaces + "{extern "); |
|
1389 |
config_var_decl->accept(*this); |
|
1390 |
s4o.print(" *"); |
|
1391 |
symbol->single_data_source->accept(*this); |
|
1392 |
s4o.print("; "); |
|
1393 |
} |
|
1394 |
else |
|
1395 |
s4o.print(s4o.indent_spaces); |
|
1396 |
current_task_name->accept(*this); |
|
1397 |
s4o.print("_R_TRIG.CLK = *"); |
|
1398 |
symbol->single_data_source->accept(*this); |
|
1399 |
s4o.print(";"); |
|
1400 |
if (config_var_decl != NULL) |
|
1401 |
s4o.print("}"); |
|
1402 |
s4o.print("\n"); |
|
1403 |
s4o.print(s4o.indent_spaces + "R_TRIG"); |
|
1404 |
s4o.print(FB_FUNCTION_SUFFIX); |
|
1405 |
s4o.print("(&"); |
|
1406 |
current_task_name->accept(*this); |
|
1407 |
s4o.print("_R_TRIG);\n"); |
|
1408 |
s4o.print(s4o.indent_spaces); |
|
1409 |
current_task_name->accept(*this); |
|
1410 |
s4o.print(" = "); |
|
1411 |
current_task_name->accept(*this); |
|
1412 |
s4o.print("_R_TRIG.Q"); |
|
1413 |
} |
|
1414 |
else { |
|
1415 |
s4o.print(s4o.indent_spaces); |
|
1416 |
current_task_name->accept(*this); |
|
1417 |
s4o.print(" = "); |
|
1418 |
if (symbol->interval_data_source != NULL) { |
|
1419 |
calculate_time_c calculate_time; |
|
1420 |
symbol->interval_data_source->accept(calculate_time); |
|
1421 |
unsigned long time = calculate_time.get_time(); |
|
1422 |
if (time != 0) { |
|
1423 |
s4o.print("!(tick % "); |
|
1424 |
s4o.print_integer((int)(time / common_ticktime)); |
|
1425 |
s4o.print(")"); |
|
1426 |
} |
|
1427 |
else |
|
1428 |
s4o.print("1"); |
|
1429 |
} |
|
1430 |
else |
|
1431 |
s4o.print("1"); |
|
1432 |
} |
|
1433 |
s4o.print(";\n"); |
|
1434 |
break; |
|
1435 |
default: |
|
1436 |
break; |
|
70 | 1437 |
} |
1438 |
return NULL; |
|
1439 |
} |
|
1440 |
||
1441 |
/* any_symbolic_variable ASSIGN prog_data_source */ |
|
1442 |
//SYM_REF2(prog_cnxn_assign_c, symbolic_variable, prog_data_source) |
|
1443 |
void *visit(prog_cnxn_assign_c *symbol) { |
|
1444 |
if (wanted_assigntype == assign_at) { |
|
1445 |
symbol_c *var_decl; |
|
1446 |
unsigned int vartype = 0; |
|
1447 |
symbol_c *current_var_reference = ((global_var_reference_c *)(symbol->prog_data_source))->global_var_name; |
|
1448 |
var_decl = search_resource_instance->get_decl(current_var_reference); |
|
1449 |
if (var_decl == NULL) { |
|
1450 |
var_decl = search_config_instance->get_decl(current_var_reference); |
|
1451 |
if (var_decl == NULL) |
|
1452 |
ERROR; |
|
1453 |
else |
|
1454 |
vartype = search_config_instance->get_vartype(); |
|
1455 |
} |
|
1456 |
else |
|
1457 |
vartype = search_resource_instance->get_vartype(); |
|
1458 |
||
1459 |
s4o.print(s4o.indent_spaces + "{extern "); |
|
1460 |
var_decl->accept(*this); |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1461 |
s4o.print(" *"); |
70 | 1462 |
symbol->prog_data_source->accept(*this); |
1463 |
s4o.print("; "); |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1464 |
s4o.printupper(current_program_name); |
70 | 1465 |
s4o.print("."); |
1466 |
symbol->symbolic_variable->accept(*this); |
|
1467 |
s4o.print(" = "); |
|
1468 |
if (vartype || search_var_instance_decl_c::global_vt) |
|
1469 |
s4o.print("*"); |
|
1470 |
symbol->prog_data_source->accept(*this); |
|
1471 |
s4o.print(";}\n"); |
|
1472 |
} |
|
1473 |
return NULL; |
|
1474 |
} |
|
1475 |
||
1476 |
/* any_symbolic_variable SENDTO data_sink */ |
|
1477 |
//SYM_REF2(prog_cnxn_sendto_c, symbolic_variable, data_sink) |
|
1478 |
void *visit(prog_cnxn_sendto_c *symbol) { |
|
1479 |
if (wanted_assigntype == send_at) { |
|
1480 |
symbol_c *var_decl; |
|
1481 |
unsigned int vartype = 0; |
|
1482 |
symbol_c *current_var_reference = ((global_var_reference_c *)(symbol->data_sink))->global_var_name; |
|
1483 |
var_decl = search_resource_instance->get_decl(current_var_reference); |
|
1484 |
if (var_decl == NULL) { |
|
1485 |
var_decl = search_config_instance->get_decl(current_var_reference); |
|
1486 |
if (var_decl == NULL) |
|
1487 |
ERROR; |
|
1488 |
else |
|
1489 |
vartype = search_config_instance->get_vartype(); |
|
1490 |
} |
|
1491 |
else |
|
1492 |
vartype = search_resource_instance->get_vartype(); |
|
1493 |
||
1494 |
s4o.print(s4o.indent_spaces + "{extern "); |
|
1495 |
var_decl->accept(*this); |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1496 |
s4o.print(" *"); |
70 | 1497 |
symbol->data_sink->accept(*this); |
1498 |
s4o.print("; "); |
|
1499 |
if (vartype || search_var_instance_decl_c::global_vt) |
|
1500 |
s4o.print("*"); |
|
1501 |
symbol->data_sink->accept(*this); |
|
1502 |
s4o.print(" = "); |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1503 |
s4o.printupper(current_program_name); |
70 | 1504 |
s4o.print("."); |
1505 |
symbol->symbolic_variable->accept(*this); |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
189
diff
changeset
|
1506 |
s4o.print(";};\n"); |
70 | 1507 |
} |
1508 |
return NULL; |
|
1509 |
} |
|
1510 |
||
1511 |
}; |
|
1512 |
||
1513 |
/***********************************************************************/ |
|
1514 |
/***********************************************************************/ |
|
1515 |
/***********************************************************************/ |
|
1516 |
/***********************************************************************/ |
|
1517 |
/***********************************************************************/ |
|
1518 |
/***********************************************************************/ |
|
1519 |
/***********************************************************************/ |
|
1520 |
/***********************************************************************/ |
|
1521 |
||
1522 |
class generate_c_c: public iterator_visitor_c { |
|
1523 |
protected: |
|
1524 |
stage4out_c &s4o; |
|
1525 |
stage4out_c pous_s4o; |
|
121
9e8ce092e169
Adding support for POU struct definition in POUS.h
lbessard
parents:
120
diff
changeset
|
1526 |
stage4out_c pous_incl_s4o; |