Skip to content

Commit 573a243

Browse files
author
James Miller
committed
---
yaml --- r: 55999 b: refs/heads/auto c: cd41ee2 h: refs/heads/master i: 55997: 3978593 55995: c0bc99e 55991: 085407e 55983: 8d55c53 55967: 1055d32 55935: e5e8a47 v: v3
1 parent 0d3dd38 commit 573a243

39 files changed

+843
-1309
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: e8cd29ba5ecae71cfde24d2e652b50acf63ea155
17+
refs/heads/auto: cd41ee2044c48c2948969ab9f28e3fd8063ba450
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libcore/num/int-template.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,15 @@ pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) {
107107
} else if step > 0 { // ascending
108108
while i < stop {
109109
if !it(i) { break }
110+
// avoiding overflow. break if i + step > max_value
111+
if i > max_value - step { break; }
110112
i += step;
111113
}
112114
} else { // descending
113115
while i > stop {
114116
if !it(i) { break }
117+
// avoiding underflow. break if i + step < min_value
118+
if i < min_value - step { break; }
115119
i += step;
116120
}
117121
}
@@ -421,10 +425,26 @@ pub fn test_ranges() {
421425
for range_step(36,30,-2) |i| {
422426
l.push(i);
423427
}
424-
assert!(l == ~[0,1,2,
425-
13,12,11,
426-
20,22,24,
427-
36,34,32]);
428+
for range_step(max_value - 2, max_value, 2) |i| {
429+
l.push(i);
430+
}
431+
for range_step(max_value - 3, max_value, 2) |i| {
432+
l.push(i);
433+
}
434+
for range_step(min_value + 2, min_value, -2) |i| {
435+
l.push(i);
436+
}
437+
for range_step(min_value + 3, min_value, -2) |i| {
438+
l.push(i);
439+
}
440+
assert_eq!(l, ~[0,1,2,
441+
13,12,11,
442+
20,22,24,
443+
36,34,32,
444+
max_value-2,
445+
max_value-3,max_value-1,
446+
min_value+2,
447+
min_value+3,min_value+1]);
428448
429449
// None of the `fail`s should execute.
430450
for range(10,0) |_i| {

branches/auto/src/libcore/num/uint-template.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ pub fn range_step(start: T,
7878
if step >= 0 {
7979
while i < stop {
8080
if !it(i) { break }
81+
// avoiding overflow. break if i + step > max_value
82+
if i > max_value - (step as T) { break; }
8183
i += step as T;
8284
}
83-
}
84-
else {
85+
} else {
8586
while i > stop {
8687
if !it(i) { break }
88+
// avoiding underflow. break if i + step < min_value
89+
if i < min_value + ((-step) as T) { break; }
8790
i -= -step as T;
8891
}
8992
}
@@ -371,11 +374,27 @@ pub fn test_ranges() {
371374
for range_step(36,30,-2) |i| {
372375
l.push(i);
373376
}
377+
for range_step(max_value - 2, max_value, 2) |i| {
378+
l.push(i);
379+
}
380+
for range_step(max_value - 3, max_value, 2) |i| {
381+
l.push(i);
382+
}
383+
for range_step(min_value + 2, min_value, -2) |i| {
384+
l.push(i);
385+
}
386+
for range_step(min_value + 3, min_value, -2) |i| {
387+
l.push(i);
388+
}
374389
375-
assert!(l == ~[0,1,2,
376-
13,12,11,
377-
20,22,24,
378-
36,34,32]);
390+
assert_eq!(l, ~[0,1,2,
391+
13,12,11,
392+
20,22,24,
393+
36,34,32,
394+
max_value-2,
395+
max_value-3,max_value-1,
396+
min_value+2,
397+
min_value+3,min_value+1]);
379398
380399
// None of the `fail`s should execute.
381400
for range(0,0) |_i| {

branches/auto/src/librustc/driver/driver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,8 @@ pub fn build_session_(sopts: @session::options,
698698
parse_sess: p_s,
699699
codemap: cm,
700700
// For a library crate, this is always none
701-
main_fn: @mut None,
701+
entry_fn: @mut None,
702+
entry_type: @mut None,
702703
span_diagnostic: span_diagnostic_handler,
703704
filesearch: filesearch,
704705
building_library: @mut false,

branches/auto/src/librustc/driver/session.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,25 @@ pub struct crate_metadata {
144144
data: ~[u8]
145145
}
146146

147+
// The type of entry function, so
148+
// users can have their own entry
149+
// functions that don't start a
150+
// scheduler
151+
#[deriving(Eq)]
152+
pub enum EntryFnType {
153+
EntryMain,
154+
EntryStart
155+
}
156+
147157
pub struct Session_ {
148158
targ_cfg: @config,
149159
opts: @options,
150160
cstore: @mut metadata::cstore::CStore,
151161
parse_sess: @mut ParseSess,
152162
codemap: @codemap::CodeMap,
153163
// For a library crate, this is always none
154-
main_fn: @mut Option<(node_id, codemap::span)>,
164+
entry_fn: @mut Option<(node_id, codemap::span)>,
165+
entry_type: @mut Option<EntryFnType>,
155166
span_diagnostic: @diagnostic::span_handler,
156167
filesearch: @filesearch::FileSearch,
157168
building_library: @mut bool,

branches/auto/src/librustc/metadata/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f
127127
tag_table_node_type_subst = 0x58,
128128
tag_table_freevars = 0x59,
129129
tag_table_tcache = 0x5a,
130-
tag_table_param_defs = 0x5b,
130+
tag_table_param_bounds = 0x5b,
131131
tag_table_inferred_modes = 0x5c,
132132
tag_table_mutbl = 0x5d,
133133
tag_table_last_use = 0x5e,

branches/auto/src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
210210
debug!("got field data %?", the_field);
211211
let ty = decoder::item_type(def, the_field, tcx, cdata);
212212
ty::ty_param_bounds_and_ty {
213-
generics: ty::Generics {type_param_defs: @~[],
213+
generics: ty::Generics {bounds: @~[],
214214
region_param: None},
215215
ty: ty
216216
}

branches/auto/src/librustc/metadata/decoder.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo};
1919
use metadata::csearch;
2020
use metadata::cstore;
2121
use metadata::decoder;
22-
use metadata::tydecode::{parse_ty_data, parse_def_id,
23-
parse_type_param_def_data,
22+
use metadata::tydecode::{parse_ty_data, parse_def_id, parse_bounds_data,
2423
parse_bare_fn_ty_data, parse_trait_ref_data};
2524
use middle::{ty, resolve};
2625

@@ -267,14 +266,13 @@ fn item_trait_ref(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::TraitRef {
267266
doc_trait_ref(tp, tcx, cdata)
268267
}
269268
270-
fn item_ty_param_defs(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd,
271-
tag: uint)
272-
-> @~[ty::TypeParameterDef] {
269+
fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd,
270+
tag: uint)
271+
-> @~[ty::param_bounds] {
273272
let mut bounds = ~[];
274273
for reader::tagged_docs(item, tag) |p| {
275-
let bd = parse_type_param_def_data(
276-
p.data, p.start, cdata.cnum, tcx,
277-
|_, did| translate_def_id(cdata, did));
274+
let bd = parse_bounds_data(p.data, p.start, cdata.cnum, tcx,
275+
|_, did| translate_def_id(cdata, did));
278276
bounds.push(bd);
279277
}
280278
@bounds
@@ -380,11 +378,11 @@ pub fn get_trait_def(cdata: cmd,
380378
tcx: ty::ctxt) -> ty::TraitDef
381379
{
382380
let item_doc = lookup_item(item_id, cdata.data);
383-
let tp_defs = item_ty_param_defs(item_doc, tcx, cdata,
384-
tag_items_data_item_ty_param_bounds);
381+
let tp_bounds = item_ty_param_bounds(item_doc, tcx, cdata,
382+
tag_items_data_item_ty_param_bounds);
385383
let rp = item_ty_region_param(item_doc);
386384
ty::TraitDef {
387-
generics: ty::Generics {type_param_defs: tp_defs,
385+
generics: ty::Generics {bounds: tp_bounds,
388386
region_param: rp},
389387
trait_ref: @item_trait_ref(item_doc, tcx, cdata)
390388
}
@@ -396,12 +394,12 @@ pub fn get_type(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
396394
let item = lookup_item(id, cdata.data);
397395
let t = item_type(ast::def_id { crate: cdata.cnum, node: id }, item, tcx,
398396
cdata);
399-
let tp_defs = if family_has_type_params(item_family(item)) {
400-
item_ty_param_defs(item, tcx, cdata, tag_items_data_item_ty_param_bounds)
397+
let tp_bounds = if family_has_type_params(item_family(item)) {
398+
item_ty_param_bounds(item, tcx, cdata, tag_items_data_item_ty_param_bounds)
401399
} else { @~[] };
402400
let rp = item_ty_region_param(item);
403401
ty::ty_param_bounds_and_ty {
404-
generics: ty::Generics {type_param_defs: tp_defs,
402+
generics: ty::Generics {bounds: tp_bounds,
405403
region_param: rp},
406404
ty: t
407405
}
@@ -755,16 +753,17 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
755753
let method_doc = lookup_item(id, cdata.data);
756754
let def_id = item_def_id(method_doc, cdata);
757755
let name = item_name(intr, method_doc);
758-
let type_param_defs = item_ty_param_defs(method_doc, tcx, cdata,
759-
tag_item_method_tps);
756+
let bounds =
757+
item_ty_param_bounds(method_doc, tcx, cdata,
758+
tag_item_method_tps);
760759
let transformed_self_ty = doc_transformed_self_ty(method_doc, tcx, cdata);
761760
let fty = doc_method_fty(method_doc, tcx, cdata);
762761
let vis = item_visibility(method_doc);
763762
let self_ty = get_self_ty(method_doc);
764763
ty::method {
765764
ident: name,
766765
generics: ty::Generics {
767-
type_param_defs: type_param_defs,
766+
bounds: bounds,
768767
region_param: None
769768
},
770769
transformed_self_ty: transformed_self_ty,
@@ -798,9 +797,8 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
798797

799798
let did = item_def_id(mth, cdata);
800799

801-
let type_param_defs =
802-
item_ty_param_defs(mth, tcx, cdata,
803-
tag_items_data_item_ty_param_bounds);
800+
let bounds = item_ty_param_bounds(mth, tcx, cdata,
801+
tag_items_data_item_ty_param_bounds);
804802
let name = item_name(intr, mth);
805803
let ty = doc_type(mth, tcx, cdata);
806804

@@ -817,7 +815,7 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
817815
let ty_method = ty::method {
818816
ident: name,
819817
generics: ty::Generics {
820-
type_param_defs: type_param_defs,
818+
bounds: bounds,
821819
region_param: None
822820
},
823821
transformed_self_ty: transformed_self_ty,

branches/auto/src/librustc/metadata/encoder.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ fn encode_family(ebml_w: writer::Encoder, c: char) {
179179

180180
pub fn def_to_str(did: def_id) -> ~str { fmt!("%d:%d", did.crate, did.node) }
181181

182-
fn encode_ty_type_param_defs(ebml_w: writer::Encoder,
183-
ecx: @EncodeContext,
184-
params: @~[ty::TypeParameterDef],
185-
tag: uint) {
182+
fn encode_ty_type_param_bounds(ebml_w: writer::Encoder,
183+
ecx: @EncodeContext,
184+
params: @~[ty::param_bounds],
185+
tag: uint) {
186186
let ty_str_ctxt = @tyencode::ctxt {
187187
diag: ecx.diag,
188188
ds: def_to_str,
@@ -191,18 +191,18 @@ fn encode_ty_type_param_defs(ebml_w: writer::Encoder,
191191
abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)};
192192
for params.each |param| {
193193
ebml_w.start_tag(tag);
194-
tyencode::enc_type_param_def(ebml_w.writer, ty_str_ctxt, param);
194+
tyencode::enc_bounds(ebml_w.writer, ty_str_ctxt, *param);
195195
ebml_w.end_tag();
196196
}
197197
}
198198

199199
fn encode_type_param_bounds(ebml_w: writer::Encoder,
200200
ecx: @EncodeContext,
201201
params: &OptVec<TyParam>) {
202-
let ty_param_defs =
203-
@params.map_to_vec(|param| *ecx.tcx.ty_param_defs.get(&param.id));
204-
encode_ty_type_param_defs(ebml_w, ecx, ty_param_defs,
205-
tag_items_data_item_ty_param_bounds);
202+
let ty_param_bounds =
203+
@params.map_to_vec(|param| *ecx.tcx.ty_param_bounds.get(&param.id));
204+
encode_ty_type_param_bounds(ebml_w, ecx, ty_param_bounds,
205+
tag_items_data_item_ty_param_bounds);
206206
}
207207

208208

@@ -588,9 +588,8 @@ fn encode_method_ty_fields(ecx: @EncodeContext,
588588
{
589589
encode_def_id(ebml_w, method_ty.def_id);
590590
encode_name(ecx, ebml_w, method_ty.ident);
591-
encode_ty_type_param_defs(ebml_w, ecx,
592-
method_ty.generics.type_param_defs,
593-
tag_item_method_tps);
591+
encode_ty_type_param_bounds(ebml_w, ecx, method_ty.generics.bounds,
592+
tag_item_method_tps);
594593
encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty);
595594
encode_method_fty(ecx, ebml_w, &method_ty.fty);
596595
encode_visibility(ebml_w, method_ty.vis);
@@ -953,9 +952,8 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
953952
method_ty.fty.purity));
954953
955954
let tpt = ty::lookup_item_type(tcx, method_def_id);
956-
encode_ty_type_param_defs(ebml_w, ecx,
957-
tpt.generics.type_param_defs,
958-
tag_items_data_item_ty_param_bounds);
955+
encode_ty_type_param_bounds(ebml_w, ecx, tpt.generics.bounds,
956+
tag_items_data_item_ty_param_bounds);
959957
encode_type(ecx, ebml_w, tpt.ty);
960958
}
961959

branches/auto/src/librustc/metadata/tydecode.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,17 +547,11 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
547547
ast::def_id { crate: crate_num, node: def_num }
548548
}
549549
550-
pub fn parse_type_param_def_data(data: @~[u8], start: uint,
551-
crate_num: int, tcx: ty::ctxt,
552-
conv: conv_did) -> ty::TypeParameterDef
553-
{
550+
pub fn parse_bounds_data(data: @~[u8], start: uint,
551+
crate_num: int, tcx: ty::ctxt, conv: conv_did)
552+
-> @~[ty::param_bound] {
554553
let st = parse_state_from_data(data, crate_num, start, tcx);
555-
parse_type_param_def(st, conv)
556-
}
557-
558-
fn parse_type_param_def(st: @mut PState, conv: conv_did) -> ty::TypeParameterDef {
559-
ty::TypeParameterDef {def_id: parse_def(st, NominalType, conv),
560-
bounds: parse_bounds(st, conv)}
554+
parse_bounds(st, conv)
561555
}
562556
563557
fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] {

branches/auto/src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
412412
enc_ty(w, cx, fsig.output);
413413
}
414414

415-
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
415+
pub fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
416416
for vec::each(*bs) |bound| {
417417
match *bound {
418418
ty::bound_owned => w.write_char('S'),
@@ -428,12 +428,6 @@ fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
428428
w.write_char('.');
429429
}
430430

431-
pub fn enc_type_param_def(w: @io::Writer, cx: @ctxt, v: &ty::TypeParameterDef) {
432-
w.write_str((cx.ds)(v.def_id));
433-
w.write_char('|');
434-
enc_bounds(w, cx, v.bounds);
435-
}
436-
437431
//
438432
// Local Variables:
439433
// mode: rust

0 commit comments

Comments
 (0)