Skip to content

Commit 3152c90

Browse files
author
Elliott Slaughter
committed
---
yaml --- r: 22692 b: refs/heads/master c: c341eb9 h: refs/heads/master v: v3
1 parent ebf07f5 commit 3152c90

File tree

16 files changed

+80
-117
lines changed

16 files changed

+80
-117
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9103e439091fbd4e5ec7e561f007172342065340
2+
refs/heads/master: c341eb90522294dda6dbce646d1c0a7170a48bfc
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/core.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ import str::{extensions, str_slice, unique_str};
1010
import vec::extensions;
1111
import vec::{const_vector, copyable_vector, immutable_vector};
1212
import vec::{immutable_copyable_vector, iter_trait_extensions, vec_concat};
13-
import iter::{base_iter, extended_iter, copyable_iter, times, timesi};
13+
import iter::{base_iter, extended_iter, copyable_iter, times};
1414
import option::extensions;
1515
import option_iter::extensions;
1616
import ptr::{extensions, ptr};
1717
import rand::extensions;
1818
import result::extensions;
19-
import int::{num, times, timesi};
20-
import i8::{num, times, timesi};
21-
import i16::{num, times, timesi};
22-
import i32::{num, times, timesi};
23-
import i64::{num, times, timesi};
24-
import uint::{num, times, timesi};
25-
import u8::{num, times, timesi};
26-
import u16::{num, times, timesi};
27-
import u32::{num, times, timesi};
28-
import u64::{num, times, timesi};
19+
import int::{num, times};
20+
import i8::{num, times};
21+
import i16::{num, times};
22+
import i32::{num, times};
23+
import i64::{num, times};
24+
import uint::{num, times};
25+
import u8::{num, times};
26+
import u16::{num, times};
27+
import u32::{num, times};
28+
import u64::{num, times};
2929
import float::num;
3030
import f32::num;
3131
import f64::num;
@@ -34,7 +34,7 @@ import num::num;
3434
export path, option, some, none, unreachable;
3535
export extensions;
3636
// The following exports are the extension impls for numeric types
37-
export num, times, timesi;
37+
export num, times;
3838
// The following exports are the common traits
3939
export str_slice, unique_str;
4040
export const_vector, copyable_vector, immutable_vector;

trunk/src/libcore/int-template.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export range;
1111
export compl;
1212
export abs;
1313
export parse_buf, from_str, to_str, to_str_bytes, str;
14-
export num, ord, eq, times, timesi;
14+
export num, ord, eq, times;
1515

1616
const min_value: T = -1 as T << (inst::bits - 1 as T);
1717
const max_value: T = min_value - 1 as T;
@@ -155,23 +155,6 @@ impl times of iter::times for T {
155155
}
156156
}
157157

158-
impl timesi of iter::timesi for T {
159-
#[inline(always)]
160-
/// Like `times`, but provides an index
161-
fn timesi(it: fn(uint) -> bool) {
162-
let slf = self as uint;
163-
if slf < 0u {
164-
fail #fmt("The .timesi method expects a nonnegative number, \
165-
but found %?", self);
166-
}
167-
let mut i = 0u;
168-
while i < slf {
169-
if !it(i) { break }
170-
i += 1u;
171-
}
172-
}
173-
}
174-
175158
// FIXME: Has alignment issues on windows and 32-bit linux (#2609)
176159
#[test]
177160
#[ignore]

trunk/src/libcore/iter.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ trait extended_iter<A> {
1616
iface times {
1717
fn times(it: fn() -> bool);
1818
}
19-
iface timesi{
20-
fn timesi(it: fn(uint) -> bool);
21-
}
2219

2320
trait copyable_iter<A:copy> {
2421
fn filter_to_vec(pred: fn(A) -> bool) -> ~[A];

trunk/src/libcore/rt.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
3737
ret rustrt::rust_upcall_exchange_malloc(td, size);
3838
}
3939

40+
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
41+
// inside a landing pad may corrupt the state of the exception handler. If a
42+
// problem occurs, call exit instead.
4043
#[rt(exchange_free)]
4144
fn rt_exchange_free(ptr: *c_char) {
4245
rustrt::rust_upcall_exchange_free(ptr);
@@ -47,6 +50,9 @@ fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char {
4750
ret rustrt::rust_upcall_malloc(td, size);
4851
}
4952

53+
// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from
54+
// inside a landing pad may corrupt the state of the exception handler. If a
55+
// problem occurs, call exit instead.
5056
#[rt(free)]
5157
fn rt_free(ptr: *c_char) {
5258
rustrt::rust_upcall_free(ptr);

trunk/src/libcore/uint-template.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export range;
1111
export compl;
1212
export to_str, to_str_bytes;
1313
export from_str, from_str_radix, str, parse_buf;
14-
export num, ord, eq, times, timesi;
14+
export num, ord, eq, times;
1515

1616
const min_value: T = 0 as T;
1717
const max_value: T = 0 as T - 1 as T;
@@ -120,19 +120,6 @@ impl times of iter::times for T {
120120
}
121121
}
122122

123-
impl timesi of iter::timesi for T {
124-
#[inline(always)]
125-
/// Like `times`, but with an index, `eachi`-style.
126-
fn timesi(it: fn(uint) -> bool) {
127-
let slf = self as uint;
128-
let mut i = 0u;
129-
while i < slf {
130-
if !it(i) { break }
131-
i += 1u;
132-
}
133-
}
134-
}
135-
136123
/// Parse a string to an int
137124
fn from_str(s: ~str) -> option<T> { parse_buf(str::bytes(s), 10u) }
138125

trunk/src/libsyntax/ast.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,8 @@ type matcher = spanned<matcher_>;
378378
enum matcher_ {
379379
/* match one token */
380380
mtc_tok(token::token),
381-
/* match repetitions of a sequence: body, separator, zero ok?,
382-
lo, hi position-in-match-array used: */
383-
mtc_rep(~[matcher], option<token::token>, bool, uint, uint),
381+
/* match repetitions of a sequence: body, separator, zero ok? : */
382+
mtc_rep(~[matcher], option<token::token>, bool),
384383
/* parse a Rust NT: name to bind, name of NT, position in match array : */
385384
mtc_bb(ident, ident, uint)
386385
}

trunk/src/libsyntax/ext/tt/earley_parser.rs

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type matcher_pos = ~{
4141
mut idx: uint,
4242
mut up: matcher_pos_up, // mutable for swapping only
4343
matches: ~[dvec<@arb_depth>],
44-
match_lo: uint, match_hi: uint,
4544
sp_lo: uint,
4645
};
4746

@@ -56,25 +55,17 @@ fn count_names(ms: &[matcher]) -> uint {
5655
vec::foldl(0u, ms, |ct, m| {
5756
ct + alt m.node {
5857
mtc_tok(_) { 0u }
59-
mtc_rep(more_ms, _, _, _, _) { count_names(more_ms) }
58+
mtc_rep(more_ms, _, _) { count_names(more_ms) }
6059
mtc_bb(_,_,_) { 1u }
6160
}})
6261
}
6362

6463
#[warn(no_non_implicitly_copyable_typarams)]
65-
fn initial_matcher_pos(ms: ~[matcher], sep: option<token>, lo: uint)
64+
fn new_matcher_pos(ms: ~[matcher], sep: option<token>, lo: uint)
6665
-> matcher_pos {
67-
let mut match_idx_hi = 0u;
68-
for ms.each() |elt| {
69-
alt elt.node {
70-
mtc_tok(_) {}
71-
mtc_rep(_,_,_,_,hi) { match_idx_hi = hi; } //it is monotonic...
72-
mtc_bb(_,_,pos) { match_idx_hi = pos+1u; } //...so latest is highest
73-
}
74-
}
7566
~{elts: ms, sep: sep, mut idx: 0u, mut up: matcher_pos_up(none),
7667
matches: copy vec::from_fn(count_names(ms), |_i| dvec::dvec()),
77-
match_lo: 0u, match_hi: match_idx_hi, sp_lo: lo}
68+
sp_lo: lo}
7869
}
7970

8071
/* logically, an arb_depth should contain only one kind of nonterminal */
@@ -88,7 +79,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@arb_depth])
8879
ret_val: hashmap<ident, @arb_depth>) {
8980
alt m {
9081
{node: mtc_tok(_), span: _} { }
91-
{node: mtc_rep(more_ms, _, _, _, _), span: _} {
82+
{node: mtc_rep(more_ms, _, _), span: _} {
9283
for more_ms.each() |next_m| { n_rec(p_s, next_m, res, ret_val) };
9384
}
9485
{node: mtc_bb(bind_name, _, idx), span: sp} {
@@ -113,7 +104,7 @@ enum parse_result {
113104
fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
114105
-> parse_result {
115106
let mut cur_eis = ~[];
116-
vec::push(cur_eis, initial_matcher_pos(ms, none, rdr.peek().sp.lo));
107+
vec::push(cur_eis, new_matcher_pos(ms, none, rdr.peek().sp.lo));
117108
118109
loop {
119110
let mut bb_eis = ~[]; // black-box parsed by parser.rs
@@ -150,10 +141,10 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
150141
// I bet this is a perf problem: we're preemptively
151142
// doing a lot of array work that will get thrown away
152143
// most of the time.
153-
154-
// Only touch the binders we have actually bound
155-
for uint::range(ei.match_lo, ei.match_hi) |idx| {
156-
let sub = ei.matches[idx].get();
144+
for ei.matches.eachi() |idx, elt| {
145+
let sub = elt.get();
146+
// Some subtrees don't contain the name at all
147+
if sub.len() == 0u { again; }
157148
new_pos.matches[idx]
158149
.push(@seq(sub, mk_sp(ei.sp_lo,sp.hi)));
159150
}
@@ -185,15 +176,10 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
185176
} else {
186177
alt copy ei.elts[idx].node {
187178
/* need to descend into sequence */
188-
mtc_rep(matchers, sep, zero_ok, match_idx_lo, match_idx_hi){
179+
mtc_rep(matchers, sep, zero_ok) {
189180
if zero_ok {
190181
let new_ei = copy ei;
191182
new_ei.idx += 1u;
192-
//we specifically matched zero repeats.
193-
for uint::range(match_idx_lo, match_idx_hi) |idx| {
194-
new_ei.matches[idx].push(@seq(~[], sp));
195-
}
196-
197183
vec::push(cur_eis, new_ei);
198184
}
199185

@@ -203,9 +189,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
203189
vec::push(cur_eis, ~{
204190
elts: matchers, sep: sep, mut idx: 0u,
205191
mut up: matcher_pos_up(some(ei_t)),
206-
matches: matches,
207-
match_lo: match_idx_lo, match_hi: match_idx_hi,
208-
sp_lo: sp.lo
192+
matches: matches, sp_lo: sp.lo
209193
});
210194
}
211195
mtc_bb(_,_,_) { vec::push(bb_eis, ei) }
@@ -232,11 +216,9 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher])
232216
if (bb_eis.len() > 0u && next_eis.len() > 0u)
233217
|| bb_eis.len() > 1u {
234218
let nts = str::connect(vec::map(bb_eis, |ei| {
235-
alt ei.elts[ei.idx].node {
236-
mtc_bb(bind,name,_) {
237-
#fmt["%s ('%s')", *name, *bind]
238-
}
239-
_ { fail; } } }), ~" or ");
219+
alt ei.elts[ei.idx].node
220+
{ mtc_bb(_,name,_) { *name } _ { fail; } }
221+
}), ~" or ");
240222
ret failure(sp, #fmt[
241223
"Local ambiguity: multiple parsing options: \
242224
built-in NTs %s or %u other options.",

trunk/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
2121
ms(mtc_bb(@~"lhs",@~"mtcs", 0u)),
2222
ms(mtc_tok(FAT_ARROW)),
2323
ms(mtc_bb(@~"rhs",@~"tt", 1u)),
24-
], some(SEMI), false, 0u, 2u))];
24+
], some(SEMI), false))];
2525

2626
let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic,
2727
cx.parse_sess().interner, none, arg);

trunk/src/libsyntax/ext/tt/transcribe.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn lockstep_iter_size(&&t: token_tree, &&r: tt_reader) -> lis {
133133

134134
fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} {
135135
let ret_val = { tok: r.cur_tok, sp: r.cur_span };
136-
while r.cur.idx >= r.cur.readme.len() {
136+
while r.cur.idx >= vec::len(r.cur.readme) {
137137
/* done with this set; pop or repeat? */
138138
if ! r.cur.dotdotdoted
139139
|| r.repeat_idx.last() == r.repeat_len.last() - 1 {
@@ -191,21 +191,20 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} {
191191
r.sp_diag.span_fatal(sp, msg);
192192
}
193193
lis_constraint(len, _) {
194+
vec::push(r.repeat_len, len);
195+
vec::push(r.repeat_idx, 0u);
196+
r.cur = @{readme: tts, mut idx: 0u, dotdotdoted: true,
197+
sep: sep, up: tt_frame_up(option::some(r.cur)) };
198+
194199
if len == 0 {
195200
if !zerok {
196201
r.sp_diag.span_fatal(sp, /* FIXME #2887 blame invoker
197202
*/
198203
~"this must repeat at least \
199204
once");
200205
}
201-
202-
r.cur.idx += 1u;
206+
/* we need to pop before we proceed, so recur */
203207
ret tt_next_token(r);
204-
} else {
205-
vec::push(r.repeat_len, len);
206-
vec::push(r.repeat_idx, 0u);
207-
r.cur = @{readme: tts, mut idx: 0u, dotdotdoted: true,
208-
sep: sep, up: tt_frame_up(option::some(r.cur))};
209208
}
210209
}
211210
}

trunk/src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,14 +1194,13 @@ class parser {
11941194
let m = if self.token == token::DOLLAR {
11951195
self.bump();
11961196
if self.token == token::LPAREN {
1197-
let name_idx_lo = *name_idx;
11981197
let ms = self.parse_matcher_subseq(name_idx, token::LPAREN,
11991198
token::RPAREN);
12001199
if ms.len() == 0u {
12011200
self.fatal(~"repetition body must be nonempty");
12021201
}
12031202
let (sep, zerok) = self.parse_sep_and_zerok();
1204-
mtc_rep(ms, sep, zerok, name_idx_lo, *name_idx)
1203+
mtc_rep(ms, sep, zerok)
12051204
} else {
12061205
let bound_to = self.parse_ident();
12071206
self.expect(token::COLON);

0 commit comments

Comments
 (0)