@@ -24,6 +24,7 @@ class NamedPattern extends Pattern, @named_pattern {
2424newtype TAddedElement =
2525 TIteratorVar ( ForEachStmt stmt ) or
2626 TIteratorVarPattern ( ForEachStmt stmt ) or
27+ TIteratorVarConcreteDecl ( ForEachStmt stmt ) or
2728 TNextCall ( ForEachStmt stmt ) or
2829 TNextCallMethodLookup ( ForEachStmt stmt ) or
2930 TNextCallInOutConversion ( ForEachStmt stmt ) or
@@ -38,7 +39,7 @@ class NewElement extends TNewElement {
3839 string toString ( ) { none ( ) }
3940}
4041
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 ) {
4243 for_each_stmts ( id , pattern , _, body )
4344}
4445
@@ -141,10 +142,13 @@ query predicate new_decl_ref_exprs(NewElement id, NewElement decl) {
141142 or
142143 exists ( ForEachStmt foreach |
143144 Fresh:: map ( TNextCallVarRef ( foreach ) ) = id and
144- Fresh:: map ( TIteratorVarPattern ( foreach ) ) = decl
145+ Fresh:: map ( TIteratorVarConcreteDecl ( foreach ) ) = decl
145146 )
146147 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+ |
148152 Fresh:: map ( TNextCallFuncRef ( foreach ) ) = id and
149153 // ForEachStmt.getSequence().getType().getMember(next)
150154 sequence = foreach .getSequence ( ) and
@@ -169,3 +173,48 @@ query predicate new_call_exprs(NewElement id) {
169173 call_exprs ( id ) or
170174 Fresh:: map ( TNextCall ( _) ) = id
171175}
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