Skip to content

Commit 4b36219

Browse files
committed
---
yaml --- r: 140698 b: refs/heads/try2 c: 18a47f9 h: refs/heads/master v: v3
1 parent 6db6e9d commit 4b36219

File tree

175 files changed

+4168
-1246
lines changed

Some content is hidden

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

175 files changed

+4168
-1246
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: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 1e241ce52bbba72e1641f44f83ced0bfea4717f9
8+
refs/heads/try2: 18a47f9580c0757f76d6b56081931d10a7859b18
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,35 +1946,6 @@ fn avg(v: &[float]) -> float {
19461946
}
19471947
~~~~
19481948

1949-
#### Swap expressions
1950-
1951-
A _swap expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) followed by a bi-directional arrow (`<->`) and another [lvalue](#lvalues-rvalues-and-temporaries).
1952-
1953-
Evaluating a swap expression causes, as a side effect, the values held in the left-hand-side and right-hand-side [lvalues](#lvalues-rvalues-and-temporaries) to be exchanged indivisibly.
1954-
1955-
Evaluating a swap expression neither changes reference counts,
1956-
nor deeply copies any owned structure pointed to by the moved [rvalue](#lvalues-rvalues-and-temporaries).
1957-
Instead, the swap expression represents an indivisible *exchange of ownership*,
1958-
between the right-hand-side and the left-hand-side of the expression.
1959-
No allocation or destruction is entailed.
1960-
1961-
An example of three different swap expressions:
1962-
1963-
~~~~~~~~
1964-
# let mut x = &mut [0];
1965-
# let mut a = &mut [0];
1966-
# let i = 0;
1967-
# struct S1 { z: int };
1968-
# struct S2 { c: int };
1969-
# let mut y = S1{z: 0};
1970-
# let mut b = S2{c: 0};
1971-
1972-
x <-> a;
1973-
x[i] <-> a[i];
1974-
y.z <-> b.c;
1975-
~~~~~~~~
1976-
1977-
19781949
#### Assignment expressions
19791950

19801951
An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) expression followed by an
@@ -2015,7 +1986,7 @@ as
20151986
== !=
20161987
&&
20171988
||
2018-
= <->
1989+
=
20191990
~~~~
20201991

20211992
Operators at the same precedence level are evaluated left-to-right.

branches/try2/doc/tutorial-ffi.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ wrapping `malloc` and `free`:
151151
~~~~
152152
use core::libc::{c_void, size_t, malloc, free};
153153
use core::unstable::intrinsics;
154+
use core::util;
154155
155156
// a wrapper around the handle returned by the foreign code
156157
pub struct Unique<T> {
@@ -184,7 +185,8 @@ impl<T: Owned> Drop for Unique<T> {
184185
fn finalize(&self) {
185186
unsafe {
186187
let mut x = intrinsics::init(); // dummy value to swap in
187-
x <-> *self.ptr; // moving the object out is needed to call the destructor
188+
// moving the object out is needed to call the destructor
189+
util::replace_ptr(self.ptr, x);
188190
free(self.ptr as *c_void)
189191
}
190192
}

branches/try2/mk/platform.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ AR_mips-unknown-linux-gnu=mips-linux-gnu-ar
247247
CFG_LIB_NAME_mips-unknown-linux-gnu=lib$(1).so
248248
CFG_LIB_GLOB_mips-unknown-linux-gnu=lib$(1)-*.so
249249
CFG_LIB_DSYM_GLOB_mips-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
250-
CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -msoft-float -mabi=32
250+
CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -msoft-float -mabi=32 -mno-compact-eh
251251
CFG_GCCISH_CXXFLAGS_mips-unknown-linux-gnu := -fno-rtti
252252
CFG_GCCISH_LINK_FLAGS_mips-unknown-linux-gnu := -shared -fPIC -g -mips32r2 -msoft-float -mabi=32
253253
CFG_GCCISH_DEF_FLAG_mips-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
254254
CFG_GCCISH_PRE_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-whole-archive
255-
CFG_GCCISH_POST_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-no-whole-archive -Wl,-znoexecstack
255+
CFG_GCCISH_POST_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-no-whole-archive
256256
CFG_DEF_SUFFIX_mips-unknown-linux-gnu := .linux.def
257257
CFG_INSTALL_NAME_mips-unknown-linux-gnu =
258258
CFG_LIBUV_LINK_FLAGS_mips-unknown-linux-gnu =

branches/try2/src/libcore/cell.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
use cast::transmute_mut;
1414
use prelude::*;
15+
use util::replace;
1516

1617
/*
1718
A dynamic, mutable location.
@@ -48,9 +49,7 @@ pub impl<T> Cell<T> {
4849
fail!(~"attempt to take an empty cell");
4950
}
5051
51-
let mut value = None;
52-
value <-> self.value;
53-
value.unwrap()
52+
replace(&mut self.value, None).unwrap()
5453
}
5554
5655
/// Returns the value, failing if the cell is full.

branches/try2/src/libcore/cleanup.rs

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

130+
#[cfg(stage0)]
130131
unsafe fn each_live_alloc(read_next_before: bool,
131132
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
132133
//! Walks the internal list of allocations
@@ -141,8 +142,8 @@ unsafe fn each_live_alloc(read_next_before: bool,
141142
let uniq =
142143
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
143144

144-
if ! f(box, uniq) {
145-
break
145+
if !f(box, uniq) {
146+
return;
146147
}
147148

148149
if read_next_before {
@@ -152,6 +153,33 @@ unsafe fn each_live_alloc(read_next_before: bool,
152153
}
153154
}
154155
}
156+
#[cfg(not(stage0))]
157+
unsafe fn each_live_alloc(read_next_before: bool,
158+
f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) -> bool {
159+
//! Walks the internal list of allocations
160+
161+
use managed;
162+
163+
let task: *Task = transmute(rustrt::rust_get_task());
164+
let box = (*task).boxed_region.live_allocs;
165+
let mut box: *mut BoxRepr = transmute(copy box);
166+
while box != mut_null() {
167+
let next_before = transmute(copy (*box).header.next);
168+
let uniq =
169+
(*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE;
170+
171+
if !f(box, uniq) {
172+
return false;
173+
}
174+
175+
if read_next_before {
176+
box = next_before;
177+
} else {
178+
box = transmute(copy (*box).header.next);
179+
}
180+
}
181+
return true;
182+
}
155183

156184
#[cfg(unix)]
157185
fn debug_mem() -> bool {

branches/try2/src/libcore/comm.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use uint;
2121
use unstable;
2222
use vec;
2323
use unstable::Exclusive;
24+
use util::replace;
2425

2526
use pipes::{recv, try_recv, wait_many, peek, PacketHeader};
2627

@@ -149,9 +150,8 @@ impl<T: Owned> GenericChan<T> for Chan<T> {
149150
#[inline(always)]
150151
fn send(&self, x: T) {
151152
unsafe {
152-
let mut endp = None;
153153
let mut self_endp = transmute_mut(&self.endp);
154-
endp <-> *self_endp;
154+
let endp = replace(self_endp, None);
155155
*self_endp = Some(streamp::client::data(endp.unwrap(), x))
156156
}
157157
}
@@ -161,9 +161,8 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
161161
#[inline(always)]
162162
fn try_send(&self, x: T) -> bool {
163163
unsafe {
164-
let mut endp = None;
165164
let mut self_endp = transmute_mut(&self.endp);
166-
endp <-> *self_endp;
165+
let endp = replace(self_endp, None);
167166
match streamp::client::try_data(endp.unwrap(), x) {
168167
Some(next) => {
169168
*self_endp = Some(next);
@@ -179,9 +178,8 @@ impl<T: Owned> GenericPort<T> for Port<T> {
179178
#[inline(always)]
180179
fn recv(&self) -> T {
181180
unsafe {
182-
let mut endp = None;
183181
let mut self_endp = transmute_mut(&self.endp);
184-
endp <-> *self_endp;
182+
let endp = replace(self_endp, None);
185183
let streamp::data(x, endp) = recv(endp.unwrap());
186184
*self_endp = Some(endp);
187185
x
@@ -191,9 +189,8 @@ impl<T: Owned> GenericPort<T> for Port<T> {
191189
#[inline(always)]
192190
fn try_recv(&self) -> Option<T> {
193191
unsafe {
194-
let mut endp = None;
195192
let mut self_endp = transmute_mut(&self.endp);
196-
endp <-> *self_endp;
193+
let endp = replace(self_endp, None);
197194
match try_recv(endp.unwrap()) {
198195
Some(streamp::data(x, endp)) => {
199196
*self_endp = Some(endp);
@@ -209,14 +206,13 @@ impl<T: Owned> Peekable<T> for Port<T> {
209206
#[inline(always)]
210207
fn peek(&self) -> bool {
211208
unsafe {
212-
let mut endp = None;
213209
let mut self_endp = transmute_mut(&self.endp);
214-
endp <-> *self_endp;
210+
let mut endp = replace(self_endp, None);
215211
let peek = match endp {
216212
Some(ref mut endp) => peek(endp),
217213
None => fail!(~"peeking empty stream")
218214
};
219-
*self_endp <-> endp;
215+
*self_endp = endp;
220216
peek
221217
}
222218
}
@@ -267,8 +263,7 @@ impl<T:Owned> GenericPort<T> for PortSet<T> {
267263
let mut result = None;
268264
// we have to swap the ports array so we aren't borrowing
269265
// aliasable mutable memory.
270-
let mut ports = ~[];
271-
ports <-> *self_ports;
266+
let mut ports = replace(self_ports, ~[]);
272267
while result.is_none() && ports.len() > 0 {
273268
let i = wait_many(ports);
274269
match ports[i].try_recv() {
@@ -281,7 +276,7 @@ impl<T:Owned> GenericPort<T> for PortSet<T> {
281276
}
282277
}
283278
}
284-
ports <-> *self_ports;
279+
*self_ports = ports;
285280
result
286281
}
287282
}
@@ -320,8 +315,7 @@ impl<T: Owned> GenericChan<T> for SharedChan<T> {
320315
fn send(&self, x: T) {
321316
let mut xx = Some(x);
322317
do self.ch.with_imm |chan| {
323-
let mut x = None;
324-
x <-> xx;
318+
let x = replace(&mut xx, None);
325319
chan.send(x.unwrap())
326320
}
327321
}
@@ -331,8 +325,7 @@ impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
331325
fn try_send(&self, x: T) -> bool {
332326
let mut xx = Some(x);
333327
do self.ch.with_imm |chan| {
334-
let mut x = None;
335-
x <-> xx;
328+
let x = replace(&mut xx, None);
336329
chan.try_send(x.unwrap())
337330
}
338331
}

branches/try2/src/libcore/condition.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use prelude::*;
1414
use task;
15-
use task::local_data::{local_data_pop, local_data_set};
15+
use local_data::{local_data_pop, local_data_set};
1616

1717
// helper for transmutation, shown below.
1818
type RustClosure = (int, int);
@@ -24,14 +24,14 @@ pub struct Handler<T, U> {
2424

2525
pub struct Condition<'self, T, U> {
2626
name: &'static str,
27-
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
27+
key: local_data::LocalDataKey<'self, Handler<T, U>>
2828
}
2929

3030
pub impl<'self, T, U> Condition<'self, T, U> {
3131
fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
3232
unsafe {
3333
let p : *RustClosure = ::cast::transmute(&h);
34-
let prev = task::local_data::local_data_get(self.key);
34+
let prev = local_data::local_data_get(self.key);
3535
let h = @Handler { handle: *p, prev: prev };
3636
Trap { cond: self, handler: h }
3737
}

branches/try2/src/libcore/container.rs

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

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

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

3846
/// Visit all values
47+
#[cfg(stage0)]
3948
fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool);
49+
/// Visit all values
50+
#[cfg(not(stage0))]
51+
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)]
4255
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))]
58+
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool;
4359

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

84+
#[cfg(stage0)]
6885
pub trait Set<T>: Mutable {
6986
/// Return true if the set contains a value
7087
fn contains(&self, value: &T) -> bool;
@@ -99,3 +116,39 @@ pub trait Set<T>: Mutable {
99116
/// Visit the values representing the union
100117
fn union(&self, other: &Self, f: &fn(&T) -> bool);
101118
}
119+
120+
#[cfg(not(stage0))]
121+
pub trait Set<T>: Mutable {
122+
/// Return true if the set contains a value
123+
fn contains(&self, value: &T) -> bool;
124+
125+
/// Add a value to the set. Return true if the value was not already
126+
/// present in the set.
127+
fn insert(&mut self, value: T) -> bool;
128+
129+
/// Remove a value from the set. Return true if the value was
130+
/// present in the set.
131+
fn remove(&mut self, value: &T) -> bool;
132+
133+
/// Return true if the set has no elements in common with `other`.
134+
/// This is equivalent to checking for an empty intersection.
135+
fn is_disjoint(&self, other: &Self) -> bool;
136+
137+
/// Return true if the set is a subset of another
138+
fn is_subset(&self, other: &Self) -> bool;
139+
140+
/// Return true if the set is a superset of another
141+
fn is_superset(&self, other: &Self) -> bool;
142+
143+
/// Visit the values representing the difference
144+
fn difference(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
145+
146+
/// Visit the values representing the symmetric difference
147+
fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
148+
149+
/// Visit the values representing the intersection
150+
fn intersection(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
151+
152+
/// Visit the values representing the union
153+
fn union(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
154+
}

branches/try2/src/libcore/core

9.02 MB
Binary file not shown.

branches/try2/src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ pub mod trie;
215215
pub mod task;
216216
pub mod comm;
217217
pub mod pipes;
218+
pub mod local_data;
218219

219220

220221
/* Runtime and platform support */
@@ -227,7 +228,6 @@ pub mod rand;
227228
pub mod run;
228229
pub mod sys;
229230
pub mod cast;
230-
pub mod flate;
231231
pub mod repr;
232232
pub mod cleanup;
233233
pub mod reflect;

0 commit comments

Comments
 (0)