Skip to content

Commit 23eab43

Browse files
committed
---
yaml --- r: 36255 b: refs/heads/try2 c: 1ead8aa h: refs/heads/master i: 36253: 138f986 36251: e35b525 36247: 7bbe71d 36239: 94f3be7 36223: a3f1ef5 v: v3
1 parent 92560d7 commit 23eab43

29 files changed

+410
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 37ed7fcaae1477cd85985886b5f8a4514bf98d0e
8+
refs/heads/try2: 1ead8aa0b583b43ac0c8cafe9ab6d9f9d2537f88
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/libcore/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
8787

8888
pub pure fn expect<T>(opt: Option<T>, reason: ~str) -> T {
8989
/*!
90-
* Gets the value out of an option without copying, printing a
90+
* Gets the value out of an option without copying, printing a
9191
* specified message on failure.
9292
*
9393
* # Failure

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ fn get_type_param_count(cstore: cstore::CStore, def: ast::def_id) -> uint {
6363
fn each_path(cstore: cstore::CStore, cnum: ast::crate_num,
6464
f: fn(decoder::path_entry) -> bool) {
6565
let crate_data = cstore::get_crate_data(cstore, cnum);
66-
decoder::each_path(cstore.intr, crate_data, f);
66+
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
67+
cstore::get_crate_data(cstore, cnum)
68+
};
69+
decoder::each_path(cstore.intr, crate_data, get_crate_data, f);
6770
}
6871

6972
fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path {

branches/try2/src/librustc/metadata/cstore.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ fn get_crate_vers(cstore: CStore, cnum: ast::crate_num) -> ~str {
9898
fn set_crate_data(cstore: CStore, cnum: ast::crate_num,
9999
data: crate_metadata) {
100100
p(cstore).metas.insert(cnum, data);
101-
for vec::each(decoder::get_crate_module_paths(cstore.intr, data)) |dp| {
101+
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
102+
cstore::get_crate_data(cstore, cnum)
103+
};
104+
for vec::each(decoder::get_crate_module_paths(cstore.intr, data,
105+
get_crate_data)) |dp| {
102106
let (did, path) = *dp;
103107
let d = {crate: cnum, node: did.node};
104108
p(cstore).mod_path_map.insert(d, @path);

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export item_type; // sketchy
6060
export maybe_get_item_ast;
6161
export decode_inlined_item;
6262
export method_info, _impl;
63+
export GetCrateDataCb;
6364

6465
// Used internally by astencode:
6566
export translate_def_id;
@@ -88,6 +89,8 @@ fn lookup_hash(d: ebml::Doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
8889
None
8990
}
9091

92+
pub type GetCrateDataCb = &fn(ast::crate_num) -> cmd;
93+
9194
fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
9295
fn eq_item(bytes: &[u8], item_id: int) -> bool {
9396
return io::u64_from_be_bytes(vec::view(bytes, 0u, 4u), 0u, 4u) as int
@@ -477,7 +480,9 @@ fn path_entry(path_string: ~str, def_like: def_like) -> path_entry {
477480
}
478481

479482
/// Iterates over all the paths in the given crate.
480-
fn each_path(intr: @ident_interner, cdata: cmd, f: fn(path_entry) -> bool) {
483+
fn each_path(intr: @ident_interner, cdata: cmd,
484+
get_crate_data: GetCrateDataCb,
485+
f: fn(path_entry) -> bool) {
481486
let root = ebml::Doc(cdata.data);
482487
let items = ebml::get_doc(root, tag_items);
483488
let items_data = ebml::get_doc(items, tag_items_data);
@@ -526,8 +531,17 @@ fn each_path(intr: @ident_interner, cdata: cmd, f: fn(path_entry) -> bool) {
526531
reexport_path = path + ~"::" + reexport_name;
527532
}
528533

534+
// This reexport may be in yet another crate
535+
let other_crates_items = if def_id.crate == cdata.cnum {
536+
items
537+
} else {
538+
let crate_data = get_crate_data(def_id.crate);
539+
let root = ebml::Doc(crate_data.data);
540+
ebml::get_doc(root, tag_items)
541+
};
542+
529543
// Get the item.
530-
match maybe_find_item(def_id.node, items) {
544+
match maybe_find_item(def_id.node, other_crates_items) {
531545
None => {}
532546
Some(item_doc) => {
533547
// Construct the def for this item.
@@ -1079,9 +1093,10 @@ fn get_crate_vers(data: @~[u8]) -> ~str {
10791093
};
10801094
}
10811095

1082-
fn iter_crate_items(intr: @ident_interner,
1083-
cdata: cmd, proc: fn(~str, ast::def_id)) {
1084-
for each_path(intr, cdata) |path_entry| {
1096+
fn iter_crate_items(intr: @ident_interner, cdata: cmd,
1097+
get_crate_data: GetCrateDataCb,
1098+
proc: fn(~str, ast::def_id)) {
1099+
for each_path(intr, cdata, get_crate_data) |path_entry| {
10851100
match path_entry.def_like {
10861101
dl_impl(*) | dl_field => {}
10871102
dl_def(def) => {
@@ -1091,7 +1106,8 @@ fn iter_crate_items(intr: @ident_interner,
10911106
}
10921107
}
10931108

1094-
fn get_crate_module_paths(intr: @ident_interner, cdata: cmd)
1109+
fn get_crate_module_paths(intr: @ident_interner, cdata: cmd,
1110+
get_crate_data: GetCrateDataCb)
10951111
-> ~[(ast::def_id, ~str)] {
10961112
fn mod_of_path(p: ~str) -> ~str {
10971113
str::connect(vec::init(str::split_str(p, ~"::")), ~"::")
@@ -1101,7 +1117,7 @@ fn get_crate_module_paths(intr: @ident_interner, cdata: cmd)
11011117
// fowarded path due to renamed import or reexport
11021118
let mut res = ~[];
11031119
let mods = map::HashMap();
1104-
do iter_crate_items(intr, cdata) |path, did| {
1120+
do iter_crate_items(intr, cdata, get_crate_data) |path, did| {
11051121
let m = mod_of_path(path);
11061122
if str::is_not_empty(m) {
11071123
// if m has a sub-item, it must be a module

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ fn enc_sty(w: io::Writer, cx: @ctxt, st: ty::sty) {
286286
w.write_char('I');
287287
w.write_uint(id.to_uint());
288288
}
289+
ty::ty_infer(ty::FloatVar(id)) => {
290+
w.write_char('X');
291+
w.write_char('F');
292+
w.write_uint(id.to_uint());
293+
}
289294
ty::ty_param({idx: id, def_id: did}) => {
290295
w.write_char('p');
291296
w.write_str(cx.ds(did));

branches/try2/src/librustc/middle/const_eval.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ fn lit_to_const(lit: @lit) -> const_val {
389389
lit_uint(n, _) => const_uint(n),
390390
lit_int_unsuffixed(n) => const_int(n),
391391
lit_float(n, _) => const_float(float::from_str(*n).get() as f64),
392+
lit_float_unsuffixed(n) =>
393+
const_float(float::from_str(*n).get() as f64),
392394
lit_nil => const_int(0i64),
393395
lit_bool(b) => const_bool(b)
394396
}

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2436,7 +2436,10 @@ fn gather_local_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) {
24362436

24372437
fn gather_external_rtcalls(ccx: @crate_ctxt) {
24382438
do cstore::iter_crate_data(ccx.sess.cstore) |_cnum, cmeta| {
2439-
do decoder::each_path(ccx.sess.intr(), cmeta) |path| {
2439+
let get_crate_data: decoder::GetCrateDataCb = |cnum| {
2440+
cstore::get_crate_data(ccx.sess.cstore, cnum)
2441+
};
2442+
do decoder::each_path(ccx.sess.intr(), cmeta, get_crate_data) |path| {
24402443
let pathname = path.path_string;
24412444
match path.def_like {
24422445
decoder::dl_def(d) => {

branches/try2/src/librustc/middle/trans/consts.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
2222
}
2323
}
2424
ast::lit_float(fs, t) => C_floating(*fs, T_float_ty(cx, t)),
25+
ast::lit_float_unsuffixed(fs) => {
26+
let lit_float_ty = ty::node_id_to_type(cx.tcx, e.id);
27+
match ty::get(lit_float_ty).sty {
28+
ty::ty_float(t) => {
29+
C_floating(*fs, T_float_ty(cx, t))
30+
}
31+
_ => {
32+
cx.sess.span_bug(lit.span,
33+
~"floating point literal doesn't have the right \
34+
type");
35+
}
36+
}
37+
}
2538
ast::lit_bool(b) => C_bool(b),
2639
ast::lit_nil => C_nil(),
2740
ast::lit_str(s) => C_estr_slice(cx, *s)

branches/try2/src/librustc/middle/ty.rs

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use util::ppaux::{ty_to_str, proto_ty_to_str, tys_to_str};
2121

2222
export ProvidedMethodSource;
2323
export InstantiatedTraitRef;
24-
export TyVid, IntVid, FnVid, RegionVid, vid;
24+
export TyVid, IntVid, FloatVid, FnVid, RegionVid, vid;
2525
export br_hashmap;
2626
export is_instantiable;
2727
export node_id_to_type;
@@ -86,6 +86,7 @@ export ty_fn, FnTy, FnTyBase, FnMeta, FnSig, mk_fn;
8686
export ty_fn_proto, ty_fn_purity, ty_fn_ret, ty_fn_ret_style, tys_in_fn_ty;
8787
export ty_int, mk_int, mk_mach_int, mk_char;
8888
export mk_i8, mk_u8, mk_i16, mk_u16, mk_i32, mk_u32, mk_i64, mk_u64;
89+
export mk_f32, mk_f64;
8990
export ty_estr, mk_estr, type_is_str;
9091
export ty_evec, mk_evec, type_is_vec;
9192
export ty_unboxed_vec, mk_unboxed_vec, mk_mut_unboxed_vec;
@@ -102,8 +103,8 @@ export ty_tup, mk_tup;
102103
export ty_type, mk_type;
103104
export ty_uint, mk_uint, mk_mach_uint;
104105
export ty_uniq, mk_uniq, mk_imm_uniq, type_is_unique_box;
105-
export ty_infer, mk_infer, type_is_ty_var, mk_var, mk_int_var;
106-
export InferTy, TyVar, IntVar;
106+
export ty_infer, mk_infer, type_is_ty_var, mk_var, mk_int_var, mk_float_var;
107+
export InferTy, TyVar, IntVar, FloatVar;
107108
export ty_self, mk_self, type_has_self;
108109
export ty_class;
109110
export Region, bound_region, encl_region;
@@ -172,7 +173,8 @@ export ty_sort_str;
172173
export normalize_ty;
173174
export to_str;
174175
export bound_const;
175-
export terr_no_integral_type, terr_ty_param_size, terr_self_substs;
176+
export terr_no_integral_type, terr_no_floating_point_type;
177+
export terr_ty_param_size, terr_self_substs;
176178
export terr_in_field, terr_record_fields, terr_vstores_differ, terr_arg_count;
177179
export terr_sorts, terr_vec, terr_str, terr_record_size, terr_tuple_size;
178180
export terr_regions_does_not_outlive, terr_mutability, terr_purity_mismatch;
@@ -666,6 +668,7 @@ enum type_err {
666668
terr_sorts(expected_found<t>),
667669
terr_self_substs,
668670
terr_no_integral_type,
671+
terr_no_floating_point_type,
669672
}
670673

671674
enum param_bound {
@@ -678,21 +681,24 @@ enum param_bound {
678681

679682
enum TyVid = uint;
680683
enum IntVid = uint;
684+
enum FloatVid = uint;
681685
enum FnVid = uint;
682686
#[auto_serialize]
683687
#[auto_deserialize]
684688
enum RegionVid = uint;
685689

686690
enum InferTy {
687691
TyVar(TyVid),
688-
IntVar(IntVid)
692+
IntVar(IntVid),
693+
FloatVar(FloatVid)
689694
}
690695

691696
impl InferTy : to_bytes::IterBytes {
692697
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
693698
match self {
694699
TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f),
695-
IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f)
700+
IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f),
701+
FloatVar(ref fv) => to_bytes::iter_bytes_2(&2u8, fv, lsb0, f)
696702
}
697703
}
698704
}
@@ -758,6 +764,11 @@ impl IntVid: vid {
758764
pure fn to_str() -> ~str { fmt!("<VI%u>", self.to_uint()) }
759765
}
760766

767+
impl FloatVid: vid {
768+
pure fn to_uint() -> uint { *self }
769+
pure fn to_str() -> ~str { fmt!("<VF%u>", self.to_uint()) }
770+
}
771+
761772
impl FnVid: vid {
762773
pure fn to_uint() -> uint { *self }
763774
pure fn to_str() -> ~str { fmt!("<F%u>", self.to_uint()) }
@@ -773,13 +784,15 @@ impl InferTy {
773784
match self {
774785
TyVar(v) => v.to_uint() << 1,
775786
IntVar(v) => (v.to_uint() << 1) + 1,
787+
FloatVar(v) => (v.to_uint() << 1) + 2
776788
}
777789
}
778790

779791
pure fn to_str() -> ~str {
780792
match self {
781793
TyVar(v) => v.to_str(),
782794
IntVar(v) => v.to_str(),
795+
FloatVar(v) => v.to_str()
783796
}
784797
}
785798
}
@@ -812,6 +825,12 @@ impl IntVid : to_bytes::IterBytes {
812825
}
813826
}
814827

828+
impl FloatVid : to_bytes::IterBytes {
829+
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
830+
(*self).iter_bytes(lsb0, f)
831+
}
832+
}
833+
815834
impl FnVid : to_bytes::IterBytes {
816835
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
817836
(*self).iter_bytes(lsb0, f)
@@ -1030,6 +1049,10 @@ fn mk_u32(cx: ctxt) -> t { mk_t(cx, ty_uint(ast::ty_u32)) }
10301049

10311050
fn mk_u64(cx: ctxt) -> t { mk_t(cx, ty_uint(ast::ty_u64)) }
10321051

1052+
fn mk_f32(cx: ctxt) -> t { mk_t(cx, ty_float(ast::ty_f32)) }
1053+
1054+
fn mk_f64(cx: ctxt) -> t { mk_t(cx, ty_float(ast::ty_f64)) }
1055+
10331056
fn mk_mach_int(cx: ctxt, tm: ast::int_ty) -> t { mk_t(cx, ty_int(tm)) }
10341057

10351058
fn mk_mach_uint(cx: ctxt, tm: ast::uint_ty) -> t { mk_t(cx, ty_uint(tm)) }
@@ -1110,9 +1133,9 @@ fn mk_class(cx: ctxt, class_id: ast::def_id, +substs: substs) -> t {
11101133

11111134
fn mk_var(cx: ctxt, v: TyVid) -> t { mk_infer(cx, TyVar(v)) }
11121135

1113-
fn mk_int_var(cx: ctxt, v: IntVid) -> t {
1114-
mk_infer(cx, IntVar(v))
1115-
}
1136+
fn mk_int_var(cx: ctxt, v: IntVid) -> t { mk_infer(cx, IntVar(v)) }
1137+
1138+
fn mk_float_var(cx: ctxt, v: FloatVid) -> t { mk_infer(cx, FloatVar(v)) }
11161139

11171140
fn mk_infer(cx: ctxt, it: InferTy) -> t { mk_t(cx, ty_infer(it)) }
11181141

@@ -1661,7 +1684,8 @@ pure fn type_is_unique(ty: t) -> bool {
16611684
pure fn type_is_scalar(ty: t) -> bool {
16621685
match get(ty).sty {
16631686
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
1664-
ty_infer(IntVar(_)) | ty_type | ty_ptr(_) => true,
1687+
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_type |
1688+
ty_ptr(_) => true,
16651689
_ => false
16661690
}
16671691
}
@@ -2428,7 +2452,7 @@ fn type_is_integral(ty: t) -> bool {
24282452
24292453
fn type_is_fp(ty: t) -> bool {
24302454
match get(ty).sty {
2431-
ty_float(_) => true,
2455+
ty_infer(FloatVar(_)) | ty_float(_) => true,
24322456
_ => false
24332457
}
24342458
}
@@ -3260,6 +3284,7 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str {
32603284
ty_tup(_) => ~"tuple",
32613285
ty_infer(TyVar(_)) => ~"inferred type",
32623286
ty_infer(IntVar(_)) => ~"integral variable",
3287+
ty_infer(FloatVar(_)) => ~"floating-point variable",
32633288
ty_param(_) => ~"type parameter",
32643289
ty_self => ~"self"
32653290
}
@@ -3387,6 +3412,10 @@ fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
33873412
~"couldn't determine an appropriate integral type for integer \
33883413
literal"
33893414
}
3415+
terr_no_floating_point_type => {
3416+
~"couldn't determine an appropriate floating point type for \
3417+
floating point literal"
3418+
}
33903419
}
33913420
}
33923421

@@ -4000,7 +4029,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool {
40004029
match get(ty).sty {
40014030
ty_bool => tycat_bool,
40024031
ty_int(_) | ty_uint(_) | ty_infer(IntVar(_)) => tycat_int,
4003-
ty_float(_) => tycat_float,
4032+
ty_float(_) | ty_infer(FloatVar(_)) => tycat_float,
40044033
ty_rec(_) | ty_tup(_) | ty_enum(_, _) => tycat_struct,
40054034
ty_bot => tycat_bot,
40064035
_ => tycat_other
@@ -4230,6 +4259,11 @@ impl IntVid : cmp::Eq {
42304259
pure fn ne(other: &IntVid) -> bool { *self != *(*other) }
42314260
}
42324261

4262+
impl FloatVid : cmp::Eq {
4263+
pure fn eq(other: &FloatVid) -> bool { *self == *(*other) }
4264+
pure fn ne(other: &FloatVid) -> bool { *self != *(*other) }
4265+
}
4266+
42334267
impl FnVid : cmp::Eq {
42344268
pure fn eq(other: &FnVid) -> bool { *self == *(*other) }
42354269
pure fn ne(other: &FnVid) -> bool { *self != *(*other) }

branches/try2/src/librustc/middle/typeck/check.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
850850
ty::mk_int_var(tcx, fcx.infcx().next_int_var_id())
851851
}
852852
ast::lit_float(_, t) => ty::mk_mach_float(tcx, t),
853+
ast::lit_float_unsuffixed(_) => {
854+
// An unsuffixed floating point literal could have any floating point
855+
// type, so we create a floating point type variable for it.
856+
ty::mk_float_var(tcx, fcx.infcx().next_float_var_id())
857+
}
853858
ast::lit_nil => ty::mk_nil(tcx),
854859
ast::lit_bool(_) => ty::mk_bool(tcx)
855860
}

branches/try2/src/librustc/middle/typeck/check/method.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ impl LookupContext {
664664
match ty::get(self_ty).sty {
665665
ty_box(*) | ty_uniq(*) | ty_rptr(*) |
666666
ty_infer(IntVar(_)) | // FIXME(#3211)---should be resolved
667+
ty_infer(FloatVar(_)) | // FIXME(#3211)---should be resolved
667668
ty_self | ty_param(*) | ty_nil | ty_bot | ty_bool |
668669
ty_int(*) | ty_uint(*) |
669670
ty_float(*) | ty_enum(*) | ty_ptr(*) | ty_rec(*) |

0 commit comments

Comments
 (0)