@@ -179,12 +179,12 @@ impl ToElementIndex for RegionElementIndex {
179
179
/// variable. The columns consist of either universal regions or
180
180
/// points in the CFG.
181
181
#[ derive( Clone ) ]
182
- pub ( super ) struct RegionValues {
182
+ pub ( super ) struct RegionValues < N : Idx > {
183
183
elements : Rc < RegionValueElements > ,
184
- matrix : SparseBitMatrix < RegionVid , RegionElementIndex > ,
184
+ matrix : SparseBitMatrix < N , RegionElementIndex > ,
185
185
}
186
186
187
- impl RegionValues {
187
+ impl < N : Idx > RegionValues < N > {
188
188
/// Creates a new set of "region values" that tracks causal information.
189
189
/// Each of the regions in num_region_variables will be initialized with an
190
190
/// empty set of points and no causal information.
@@ -197,35 +197,35 @@ impl RegionValues {
197
197
Self {
198
198
elements : elements. clone ( ) ,
199
199
matrix : SparseBitMatrix :: new (
200
- RegionVid :: new ( num_region_variables) ,
200
+ N :: new ( num_region_variables) ,
201
201
RegionElementIndex :: new ( elements. num_elements ( ) ) ,
202
202
) ,
203
203
}
204
204
}
205
205
206
206
/// Adds the given element to the value for the given region. Returns true if
207
207
/// the element is newly added (i.e., was not already present).
208
- pub ( super ) fn add_element < E : ToElementIndex > ( & mut self , r : RegionVid , elem : E ) -> bool {
208
+ pub ( super ) fn add_element < E : ToElementIndex > ( & mut self , r : N , elem : E ) -> bool {
209
209
let i = self . elements . index ( elem) ;
210
210
debug ! ( "add(r={:?}, elem={:?})" , r, elem) ;
211
211
self . matrix . add ( r, i)
212
212
}
213
213
214
214
/// Add all elements in `r_from` to `r_to` (because e.g. `r_to:
215
215
/// r_from`).
216
- pub ( super ) fn add_region ( & mut self , r_to : RegionVid , r_from : RegionVid ) -> bool {
216
+ pub ( super ) fn add_region ( & mut self , r_to : N , r_from : N ) -> bool {
217
217
self . matrix . merge ( r_from, r_to)
218
218
}
219
219
220
220
/// True if the region `r` contains the given element.
221
- pub ( super ) fn contains < E : ToElementIndex > ( & self , r : RegionVid , elem : E ) -> bool {
221
+ pub ( super ) fn contains < E : ToElementIndex > ( & self , r : N , elem : E ) -> bool {
222
222
let i = self . elements . index ( elem) ;
223
223
self . matrix . contains ( r, i)
224
224
}
225
225
226
226
/// True if `sup_region` contains all the CFG points that
227
227
/// `sub_region` contains. Ignores universal regions.
228
- pub ( super ) fn contains_points ( & self , sup_region : RegionVid , sub_region : RegionVid ) -> bool {
228
+ pub ( super ) fn contains_points ( & self , sup_region : N , sub_region : N ) -> bool {
229
229
// This could be done faster by comparing the bitsets. But I
230
230
// am lazy.
231
231
self . element_indices_contained_in ( sub_region)
@@ -238,15 +238,15 @@ impl RegionValues {
238
238
/// `elements_contained_in`.
239
239
pub ( super ) fn element_indices_contained_in < ' a > (
240
240
& ' a self ,
241
- r : RegionVid ,
241
+ r : N ,
242
242
) -> impl Iterator < Item = RegionElementIndex > + ' a {
243
243
self . matrix . iter ( r) . map ( move |i| i)
244
244
}
245
245
246
246
/// Returns just the universal regions that are contained in a given region's value.
247
247
pub ( super ) fn universal_regions_outlived_by < ' a > (
248
248
& ' a self ,
249
- r : RegionVid ,
249
+ r : N ,
250
250
) -> impl Iterator < Item = RegionVid > + ' a {
251
251
self . element_indices_contained_in ( r)
252
252
. map ( move |i| self . elements . to_universal_region ( i) )
@@ -257,14 +257,14 @@ impl RegionValues {
257
257
/// Returns all the elements contained in a given region's value.
258
258
pub ( super ) fn elements_contained_in < ' a > (
259
259
& ' a self ,
260
- r : RegionVid ,
260
+ r : N ,
261
261
) -> impl Iterator < Item = RegionElement > + ' a {
262
262
self . element_indices_contained_in ( r)
263
263
. map ( move |r| self . elements . to_element ( r) )
264
264
}
265
265
266
266
/// Returns a "pretty" string value of the region. Meant for debugging.
267
- pub ( super ) fn region_value_str ( & self , r : RegionVid ) -> String {
267
+ pub ( super ) fn region_value_str ( & self , r : N ) -> String {
268
268
let mut result = String :: new ( ) ;
269
269
result. push_str ( "{" ) ;
270
270
0 commit comments