@@ -24,6 +24,7 @@ class NamedPattern extends Pattern, @named_pattern {
24
24
newtype TAddedElement =
25
25
TIteratorVar ( ForEachStmt stmt ) or
26
26
TIteratorVarPattern ( ForEachStmt stmt ) or
27
+ TIteratorVarConcreteDecl ( ForEachStmt stmt ) or
27
28
TNextCall ( ForEachStmt stmt ) or
28
29
TNextCallMethodLookup ( ForEachStmt stmt ) or
29
30
TNextCallInOutConversion ( ForEachStmt stmt ) or
@@ -38,7 +39,7 @@ class NewElement extends TNewElement {
38
39
string toString ( ) { none ( ) }
39
40
}
40
41
41
- query predicate new_for_each_stmts ( ForEachStmt id , NamedPattern pattern , Element body ) {
42
+ query predicate new_for_each_stmts ( ForEachStmt id , Pattern pattern , Element body ) {
42
43
for_each_stmts ( id , pattern , _, body )
43
44
}
44
45
@@ -141,10 +142,13 @@ query predicate new_decl_ref_exprs(NewElement id, NewElement decl) {
141
142
or
142
143
exists ( ForEachStmt foreach |
143
144
Fresh:: map ( TNextCallVarRef ( foreach ) ) = id and
144
- Fresh:: map ( TIteratorVarPattern ( foreach ) ) = decl
145
+ Fresh:: map ( TIteratorVarConcreteDecl ( foreach ) ) = decl
145
146
)
146
147
or
147
- exists ( ForEachStmt foreach , @element sequence , @element exprType , @element parentType , @element typeDecl |
148
+ exists (
149
+ ForEachStmt foreach , @element sequence , @element exprType , @element parentType ,
150
+ @element typeDecl
151
+ |
148
152
Fresh:: map ( TNextCallFuncRef ( foreach ) ) = id and
149
153
// ForEachStmt.getSequence().getType().getMember(next)
150
154
sequence = foreach .getSequence ( ) and
@@ -169,3 +173,48 @@ query predicate new_call_exprs(NewElement id) {
169
173
call_exprs ( id ) or
170
174
Fresh:: map ( TNextCall ( _) ) = id
171
175
}
176
+
177
+ query predicate new_locatable_locations ( NewElement locatable , NewElement location ) {
178
+ locatable_locations ( locatable , location )
179
+ or
180
+ exists ( ForEachStmt stmt |
181
+ locatable = Fresh:: map ( TIteratorVarPattern ( stmt ) ) or
182
+ locatable = Fresh:: map ( TIteratorVarConcreteDecl ( stmt ) ) or
183
+ locatable = Fresh:: map ( TNextCall ( stmt ) ) or
184
+ locatable = Fresh:: map ( TNextCallMethodLookup ( stmt ) ) or
185
+ locatable = Fresh:: map ( TNextCallInOutConversion ( stmt ) ) or
186
+ locatable = Fresh:: map ( TNextCallVarRef ( stmt ) )
187
+ |
188
+ locatable_locations ( stmt , location )
189
+ )
190
+ }
191
+
192
+ query predicate new_concrete_var_decls ( NewElement decl , int introducer_int ) {
193
+ concrete_var_decls ( decl , introducer_int )
194
+ or
195
+ exists ( ForEachStmt stmt |
196
+ decl = Fresh:: map ( TIteratorVarConcreteDecl ( stmt ) ) and
197
+ introducer_int = 1
198
+ )
199
+ }
200
+
201
+ query predicate new_var_decls ( NewElement decl , string name , Element type ) {
202
+ var_decls ( decl , name , type )
203
+ or
204
+ exists ( ForEachStmt stmt |
205
+ decl = Fresh:: map ( TIteratorVarConcreteDecl ( stmt ) ) and
206
+ expr_types ( stmt .getSequence ( ) , type ) and
207
+ name = stmt .getPattern ( ) .getGeneratorString ( )
208
+ )
209
+ }
210
+
211
+ query predicate new_expr_types ( NewElement expr , NewElement type ) {
212
+ expr_types ( expr , type )
213
+ or
214
+ exists ( ForEachStmt stmt , Element pattern , Element var_decl |
215
+ expr = Fresh:: map ( TNextCall ( stmt ) ) and
216
+ for_each_stmts ( stmt , pattern , _, _) and
217
+ var_decl_parent_patterns ( var_decl , pattern ) and
218
+ var_decls ( var_decl , _, type )
219
+ )
220
+ }
0 commit comments