Skip to content

Commit ff608ab

Browse files
committed
---
yaml --- r: 93943 b: refs/heads/try c: 7b96f13 h: refs/heads/master i: 93941: 0cfa6b1 93939: 0638f41 93935: c3230d6 v: v3
1 parent 0c3096f commit ff608ab

File tree

30 files changed

+227
-439
lines changed

30 files changed

+227
-439
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: e4136bd552bc7bf2b83ceb5d114f9a254bfa2b01
5+
refs/heads/try: 7b96f13d7d046a5f625af73765515715a270757e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libextra/c_vec.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
*/
3838

3939
use std::ptr;
40+
use std::routine::Runnable;
4041
use std::util;
4142

4243
/**
@@ -49,7 +50,7 @@ pub struct CVec<T> {
4950
}
5051

5152
struct DtorRes {
52-
dtor: Option<proc()>,
53+
dtor: Option<~Runnable>,
5354
}
5455

5556
#[unsafe_destructor]
@@ -58,13 +59,13 @@ impl Drop for DtorRes {
5859
let dtor = util::replace(&mut self.dtor, None);
5960
match dtor {
6061
None => (),
61-
Some(f) => f()
62+
Some(f) => f.run()
6263
}
6364
}
6465
}
6566

6667
impl DtorRes {
67-
fn new(dtor: Option<proc()>) -> DtorRes {
68+
fn new(dtor: Option<~Runnable>) -> DtorRes {
6869
DtorRes {
6970
dtor: dtor,
7071
}
@@ -102,7 +103,7 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
102103
* * dtor - A function to run when the value is destructed, useful
103104
* for freeing the buffer, etc.
104105
*/
105-
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: proc())
106+
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: ~Runnable)
106107
-> CVec<T> {
107108
return CVec{
108109
base: base,
@@ -154,6 +155,19 @@ mod tests {
154155

155156
use std::libc::*;
156157
use std::libc;
158+
use std::routine::Runnable;
159+
160+
struct LibcFree {
161+
mem: *c_void,
162+
}
163+
164+
impl Runnable for LibcFree {
165+
fn run(~self) {
166+
unsafe {
167+
libc::free(self.mem)
168+
}
169+
}
170+
}
157171

158172
fn malloc(n: size_t) -> CVec<u8> {
159173
unsafe {
@@ -163,7 +177,9 @@ mod tests {
163177

164178
return c_vec_with_dtor(mem as *mut u8,
165179
n as uint,
166-
proc() unsafe { libc::free(mem); });
180+
~LibcFree {
181+
mem: mem,
182+
} as ~Runnable);
167183
}
168184
}
169185

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use syntax::abi;
2828
use syntax::parse::token;
2929
use syntax;
3030

31+
use std::int;
3132
use std::hashmap::{HashMap,HashSet};
3233

3334
#[deriving(Clone)]
@@ -208,7 +209,7 @@ pub struct Session_ {
208209
building_library: @mut bool,
209210
working_dir: Path,
210211
lints: @mut HashMap<ast::NodeId, ~[(lint::lint, codemap::Span, ~str)]>,
211-
node_id: @mut ast::NodeId,
212+
node_id: @mut uint,
212213
}
213214

214215
pub type Session = @Session_;
@@ -273,15 +274,13 @@ impl Session_ {
273274
pub fn next_node_id(&self) -> ast::NodeId {
274275
self.reserve_node_ids(1)
275276
}
276-
pub fn reserve_node_ids(&self, count: ast::NodeId) -> ast::NodeId {
277+
pub fn reserve_node_ids(&self, count: uint) -> ast::NodeId {
277278
let v = *self.node_id;
278-
279-
match v.checked_add(&count) {
280-
Some(next) => { *self.node_id = next; }
281-
None => self.bug("Input too large, ran out of node ids!")
279+
*self.node_id += count;
280+
if v > (int::max_value as uint) {
281+
self.bug("Input too large, ran out of node ids!");
282282
}
283-
284-
v
283+
v as int
285284
}
286285
pub fn diagnostic(&self) -> @mut diagnostic::span_handler {
287286
self.span_diagnostic

branches/try/src/librustc/lib/llvm.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -128,62 +128,22 @@ pub enum RealPredicate {
128128

129129
// The LLVM TypeKind type - must stay in sync with the def of
130130
// LLVMTypeKind in llvm/include/llvm-c/Core.h
131-
#[cfg(not(stage0))]
132-
#[deriving(Eq)]
133-
#[repr(C)]
134-
pub enum TypeKind {
135-
Void = 0,
136-
Half = 1,
137-
Float = 2,
138-
Double = 3,
139-
X86_FP80 = 4,
140-
FP128 = 5,
141-
PPC_FP128 = 6,
142-
Label = 7,
143-
Integer = 8,
144-
Function = 9,
145-
Struct = 10,
146-
Array = 11,
147-
Pointer = 12,
148-
Vector = 13,
149-
Metadata = 14,
150-
X86_MMX = 15,
151-
}
152-
153-
// NOTE remove these after snapshot. (See also #10308.)
154-
#[cfg(stage0)]
155131
pub type TypeKind = u32;
156-
#[cfg(stage0)]
157132
pub static Void: TypeKind = 0;
158-
#[cfg(stage0)]
159133
pub static Half: TypeKind = 1;
160-
#[cfg(stage0)]
161134
pub static Float: TypeKind = 2;
162-
#[cfg(stage0)]
163135
pub static Double: TypeKind = 3;
164-
#[cfg(stage0)]
165136
pub static X86_FP80: TypeKind = 4;
166-
#[cfg(stage0)]
167137
pub static FP128: TypeKind = 5;
168-
#[cfg(stage0)]
169138
pub static PPC_FP128: TypeKind = 6;
170-
#[cfg(stage0)]
171139
pub static Label: TypeKind = 7;
172-
#[cfg(stage0)]
173140
pub static Integer: TypeKind = 8;
174-
#[cfg(stage0)]
175141
pub static Function: TypeKind = 9;
176-
#[cfg(stage0)]
177142
pub static Struct: TypeKind = 10;
178-
#[cfg(stage0)]
179143
pub static Array: TypeKind = 11;
180-
#[cfg(stage0)]
181144
pub static Pointer: TypeKind = 12;
182-
#[cfg(stage0)]
183145
pub static Vector: TypeKind = 13;
184-
#[cfg(stage0)]
185146
pub static Metadata: TypeKind = 14;
186-
#[cfg(stage0)]
187147
pub static X86_MMX: TypeKind = 15;
188148

189149
#[repr(C)]

branches/try/src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl visit::Visitor<()> for ReadCrateVisitor {
6767

6868
#[deriving(Clone)]
6969
struct cache_entry {
70-
cnum: ast::CrateNum,
70+
cnum: int,
7171
span: Span,
7272
hash: @str,
7373
metas: @~[@ast::MetaItem]
@@ -242,7 +242,7 @@ fn metas_with_ident(ident: @str, metas: ~[@ast::MetaItem])
242242
}
243243

244244
fn existing_match(e: &Env, metas: &[@ast::MetaItem], hash: &str)
245-
-> Option<ast::CrateNum> {
245+
-> Option<int> {
246246
for c in e.crate_cache.iter() {
247247
if loader::metadata_matches(*c.metas, metas)
248248
&& (hash.is_empty() || c.hash.as_slice() == hash) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ fn lookup_hash(d: ebml::Doc, eq_fn: |&[u8]| -> bool, hash: u64) ->
7676

7777
pub type GetCrateDataCb<'self> = 'self |ast::CrateNum| -> Cmd;
7878

79-
pub fn maybe_find_item(item_id: ast::NodeId, items: ebml::Doc) -> Option<ebml::Doc> {
80-
fn eq_item(bytes: &[u8], item_id: ast::NodeId) -> bool {
79+
pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
80+
fn eq_item(bytes: &[u8], item_id: int) -> bool {
8181
return u64_from_be_bytes(
82-
bytes.slice(0u, 4u), 0u, 4u) as ast::NodeId
82+
bytes.slice(0u, 4u), 0u, 4u) as int
8383
== item_id;
8484
}
8585
lookup_hash(items,
8686
|a| eq_item(a, item_id),
8787
(item_id as i64).hash())
8888
}
8989

90-
fn find_item(item_id: ast::NodeId, items: ebml::Doc) -> ebml::Doc {
90+
fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
9191
match maybe_find_item(item_id, items) {
9292
None => fail!("lookup_item: id not found: {}", item_id),
9393
Some(d) => d
@@ -96,7 +96,7 @@ fn find_item(item_id: ast::NodeId, items: ebml::Doc) -> ebml::Doc {
9696

9797
// Looks up an item in the given metadata and returns an ebml doc pointing
9898
// to the item data.
99-
pub fn lookup_item(item_id: ast::NodeId, data: @~[u8]) -> ebml::Doc {
99+
pub fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
100100
let items = reader::get_doc(reader::Doc(data), tag_items);
101101
find_item(item_id, items)
102102
}
@@ -343,7 +343,7 @@ fn item_name(intr: @ident_interner, item: ebml::Doc) -> ast::Ident {
343343
let string = name.as_str_slice();
344344
match intr.find_equiv(&string) {
345345
None => token::str_to_ident(string),
346-
Some(val) => ast::Ident::new(val as ast::Name),
346+
Some(val) => ast::Ident::new(val),
347347
}
348348
}
349349

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type conv_did<'self> =
5858

5959
pub struct PState<'self> {
6060
data: &'self [u8],
61-
crate: ast::CrateNum,
61+
crate: int,
6262
pos: uint,
6363
tcx: ty::ctxt
6464
}
@@ -101,7 +101,7 @@ fn parse_ident_(st: &mut PState, is_last: |char| -> bool) -> ast::Ident {
101101
return st.tcx.sess.ident_of(rslt);
102102
}
103103

104-
pub fn parse_state_from_data<'a>(data: &'a [u8], crate_num: ast::CrateNum,
104+
pub fn parse_state_from_data<'a>(data: &'a [u8], crate_num: int,
105105
pos: uint, tcx: ty::ctxt) -> PState<'a> {
106106
PState {
107107
data: data,
@@ -111,19 +111,19 @@ pub fn parse_state_from_data<'a>(data: &'a [u8], crate_num: ast::CrateNum,
111111
}
112112
}
113113

114-
pub fn parse_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: ty::ctxt,
114+
pub fn parse_ty_data(data: &[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
115115
conv: conv_did) -> ty::t {
116116
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
117117
parse_ty(&mut st, conv)
118118
}
119119

120-
pub fn parse_bare_fn_ty_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: ty::ctxt,
120+
pub fn parse_bare_fn_ty_data(data: &[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
121121
conv: conv_did) -> ty::BareFnTy {
122122
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
123123
parse_bare_fn_ty(&mut st, conv)
124124
}
125125

126-
pub fn parse_trait_ref_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: ty::ctxt,
126+
pub fn parse_trait_ref_data(data: &[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
127127
conv: conv_did) -> ty::TraitRef {
128128
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
129129
parse_trait_ref(&mut st, conv)
@@ -251,15 +251,15 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
251251
match next(st) {
252252
'b' => {
253253
assert_eq!(next(st), '[');
254-
let id = parse_uint(st) as ast::NodeId;
254+
let id = parse_uint(st) as int;
255255
assert_eq!(next(st), '|');
256256
let br = parse_bound_region(st, |x,y| conv(x,y));
257257
assert_eq!(next(st), ']');
258258
ty::ReLateBound(id, br)
259259
}
260260
'B' => {
261261
assert_eq!(next(st), '[');
262-
let node_id = parse_uint(st) as ast::NodeId;
262+
let node_id = parse_uint(st) as int;
263263
assert_eq!(next(st), '|');
264264
let index = parse_uint(st);
265265
assert_eq!(next(st), '|');
@@ -268,15 +268,15 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
268268
}
269269
'f' => {
270270
assert_eq!(next(st), '[');
271-
let id = parse_uint(st) as ast::NodeId;
271+
let id = parse_uint(st) as int;
272272
assert_eq!(next(st), '|');
273273
let br = parse_bound_region(st, |x,y| conv(x,y));
274274
assert_eq!(next(st), ']');
275275
ty::ReFree(ty::FreeRegion {scope_id: id,
276276
bound_region: br})
277277
}
278278
's' => {
279-
let id = parse_uint(st) as ast::NodeId;
279+
let id = parse_uint(st) as int;
280280
assert_eq!(next(st), '|');
281281
ty::ReScope(id)
282282
}
@@ -539,7 +539,7 @@ fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy {
539539

540540
fn parse_sig(st: &mut PState, conv: conv_did) -> ty::FnSig {
541541
assert_eq!(next(st), '[');
542-
let id = parse_uint(st) as ast::NodeId;
542+
let id = parse_uint(st) as int;
543543
assert_eq!(next(st), '|');
544544
let mut inputs = ~[];
545545
while peek(st) != ']' {
@@ -572,20 +572,20 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId {
572572
let def_part = buf.slice(colon_idx + 1u, len);
573573

574574
let crate_num = match uint::parse_bytes(crate_part, 10u) {
575-
Some(cn) => cn as ast::CrateNum,
575+
Some(cn) => cn as int,
576576
None => fail!("internal error: parse_def_id: crate number expected, but found {:?}",
577577
crate_part)
578578
};
579579
let def_num = match uint::parse_bytes(def_part, 10u) {
580-
Some(dn) => dn as ast::NodeId,
580+
Some(dn) => dn as int,
581581
None => fail!("internal error: parse_def_id: id expected, but found {:?}",
582582
def_part)
583583
};
584584
ast::DefId { crate: crate_num, node: def_num }
585585
}
586586

587587
pub fn parse_type_param_def_data(data: &[u8], start: uint,
588-
crate_num: ast::CrateNum, tcx: ty::ctxt,
588+
crate_num: int, tcx: ty::ctxt,
589589
conv: conv_did) -> ty::TypeParameterDef
590590
{
591591
let mut st = parse_state_from_data(data, crate_num, start, tcx);

branches/try/src/librustc/middle/astencode.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ fn reserve_id_range(sess: Session,
161161
// Handle the case of an empty range:
162162
if from_id_range.empty() { return from_id_range; }
163163
let cnt = from_id_range.max - from_id_range.min;
164-
let to_id_min = sess.reserve_node_ids(cnt);
164+
assert!(cnt >= 0);
165+
let to_id_min = sess.reserve_node_ids(cnt as uint);
165166
let to_id_max = to_id_min + cnt;
166167
ast_util::id_range { min: to_id_min, max: to_id_max }
167168
}
@@ -1203,7 +1204,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
12031204
let tbl_doc = ast_doc.get(c::tag_table as uint);
12041205
reader::docs(tbl_doc, |tag, entry_doc| {
12051206
let id0 = entry_doc.get(c::tag_table_id as uint).as_int();
1206-
let id = xcx.tr_id(id0 as ast::NodeId);
1207+
let id = xcx.tr_id(id0);
12071208

12081209
debug!(">> Side table document with tag 0x{:x} \
12091210
found for id {} (orig {})",

branches/try/src/librustc/middle/trans/type_.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ impl Type {
278278
Type::opaque_box(cx).ptr_to()
279279
}
280280

281+
pub fn enum_discrim(cx: &CrateContext) -> Type {
282+
cx.int_type
283+
}
284+
281285
pub fn opaque_trait(ctx: &CrateContext, store: ty::TraitStore) -> Type {
282286
let tydesc_ptr = ctx.tydesc_type.ptr_to();
283287
let box_ty = match store {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub struct field_ty {
169169
// the types of AST nodes.
170170
#[deriving(Eq,IterBytes)]
171171
pub struct creader_cache_key {
172-
cnum: CrateNum,
172+
cnum: int,
173173
pos: uint,
174174
len: uint
175175
}

0 commit comments

Comments
 (0)