@@ -16,6 +16,7 @@ import tstate::ann::{pre_and_post, pre_and_post_state, empty_ann, prestate,
16
16
import tritv:: * ;
17
17
import bitvectors:: promises_;
18
18
import driver:: session:: session;
19
+ import dvec:: { dvec, extensions} ;
19
20
20
21
import syntax:: print:: pprust:: { constr_args_to_str, lit_to_str} ;
21
22
@@ -197,7 +198,7 @@ type constraint = {
197
198
path: @path,
198
199
// FIXME: really only want it to be mut during collect_locals.
199
200
// freeze it after that.
200
- descs: @mut [ pred_args]
201
+ descs: @dvec < pred_args >
201
202
} ;
202
203
203
204
type tsconstr = {
@@ -473,8 +474,7 @@ fn node_id_to_def(ccx: crate_ctxt, id: node_id) -> option<def> {
473
474
474
475
fn norm_a_constraint( id: def_id, c: constraint) -> [ norm_constraint] {
475
476
let mut rslt: [ norm_constraint] = [ ] ;
476
- let descs = * c. descs;
477
- for vec:: each( descs) { |pd|
477
+ for ( * c. descs) . each { |pd|
478
478
rslt +=
479
479
[ { bit_num: pd. node. bit_num,
480
480
c: respan( pd. span, { path: c. path,
@@ -498,11 +498,11 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
498
498
// FIXME
499
499
// Would rather take an immutable vec as an argument,
500
500
// should freeze it at some earlier point.
501
- fn match_args( fcx: fn_ctxt, occs: @mut [ pred_args] ,
501
+ fn match_args( fcx: fn_ctxt, occs: @dvec< pred_args> ,
502
502
occ: [ @constr_arg_use] ) -> uint {
503
503
#debug( "match_args: looking at %s",
504
504
constr_args_to_str( fn @( i: inst) -> str { ret i. ident; } , occ) ) ;
505
- for vec :: each ( * occs) { |pd|
505
+ for ( * occs) . each { |pd|
506
506
log( debug,
507
507
"match_args: candidate " + pred_args_to_str( pd) ) ;
508
508
fn eq( p: inst, q: inst) -> bool { ret p. node == q. node; }
@@ -613,7 +613,8 @@ fn substitute_arg(cx: ty::ctxt, actuals: [@expr], a: @constr_arg) ->
613
613
}
614
614
}
615
615
616
- fn pred_args_matches( pattern : [ constr_arg_general_ < inst > ] , desc : pred_args ) ->
616
+ fn pred_args_matches( pattern : [ constr_arg_general_ < inst > ] ,
617
+ desc : pred_args ) ->
617
618
bool {
618
619
let mut i = 0 u;
619
620
for desc. node. args. each { |c|
@@ -638,7 +639,8 @@ fn pred_args_matches(pattern: [constr_arg_general_<inst>], desc: pred_args) ->
638
639
ret true;
639
640
}
640
641
641
- fn find_instance_( pattern: [ constr_arg_general_ < inst > ] , descs: [ pred_args] ) ->
642
+ fn find_instance_( pattern: [ constr_arg_general_ < inst > ] ,
643
+ descs: [ pred_args] ) ->
642
644
option < uint > {
643
645
for descs. each { |d|
644
646
if pred_args_matches( pattern, d) { ret some( d. node. bit_num) ; }
@@ -660,15 +662,19 @@ fn find_instances(_fcx: fn_ctxt, subst: subst,
660
662
661
663
if vec:: len( subst) == 0 u { ret [ ] ; }
662
664
let mut res = [ ] ;
663
- for ( * c. descs) . each { |d|
664
- if args_mention( d. node. args, find_in_subst_bool, subst) {
665
- let old_bit_num = d. node. bit_num;
666
- let newv = replace( subst, d) ;
667
- alt find_instance_( newv, * c. descs) {
668
- some( d1) { res += [ { from: old_bit_num, to: d1} ] }
669
- _ { }
670
- }
671
- } else { }
665
+ ( * c. descs) . swap { |v|
666
+ let v <- vec:: from_mut ( v ) ;
667
+ for v. each { |d|
668
+ if args_mention ( d. node . args , find_in_subst_bool, subst) {
669
+ let old_bit_num = d. node . bit_num ;
670
+ let newv = replace ( subst, d) ;
671
+ alt find_instance_ ( newv, v) {
672
+ some ( d1) { res += [ { from: old_bit_num, to: d1} ] }
673
+ _ { }
674
+ }
675
+ } else { }
676
+ }
677
+ vec:: to_mut ( v )
672
678
}
673
679
ret res;
674
680
}
@@ -897,12 +903,6 @@ fn args_mention<T>(args: [@constr_arg_use],
897
903
898
904
fn use_var( fcx: fn_ctxt, v: node_id) { * fcx. enclosing. used_vars += [ v] ; }
899
905
900
- // FIXME: This should be a function in vec::.
901
- fn vec_contains( v: @mut [ node_id] , i: node_id) -> bool {
902
- for vec:: each( * v) { |d| if d == i { ret true; } }
903
- ret false;
904
- }
905
-
906
906
fn op_to_oper_ty( io: init_op) -> oper_type {
907
907
alt io { init_move { oper_move } _ { oper_assign } }
908
908
}
0 commit comments