Skip to content

Commit 0c17023

Browse files
committed
---
yaml --- r: 47486 b: refs/heads/try c: 6267339 h: refs/heads/master v: v3
1 parent 3e787dc commit 0c17023

File tree

18 files changed

+302
-102
lines changed

18 files changed

+302
-102
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: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: 12f06bb496cf5f3ec692f2b71309bb56d4571992
5+
refs/heads/try: 6267339d6869a27b95f13c578a235204a1562697
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/comm.rs

Lines changed: 150 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -104,64 +104,98 @@ pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
104104
(Port_(Port_ { endp: Some(s) }), Chan_(Chan_{ endp: Some(c) }))
105105
}
106106
107+
// Add an inherent method so that imports of GenericChan are not
108+
// required.
109+
#[cfg(stage1)]
110+
#[cfg(stage2)]
111+
pub impl<T: Owned> Chan<T> {
112+
fn send(&self, x: T) { chan_send(self, x) }
113+
fn try_send(&self, x: T) -> bool { chan_try_send(self, x) }
114+
}
115+
107116
impl<T: Owned> GenericChan<T> for Chan<T> {
108-
fn send(&self, x: T) {
109-
let mut endp = None;
110-
endp <-> self.endp;
111-
self.endp = Some(
112-
streamp::client::data(unwrap(endp), x))
113-
}
117+
fn send(&self, x: T) { chan_send(self, x) }
114118
}
115119
116-
impl<T: Owned> GenericSmartChan<T> for Chan<T> {
120+
#[inline(always)]
121+
fn chan_send<T:Owned>(self: &Chan<T>, x: T) {
122+
let mut endp = None;
123+
endp <-> self.endp;
124+
self.endp = Some(
125+
streamp::client::data(unwrap(endp), x))
126+
}
117127
128+
impl<T: Owned> GenericSmartChan<T> for Chan<T> {
118129
fn try_send(&self, x: T) -> bool {
119-
let mut endp = None;
120-
endp <-> self.endp;
121-
match streamp::client::try_data(unwrap(endp), x) {
122-
Some(next) => {
123-
self.endp = Some(next);
124-
true
125-
}
126-
None => false
127-
}
130+
chan_try_send(self, x)
128131
}
129132
}
130133
131-
impl<T: Owned> GenericPort<T> for Port<T> {
132-
fn recv(&self) -> T {
133-
let mut endp = None;
134-
endp <-> self.endp;
135-
let streamp::data(x, endp) = recv(unwrap(endp));
136-
self.endp = Some(endp);
137-
x
134+
#[inline(always)]
135+
fn chan_try_send<T:Owned>(self: &Chan<T>, x: T) -> bool {
136+
let mut endp = None;
137+
endp <-> self.endp;
138+
match streamp::client::try_data(unwrap(endp), x) {
139+
Some(next) => {
140+
self.endp = Some(next);
141+
true
142+
}
143+
None => false
138144
}
145+
}
139146
140-
fn try_recv(&self) -> Option<T> {
141-
let mut endp = None;
142-
endp <-> self.endp;
143-
match try_recv(unwrap(endp)) {
144-
Some(streamp::data(x, endp)) => {
147+
// Use an inherent impl so that imports are not required:
148+
#[cfg(stage1)]
149+
#[cfg(stage2)]
150+
pub impl<T: Owned> Port<T> {
151+
fn recv(&self) -> T { port_recv(self) }
152+
fn try_recv(&self) -> Option<T> { port_try_recv(self) }
153+
pure fn peek(&self) -> bool { port_peek(self) }
154+
}
155+
156+
impl<T: Owned> GenericPort<T> for Port<T> {
157+
// These two calls will prefer the inherent versions above:
158+
fn recv(&self) -> T { port_recv(self) }
159+
fn try_recv(&self) -> Option<T> { port_try_recv(self) }
160+
}
161+
162+
#[inline(always)]
163+
fn port_recv<T:Owned>(self: &Port<T>) -> T {
164+
let mut endp = None;
165+
endp <-> self.endp;
166+
let streamp::data(x, endp) = recv(unwrap(endp));
167+
self.endp = Some(endp);
168+
x
169+
}
170+
171+
#[inline(always)]
172+
fn port_try_recv<T:Owned>(self: &Port<T>) -> Option<T> {
173+
let mut endp = None;
174+
endp <-> self.endp;
175+
match try_recv(unwrap(endp)) {
176+
Some(streamp::data(x, endp)) => {
145177
self.endp = Some(endp);
146178
Some(x)
147-
}
148-
None => None
149179
}
180+
None => None
150181
}
151182
}
152183
153184
impl<T: Owned> Peekable<T> for Port<T> {
154-
pure fn peek(&self) -> bool {
155-
unsafe {
156-
let mut endp = None;
157-
endp <-> self.endp;
158-
let peek = match &endp {
159-
&Some(ref endp) => peek(endp),
160-
&None => fail!(~"peeking empty stream")
161-
};
162-
self.endp <-> endp;
163-
peek
164-
}
185+
pure fn peek(&self) -> bool { port_peek(self) }
186+
}
187+
188+
#[inline(always)]
189+
pure fn port_peek<T:Owned>(self: &Port<T>) -> bool {
190+
unsafe {
191+
let mut endp = None;
192+
endp <-> self.endp;
193+
let peek = match &endp {
194+
&Some(ref endp) => peek(endp),
195+
&None => fail!(~"peeking empty stream")
196+
};
197+
self.endp <-> endp;
198+
peek
165199
}
166200
}
167201
@@ -187,8 +221,16 @@ pub fn PortSet<T: Owned>() -> PortSet<T>{
187221
}
188222
}
189223
190-
pub impl<T: Owned> PortSet<T> {
224+
// Use an inherent impl so that imports are not required:
225+
#[cfg(stage1)]
226+
#[cfg(stage2)]
227+
pub impl<T:Owned> PortSet<T> {
228+
fn recv(&self) -> T { port_set_recv(self) }
229+
fn try_recv(&self) -> Option<T> { port_set_try_recv(self) }
230+
pure fn peek(&self) -> bool { port_set_peek(self) }
231+
}
191232
233+
pub impl<T: Owned> PortSet<T> {
192234
fn add(&self, port: Port<T>) {
193235
self.ports.push(port)
194236
}
@@ -200,69 +242,89 @@ pub impl<T: Owned> PortSet<T> {
200242
}
201243
}
202244
203-
impl<T: Owned> GenericPort<T> for PortSet<T> {
204-
205-
fn try_recv(&self) -> Option<T> {
206-
let mut result = None;
207-
// we have to swap the ports array so we aren't borrowing
208-
// aliasable mutable memory.
209-
let mut ports = ~[];
210-
ports <-> self.ports;
211-
while result.is_none() && ports.len() > 0 {
212-
let i = wait_many(ports);
213-
match ports[i].try_recv() {
214-
Some(m) => {
215-
result = Some(m);
216-
}
217-
None => {
218-
// Remove this port.
219-
let _ = ports.swap_remove(i);
220-
}
245+
impl<T:Owned> GenericPort<T> for PortSet<T> {
246+
fn try_recv(&self) -> Option<T> { port_set_try_recv(self) }
247+
fn recv(&self) -> T { port_set_recv(self) }
248+
}
249+
250+
#[inline(always)]
251+
fn port_set_recv<T:Owned>(self: &PortSet<T>) -> T {
252+
port_set_try_recv(self).expect("port_set: endpoints closed")
253+
}
254+
255+
#[inline(always)]
256+
fn port_set_try_recv<T:Owned>(self: &PortSet<T>) -> Option<T> {
257+
let mut result = None;
258+
// we have to swap the ports array so we aren't borrowing
259+
// aliasable mutable memory.
260+
let mut ports = ~[];
261+
ports <-> self.ports;
262+
while result.is_none() && ports.len() > 0 {
263+
let i = wait_many(ports);
264+
match ports[i].try_recv() {
265+
Some(m) => {
266+
result = Some(m);
267+
}
268+
None => {
269+
// Remove this port.
270+
let _ = ports.swap_remove(i);
221271
}
222272
}
223-
ports <-> self.ports;
224-
result
225273
}
226-
227-
fn recv(&self) -> T {
228-
self.try_recv().expect("port_set: endpoints closed")
229-
}
230-
274+
ports <-> self.ports;
275+
result
231276
}
232277
233278
impl<T: Owned> Peekable<T> for PortSet<T> {
234-
pure fn peek(&self) -> bool {
235-
// It'd be nice to use self.port.each, but that version isn't
236-
// pure.
237-
for vec::each(self.ports) |p| {
238-
if p.peek() { return true }
239-
}
240-
false
279+
pure fn peek(&self) -> bool { port_set_peek(self) }
280+
}
281+
282+
#[inline(always)]
283+
pure fn port_set_peek<T:Owned>(self: &PortSet<T>) -> bool {
284+
// It'd be nice to use self.port.each, but that version isn't
285+
// pure.
286+
for vec::each(self.ports) |p| {
287+
if p.peek() { return true }
241288
}
289+
false
242290
}
243291
292+
244293
/// A channel that can be shared between many senders.
245294
pub type SharedChan<T> = unstable::Exclusive<Chan<T>>;
246295
296+
#[cfg(stage1)]
297+
#[cfg(stage2)]
298+
pub impl<T: Owned> SharedChan<T> {
299+
fn send(&self, x: T) { shared_chan_send(self, x) }
300+
fn try_send(&self, x: T) -> bool { shared_chan_try_send(self, x) }
301+
}
302+
247303
impl<T: Owned> GenericChan<T> for SharedChan<T> {
248-
fn send(&self, x: T) {
249-
let mut xx = Some(x);
250-
do self.with_imm |chan| {
251-
let mut x = None;
252-
x <-> xx;
253-
chan.send(option::unwrap(x))
254-
}
304+
fn send(&self, x: T) { shared_chan_send(self, x) }
305+
}
306+
307+
#[inline(always)]
308+
fn shared_chan_send<T:Owned>(self: &SharedChan<T>, x: T) {
309+
let mut xx = Some(x);
310+
do self.with_imm |chan| {
311+
let mut x = None;
312+
x <-> xx;
313+
chan.send(option::unwrap(x))
255314
}
256315
}
257316
258317
impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
259-
fn try_send(&self, x: T) -> bool {
260-
let mut xx = Some(x);
261-
do self.with_imm |chan| {
262-
let mut x = None;
263-
x <-> xx;
264-
chan.try_send(option::unwrap(x))
265-
}
318+
fn try_send(&self, x: T) -> bool { shared_chan_try_send(self, x) }
319+
}
320+
321+
#[inline(always)]
322+
fn shared_chan_try_send<T:Owned>(self: &SharedChan<T>, x: T) -> bool {
323+
let mut xx = Some(x);
324+
do self.with_imm |chan| {
325+
let mut x = None;
326+
x <-> xx;
327+
chan.try_send(option::unwrap(x))
266328
}
267329
}
268330

branches/try/src/libcore/core.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Implicitly, all crates behave as if they included the following prologue:
5050

5151
#[warn(vecs_implicitly_copyable)];
5252
#[deny(non_camel_case_types)];
53+
#[allow(deprecated_self)];
5354
#[allow(deprecated_mutable_fields)];
5455

5556
/* The Prelude. */

branches/try/src/libcore/dvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ priv impl<A> DVec<A> {
108108
pub impl<A> DVec<A> {
109109
// FIXME (#3758): This should not need to be public.
110110
#[inline(always)]
111-
fn check_out<B>(&self, f: &fn(v: ~[A]) -> B) -> B {
111+
fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B {
112112
unsafe {
113113
let mut data = cast::reinterpret_cast(&null::<()>());
114114
data <-> self.data;

branches/try/src/libcore/hash.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub trait Streaming {
6868
fn input(&self, (&[const u8]));
6969
// These can be refactored some when we have default methods.
7070
fn result_bytes(&self) -> ~[u8];
71-
fn result_str(&self) -> ~str;
71+
fn result_str() -> ~str;
7272
fn result_u64(&self) -> u64;
7373
fn reset(&self);
7474
}
@@ -349,7 +349,8 @@ impl Streaming for &SipState {
349349
]
350350
}
351351

352-
fn result_str(&self) -> ~str {
352+
// IMPLICIT SELF WARNING: fix me!
353+
fn result_str() -> ~str {
353354
let r = self.result_bytes();
354355
let mut s = ~"";
355356
for vec::each(r) |b| {

branches/try/src/libcore/unstable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ fn LittleLock() -> LittleLock {
228228

229229
pub impl LittleLock {
230230
#[inline(always)]
231-
unsafe fn lock<T>(&self, f: fn() -> T) -> T {
231+
unsafe fn lock<T>(f: fn() -> T) -> T {
232232
struct Unlock {
233233
l: rust_little_lock,
234234
drop {
@@ -280,7 +280,7 @@ pub impl<T:Owned> Exclusive<T> {
280280
// accessing the provided condition variable) are prohibited while inside
281281
// the exclusive. Supporting that is a work in progress.
282282
#[inline(always)]
283-
unsafe fn with<U>(&self, f: fn(x: &mut T) -> U) -> U {
283+
unsafe fn with<U>(f: fn(x: &mut T) -> U) -> U {
284284
unsafe {
285285
let rec = get_shared_mutable_state(&self.x);
286286
do (*rec).lock.lock {
@@ -297,7 +297,7 @@ pub impl<T:Owned> Exclusive<T> {
297297
}
298298

299299
#[inline(always)]
300-
unsafe fn with_imm<U>(&self, f: fn(x: &T) -> U) -> U {
300+
unsafe fn with_imm<U>(f: fn(x: &T) -> U) -> U {
301301
do self.with |x| {
302302
f(cast::transmute_immut(x))
303303
}

branches/try/src/librustc/back/link.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use middle::ty;
2323
use util::ppaux;
2424

2525
use core::char;
26+
use core::hash::Streaming;
2627
use core::hash;
2728
use core::io::{Writer, WriterUtil};
2829
use core::libc::{c_int, c_uint, c_char};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use core::dvec;
2626
use core::flate;
2727
use core::hash::{Hash, HashUtil};
2828
use core::int;
29-
use core::io::WriterUtil;
29+
use core::io::{Writer, WriterUtil};
3030
use core::io;
3131
use core::str;
3232
use core::to_bytes::IterBytes;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ use core::{dvec, io, option, vec};
2929
use std::ebml::reader;
3030
use std::ebml;
3131
use std::serialize;
32-
use std::serialize::{Encodable, EncoderHelpers, DecoderHelpers};
33-
use std::serialize::Decodable;
32+
use std::serialize::{Encoder, Encodable, EncoderHelpers, DecoderHelpers};
33+
use std::serialize::{Decoder, Decodable};
3434
use syntax::ast;
3535
use syntax::ast_map;
36+
use syntax::ast_util::inlined_item_utils;
3637
use syntax::ast_util;
3738
use syntax::codemap::span;
3839
use syntax::codemap;

0 commit comments

Comments
 (0)