author | laurent |
Fri, 01 Apr 2011 17:26:29 +0200 | |
changeset 255 | 86ef2244aef1 |
parent 202 | da1a8186f86f |
child 265 | 4d222f46f8cc |
permissions | -rw-r--r-- |
181 | 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 |
* Function call parameter iterator. |
|
28 |
* |
|
29 |
* This is part of the 4th stage that generates |
|
30 |
* a c++ source program equivalent to the IL and ST |
|
31 |
* code. |
|
32 |
*/ |
|
33 |
||
34 |
||
35 |
#include "../absyntax/visitor.hh" |
|
36 |
||
37 |
||
38 |
||
39 |
/* given a function_body_c, iterate through each |
|
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
40 |
* function/FB call in that code. |
181 | 41 |
*/ |
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
42 |
|
181 | 43 |
class function_call_iterator_c : public iterator_visitor_c { |
44 |
||
45 |
private: |
|
46 |
symbol_c *start_symbol; |
|
47 |
int next_fcall, fcall_count; |
|
48 |
symbol_c *current_fcall_name; |
|
49 |
symbol_c *current_finvocation; |
|
50 |
||
51 |
public: |
|
52 |
/* initialise the iterator object. |
|
53 |
* We must be given a reference to the function declaration |
|
54 |
* that will be analysed... |
|
55 |
*/ |
|
56 |
function_call_iterator_c(symbol_c *symbol); |
|
57 |
||
58 |
/* Skip to the next function call. After object creation, |
|
59 |
* the object references _before_ the first, so |
|
60 |
* this function must be called once to get the object to |
|
61 |
* reference the first function call... |
|
62 |
* |
|
63 |
* Returns the function_invocation_c! |
|
64 |
*/ |
|
65 |
symbol_c *next(void); |
|
66 |
||
67 |
/* Returns the name of the currently referenced function invocation */ |
|
68 |
identifier_c *fname(void); |
|
69 |
||
70 |
private: |
|
71 |
/***************************************/ |
|
72 |
/* B.3 - Language ST (Structured Text) */ |
|
73 |
/***************************************/ |
|
74 |
/***********************/ |
|
75 |
/* B 3.1 - Expressions */ |
|
76 |
/***********************/ |
|
77 |
void *visit(function_invocation_c *symbol); |
|
78 |
||
79 |
/****************************************/ |
|
80 |
/* B.2 - Language IL (Instruction List) */ |
|
81 |
/****************************************/ |
|
82 |
/***********************************/ |
|
83 |
/* B 2.1 Instructions and Operands */ |
|
84 |
/***********************************/ |
|
85 |
||
86 |
/* | function_name [il_operand_list] */ |
|
87 |
// SYM_REF2(il_function_call_c, function_name, il_operand_list) |
|
88 |
void *visit(il_function_call_c *symbol); |
|
89 |
||
90 |
/* | function_name '(' eol_list [il_param_list] ')' */ |
|
91 |
// SYM_REF2(il_formal_funct_call_c, function_name, il_param_list) |
|
92 |
void *visit(il_formal_funct_call_c *symbol); |
|
93 |
||
94 |
}; // class function_call_iterator_c |
|
95 |
||
96 |
||
97 |
||
98 |