Skip to content

Commit 191c46a

Browse files
committed
---
yaml --- r: 62523 b: refs/heads/snap-stage3 c: ea06407 h: refs/heads/master i: 62521: bcf2802 62519: bb7fba4 v: v3
1 parent 6624876 commit 191c46a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+9859
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 66319b027888ceddf024a5919e007caceaf369f3
4+
refs/heads/snap-stage3: ea0640764a5d9bc01d821c74bef039b6051d5169
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/cast.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ pub mod rusti {
2424
}
2525

2626
/// Casts the value at `src` to U. The two types must have the same length.
27+
#[cfg(not(stage0))]
28+
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
29+
let mut dest: U = unstable::intrinsics::uninit();
30+
{
31+
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
32+
let src_ptr: *u8 = rusti::transmute(src);
33+
unstable::intrinsics::memmove64(dest_ptr,
34+
src_ptr,
35+
sys::size_of::<U>() as u64);
36+
}
37+
dest
38+
}
39+
40+
#[cfg(stage0)]
2741
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
2842
let mut dest: U = unstable::intrinsics::init();
2943
{

branches/snap-stage3/src/libcore/char.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
1313
use option::{None, Option, Some};
1414
use str;
15+
#[cfg(stage0)]
16+
use str::StrSlice;
17+
#[cfg(not(stage0))]
1518
use str::{StrSlice, OwnedStr};
1619
use u32;
1720
use uint;
@@ -188,6 +191,21 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> {
188191
}
189192
}
190193

194+
#[cfg(stage0)]
195+
pub fn escape_unicode(c: char) -> ~str {
196+
let s = u32::to_str_radix(c as u32, 16u);
197+
let (c, pad) = (if c <= '\xff' { ('x', 2u) }
198+
else if c <= '\uffff' { ('u', 4u) }
199+
else { ('U', 8u) });
200+
assert!(str::len(s) <= pad);
201+
let mut out = ~"\\";
202+
str::push_str(&mut out, str::from_char(c));
203+
for uint::range(str::len(s), pad) |_i|
204+
{ str::push_str(&mut out, ~"0"); }
205+
str::push_str(&mut out, s);
206+
out
207+
}
208+
191209
///
192210
/// Return the hexadecimal unicode escape of a char.
193211
///
@@ -197,6 +215,7 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> {
197215
/// - chars in [0x100,0xffff] get 4-digit escapes: `\\uNNNN`
198216
/// - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN`
199217
///
218+
#[cfg(not(stage0))]
200219
pub fn escape_unicode(c: char) -> ~str {
201220
let s = u32::to_str_radix(c as u32, 16u);
202221
let (c, pad) = cond!(
@@ -239,7 +258,23 @@ pub fn escape_default(c: char) -> ~str {
239258
}
240259
}
241260

261+
#[cfg(stage0)]
262+
pub fn len_utf8_bytes(c: char) -> uint {
263+
static max_one_b: uint = 128u;
264+
static max_two_b: uint = 2048u;
265+
static max_three_b: uint = 65536u;
266+
static max_four_b: uint = 2097152u;
267+
268+
let code = c as uint;
269+
if code < max_one_b { 1u }
270+
else if code < max_two_b { 2u }
271+
else if code < max_three_b { 3u }
272+
else if code < max_four_b { 4u }
273+
else { fail!("invalid character!") }
274+
}
275+
242276
/// Returns the amount of bytes this character would need if encoded in utf8
277+
#[cfg(not(stage0))]
243278
pub fn len_utf8_bytes(c: char) -> uint {
244279
static MAX_ONE_B: uint = 128u;
245280
static MAX_TWO_B: uint = 2048u;

branches/snap-stage3/src/libcore/cleanup.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,33 @@ struct AnnihilateStats {
127127
n_bytes_freed: uint
128128
}
129129

130+
#[cfg(stage0)]
131+
unsafe fn each_live_alloc(read_next_before: bool,
132+
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
133+
//! Walks the internal list of allocations
134+
135+
use managed;
136+
137+
let task: *Task = transmute(rustrt::rust_get_task());
138+
let box = (*task).boxed_region.live_allocs;
139+
let mut box: *mut BoxRepr = transmute(copy box);
140+
while box != mut_null() {
141+
let next_before = transmute(copy (*box).header.next);
142+
let uniq =
143+
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
144+
145+
if !f(box, uniq) {
146+
return;
147+
}
148+
149+
if read_next_before {
150+
box = next_before;
151+
} else {
152+
box = transmute(copy (*box).header.next);
153+
}
154+
}
155+
}
156+
#[cfg(not(stage0))]
130157
unsafe fn each_live_alloc(read_next_before: bool,
131158
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) -> bool {
132159
//! Walks the internal list of allocations

branches/snap-stage3/src/libcore/container.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,31 @@ pub trait Map<K, V>: Mutable {
3030
fn contains_key(&self, key: &K) -> bool;
3131

3232
// Visits all keys and values
33+
#[cfg(stage0)]
34+
fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool);
35+
// Visits all keys and values
36+
#[cfg(not(stage0))]
3337
fn each<'a>(&'a self, f: &fn(&K, &'a V) -> bool) -> bool;
3438

3539
/// Visit all keys
40+
#[cfg(stage0)]
41+
fn each_key(&self, f: &fn(&K) -> bool);
42+
/// Visit all keys
43+
#[cfg(not(stage0))]
3644
fn each_key(&self, f: &fn(&K) -> bool) -> bool;
3745

3846
/// Visit all values
47+
#[cfg(stage0)]
48+
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool);
49+
/// Visit all values
50+
#[cfg(not(stage0))]
3951
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool) -> bool;
4052

4153
/// Iterate over the map and mutate the contained values
54+
#[cfg(stage0)]
55+
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
56+
/// Iterate over the map and mutate the contained values
57+
#[cfg(not(stage0))]
4258
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool;
4359

4460
/// Return a reference to the value corresponding to the key
@@ -65,6 +81,43 @@ pub trait Map<K, V>: Mutable {
6581
fn pop(&mut self, k: &K) -> Option<V>;
6682
}
6783

84+
#[cfg(stage0)]
85+
pub trait Set<T>: Mutable {
86+
/// Return true if the set contains a value
87+
fn contains(&self, value: &T) -> bool;
88+
89+
/// Add a value to the set. Return true if the value was not already
90+
/// present in the set.
91+
fn insert(&mut self, value: T) -> bool;
92+
93+
/// Remove a value from the set. Return true if the value was
94+
/// present in the set.
95+
fn remove(&mut self, value: &T) -> bool;
96+
97+
/// Return true if the set has no elements in common with `other`.
98+
/// This is equivalent to checking for an empty intersection.
99+
fn is_disjoint(&self, other: &Self) -> bool;
100+
101+
/// Return true if the set is a subset of another
102+
fn is_subset(&self, other: &Self) -> bool;
103+
104+
/// Return true if the set is a superset of another
105+
fn is_superset(&self, other: &Self) -> bool;
106+
107+
/// Visit the values representing the difference
108+
fn difference(&self, other: &Self, f: &fn(&T) -> bool);
109+
110+
/// Visit the values representing the symmetric difference
111+
fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool);
112+
113+
/// Visit the values representing the intersection
114+
fn intersection(&self, other: &Self, f: &fn(&T) -> bool);
115+
116+
/// Visit the values representing the union
117+
fn union(&self, other: &Self, f: &fn(&T) -> bool);
118+
}
119+
120+
#[cfg(not(stage0))]
68121
pub trait Set<T>: Mutable {
69122
/// Return true if the set contains a value
70123
fn contains(&self, value: &T) -> bool;

branches/snap-stage3/src/libcore/gc.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ unsafe fn _walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
171171
return true;
172172
}
173173

174+
#[cfg(stage0)]
175+
unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) {
176+
_walk_safe_point(fp, sp, visitor);
177+
}
178+
#[cfg(not(stage0))]
174179
unsafe fn walk_safe_point(fp: *Word, sp: SafePoint, visitor: Visitor) -> bool {
175180
_walk_safe_point(fp, sp, visitor)
176181
}
@@ -298,6 +303,11 @@ unsafe fn _walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> boo
298303
return true;
299304
}
300305

306+
#[cfg(stage0)]
307+
unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
308+
_walk_gc_roots(mem, sentinel, visitor);
309+
}
310+
#[cfg(not(stage0))]
301311
unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) -> bool {
302312
_walk_gc_roots(mem, sentinel, visitor)
303313
}

branches/snap-stage3/src/libcore/hash.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* CPRNG like rand::rng.
2020
*/
2121

22+
#[cfg(stage0)]
23+
use cast;
2224
use container::Container;
2325
use old_iter::BaseIter;
2426
use rt::io::Writer;
@@ -76,6 +78,14 @@ pub trait Streaming {
7678
fn reset(&mut self);
7779
}
7880

81+
// XXX: Ugly workaround for bootstrapping.
82+
#[cfg(stage0)]
83+
fn transmute_for_stage0<'a>(bytes: &'a [const u8]) -> &'a [u8] {
84+
unsafe {
85+
cast::transmute(bytes)
86+
}
87+
}
88+
#[cfg(not(stage0))]
7989
fn transmute_for_stage0<'a>(bytes: &'a [u8]) -> &'a [u8] {
8090
bytes
8191
}

0 commit comments

Comments
 (0)