@@ -45,7 +45,7 @@ fn path_to_ident(pth: &path) -> option::t[ident] {
45
45
type clause = { params : binders , body : @expr} ;
46
46
47
47
/* logically, an arb_depth should contain only one kind of matchable */
48
- tag arb_depth[ T ] { leaf ( T ) ; seq ( vec [ arb_depth[ T ] ] , span) ; }
48
+ tag arb_depth[ T ] { leaf ( T ) ; seq ( @ [ arb_depth[ T ] ] , span) ; }
49
49
50
50
51
51
tag matchable {
@@ -118,11 +118,11 @@ fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr])
118
118
ret { fixed : elts, rep : none} ;
119
119
}
120
120
121
- fn option_flatten_map[ T , U ] ( f: & fn ( & T ) -> option:: t[ U ] , v: & vec [ T ] ) ->
122
- option:: t[ vec [ U ] ] {
123
- let res = vec :: alloc [ U ] ( vec :: len ( v ) ) ;
121
+ fn option_flatten_map[ T , U ] ( f: & fn ( & T ) -> option:: t[ U ] , v: & [ T ] ) ->
122
+ option:: t[ [ U ] ] {
123
+ let res = ~ [ ] ;
124
124
for elem: T in v {
125
- alt f( elem) { none. { ret none ; } some ( fv) { res += [ fv] ; } }
125
+ alt f( elem) { none. { ret none ; } some ( fv) { res += ~ [ fv] ; } }
126
126
}
127
127
ret some ( res) ;
128
128
}
@@ -131,9 +131,9 @@ fn a_d_map(ad: &arb_depth[matchable], f: &selector) -> match_result {
131
131
alt ad {
132
132
leaf( x) { ret f( x) ; }
133
133
seq ( ads, span) {
134
- alt option_flatten_map ( bind a_d_map ( _, f) , ads) {
134
+ alt option_flatten_map ( bind a_d_map ( _, f) , * ads) {
135
135
none. { ret none ; }
136
- some ( ts) { ret some ( seq ( ts, span) ) ; }
136
+ some ( ts) { ret some ( seq ( @ ts, span) ) ; }
137
137
}
138
138
}
139
139
}
@@ -200,7 +200,7 @@ fn use_selectors_to_bind(b: &binders, e: @expr) -> option::t[bindings] {
200
200
/* use the bindings on the body to generate the expanded code */
201
201
202
202
fn transcribe ( cx : & ext_ctxt , b : & bindings , body : @expr) -> @expr {
203
- let idx_path : @mutable vec [ uint ] = @mutable [ ] ;
203
+ let idx_path : @mutable [ uint ] = @mutable ~ [ ] ;
204
204
let afp = default_ast_fold ( ) ;
205
205
let f_pre =
206
206
{ fold_ident: bind transcribe_ident ( cx, b, idx_path, _, _) ,
@@ -220,7 +220,7 @@ fn transcribe(cx: &ext_ctxt, b: &bindings, body: @expr) -> @expr {
220
220
221
221
222
222
/* helper: descend into a matcher */
223
- fn follow ( m : & arb_depth[ matchable ] , idx_path : @mutable vec [ uint ] ) ->
223
+ fn follow( m: & arb_depth[ matchable] , idx_path : @mutable [ uint ] ) ->
224
224
arb_depth[ matchable ] {
225
225
let res: arb_depth[ matchable ] = m;
226
226
for idx: uint in * idx_path {
@@ -233,7 +233,7 @@ fn follow(m: &arb_depth[matchable], idx_path: @mutable vec[uint]) ->
233
233
}
234
234
235
235
fn follow_for_trans ( cx : & ext_ctxt , mmaybe : & option:: t [ arb_depth[ matchable ] ] ,
236
- idx_path : @mutable vec [ uint ] ) -> option:: t [ matchable ] {
236
+ idx_path : @mutable [ uint ] ) -> option:: t [ matchable ] {
237
237
alt mmaybe {
238
238
none. { ret none }
239
239
some ( m) {
@@ -271,7 +271,7 @@ iter free_vars(b: &bindings, e: @expr) -> ident {
271
271
272
272
273
273
/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
274
- fn transcribe_exprs ( cx : & ext_ctxt , b : & bindings , idx_path : @mutable vec [ uint ] ,
274
+ fn transcribe_exprs ( cx : & ext_ctxt , b : & bindings , idx_path : @mutable [ uint ] ,
275
275
recur : fn ( & @expr) -> @expr , exprs : [ @expr] )
276
276
-> [ @expr] {
277
277
alt elts_to_ell ( cx , exprs ) {
@@ -290,10 +290,10 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
290
290
seq ( ms, _) {
291
291
alt repeat {
292
292
none. {
293
- repeat = some ( { rep_count: vec :: len ( ms) , name: fv} ) ;
293
+ repeat = some ( { rep_count: ivec :: len ( * ms) , name: fv} ) ;
294
294
}
295
295
some ( { rep_count: old_len, name: old_name} ) {
296
- let len = vec :: len ( ms) ;
296
+ let len = ivec :: len ( * ms) ;
297
297
if old_len != len {
298
298
let msg = #fmt ( "'%s' occurs %u times, but " , fv,
299
299
len) + #fmt ( "'%s' occurs %u times" ,
@@ -315,9 +315,9 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
315
315
/* Whew, we now know how how many times to repeat */
316
316
let idx: uint = 0 u;
317
317
while idx < rc {
318
- vec :: push ( * idx_path, idx) ;
318
+ * idx_path += ~ [ idx] ;
319
319
res += ~[ recur ( repeat_me) ] ; // whew!
320
- vec :: pop ( * idx_path) ;
320
+ ivec :: pop ( * idx_path) ;
321
321
idx += 1 u;
322
322
}
323
323
}
@@ -332,7 +332,7 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
332
332
333
333
334
334
// substitute, in a position that's required to be an ident
335
- fn transcribe_ident( cx: & ext_ctxt, b: & bindings, idx_path: @mutable vec [ uint] ,
335
+ fn transcribe_ident( cx: & ext_ctxt, b: & bindings, idx_path: @mutable [ uint] ,
336
336
i: & ident, fld: ast_fold) -> ident {
337
337
ret alt follow_for_trans( cx, b. find ( i) , idx_path) {
338
338
some( match_ident( a_id) ) { a_id. node }
@@ -342,7 +342,7 @@ fn transcribe_ident(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
342
342
}
343
343
344
344
345
- fn transcribe_path( cx: & ext_ctxt, b: & bindings, idx_path: @mutable vec [ uint] ,
345
+ fn transcribe_path( cx: & ext_ctxt, b: & bindings, idx_path: @mutable [ uint] ,
346
346
p: & path_, fld: ast_fold) -> path_ {
347
347
// Don't substitute into qualified names.
348
348
if ivec:: len( p. types ) > 0 u || ivec:: len ( p. idents ) != 1 u { ret p; }
@@ -357,7 +357,7 @@ fn transcribe_path(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
357
357
}
358
358
359
359
360
- fn transcribe_expr( cx: & ext_ctxt, b: & bindings, idx_path: @mutable vec [ uint] ,
360
+ fn transcribe_expr( cx: & ext_ctxt, b: & bindings, idx_path: @mutable [ uint] ,
361
361
e: & ast:: expr_, fld: ast_fold,
362
362
orig: fn ( & ast:: expr_, ast_fold) -> ast:: expr_ ) ->
363
363
ast:: expr_ {
@@ -385,7 +385,7 @@ fn transcribe_expr(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
385
385
}
386
386
}
387
387
388
- fn transcribe_type( cx: & ext_ctxt, b: & bindings, idx_path: @mutable vec [ uint] ,
388
+ fn transcribe_type( cx: & ext_ctxt, b: & bindings, idx_path: @mutable [ uint] ,
389
389
t: & ast:: ty_, fld: ast_fold,
390
390
orig: fn ( & ast:: ty_, ast_fold) -> ast:: ty_ ) -> ast:: ty_ {
391
391
ret alt t {
@@ -409,7 +409,7 @@ fn transcribe_type(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
409
409
/* for parsing reasons, syntax variables bound to blocks must be used like
410
410
`{v}` */
411
411
412
- fn transcribe_block( cx: & ext_ctxt, b: & bindings, idx_path: @mutable vec [ uint] ,
412
+ fn transcribe_block( cx: & ext_ctxt, b: & bindings, idx_path: @mutable [ uint] ,
413
413
blk: & blk_, fld: ast_fold,
414
414
orig: fn ( & blk_, ast_fold) -> blk_ ) -> blk_ {
415
415
ret alt block_to_ident( blk) {
@@ -578,14 +578,6 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) {
578
578
}
579
579
}
580
580
581
- /* TODO: move this to vec.rs */
582
-
583
- fn ivec_to_vec[ T ] ( v: & [ T ] ) -> vec[ T ] {
584
- let rs: vec[ T ] = vec:: alloc[ T ] ( ivec:: len ( v) ) ;
585
- for ve: T in v { rs += [ ve] ; }
586
- ret rs;
587
- }
588
-
589
581
fn p_t_s_r_ellipses( cx: & ext_ctxt, repeat_me: @expr, offset : uint ,
590
582
s : & selector , b : & binders ) {
591
583
fn select ( cx : & ext_ctxt , repeat_me: @expr, offset : uint , m : & matchable ) ->
@@ -602,7 +594,7 @@ fn p_t_s_r_ellipses(cx: &ext_ctxt, repeat_me: @expr, offset: uint,
602
594
}
603
595
// using repeat_me.span is a little wacky, but the
604
596
// error we want to report is one in the macro def
605
- some ( seq ( elts, repeat_me. span ) )
597
+ some ( seq ( @ivec :: from_vec ( elts) , repeat_me. span ) )
606
598
}
607
599
_ { none }
608
600
}
0 commit comments