Skip to content

Commit be9d12a

Browse files
committed
---
yaml --- r: 149048 b: refs/heads/try2 c: d0affa5 h: refs/heads/master v: v3
1 parent 6c5ce38 commit be9d12a

File tree

34 files changed

+222
-152
lines changed

34 files changed

+222
-152
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: 66c036c293626bf38cd3c3635abbf0fa8c80260c
8+
refs/heads/try2: d0affa5c8d99ec6d1096a3ba0cea12d6eb24d684
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
7474
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
7575
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
7676
| $$(TLIB$(1)_T_$(2)_H_$(3))/
77-
@$$(call E, compile_and_link: $$(@D)/lib$(4))
77+
@$$(call E, oxidize: $$(@D)/lib$(4))
7878
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
7979
$$(dir $$@)$$(call CFG_LIB_GLOB_$(2),$(4)))
8080
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
@@ -113,7 +113,7 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
113113
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \
114114
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
115115
| $$(TBIN$(1)_T_$(4)_H_$(3))/
116-
@$$(call E, compile_and_link: $$@)
116+
@$$(call E, oxidize: $$@)
117117
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg $(4)
118118

119119
endef

branches/try2/mk/tests.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
347347
$$(CRATEFILE_$(4)) \
348348
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
349349
$$(STDTESTDEP_$(1)_$(2)_$(3)_$(4))
350-
@$$(call E, compile_and_link: $$@)
350+
@$$(call E, oxidize: $$@)
351351
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
352352
-L "$$(RT_OUTPUT_DIR_$(2))" \
353353
-L "$$(LLVM_LIBDIR_$(2))"
@@ -835,15 +835,15 @@ define DEF_CHECK_FAST_FOR_T_H
835835
$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
836836
tmp/$$(FT).rc \
837837
$$(SREQ2_T_$(2)_H_$(3))
838-
@$$(call E, compile_and_link: $$@)
838+
@$$(call E, oxidize: $$@)
839839
$$(STAGE2_T_$(2)_H_$(3)) --crate-type=dylib --out-dir $$(@D) $$< \
840840
-L "$$(RT_OUTPUT_DIR_$(2))"
841841

842842
$(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
843843
tmp/$$(FT_DRIVER).rs \
844844
$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
845845
$$(SREQ2_T_$(2)_H_$(3))
846-
@$$(call E, compile_and_link: $$@ $$<)
846+
@$$(call E, oxidize: $$@ $$<)
847847
$$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$< \
848848
-L "$$(RT_OUTPUT_DIR_$(2))"
849849

branches/try2/src/doc/guide-ffi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ and `free`:
176176
~~~~
177177
use std::cast;
178178
use std::libc::{c_void, size_t, malloc, free};
179+
use std::mem;
179180
use std::ptr;
180-
use std::unstable::intrinsics;
181181
182182
// Define a wrapper around the handle returned by the foreign code.
183183
// Unique<T> has the same semantics as ~T
@@ -199,7 +199,7 @@ impl<T: Send> Unique<T> {
199199
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
200200
// move_val_init moves a value into this memory without
201201
// attempting to drop the original value.
202-
intrinsics::move_val_init(&mut *ptr, value);
202+
mem::move_val_init(&mut *ptr, value);
203203
Unique{ptr: ptr}
204204
}
205205
}
@@ -226,7 +226,7 @@ impl<T: Send> Unique<T> {
226226
impl<T: Send> Drop for Unique<T> {
227227
fn drop(&mut self) {
228228
unsafe {
229-
let x = intrinsics::uninit(); // dummy value to swap in
229+
let x = mem::uninit(); // dummy value to swap in
230230
// We need to move the object out of the box, so that
231231
// the destructor is called (at the end of this scope.)
232232
ptr::replace_ptr(self.ptr, x);

branches/try2/src/doc/tutorial.md

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -647,31 +647,8 @@ match mypoint {
647647

648648
## Enums
649649

650-
Enums are datatypes that have several alternate representations. For
651-
example, consider the following type:
652-
653-
~~~~
654-
# struct Point { x: f64, y: f64 }
655-
enum Shape {
656-
Circle(Point, f64),
657-
Rectangle(Point, Point)
658-
}
659-
~~~~
660-
661-
A value of this type is either a `Circle`, in which case it contains a
662-
`Point` struct and a f64, or a `Rectangle`, in which case it contains
663-
two `Point` structs. The run-time representation of such a value
664-
includes an identifier of the actual form that it holds, much like the
665-
"tagged union" pattern in C, but with better static guarantees.
666-
667-
The above declaration will define a type `Shape` that can refer to
668-
such shapes, and two functions, `Circle` and `Rectangle`, which can be
669-
used to construct values of the type (taking arguments of the
670-
specified types). So `Circle(Point { x: 0.0, y: 0.0 }, 10.0)` is the way to
671-
create a new circle.
672-
673-
Enum variants need not have parameters. This `enum` declaration,
674-
for example, is equivalent to a C enum:
650+
Enums are datatypes with several alternate representations. A simple `enum`
651+
defines one or more constants, all of which have the same type:
675652

676653
~~~~
677654
enum Direction {
@@ -682,12 +659,21 @@ enum Direction {
682659
}
683660
~~~~
684661

685-
This declaration defines `North`, `East`, `South`, and `West` as constants,
686-
all of which have type `Direction`.
662+
Each variant of this enum has a unique and constant integral discriminator
663+
value. If no explicit discriminator is specified for a variant, the value
664+
defaults to the value of the previous variant plus one. If the first variant
665+
does not have a discriminator, it defaults to 0. For example, the value of
666+
`North` is 0, `East` is 1, `South` is 2, and `West` is 3.
687667

688-
When an enum is C-like (that is, when none of the variants have
689-
parameters), it is possible to explicitly set the discriminator values
690-
to a constant value:
668+
When an enum has simple integer discriminators, you can apply the `as` cast
669+
operator to convert a variant to its discriminator value as an `int`:
670+
671+
~~~~
672+
# enum Direction { North }
673+
println!( "{:?} => {}", North, North as int );
674+
~~~~
675+
676+
It is possible to set the discriminator values to chosen constant values:
691677

692678
~~~~
693679
enum Color {
@@ -697,17 +683,30 @@ enum Color {
697683
}
698684
~~~~
699685

700-
If an explicit discriminator is not specified for a variant, the value
701-
defaults to the value of the previous variant plus one. If the first
702-
variant does not have a discriminator, it defaults to 0. For example,
703-
the value of `North` is 0, `East` is 1, `South` is 2, and `West` is 3.
686+
Variants do not have to be simple values; they may be more complex:
704687

705-
When an enum is C-like, you can apply the `as` cast operator to
706-
convert it to its discriminator value as an `int`.
688+
~~~~
689+
# struct Point { x: f64, y: f64 }
690+
enum Shape {
691+
Circle(Point, f64),
692+
Rectangle(Point, Point)
693+
}
694+
~~~~
707695

708-
For enum types with multiple variants, destructuring is the only way to
709-
get at their contents. All variant constructors can be used as
710-
patterns, as in this definition of `area`:
696+
A value of this type is either a `Circle`, in which case it contains a
697+
`Point` struct and a f64, or a `Rectangle`, in which case it contains
698+
two `Point` structs. The run-time representation of such a value
699+
includes an identifier of the actual form that it holds, much like the
700+
"tagged union" pattern in C, but with better static guarantees.
701+
702+
This declaration defines a type `Shape` that can refer to such shapes, and two
703+
functions, `Circle` and `Rectangle`, which can be used to construct values of
704+
the type. To create a new Circle, write `Circle(Point { x: 0.0, y: 0.0 },
705+
10.0)`.
706+
707+
All of these variant constructors may be used as patterns. The only way to
708+
access the contents of an enum instance is the destructuring of a match. For
709+
example:
711710

712711
~~~~
713712
use std::f64;
@@ -721,10 +720,8 @@ fn area(sh: Shape) -> f64 {
721720
}
722721
~~~~
723722

724-
You can write a lone `_` to ignore an individual field, and can
725-
ignore all fields of a variant like: `Circle(..)`. As in their
726-
introduction form, nullary enum patterns are written without
727-
parentheses.
723+
Use a lone `_` to ignore an individual field. Ignore all fields of a variant
724+
like: `Circle(..)`. Nullary enum patterns are written without parentheses:
728725

729726
~~~~
730727
# struct Point { x: f64, y: f64 }

branches/try2/src/libarena/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ use collections::list;
3232
use std::cast::{transmute, transmute_mut, transmute_mut_region};
3333
use std::cast;
3434
use std::cell::{Cell, RefCell};
35+
use std::mem;
3536
use std::num;
3637
use std::ptr;
3738
use std::kinds::marker;
38-
use std::mem;
3939
use std::rc::Rc;
4040
use std::rt::global_heap;
4141
use std::unstable::intrinsics::{TyDesc, get_tydesc};
@@ -216,7 +216,7 @@ impl Arena {
216216
unsafe {
217217
let ptr = self.alloc_pod_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
218218
let ptr: *mut T = transmute(ptr);
219-
intrinsics::move_val_init(&mut (*ptr), op());
219+
mem::move_val_init(&mut (*ptr), op());
220220
return transmute(ptr);
221221
}
222222
}
@@ -278,7 +278,7 @@ impl Arena {
278278
// has *not* been initialized yet.
279279
*ty_ptr = transmute(tydesc);
280280
// Actually initialize it
281-
intrinsics::move_val_init(&mut(*ptr), op());
281+
mem::move_val_init(&mut(*ptr), op());
282282
// Now that we are done, update the tydesc to indicate that
283283
// the object is there.
284284
*ty_ptr = bitpack_tydesc_ptr(tydesc, true);
@@ -379,7 +379,7 @@ impl TypedArenaChunk {
379379
let mut chunk = unsafe {
380380
let chunk = global_heap::exchange_malloc(size);
381381
let mut chunk: ~TypedArenaChunk = cast::transmute(chunk);
382-
intrinsics::move_val_init(&mut chunk.next, next);
382+
mem::move_val_init(&mut chunk.next, next);
383383
chunk
384384
};
385385

@@ -466,7 +466,7 @@ impl<T> TypedArena<T> {
466466
}
467467

468468
let ptr: &'a mut T = cast::transmute(this.ptr);
469-
intrinsics::move_val_init(ptr, object);
469+
mem::move_val_init(ptr, object);
470470
this.ptr = this.ptr.offset(1);
471471
let ptr: &'a T = ptr;
472472
ptr

branches/try2/src/libcollections/priority_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#[allow(missing_doc)];
1414

1515
use std::clone::Clone;
16-
use std::unstable::intrinsics::{move_val_init, init};
16+
use std::mem::{move_val_init, init};
1717
use std::util::{replace, swap};
1818
use std::vec;
1919

branches/try2/src/libnative/io/file.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use std::io::IoError;
1616
use std::io;
1717
use std::libc::{c_int, c_void};
1818
use std::libc;
19+
use std::mem;
1920
use std::os;
2021
use std::rt::rtio;
21-
use std::unstable::intrinsics;
2222
use std::vec;
2323

2424
use io::{IoResult, retry};
@@ -147,7 +147,7 @@ impl rtio::RtioFileStream for FileDesc {
147147
#[cfg(windows)]
148148
fn os_pread(fd: c_int, buf: *u8, amt: uint, offset: u64) -> IoResult<int> {
149149
unsafe {
150-
let mut overlap: libc::OVERLAPPED = intrinsics::init();
150+
let mut overlap: libc::OVERLAPPED = mem::init();
151151
let handle = libc::get_osfhandle(fd) as libc::HANDLE;
152152
let mut bytes_read = 0;
153153
overlap.Offset = offset as libc::DWORD;
@@ -179,7 +179,7 @@ impl rtio::RtioFileStream for FileDesc {
179179
#[cfg(windows)]
180180
fn os_pwrite(fd: c_int, buf: *u8, amt: uint, offset: u64) -> IoResult<()> {
181181
unsafe {
182-
let mut overlap: libc::OVERLAPPED = intrinsics::init();
182+
let mut overlap: libc::OVERLAPPED = mem::init();
183183
let handle = libc::get_osfhandle(fd) as libc::HANDLE;
184184
overlap.Offset = offset as libc::DWORD;
185185
overlap.OffsetHigh = (offset >> 32) as libc::DWORD;
@@ -867,7 +867,7 @@ pub fn stat(p: &CString) -> IoResult<io::FileStat> {
867867

868868
#[cfg(windows)]
869869
fn os_stat(p: &CString) -> IoResult<io::FileStat> {
870-
let mut stat: libc::stat = unsafe { intrinsics::uninit() };
870+
let mut stat: libc::stat = unsafe { mem::uninit() };
871871
as_utf16_p(p.as_str().unwrap(), |up| {
872872
match retry(|| unsafe { libc::wstat(up, &mut stat) }) {
873873
0 => Ok(mkstat(&stat, p)),
@@ -878,7 +878,7 @@ pub fn stat(p: &CString) -> IoResult<io::FileStat> {
878878

879879
#[cfg(unix)]
880880
fn os_stat(p: &CString) -> IoResult<io::FileStat> {
881-
let mut stat: libc::stat = unsafe { intrinsics::uninit() };
881+
let mut stat: libc::stat = unsafe { mem::uninit() };
882882
match retry(|| unsafe { libc::stat(p.with_ref(|p| p), &mut stat) }) {
883883
0 => Ok(mkstat(&stat, p)),
884884
_ => Err(super::last_error()),
@@ -897,7 +897,7 @@ pub fn lstat(p: &CString) -> IoResult<io::FileStat> {
897897

898898
#[cfg(unix)]
899899
fn os_lstat(p: &CString) -> IoResult<io::FileStat> {
900-
let mut stat: libc::stat = unsafe { intrinsics::uninit() };
900+
let mut stat: libc::stat = unsafe { mem::uninit() };
901901
match retry(|| unsafe { libc::lstat(p.with_ref(|p| p), &mut stat) }) {
902902
0 => Ok(mkstat(&stat, p)),
903903
_ => Err(super::last_error()),

branches/try2/src/libnative/io/net.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use std::libc;
1515
use std::mem;
1616
use std::rt::rtio;
1717
use std::sync::arc::UnsafeArc;
18-
use std::unstable::intrinsics;
1918

2019
use super::{IoResult, retry};
2120
use super::file::keep_going;
@@ -28,10 +27,10 @@ use super::file::keep_going;
2827
#[cfg(unix)] pub type sock_t = super::file::fd_t;
2928

3029
pub fn htons(u: u16) -> u16 {
31-
intrinsics::to_be16(u as i16) as u16
30+
mem::to_be16(u as i16) as u16
3231
}
3332
pub fn ntohs(u: u16) -> u16 {
34-
intrinsics::from_be16(u as i16) as u16
33+
mem::from_be16(u as i16) as u16
3534
}
3635

3736
enum InAddr {
@@ -68,7 +67,7 @@ fn ip_to_inaddr(ip: ip::IpAddr) -> InAddr {
6867

6968
fn addr_to_sockaddr(addr: ip::SocketAddr) -> (libc::sockaddr_storage, uint) {
7069
unsafe {
71-
let storage: libc::sockaddr_storage = intrinsics::init();
70+
let storage: libc::sockaddr_storage = mem::init();
7271
let len = match ip_to_inaddr(addr.ip) {
7372
InAddr(inaddr) => {
7473
let storage: *mut libc::sockaddr_in = cast::transmute(&storage);
@@ -138,7 +137,7 @@ fn sockname(fd: sock_t,
138137
*mut libc::socklen_t) -> libc::c_int)
139138
-> IoResult<ip::SocketAddr>
140139
{
141-
let mut storage: libc::sockaddr_storage = unsafe { intrinsics::init() };
140+
let mut storage: libc::sockaddr_storage = unsafe { mem::init() };
142141
let mut len = mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t;
143142
unsafe {
144143
let storage = &mut storage as *mut libc::sockaddr_storage;
@@ -225,7 +224,7 @@ pub fn init() {
225224

226225
LOCK.lock();
227226
if !INITIALIZED {
228-
let mut data: WSADATA = intrinsics::init();
227+
let mut data: WSADATA = mem::init();
229228
let ret = WSAStartup(0x202, // version 2.2
230229
&mut data);
231230
assert_eq!(ret, 0);
@@ -438,7 +437,7 @@ impl TcpAcceptor {
438437

439438
pub fn native_accept(&mut self) -> IoResult<TcpStream> {
440439
unsafe {
441-
let mut storage: libc::sockaddr_storage = intrinsics::init();
440+
let mut storage: libc::sockaddr_storage = mem::init();
442441
let storagep = &mut storage as *mut libc::sockaddr_storage;
443442
let size = mem::size_of::<libc::sockaddr_storage>();
444443
let mut size = size as libc::socklen_t;
@@ -543,7 +542,7 @@ impl rtio::RtioSocket for UdpSocket {
543542
impl rtio::RtioUdpSocket for UdpSocket {
544543
fn recvfrom(&mut self, buf: &mut [u8]) -> IoResult<(uint, ip::SocketAddr)> {
545544
unsafe {
546-
let mut storage: libc::sockaddr_storage = intrinsics::init();
545+
let mut storage: libc::sockaddr_storage = mem::init();
547546
let storagep = &mut storage as *mut libc::sockaddr_storage;
548547
let mut addrlen: libc::socklen_t =
549548
mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t;

0 commit comments

Comments
 (0)