1
+ import std:: ivec;
1
2
import std:: str;
2
3
import std:: vec;
3
4
import std:: vec:: len;
@@ -48,7 +49,7 @@ fn def_id_to_str(def_id d) -> str {
48
49
ret int:: str ( d. _0 ) + "," + int:: str ( d. _1 ) ;
49
50
}
50
51
51
- fn comma_str ( vec [ @constr_arg_use] args ) -> str {
52
+ fn comma_str ( & ( @constr_arg_use) [ ] args) -> str {
52
53
auto rslt = "" ;
53
54
auto comma = false ;
54
55
for ( @constr_arg_use a in args ) {
@@ -107,17 +108,17 @@ fn first_difference_string(&fn_ctxt fcx, &tritv::t expected, &tritv::t actual)
107
108
108
109
fn log_tritv_err ( fn_ctxt fcx, tritv:: t v) { log_err tritv_to_str ( fcx, v) ; }
109
110
110
- fn tos ( vec [ uint] v ) -> str {
111
+ fn tos ( & uint[ ] v) -> str {
111
112
auto rslt = "" ;
112
113
for ( uint i in v) { if ( i == 0 u) { rslt += "0" ; }
113
114
else if ( i == 1 u) { rslt += "1" ; }
114
115
else { rslt += "?" ; } }
115
116
ret rslt ;
116
117
}
117
118
118
- fn log_cond ( vec [ uint] v ) { log tos ( v) ; }
119
+ fn log_cond( & uint[ ] v) { log tos ( v ) ; }
119
120
120
- fn log_cond_err ( vec [ uint] v ) { log_err tos( v) ; }
121
+ fn log_cond_err( & uint[ ] v) { log_err tos ( v ) ; }
121
122
122
123
fn log_pp( & pre_and_post pp) {
123
124
auto p1 = tritv:: to_vec ( pp. precondition ) ;
@@ -157,10 +158,10 @@ fn log_states_err(&pre_and_post_state pp) {
157
158
158
159
fn print_ident( & ident i) { log " " + i + " "; }
159
160
160
- fn print_idents ( vec [ ident] idents ) {
161
- if ( len[ ident] ( idents) == 0 u) {
162
- ret ;
163
- } else { log "an ident: " + pop [ ident ] ( idents ) ; print_idents ( idents) ; }
161
+ fn print_idents(&mutable ident[ ] idents) {
162
+ if (ivec:: len[ident](idents) == 0u) { ret; }
163
+ log " an ident : " + ivec::pop[ident](idents) ;
164
+ print_idents(idents);
164
165
}
165
166
166
167
@@ -194,18 +195,21 @@ to represent predicate *arguments* however. This type
194
195
195
196
Both types store an ident and span, for error-logging purposes.
196
197
*/
197
- type pred_desc_ = rec ( vec [ @constr_arg_use] args , uint bit_num ) ;
198
+ type pred_desc_ = rec(( @constr_arg_use)[ ] args, uint bit_num);
198
199
199
200
type pred_desc = spanned[pred_desc_];
200
201
201
202
type constr_arg_use = constr_arg_general[tup(ident, def_id)];
202
203
203
204
tag constraint {
204
205
cinit(uint, span, ident);
205
- cpred ( path, @mutable vec [ pred_desc] ) ;
206
+ cpred(path, @mutable pred_desc[ ]);
206
207
}
207
208
208
- tag constr__ { ninit( ident) ; npred ( path, vec[ @constr_arg_use] ) ; }
209
+ tag constr__ {
210
+ ninit(ident);
211
+ npred(path, (@constr_arg_use)[]);
212
+ }
209
213
210
214
type constr_ = rec(node_id id, constr__ c);
211
215
@@ -223,11 +227,11 @@ type fn_info = rec(constr_map constrs,
223
227
used*/
224
228
// Doesn't seem to work without the @ --
225
229
// bug?
226
- @mutable vec [ node_id] used_vars ) ;
230
+ @mutable node_id[ ] used_vars);
227
231
228
232
229
233
/* mapping from node ID to typestate annotation */
230
- type node_ann_table = @mutable vec [ mutable ts_ann ] ;
234
+ type node_ann_table = @mutable ts_ann [mutable];
231
235
232
236
233
237
/* mapping from function name to fn_info map */
@@ -243,15 +247,15 @@ fn get_fn_info(&crate_ctxt ccx, node_id id) -> fn_info {
243
247
}
244
248
245
249
fn add_node(&crate_ctxt ccx, node_id i, &ts_ann a) {
246
- auto sz = len ( * ccx. node_anns ) ;
250
+ auto sz = ivec:: len(*ccx.node_anns);
247
251
if (sz <= i as uint) {
248
- grow ( * ccx. node_anns , ( i as uint ) - sz + 1 u, empty_ann ( 0 u) ) ;
252
+ ivec::grow_mut (*ccx.node_anns, (i as uint) - sz + 1u, empty_ann(0u));
249
253
}
250
254
ccx.node_anns.(i) = a;
251
255
}
252
256
253
257
fn get_ts_ann(&crate_ctxt ccx, node_id i) -> option::t[ts_ann] {
254
- if ( i as uint < len ( * ccx. node_anns ) ) {
258
+ if (i as uint < ivec:: len(*ccx.node_anns)) {
255
259
ret some[ts_ann](ccx.node_anns.(i));
256
260
} else { ret none[ts_ann]; }
257
261
}
@@ -439,7 +443,7 @@ fn pure_exp(&crate_ctxt ccx, node_id id, &prestate p) -> bool {
439
443
fn num_constraints ( fn_info m) -> uint { ret m. num_constraints ; }
440
444
441
445
fn new_crate_ctxt ( ty:: ctxt cx) -> crate_ctxt {
442
- let vec [ mutable ts_ann ] na = vec :: empty_mut ( ) ;
446
+ let ts_ann [ mutable] na = ~ [ mutable ] ;
443
447
ret rec( tcx=cx, node_anns=@mutable na, fm=@new_int_hash[ fn_info] ( ) ) ;
444
448
}
445
449
@@ -474,19 +478,18 @@ fn node_id_to_def(&crate_ctxt ccx, node_id id) -> option::t[def] {
474
478
ret ccx. tcx . def_map . find ( id) ;
475
479
}
476
480
477
- fn norm_a_constraint ( node_id id, & constraint c) -> vec [ norm_constraint ] {
481
+ fn norm_a_constraint ( node_id id, & constraint c) -> norm_constraint [ ] {
478
482
alt ( c) {
479
483
case ( cinit ( ?n, ?sp, ?i) ) {
480
- ret [ rec ( bit_num=n, c=respan ( sp, rec ( id=id, c=ninit ( i) ) ) ) ] ;
484
+ ret ~ [ rec ( bit_num=n, c=respan ( sp, rec ( id=id, c=ninit ( i) ) ) ) ] ;
481
485
}
482
486
case ( cpred ( ?p, ?descs) ) {
483
- let vec [ norm_constraint] rslt = [ ] ;
487
+ let norm_constraint[ ] rslt = ~ [ ] ;
484
488
for ( pred_desc pd in * descs) {
485
- vec:: push ( rslt,
486
- rec ( bit_num=pd. node . bit_num ,
489
+ rslt += ~[ rec ( bit_num=pd. node . bit_num ,
487
490
c=respan ( pd. span ,
488
491
rec ( id=id,
489
- c=npred ( p, pd. node . args ) ) ) ) ) ;
492
+ c=npred ( p, pd. node . args ) ) ) ) ] ;
490
493
}
491
494
ret rslt;
492
495
}
@@ -496,15 +499,15 @@ fn norm_a_constraint(node_id id, &constraint c) -> vec[norm_constraint] {
496
499
497
500
// Tried to write this as an iterator, but I got a
498
501
// non-exhaustive match in trans.
499
- fn constraints ( & fn_ctxt fcx) -> vec [ norm_constraint ] {
500
- let vec [ norm_constraint] rslt = [ ] ;
502
+ fn constraints ( & fn_ctxt fcx) -> norm_constraint [ ] {
503
+ let norm_constraint[ ] rslt = ~ [ ] ;
501
504
for each ( @tup( node_id, constraint) p in fcx. enclosing . constrs . items ( ) ) {
502
505
rslt += norm_a_constraint ( p. _0 , p. _1 ) ;
503
506
}
504
507
ret rslt;
505
508
}
506
509
507
- fn match_args( & fn_ctxt fcx, vec [ pred_desc] occs , & ( @constr_arg_use) [ ] occ) ->
510
+ fn match_args ( & fn_ctxt fcx, & pred_desc[ ] occs, & ( @constr_arg_use) [ ] occ ) ->
508
511
uint {
509
512
log "match_args: looking at " +
510
513
constr_args_to_str ( std:: util:: fst[ ident, def_id] , occ) ;
@@ -564,10 +567,10 @@ fn expr_to_constr_arg(ty::ctxt tcx, &@expr e) -> @constr_arg_use {
564
567
}
565
568
}
566
569
567
- fn exprs_to_constr_args ( ty:: ctxt tcx, vec [ @expr] args ) ->
568
- vec [ @constr_arg_use ] {
570
+ fn exprs_to_constr_args ( ty:: ctxt tcx, & ( @expr) [ ] args)
571
+ -> ( @constr_arg_use ) [ ] {
569
572
auto f = bind expr_to_constr_arg ( tcx, _) ;
570
- ret vec :: map ( f, args) ;
573
+ ret ivec :: map ( f, args) ;
571
574
}
572
575
573
576
fn expr_to_constr ( ty:: ctxt tcx, & @expr e ) -> constr {
@@ -578,10 +581,14 @@ fn expr_to_constr(ty::ctxt tcx, &@expr e) -> constr {
578
581
expr_call ( ?operator, ?args) ) {
579
582
alt ( operator. node ) {
580
583
case ( expr_path ( ?p) ) {
584
+ // FIXME: Remove this vec->ivec conversion.
585
+ auto args_ivec = ~[ ] ;
586
+ for ( @expr e in args) { args_ivec += ~[ e] ; }
587
+
581
588
ret respan ( e. span ,
582
589
rec ( id=node_id_for_constr ( tcx, operator. id ) ,
583
- c=npred ( p,
584
- exprs_to_constr_args ( tcx , args ) ) ) ) ;
590
+ c=npred ( p, exprs_to_constr_args ( tcx ,
591
+ args_ivec ) ) ) ) ;
585
592
}
586
593
case ( _) {
587
594
tcx. sess . span_fatal ( operator. span ,
@@ -609,20 +616,20 @@ fn pred_desc_to_str(&pred_desc p) -> str {
609
616
constr_args_to_str ( std:: util:: fst[ ident, def_id] , cau_ivec) + ">" ;
610
617
}
611
618
612
- fn substitute_constr_args ( & ty:: ctxt cx, & vec [ @expr] actuals,
619
+ fn substitute_constr_args ( & ty:: ctxt cx, & ( @expr) [ ] actuals,
613
620
& @ty:: constr_def c) -> constr__ {
614
- let vec [ @constr_arg_use] rslt = [ ] ;
621
+ let ( @constr_arg_use) [ ] rslt = ~ [ ] ;
615
622
for ( @constr_arg a in c. node. args) {
616
- rslt += [ substitute_arg ( cx, actuals, a) ] ;
623
+ rslt += ~ [ substitute_arg( cx, actuals, a) ] ;
617
624
}
618
625
ret npred( c. node. path, rslt ) ;
619
626
}
620
627
621
- type subst = vec [ tup ( arg , @expr) ] ;
628
+ type subst = tup ( arg , @expr) [ ] ;
622
629
623
- fn substitute_arg ( & ty:: ctxt cx, & vec [ @expr] actuals, @constr_arg a ) ->
630
+ fn substitute_arg( & ty:: ctxt cx, & ( @expr) [ ] actuals, @constr_arg a) ->
624
631
@constr_arg_use {
625
- auto num_actuals = vec :: len ( actuals) ;
632
+ auto num_actuals = ivec : : len( actuals) ;
626
633
alt ( a. node) {
627
634
case ( carg_ident( ?i) ) {
628
635
if ( i < num_actuals) {
@@ -778,26 +785,28 @@ fn non_init_constraint_mentions(&fn_ctxt fcx, &norm_constraint c,
778
785
}
779
786
780
787
781
- fn args_mention ( & vec [ @constr_arg_use] args , & def_id v) -> bool {
788
+ fn args_mention ( & ( @constr_arg_use) [ ] args, & def_id v) -> bool {
782
789
fn mentions( & def_id v, & @constr_arg_use a) -> bool {
783
790
alt ( a. node) {
784
791
case ( carg_ident( ?p1) ) { p1. _1 == v }
785
792
case ( _) { false }
786
793
}
787
794
}
788
- ret util :: common :: any[ @constr_arg_use] ( bind mentions ( v, _) , args) ;
795
+ ret ivec :: any[ @constr_arg_use] ( bind mentions( v, _) , args) ;
789
796
}
790
797
791
798
fn use_var( & fn_ctxt fcx, & node_id v ) {
792
- vec :: push ( * fcx. enclosing . used_vars , v ) ;
799
+ * fcx. enclosing . used_vars += ~ [ v ] ;
793
800
}
794
801
795
- fn vec_contains ( & @mutable vec[ node_id] v , & node_id i) -> bool {
802
+ // FIXME: This should be a function in std::ivec::.
803
+ fn vec_contains ( & @mutable ( node_id[ ] ) v , & node_id i) -> bool {
796
804
for ( node_id d in * v) {
797
805
if ( d == i) { ret true ; }
798
806
}
799
807
ret false ;
800
808
}
809
+
801
810
//
802
811
// Local Variables:
803
812
// mode: rust
0 commit comments