author | Mario de Sousa <msousa@fe.up.pt> |
Mon, 16 Apr 2012 14:41:07 +0100 | |
changeset 510 | 9317e04c1dde |
parent 507 | 30b31d8f6d0f |
child 511 | b22ae67d8003 |
permissions | -rw-r--r-- |
181 | 1 |
/* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
3 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
4 |
* Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
279
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
265
diff
changeset
|
5 |
* Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
6 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
7 |
* This program is free software: you can redistribute it and/or modify |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
8 |
* it under the terms of the GNU General Public License as published by |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
9 |
* the Free Software Foundation, either version 3 of the License, or |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
10 |
* (at your option) any later version. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
11 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
12 |
* This program is distributed in the hope that it will be useful, |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
15 |
* GNU General Public License for more details. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
16 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
19 |
* |
181 | 20 |
* |
21 |
* This code is made available on the understanding that it will not be |
|
22 |
* used in safety-critical situations without a full and competent review. |
|
23 |
*/ |
|
24 |
||
25 |
/* |
|
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
226
diff
changeset
|
26 |
* An IEC 61131-3 compiler. |
181 | 27 |
* |
28 |
* Based on the |
|
29 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
30 |
* |
|
31 |
*/ |
|
32 |
||
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
33 |
/* Search in a VAR* END_VAR declaration for the delcration of the specified variable instance. |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
34 |
* Will return: |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
35 |
* - the declaration itself (get_decl() ) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
36 |
* - the type of declaration in which the variable was declared (get_vartype() ) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
37 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
38 |
* The variable instance may NOT be a member of a structure of a memeber |
181 | 39 |
* of a structure of an element of an array of ... |
40 |
* |
|
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
41 |
* For example, considering the following 'variables': |
181 | 42 |
* window.points[1].coordinate.x |
43 |
* window.points[1].colour |
|
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
44 |
* offset[99] |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
45 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
46 |
* passing a reference to 'points', 'points[1]', 'points[1].colour', 'colour' |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
47 |
* ARE NOT ALLOWED! |
181 | 48 |
* |
49 |
* This class must only be passed the name of the variable that will appear |
|
50 |
* in the variable declaration. In the above examples, this would be |
|
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
51 |
* 'window.points[1].coordinate.x' |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
52 |
* 'window.points[1].coordinate' |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
53 |
* 'window.points[1]' |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
54 |
* 'window' |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
55 |
* 'window.points[1].colour' |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
56 |
* 'offset' |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
57 |
* 'offset[99]' |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
58 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
59 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
60 |
*/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
61 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
62 |
/* Note: |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
63 |
* Determining the declaration type of a specific variable instance (including |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
64 |
* function block instances) really means determining whether the variable was declared in a |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
65 |
* VAR_INPUT |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
66 |
* VAR_OUTPUT |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
67 |
* VAR_IN_OUT |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
68 |
* VAR |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
69 |
* VAR_TEMP |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
70 |
* VAR_EXTERNAL |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
71 |
* VAR_GLOBAL |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
72 |
* VAR <var_name> AT <location> -> Located variable! |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
73 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
74 |
*/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
75 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
76 |
/* Note: |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
77 |
* The current_type_decl that this class returns may reference the |
181 | 78 |
* name of a type, or the type declaration itself! |
79 |
* For an example of the first, consider a variable declared as ... |
|
80 |
* x : AAA; |
|
81 |
* where the AAA type is previously declared as whatever. |
|
82 |
* For an example of the second, consider a variable declared as ... |
|
83 |
* x : array of int [10]; ----> is allowed |
|
84 |
* |
|
85 |
* If it is the first, we will return a reference to the name, if the second |
|
86 |
* we return a reference to the declaration!! |
|
87 |
*/ |
|
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
88 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
89 |
|
181 | 90 |
#include "absyntax_utils.hh" |
91 |
||
92 |
||
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
93 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
94 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
95 |
/**********************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
96 |
/* A small helper visitor class, that will */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
97 |
/* return the name of a variable, as it will */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
98 |
/* appear in the variable declaration. */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
99 |
/**********************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
100 |
/* For ex.: |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
101 |
* VAR |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
102 |
* A : int; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
103 |
* B : ARRAY [1..9] of int; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
104 |
* C : some_struct_t; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
105 |
* END_VAR |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
106 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
107 |
* A := 56; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
108 |
* B[8] := 99; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
109 |
* C.e := 77; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
110 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
111 |
* Calling this visitor class with symbolic_variable_c instance referencing 'A' in |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
112 |
* the line 'A := 56', will return the string "A". |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
113 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
114 |
* Calling this visitor class with array_variable_c instance referencing 'B[8]' in |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
115 |
* the line 'B[8] := 99', will return the string "B". |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
116 |
* |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
117 |
* Calling this visitor class with array_variable_c instance referencing 'C.e' in |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
118 |
* the line 'C.e := 77', will return the string "C". |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
119 |
*/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
120 |
class get_var_name_c : public search_visitor_c { |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
121 |
private: |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
122 |
static get_var_name_c *singleton_instance_; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
123 |
public: |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
124 |
get_var_name_c(void) {}; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
125 |
~get_var_name_c(void) {}; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
126 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
127 |
static token_c *get_name(symbol_c *symbol) { |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
128 |
if (NULL == singleton_instance_) singleton_instance_ = new get_var_name_c(); |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
129 |
if (NULL == singleton_instance_) ERROR; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
130 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
131 |
return (token_c *)(symbol->accept(*singleton_instance_)); |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
132 |
} |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
133 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
134 |
private: |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
135 |
/*************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
136 |
/* B.1 - Common elements */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
137 |
/*************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
138 |
/*******************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
139 |
/* B 1.1 - Letters, digits and identifiers */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
140 |
/*******************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
141 |
// SYM_TOKEN(identifier_c) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
142 |
void *visit(identifier_c *symbol); |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
143 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
144 |
/*********************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
145 |
/* B 1.4 - Variables */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
146 |
/*********************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
147 |
// SYM_REF2(symbolic_variable_c, var_name, unused) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
148 |
void *visit(symbolic_variable_c *symbol); |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
149 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
150 |
/********************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
151 |
/* B.1.4.1 Directly Represented Variables */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
152 |
/********************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
153 |
// SYM_TOKEN(direct_variable_c) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
154 |
// void *visit(direct_variable_c *symbol); |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
155 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
156 |
/*************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
157 |
/* B.1.4.2 Multi-element Variables */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
158 |
/*************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
159 |
/* subscripted_variable '[' subscript_list ']' */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
160 |
// SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
161 |
void *visit(array_variable_c *symbol); |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
162 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
163 |
/* subscript_list ',' subscript */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
164 |
// SYM_LIST(subscript_list_c) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
165 |
// void *visit(subscript_list_c *symbol); |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
166 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
167 |
/* record_variable '.' field_selector */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
168 |
/* WARNING: input and/or output variables of function blocks |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
169 |
* may be accessed as fields of a tructured variable! |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
170 |
* Code handling a structured_variable_c must take |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
171 |
* this into account! |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
172 |
*/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
173 |
// SYM_REF2(structured_variable_c, record_variable, field_selector) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
174 |
void *visit(structured_variable_c *symbol); |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
175 |
}; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
176 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
177 |
get_var_name_c *get_var_name_c::singleton_instance_ = NULL; |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
178 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
179 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
180 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
181 |
/*************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
182 |
/* B.1 - Common elements */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
183 |
/*************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
184 |
/*******************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
185 |
/* B 1.1 - Letters, digits and identifiers */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
186 |
/*******************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
187 |
// SYM_TOKEN(identifier_c) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
188 |
void *get_var_name_c::visit(identifier_c *symbol) {return (void *)symbol;} |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
189 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
190 |
/*********************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
191 |
/* B 1.4 - Variables */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
192 |
/*********************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
193 |
// SYM_REF2(symbolic_variable_c, var_name, unused) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
194 |
void *get_var_name_c::visit(symbolic_variable_c *symbol) {return symbol->var_name->accept(*this);} |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
195 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
196 |
/********************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
197 |
/* B.1.4.1 Directly Represented Variables */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
198 |
/********************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
199 |
// SYM_TOKEN(direct_variable_c) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
200 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
201 |
/*************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
202 |
/* B.1.4.2 Multi-element Variables */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
203 |
/*************************************/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
204 |
/* subscripted_variable '[' subscript_list ']' */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
205 |
// SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
206 |
void *get_var_name_c::visit(array_variable_c *symbol) {return symbol->subscripted_variable->accept(*this);} |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
207 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
208 |
/* subscript_list ',' subscript */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
209 |
// SYM_LIST(subscript_list_c) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
210 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
211 |
/* record_variable '.' field_selector */ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
212 |
/* WARNING: input and/or output variables of function blocks |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
213 |
* may be accessed as fields of a tructured variable! |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
214 |
* Code handling a structured_variable_c must take |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
215 |
* this into account! |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
216 |
*/ |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
217 |
// SYM_REF2(structured_variable_c, record_variable, field_selector) |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
218 |
void *get_var_name_c::visit(structured_variable_c *symbol) {return symbol->record_variable->accept(*this);} |
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
219 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
220 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
221 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
222 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
223 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
224 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
225 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
226 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
227 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
228 |
|
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
229 |
|
181 | 230 |
search_var_instance_decl_c::search_var_instance_decl_c(symbol_c *search_scope) { |
231 |
this->current_vartype = none_vt; |
|
232 |
this->search_scope = search_scope; |
|
233 |
this->search_name = NULL; |
|
234 |
this->current_type_decl = NULL; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
235 |
this->current_option = none_opt; |
181 | 236 |
} |
237 |
||
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
238 |
symbol_c *search_var_instance_decl_c::get_decl(symbol_c *variable) { |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
239 |
this->current_vartype = none_vt; |
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
240 |
this->current_option = none_opt; |
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
241 |
this->search_name = get_var_name_c::get_name(variable); |
181 | 242 |
return (symbol_c *)search_scope->accept(*this); |
243 |
} |
|
244 |
||
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
245 |
unsigned int search_var_instance_decl_c::get_vartype(symbol_c *variable) { |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
279
diff
changeset
|
246 |
this->current_vartype = none_vt; |
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
247 |
this->current_option = none_opt; |
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
248 |
this->search_name = get_var_name_c::get_name(variable); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
279
diff
changeset
|
249 |
search_scope->accept(*this); |
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
250 |
return this->current_vartype; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
251 |
} |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
252 |
|
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
253 |
unsigned int search_var_instance_decl_c::get_option(symbol_c *variable) { |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
254 |
this->current_vartype = none_vt; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
255 |
this->current_option = none_opt; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
256 |
this->search_name = get_var_name_c::get_name(variable); |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
257 |
search_scope->accept(*this); |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
258 |
return this->current_option; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
259 |
} |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
279
diff
changeset
|
260 |
|
181 | 261 |
/***************************/ |
262 |
/* B 0 - Programming Model */ |
|
263 |
/***************************/ |
|
264 |
void *search_var_instance_decl_c::visit(library_c *symbol) { |
|
265 |
/* we do not want to search multiple declaration scopes, |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
266 |
* so we do not visit all the functions, function blocks, etc... |
181 | 267 |
*/ |
268 |
return NULL; |
|
269 |
} |
|
270 |
||
271 |
||
272 |
||
273 |
/******************************************/ |
|
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
274 |
/* B 1.4.3 - Declaration & Initialization */ |
181 | 275 |
/******************************************/ |
217
f5dfadf5de54
Adding support for declare, init, get and set macros
laurent
parents:
202
diff
changeset
|
276 |
|
181 | 277 |
/* edge -> The F_EDGE or R_EDGE directive */ |
278 |
// SYM_REF2(edge_declaration_c, edge, var1_list) |
|
279 |
// TODO |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
280 |
void *search_var_instance_decl_c::visit(constant_option_c *symbol) { |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
281 |
current_option = constant_opt; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
282 |
return NULL; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
283 |
} |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
284 |
|
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
285 |
void *search_var_instance_decl_c::visit(retain_option_c *symbol) { |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
286 |
current_option = retain_opt; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
287 |
return NULL; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
288 |
} |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
289 |
|
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
290 |
void *search_var_instance_decl_c::visit(non_retain_option_c *symbol) { |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
291 |
current_option = non_retain_opt; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
292 |
return NULL; |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
293 |
} |
181 | 294 |
|
295 |
void *search_var_instance_decl_c::visit(input_declarations_c *symbol) { |
|
296 |
current_vartype = input_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
297 |
current_option = none_opt; /* not really required. Just to make the code more readable */ |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
298 |
if (NULL != symbol->option) |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
299 |
symbol->option->accept(*this); |
181 | 300 |
void *res = symbol->input_declaration_list->accept(*this); |
301 |
if (res == NULL) { |
|
302 |
current_vartype = none_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
303 |
current_option = none_opt; |
181 | 304 |
} |
305 |
return res; |
|
306 |
} |
|
307 |
||
308 |
/* VAR_OUTPUT [RETAIN | NON_RETAIN] var_init_decl_list END_VAR */ |
|
309 |
/* option -> may be NULL ! */ |
|
310 |
void *search_var_instance_decl_c::visit(output_declarations_c *symbol) { |
|
311 |
current_vartype = output_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
312 |
current_option = none_opt; /* not really required. Just to make the code more readable */ |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
313 |
if (NULL != symbol->option) |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
314 |
symbol->option->accept(*this); |
181 | 315 |
void *res = symbol->var_init_decl_list->accept(*this); |
316 |
if (res == NULL) { |
|
317 |
current_vartype = none_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
318 |
current_option = none_opt; |
181 | 319 |
} |
320 |
return res; |
|
321 |
} |
|
322 |
||
323 |
/* VAR_IN_OUT var_declaration_list END_VAR */ |
|
324 |
void *search_var_instance_decl_c::visit(input_output_declarations_c *symbol) { |
|
325 |
current_vartype = inoutput_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
326 |
current_option = none_opt; /* not really required. Just to make the code more readable */ |
181 | 327 |
void *res = symbol->var_declaration_list->accept(*this); |
328 |
if (res == NULL) { |
|
329 |
current_vartype = none_vt; |
|
330 |
} |
|
331 |
return res; |
|
332 |
} |
|
333 |
||
202
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
334 |
/* ENO : BOOL */ |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
335 |
void *search_var_instance_decl_c::visit(eno_param_declaration_c *symbol) { |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
336 |
if (compare_identifiers(symbol->name, search_name) == 0) |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
337 |
return symbol->type; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
338 |
return NULL; |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
339 |
} |
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
340 |
|
da1a8186f86f
Initial (very rough) version of semantic checker (stage3)
Catarina Boucinha <ccb@fe.up.pt>
parents:
181
diff
changeset
|
341 |
|
181 | 342 |
/* VAR [CONSTANT] var_init_decl_list END_VAR */ |
343 |
/* option -> may be NULL ! */ |
|
344 |
/* helper symbol for input_declarations */ |
|
345 |
void *search_var_instance_decl_c::visit(var_declarations_c *symbol) { |
|
346 |
current_vartype = private_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
347 |
current_option = none_opt; /* not really required. Just to make the code more readable */ |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
348 |
if (NULL != symbol->option) |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
349 |
symbol->option->accept(*this); |
181 | 350 |
void *res = symbol->var_init_decl_list->accept(*this); |
351 |
if (res == NULL) { |
|
352 |
current_vartype = none_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
353 |
current_option = none_opt; |
181 | 354 |
} |
355 |
return res; |
|
356 |
} |
|
357 |
||
358 |
/* VAR RETAIN var_init_decl_list END_VAR */ |
|
359 |
void *search_var_instance_decl_c::visit(retentive_var_declarations_c *symbol) { |
|
360 |
current_vartype = private_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
361 |
current_option = retain_opt; |
181 | 362 |
void *res = symbol->var_init_decl_list->accept(*this); |
363 |
if (res == NULL) { |
|
364 |
current_vartype = none_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
365 |
current_option = none_opt; |
181 | 366 |
} |
367 |
return res; |
|
368 |
} |
|
369 |
||
370 |
/* VAR [CONSTANT|RETAIN|NON_RETAIN] located_var_decl_list END_VAR */ |
|
371 |
/* option -> may be NULL ! */ |
|
372 |
//SYM_REF2(located_var_declarations_c, option, located_var_decl_list) |
|
373 |
void *search_var_instance_decl_c::visit(located_var_declarations_c *symbol) { |
|
374 |
current_vartype = located_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
375 |
current_option = none_opt; /* not really required. Just to make the code more readable */ |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
376 |
if (NULL != symbol->option) |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
377 |
symbol->option->accept(*this); |
181 | 378 |
void *res = symbol->located_var_decl_list->accept(*this); |
379 |
if (res == NULL) { |
|
380 |
current_vartype = none_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
381 |
current_option = none_opt; |
181 | 382 |
} |
383 |
return res; |
|
384 |
} |
|
385 |
||
386 |
/*| VAR_EXTERNAL [CONSTANT] external_declaration_list END_VAR */ |
|
387 |
/* option -> may be NULL ! */ |
|
388 |
//SYM_REF2(external_var_declarations_c, option, external_declaration_list) |
|
389 |
void *search_var_instance_decl_c::visit(external_var_declarations_c *symbol) { |
|
390 |
current_vartype = external_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
391 |
current_option = none_opt; /* not really required. Just to make the code more readable */ |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
392 |
if (NULL != symbol->option) |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
393 |
symbol->option->accept(*this); |
181 | 394 |
void *res = symbol->external_declaration_list->accept(*this); |
395 |
if (res == NULL) { |
|
396 |
current_vartype = none_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
397 |
current_option = none_opt; |
181 | 398 |
} |
399 |
return res; |
|
400 |
} |
|
401 |
||
402 |
/*| VAR_GLOBAL [CONSTANT|RETAIN] global_var_decl_list END_VAR */ |
|
403 |
/* option -> may be NULL ! */ |
|
404 |
//SYM_REF2(global_var_declarations_c, option, global_var_decl_list) |
|
405 |
void *search_var_instance_decl_c::visit(global_var_declarations_c *symbol) { |
|
406 |
current_vartype = global_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
407 |
current_option = none_opt; /* not really required. Just to make the code more readable */ |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
408 |
if (NULL != symbol->option) |
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
409 |
symbol->option->accept(*this); |
181 | 410 |
void *res = symbol->global_var_decl_list->accept(*this); |
411 |
if (res == NULL) { |
|
412 |
current_vartype = none_vt; |
|
507
30b31d8f6d0f
Determine the modifiers (CONST, REATAIN) used when declaring a variable.
manuele.conti@sirius-es.it
parents:
504
diff
changeset
|
413 |
current_option = none_opt; |
181 | 414 |
} |
415 |
return res; |
|
416 |
} |
|
417 |
||
418 |
/* var1_list is one of the following... |
|
419 |
* simple_spec_init_c * |
|
420 |
* subrange_spec_init_c * |
|
421 |
* enumerated_spec_init_c * |
|
422 |
*/ |
|
423 |
// SYM_REF2(var1_init_decl_c, var1_list, spec_init) |
|
424 |
void *search_var_instance_decl_c::visit(var1_init_decl_c *symbol) { |
|
425 |
current_type_decl = symbol->spec_init; |
|
426 |
return symbol->var1_list->accept(*this); |
|
427 |
} |
|
428 |
||
429 |
/* var1_list ',' variable_name */ |
|
430 |
// SYM_LIST(var1_list_c) |
|
431 |
void *search_var_instance_decl_c::visit(var1_list_c *symbol) { |
|
432 |
list_c *list = symbol; |
|
433 |
for(int i = 0; i < list->n; i++) { |
|
434 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
435 |
/* by now, current_type_decl should be != NULL */ |
|
436 |
return current_type_decl; |
|
437 |
} |
|
438 |
return NULL; |
|
439 |
} |
|
440 |
||
441 |
/* name_list ':' function_block_type_name ASSIGN structure_initialization */ |
|
442 |
/* structure_initialization -> may be NULL ! */ |
|
443 |
void *search_var_instance_decl_c::visit(fb_name_decl_c *symbol) { |
|
444 |
current_type_decl = symbol->function_block_type_name; |
|
445 |
return symbol->fb_name_list->accept(*this); |
|
446 |
} |
|
447 |
||
448 |
/* name_list ',' fb_name */ |
|
449 |
void *search_var_instance_decl_c::visit(fb_name_list_c *symbol) { |
|
450 |
list_c *list = symbol; |
|
451 |
for(int i = 0; i < list->n; i++) { |
|
452 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
504
f8d422b98315
Fix bug by expanding permissible data input of search_var_instance_decl_c
Mario de Sousa <msousa@fe.up.pt>
parents:
417
diff
changeset
|
453 |
/* by now, current_fb_declaration should be != NULL */ |
181 | 454 |
return current_type_decl; |
455 |
} |
|
456 |
return NULL; |
|
457 |
} |
|
458 |
||
459 |
/* var1_list ':' array_spec_init */ |
|
460 |
// SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) |
|
461 |
void *search_var_instance_decl_c::visit(array_var_init_decl_c *symbol) { |
|
462 |
current_type_decl = symbol->array_spec_init; |
|
463 |
return symbol->var1_list->accept(*this); |
|
464 |
} |
|
465 |
||
466 |
/* var1_list ':' initialized_structure */ |
|
467 |
// SYM_REF2(structured_var_init_decl_c, var1_list, initialized_structure) |
|
468 |
void *search_var_instance_decl_c::visit(structured_var_init_decl_c *symbol) { |
|
469 |
current_type_decl = symbol->initialized_structure; |
|
470 |
return symbol->var1_list->accept(*this); |
|
471 |
} |
|
472 |
||
473 |
/* var1_list ':' array_specification */ |
|
474 |
// SYM_REF2(array_var_declaration_c, var1_list, array_specification) |
|
475 |
void *search_var_instance_decl_c::visit(array_var_declaration_c *symbol) { |
|
476 |
current_type_decl = symbol->array_specification; |
|
477 |
return symbol->var1_list->accept(*this); |
|
478 |
} |
|
479 |
||
480 |
/* var1_list ':' structure_type_name */ |
|
481 |
// SYM_REF2(structured_var_declaration_c, var1_list, structure_type_name) |
|
482 |
void *search_var_instance_decl_c::visit(structured_var_declaration_c *symbol) { |
|
483 |
current_type_decl = symbol->structure_type_name; |
|
484 |
return symbol->var1_list->accept(*this); |
|
485 |
} |
|
486 |
||
487 |
/* [variable_name] location ':' located_var_spec_init */ |
|
488 |
/* variable_name -> may be NULL ! */ |
|
489 |
// SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) |
|
490 |
// TODO!! |
|
491 |
||
492 |
/* global_var_name ':' (simple_specification|subrange_specification|enumerated_specification|array_specification|prev_declared_structure_type_name|function_block_type_name */ |
|
493 |
// SYM_REF2(external_declaration_c, global_var_name, specification) |
|
494 |
void *search_var_instance_decl_c::visit(external_declaration_c *symbol) { |
|
495 |
if (compare_identifiers(symbol->global_var_name, search_name) == 0) |
|
496 |
return symbol->specification; |
|
497 |
return NULL; |
|
498 |
} |
|
499 |
||
500 |
/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ |
|
501 |
/* type_specification ->may be NULL ! */ |
|
502 |
// SYM_REF2(global_var_decl_c, global_var_spec, type_specification) |
|
503 |
void *search_var_instance_decl_c::visit(global_var_decl_c *symbol) { |
|
504 |
if (symbol->type_specification != NULL) { |
|
505 |
current_type_decl = symbol->type_specification; |
|
506 |
return symbol->global_var_spec->accept(*this); |
|
507 |
} |
|
508 |
else |
|
509 |
return NULL; |
|
510 |
} |
|
511 |
||
512 |
/*| global_var_name location */ |
|
513 |
//SYM_REF2(global_var_spec_c, global_var_name, location) |
|
514 |
void *search_var_instance_decl_c::visit(global_var_spec_c *symbol) { |
|
515 |
if (symbol->global_var_name != NULL && compare_identifiers(symbol->global_var_name, search_name) == 0) |
|
516 |
return current_type_decl; |
|
517 |
else |
|
518 |
return symbol->location->accept(*this); |
|
519 |
} |
|
520 |
||
521 |
/*| global_var_list ',' global_var_name */ |
|
522 |
//SYM_LIST(global_var_list_c) |
|
523 |
void *search_var_instance_decl_c::visit(global_var_list_c *symbol) { |
|
524 |
list_c *list = symbol; |
|
525 |
for(int i = 0; i < list->n; i++) { |
|
526 |
if (compare_identifiers(list->elements[i], search_name) == 0) |
|
527 |
/* by now, current_type_decl should be != NULL */ |
|
528 |
return current_type_decl; |
|
529 |
} |
|
530 |
return NULL; |
|
531 |
} |
|
532 |
||
533 |
/* [variable_name] location ':' located_var_spec_init */ |
|
534 |
/* variable_name -> may be NULL ! */ |
|
535 |
//SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused) |
|
536 |
void *search_var_instance_decl_c::visit(located_var_decl_c *symbol) { |
|
537 |
if (symbol->variable_name != NULL && compare_identifiers(symbol->variable_name, search_name) == 0) |
|
538 |
return symbol->located_var_spec_init; |
|
539 |
else { |
|
540 |
current_type_decl = symbol->located_var_spec_init; |
|
541 |
return symbol->location->accept(*this); |
|
542 |
} |
|
543 |
} |
|
544 |
||
545 |
/*| global_var_spec ':' [located_var_spec_init|function_block_type_name] */ |
|
546 |
/* type_specification ->may be NULL ! */ |
|
547 |
// SYM_REF2(global_var_decl_c, global_var_spec, type_specification) |
|
548 |
// TODO!! |
|
549 |
||
550 |
/* AT direct_variable */ |
|
551 |
// SYM_REF2(location_c, direct_variable, unused) |
|
552 |
void *search_var_instance_decl_c::visit(location_c *symbol) { |
|
553 |
if (compare_identifiers(symbol->direct_variable, search_name) == 0) |
|
554 |
return current_type_decl; |
|
555 |
else |
|
556 |
return NULL; |
|
557 |
} |
|
558 |
||
559 |
/*| global_var_list ',' global_var_name */ |
|
560 |
// SYM_LIST(global_var_list_c) |
|
561 |
// TODO!! |
|
562 |
||
563 |
/* var1_list ':' single_byte_string_spec */ |
|
564 |
// SYM_REF2(single_byte_string_var_declaration_c, var1_list, single_byte_string_spec) |
|
565 |
void *search_var_instance_decl_c::visit(single_byte_string_var_declaration_c *symbol) { |
|
566 |
current_type_decl = symbol->single_byte_string_spec; |
|
567 |
return symbol->var1_list->accept(*this); |
|
568 |
} |
|
569 |
||
570 |
/* STRING ['[' integer ']'] [ASSIGN single_byte_character_string] */ |
|
571 |
/* integer ->may be NULL ! */ |
|
572 |
/* single_byte_character_string ->may be NULL ! */ |
|
573 |
// SYM_REF2(single_byte_string_spec_c, integer, single_byte_character_string) |
|
574 |
// TODO!! |
|
575 |
||
576 |
/* var1_list ':' double_byte_string_spec */ |
|
577 |
// SYM_REF2(double_byte_string_var_declaration_c, var1_list, double_byte_string_spec) |
|
578 |
void *search_var_instance_decl_c::visit(double_byte_string_var_declaration_c *symbol) { |
|
579 |
current_type_decl = symbol->double_byte_string_spec; |
|
580 |
return symbol->var1_list->accept(*this); |
|
581 |
} |
|
582 |
||
583 |
/* WSTRING ['[' integer ']'] [ASSIGN double_byte_character_string] */ |
|
584 |
/* integer ->may be NULL ! */ |
|
585 |
/* double_byte_character_string ->may be NULL ! */ |
|
586 |
// SYM_REF2(double_byte_string_spec_c, integer, double_byte_character_string) |
|
587 |
// TODO!! |
|
588 |
||
589 |
/* variable_name incompl_location ':' var_spec */ |
|
590 |
// SYM_REF4(incompl_located_var_decl_c, variable_name, incompl_location, var_spec, unused) |
|
591 |
// TODO!! |
|
592 |
||
593 |
/* AT incompl_location_token */ |
|
594 |
// SYM_TOKEN(incompl_location_c) |
|
595 |
// TODO!! |
|
596 |
||
597 |
||
598 |
/**************************************/ |
|
599 |
/* B.1.5 - Program organization units */ |
|
600 |
/**************************************/ |
|
601 |
/***********************/ |
|
602 |
/* B 1.5.1 - Functions */ |
|
603 |
/***********************/ |
|
604 |
// SYM_REF4(function_declaration_c, derived_function_name, type_name, var_declarations_list, function_body) |
|
605 |
void *search_var_instance_decl_c::visit(function_declaration_c *symbol) { |
|
606 |
/* functions have a variable named after themselves, to store |
|
607 |
* the variable that will be returned!! |
|
608 |
*/ |
|
609 |
if (compare_identifiers(symbol->derived_function_name, search_name) == 0) |
|
610 |
return symbol->type_name; |
|
611 |
||
612 |
/* no need to search through all the body, so we only |
|
613 |
* visit the variable declarations...! |
|
614 |
*/ |
|
615 |
return symbol->var_declarations_list->accept(*this); |
|
616 |
} |
|
617 |
||
618 |
/*****************************/ |
|
619 |
/* B 1.5.2 - Function Blocks */ |
|
620 |
/*****************************/ |
|
621 |
void *search_var_instance_decl_c::visit(function_block_declaration_c *symbol) { |
|
622 |
/* no need to search through all the body, so we only |
|
623 |
* visit the variable declarations...! |
|
624 |
*/ |
|
625 |
return symbol->var_declarations->accept(*this); |
|
626 |
} |
|
627 |
||
628 |
/**********************/ |
|
629 |
/* B 1.5.3 - Programs */ |
|
630 |
/**********************/ |
|
631 |
void *search_var_instance_decl_c::visit(program_declaration_c *symbol) { |
|
632 |
/* no need to search through all the body, so we only |
|
633 |
* visit the variable declarations...! |
|
634 |
*/ |
|
635 |
return symbol->var_declarations->accept(*this); |
|
636 |
} |
|
637 |
||
638 |
||
639 |
/********************************/ |
|
640 |
/* B 1.7 Configuration elements */ |
|
641 |
/********************************/ |
|
642 |
||
643 |
/* |
|
644 |
CONFIGURATION configuration_name |
|
645 |
optional_global_var_declarations |
|
646 |
(resource_declaration_list | single_resource_declaration) |
|
647 |
optional_access_declarations |
|
648 |
optional_instance_specific_initializations |
|
649 |
END_CONFIGURATION |
|
650 |
*/ |
|
651 |
/* |
|
652 |
SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused) |
|
653 |
*/ |
|
654 |
void *search_var_instance_decl_c::visit(configuration_declaration_c *symbol) { |
|
655 |
/* no need to search through all the configuration, so we only |
|
656 |
* visit the global variable declarations...! |
|
657 |
*/ |
|
658 |
if (symbol->global_var_declarations != NULL) |
|
659 |
return symbol->global_var_declarations->accept(*this); |
|
660 |
else |
|
661 |
return NULL; |
|
662 |
} |
|
663 |
||
664 |
/* |
|
665 |
RESOURCE resource_name ON resource_type_name |
|
666 |
optional_global_var_declarations |
|
667 |
single_resource_declaration |
|
668 |
END_RESOURCE |
|
669 |
*/ |
|
670 |
// SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration) |
|
671 |
void *search_var_instance_decl_c::visit(resource_declaration_c *symbol) { |
|
672 |
/* no need to search through all the resource, so we only |
|
673 |
* visit the global variable declarations...! |
|
674 |
*/ |
|
675 |
if (symbol->global_var_declarations != NULL) |
|
676 |
return symbol->global_var_declarations->accept(*this); |
|
677 |
else |
|
678 |
return NULL; |
|
679 |
} |
|
680 |
||
681 |
/* task_configuration_list program_configuration_list */ |
|
682 |
// SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list) |
|
683 |
void *search_var_instance_decl_c::visit(single_resource_declaration_c *symbol) { |
|
684 |
/* no need to search through all the resource, |
|
685 |
* and there is no global variable declarations...! |
|
686 |
*/ |
|
687 |
return NULL; |
|
688 |
} |
|
689 |