@@ -70,6 +70,8 @@ pub struct VariableIndexEntry {
70
70
pub argument_type : ArgumentType ,
71
71
/// true if this variable is a compile-time-constant
72
72
is_constant : bool ,
73
+ // true if this variable is in a 'VAR_EXTERNAL' block
74
+ is_var_external : bool ,
73
75
/// the variable's datatype
74
76
pub data_type_name : String ,
75
77
/// the index of the member-variable in it's container (e.g. struct). defautls to 0 (Single variables)
@@ -130,6 +132,7 @@ pub struct MemberInfo<'b> {
130
132
variable_type_name : & ' b str ,
131
133
binding : Option < HardwareBinding > ,
132
134
is_constant : bool ,
135
+ is_var_external : bool ,
133
136
varargs : Option < VarArgs > ,
134
137
}
135
138
@@ -148,6 +151,7 @@ impl VariableIndexEntry {
148
151
initial_value : None ,
149
152
argument_type,
150
153
is_constant : false ,
154
+ is_var_external : false ,
151
155
data_type_name : data_type_name. to_string ( ) ,
152
156
location_in_parent,
153
157
linkage : LinkageType :: Internal ,
@@ -169,6 +173,7 @@ impl VariableIndexEntry {
169
173
initial_value : None ,
170
174
argument_type : ArgumentType :: ByVal ( VariableType :: Global ) ,
171
175
is_constant : false ,
176
+ is_var_external : false ,
172
177
data_type_name : data_type_name. to_string ( ) ,
173
178
location_in_parent : 0 ,
174
179
linkage : LinkageType :: Internal ,
@@ -203,6 +208,11 @@ impl VariableIndexEntry {
203
208
self
204
209
}
205
210
211
+ pub fn set_var_external ( mut self , var_external : bool ) -> Self {
212
+ self . is_var_external = var_external;
213
+ self
214
+ }
215
+
206
216
/// Creates a new VariableIndexEntry from the current entry with a new container and type
207
217
/// This is used to create new entries from previously generic entries
208
218
pub fn into_typed ( & self , container : & str , new_type : & str ) -> Self {
@@ -253,6 +263,10 @@ impl VariableIndexEntry {
253
263
self . linkage == LinkageType :: External
254
264
}
255
265
266
+ pub fn is_var_external ( & self ) -> bool {
267
+ self . is_var_external
268
+ }
269
+
256
270
pub fn get_declaration_type ( & self ) -> ArgumentType {
257
271
self . argument_type
258
272
}
@@ -350,6 +364,7 @@ pub enum VariableType {
350
364
InOut ,
351
365
Global ,
352
366
Return ,
367
+ External ,
353
368
}
354
369
355
370
impl VariableType {
@@ -368,6 +383,7 @@ impl std::fmt::Display for VariableType {
368
383
VariableType :: InOut => write ! ( f, "InOut" ) ,
369
384
VariableType :: Global => write ! ( f, "Global" ) ,
370
385
VariableType :: Return => write ! ( f, "Return" ) ,
386
+ VariableType :: External => write ! ( f, "External" ) ,
371
387
}
372
388
}
373
389
}
@@ -1138,13 +1154,18 @@ impl Index {
1138
1154
/// Searches for variable name in the given container, if not found, attempts to search for it in super classes
1139
1155
pub fn find_member ( & self , container_name : & str , variable_name : & str ) -> Option < & VariableIndexEntry > {
1140
1156
// Find pou in index
1141
- self . find_local_member ( container_name, variable_name) . or_else ( || {
1142
- if let Some ( class) = self . find_pou ( container_name) . and_then ( |it| it. get_super_class ( ) ) {
1143
- self . find_member ( class, variable_name)
1144
- } else {
1145
- None
1146
- }
1147
- } )
1157
+ self . find_local_member ( container_name, variable_name)
1158
+ . or_else ( || {
1159
+ if let Some ( class) = self . find_pou ( container_name) . and_then ( |it| it. get_super_class ( ) ) {
1160
+ self . find_member ( class, variable_name)
1161
+ } else {
1162
+ None
1163
+ }
1164
+ } )
1165
+ . filter ( |it| {
1166
+ // VAR_EXTERNAL variables are not local members
1167
+ !it. is_var_external ( )
1168
+ } )
1148
1169
}
1149
1170
1150
1171
/// Searches for method names in the given container, if not found, attempts to search for it in super class
@@ -1518,6 +1539,7 @@ impl Index {
1518
1539
. set_initial_value ( initial_value)
1519
1540
. set_hardware_binding ( member_info. binding )
1520
1541
. set_varargs ( member_info. varargs )
1542
+ . set_var_external ( member_info. is_var_external )
1521
1543
}
1522
1544
1523
1545
pub fn register_enum_variant (
0 commit comments