Skip to content

Commit 8c88155

Browse files
committed
---
yaml --- r: 4581 b: refs/heads/master c: b32889d h: refs/heads/master i: 4579: d461bde v: v3
1 parent 0cef1a9 commit 8c88155

File tree

2 files changed

+22
-30
lines changed

2 files changed

+22
-30
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: f195814df3209f57e31a9c3e42a08d0ea32e6f44
2+
refs/heads/master: b32889d82c959642d1595cf588ec75d76e6fa142

trunk/src/comp/syntax/ext/simplext.rs

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn path_to_ident(pth: &path) -> option::t[ident] {
4545
type clause = {params: binders, body: @expr};
4646

4747
/* 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); }
4949

5050

5151
tag matchable {
@@ -118,11 +118,11 @@ fn elts_to_ell(cx: &ext_ctxt, elts: &[@expr])
118118
ret {fixed: elts, rep: none};
119119
}
120120

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 = ~[];
124124
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]; } }
126126
}
127127
ret some(res);
128128
}
@@ -131,9 +131,9 @@ fn a_d_map(ad: &arb_depth[matchable], f: &selector) -> match_result {
131131
alt ad {
132132
leaf(x) { ret f(x); }
133133
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) {
135135
none. { ret none; }
136-
some(ts) { ret some(seq(ts, span)); }
136+
some(ts) { ret some(seq(@ts, span)); }
137137
}
138138
}
139139
}
@@ -200,7 +200,7 @@ fn use_selectors_to_bind(b: &binders, e: @expr) -> option::t[bindings] {
200200
/* use the bindings on the body to generate the expanded code */
201201

202202
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 ~[];
204204
let afp = default_ast_fold();
205205
let f_pre =
206206
{fold_ident: bind transcribe_ident(cx, b, idx_path, _, _),
@@ -220,7 +220,7 @@ fn transcribe(cx: &ext_ctxt, b: &bindings, body: @expr) -> @expr {
220220

221221

222222
/* 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]) ->
224224
arb_depth[matchable] {
225225
let res: arb_depth[matchable] = m;
226226
for idx: uint in *idx_path {
@@ -233,7 +233,7 @@ fn follow(m: &arb_depth[matchable], idx_path: @mutable vec[uint]) ->
233233
}
234234

235235
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] {
237237
alt mmaybe {
238238
none. { ret none }
239239
some(m) {
@@ -271,7 +271,7 @@ iter free_vars(b: &bindings, e: @expr) -> ident {
271271

272272

273273
/* 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],
275275
recur: fn(&@expr) -> @expr , exprs: [@expr])
276276
-> [@expr] {
277277
alt elts_to_ell(cx, exprs) {
@@ -290,10 +290,10 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
290290
seq(ms, _) {
291291
alt repeat {
292292
none. {
293-
repeat = some({rep_count: vec::len(ms), name: fv});
293+
repeat = some({rep_count: ivec::len(*ms), name: fv});
294294
}
295295
some({rep_count: old_len, name: old_name}) {
296-
let len = vec::len(ms);
296+
let len = ivec::len(*ms);
297297
if old_len != len {
298298
let msg = #fmt("'%s' occurs %u times, but ", fv,
299299
len) + #fmt("'%s' occurs %u times",
@@ -315,9 +315,9 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
315315
/* Whew, we now know how how many times to repeat */
316316
let idx: uint = 0u;
317317
while idx < rc {
318-
vec::push(*idx_path, idx);
318+
*idx_path += ~[idx];
319319
res += ~[recur(repeat_me)]; // whew!
320-
vec::pop(*idx_path);
320+
ivec::pop(*idx_path);
321321
idx += 1u;
322322
}
323323
}
@@ -332,7 +332,7 @@ fn transcribe_exprs(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
332332

333333

334334
// 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],
336336
i: &ident, fld: ast_fold) -> ident {
337337
ret alt follow_for_trans(cx, b.find(i), idx_path) {
338338
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],
342342
}
343343

344344

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],
346346
p: &path_, fld: ast_fold) -> path_ {
347347
// Don't substitute into qualified names.
348348
if ivec::len(p.types) > 0u || ivec::len(p.idents) != 1u { ret p; }
@@ -357,7 +357,7 @@ fn transcribe_path(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
357357
}
358358

359359

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],
361361
e: &ast::expr_, fld: ast_fold,
362362
orig: fn(&ast::expr_, ast_fold) -> ast::expr_ ) ->
363363
ast::expr_ {
@@ -385,7 +385,7 @@ fn transcribe_expr(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
385385
}
386386
}
387387

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],
389389
t: &ast::ty_, fld: ast_fold,
390390
orig: fn(&ast::ty_, ast_fold) -> ast::ty_ ) -> ast::ty_ {
391391
ret alt t {
@@ -409,7 +409,7 @@ fn transcribe_type(cx: &ext_ctxt, b: &bindings, idx_path: @mutable vec[uint],
409409
/* for parsing reasons, syntax variables bound to blocks must be used like
410410
`{v}` */
411411

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],
413413
blk: &blk_, fld: ast_fold,
414414
orig: fn(&blk_, ast_fold) -> blk_ ) -> blk_ {
415415
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) {
578578
}
579579
}
580580

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-
589581
fn p_t_s_r_ellipses(cx: &ext_ctxt, repeat_me: @expr, offset: uint,
590582
s: &selector, b: &binders) {
591583
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,
602594
}
603595
// using repeat_me.span is a little wacky, but the
604596
// 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))
606598
}
607599
_ { none }
608600
}

0 commit comments

Comments
 (0)