Skip to content

Commit fe694f5

Browse files
committed
---
yaml --- r: 13694 b: refs/heads/master c: 6322eda h: refs/heads/master v: v3
1 parent 99d7116 commit fe694f5

File tree

118 files changed

+1776
-1261
lines changed

Some content is hidden

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

118 files changed

+1776
-1261
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b837f37d404bd74eec95496281814f268dbdcd23
2+
refs/heads/master: 6322eda35ca0e5d05247eccfa820f0aa730591ce
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/RELEASES.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Version 0.3 (June 2012) - not yet!
77
* Integer-literal suffix inference
88
* Per-module control over warnings, errors
99
* #[cfg(windows)] and #[cfg(unix)] attributes
10-
* *-patterns (wildcard extended to all constructor fields)
1110

1211
* Semantic cleanup
1312
* Resolve pass and exhaustiveness checker rewritten
@@ -18,13 +17,12 @@ Version 0.3 (June 2012) - not yet!
1817
* Experimental new language features
1918
* Slices and fixed-size, interior-allocated vectors
2019
* #!-comments for lang versioning, shell execution
21-
* Destructors and iface implementation for classes;
22-
type-parameterized classes and class methods
20+
* More work on classes
2321
* Type reflection
2422

2523
* Removal of various obsolete features
2624
* Keywords: be, prove, syntax, note, mutable, do, bind
27-
* Constructs: do-while loops, fn binding, resources
25+
* Constructs: do-while loops, fn binding,
2826

2927
* Compiler reorganization
3028
* Syntax-layer of compiler split into separate crate
@@ -41,9 +39,6 @@ Version 0.3 (June 2012) - not yet!
4139
* Syntax extensions: #line, #col, #file, #mod,
4240
#stringify, #include, #include_str, #include_bin.
4341

44-
* Tool improvements
45-
* Cargo automatically resolves dependencies
46-
4742
Version 0.2 (March 2012)
4843
-------------------------
4944

trunk/configure

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,13 @@ fi
311311
step_msg "looking for build programs"
312312

313313
probe_need CFG_PERL perl
314-
probe_need CFG_PYTHON python python2.6 python2 python3
315314
probe_need CFG_CURL curl
315+
probe_need CFG_PYTHON python2.7 python2.6 python2 python
316+
317+
python_version=$($CFG_PYTHON -V 2>&1)
318+
if [ $(echo $python_version | grep -c '^Python 2\.[4567]') -ne 1 ]; then
319+
err "Found $python_version, but LLVM requires Python 2.4-2.7"
320+
fi
316321

317322
# If we have no git directory then we are probably a tarball distribution
318323
# and shouldn't attempt to load submodules

trunk/doc/rust.md

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,40 +1127,30 @@ enum list<T> {
11271127
let a: list<int> = cons(7, @cons(13, @nil));
11281128
~~~~
11291129

1130-
### Classes
1130+
### Resources
11311131

1132-
TODO: more about classes
1133-
1134-
_Classes_ are named record types that may have a destructor associated
1135-
with them, as well as fields and methods. For historical reasons, we
1136-
may call a class with a destructor and a single field a "resource".
1137-
1138-
A _class item_ declares a class type:
1132+
_Resources_ are values that have a destructor associated with them. A
1133+
_resource item_ is used to declare resource type and constructor.
11391134

11401135
~~~~
1141-
class file_descriptor {
1142-
let fd: libc::c_int;
1143-
new(fd: libc::c_int) { self.fd = fd; }
1144-
drop { libc::close(self.fd); }
1136+
resource file_descriptor(fd: libc::c_int) {
1137+
libc::close(fd);
11451138
}
11461139
~~~~
11471140

11481141
Calling the `file_descriptor` constructor function on an integer will
11491142
produce a value with the `file_descriptor` type. Resource types have a
1150-
noncopyable [type kind](#type-kinds), and thus may not be
1151-
copied. Class types that don't have destructors may be copied if all
1152-
their fields are copyable. The semantics guarantee that for each
1153-
constructed resource value, the destructor will run once: when the
1154-
value is disposed of (barring drastic program termination that somehow
1155-
prevents unwinding from taking place). For stack-allocated values,
1156-
disposal happens when the value goes out of scope. For values in
1157-
shared boxes, it happens when the reference count of the box reaches
1158-
zero.
1159-
1160-
The argument or arguments to the class constructor may be stored in
1161-
the class's named fields, and can be accessed by a field reference. In
1162-
this case, the `file_descriptor`'s data field would be accessed like
1163-
`f.fd`, if `f` is a value of type `file_descriptor`.
1143+
noncopyable [type kind](#type-kinds), and thus may not be copied. The
1144+
semantics guarantee that for each constructed resources value, the
1145+
destructor will run once: when the value is disposed of (barring
1146+
drastic program termination that somehow prevents unwinding from taking
1147+
place). For stack-allocated values, disposal happens when the value
1148+
goes out of scope. For values in shared boxes, it happens when the
1149+
reference count of the box reaches zero.
1150+
1151+
The argument to the resource constructor is stored in the resulting
1152+
value, and can be accessed using the dereference (`*`) [unary
1153+
operator](#unary-operator-expressions).
11641154

11651155
### Interfaces
11661156

trunk/doc/tutorial.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,26 @@ Like vectors, strings are always unique. You can wrap them in a shared
13771377
box to share them. Unlike vectors, there is no mutable variant of
13781378
strings. They are always immutable.
13791379
1380-
NOTE: Section on resources removed. ToDo: document classes and destructors
1380+
## Resources
1381+
1382+
Resources are data types that have a destructor associated with them.
1383+
1384+
~~~~
1385+
# fn close_file_desc(x: int) {}
1386+
resource file_desc(fd: int) {
1387+
close_file_desc(fd);
1388+
}
1389+
~~~~
1390+
1391+
This defines a type `file_desc` and a constructor of the same name,
1392+
which takes an integer. The type has an associated destructor procedure,
1393+
whose contents are specified by the block. Values of such a type can not
1394+
be copied, and when they are destroyed (by going out of scope, or, when
1395+
boxed, when their box is cleaned up), their body runs. In the example
1396+
above, this would cause the given file descriptor to be closed.
1397+
1398+
NOTE: We're considering alternative approaches for data types with
1399+
destructors. Resources might go away in the future.
13811400
13821401
# Argument passing
13831402
@@ -1562,7 +1581,7 @@ without any sophistication).
15621581
## Kinds
15631582
15641583
Perhaps surprisingly, the 'copy' (duplicate) operation is not defined
1565-
for all Rust types. Resource types (classes with destructors) cannot be
1584+
for all Rust types. Resource types (types with destructors) can not be
15661585
copied, and neither can any type whose copying would require copying a
15671586
resource (such as records or unique boxes containing a resource).
15681587

trunk/mk/platform.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ endef
99
$(foreach t,$(CFG_TARGET_TRIPLES),$(eval $(call DEF_HOST_VAR,$(t))))
1010
$(foreach t,$(CFG_TARGET_TRIPLES),$(info cfg: host for $(t) is $(HOST_$(t))))
1111

12+
# FIXME: This appears to do nothing
13+
CFG_GCCISH_FLAGS += -fno-strict-aliasing
14+
1215
# FIXME: no-omit-frame-pointer is just so that task_start_wrapper
1316
# has a frame pointer and the stack walker can understand it. Turning off
1417
# frame pointers everywhere is overkill
@@ -143,7 +146,7 @@ ifdef CFG_UNIXY
143146
CFG_VALGRIND += wine
144147
endif
145148

146-
CFG_GCCISH_CFLAGS := -march=i586
149+
CFG_GCCISH_CFLAGS := -fno-strict-aliasing -march=i586
147150
CFG_GCCISH_PRE_LIB_FLAGS :=
148151
CFG_GCCISH_POST_LIB_FLAGS :=
149152
CFG_GCCISH_DEF_FLAG :=

trunk/src/libcore/arc.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,17 @@ type arc_data<T> = {
2424
data: T
2525
};
2626

27-
class arc_destruct<T> {
28-
let data: *libc::c_void;
29-
new(data: *libc::c_void) { self.data = data; }
30-
drop unsafe {
31-
let data: ~arc_data<T> = unsafe::reinterpret_cast(self.data);
32-
let new_count = rustrt::rust_atomic_decrement(&mut data.count);
33-
assert new_count >= 0;
34-
if new_count == 0 {
35-
// drop glue takes over.
36-
} else {
37-
unsafe::forget(data);
38-
}
39-
}
27+
resource arc_destruct<T>(data: *libc::c_void) {
28+
unsafe {
29+
let data: ~arc_data<T> = unsafe::reinterpret_cast(data);
30+
let new_count = rustrt::rust_atomic_decrement(&mut data.count);
31+
assert new_count >= 0;
32+
if new_count == 0 {
33+
// drop glue takes over.
34+
} else {
35+
unsafe::forget(data);
36+
}
37+
}
4038
}
4139

4240
type arc<T: const> = arc_destruct<T>;
@@ -54,7 +52,7 @@ fn arc<T: const>(-data: T) -> arc<T> {
5452
wrapper."]
5553
fn get<T: const>(rc: &a.arc<T>) -> &a.T {
5654
unsafe {
57-
let ptr: ~arc_data<T> = unsafe::reinterpret_cast((*rc).data);
55+
let ptr: ~arc_data<T> = unsafe::reinterpret_cast(**rc);
5856
// Cast us back into the correct region
5957
let r = unsafe::reinterpret_cast(&ptr.data);
6058
unsafe::forget(ptr);
@@ -69,12 +67,12 @@ object. However, one of the `arc` objects can be sent to another task,
6967
allowing them to share the underlying data."]
7068
fn clone<T: const>(rc: &arc<T>) -> arc<T> {
7169
unsafe {
72-
let ptr: ~arc_data<T> = unsafe::reinterpret_cast((*rc).data);
70+
let ptr: ~arc_data<T> = unsafe::reinterpret_cast(**rc);
7371
let new_count = rustrt::rust_atomic_increment(&mut ptr.count);
7472
assert new_count >= 2;
7573
unsafe::forget(ptr);
7674
}
77-
arc_destruct((*rc).data)
75+
arc_destruct(**rc)
7876
}
7977

8078
// An arc over mutable data that is protected by a lock.
@@ -95,19 +93,17 @@ impl methods<T: send> for exclusive<T> {
9593
fn clone() -> exclusive<T> {
9694
unsafe {
9795
// this makes me nervous...
98-
let ptr: ~arc_data<ex_data<T>> =
99-
unsafe::reinterpret_cast(self.data);
96+
let ptr: ~arc_data<ex_data<T>> = unsafe::reinterpret_cast(*self);
10097
let new_count = rustrt::rust_atomic_increment(&mut ptr.count);
10198
assert new_count > 1;
10299
unsafe::forget(ptr);
103100
}
104-
arc_destruct(self.data)
101+
arc_destruct(*self)
105102
}
106103

107104
fn with<U>(f: fn(sys::condition, x: &T) -> U) -> U {
108105
unsafe {
109-
let ptr: ~arc_data<ex_data<T>> =
110-
unsafe::reinterpret_cast(self.data);
106+
let ptr: ~arc_data<ex_data<T>> = unsafe::reinterpret_cast(*self);
111107
let r = {
112108
let rec: &ex_data<T> = &(*ptr).data;
113109
rec.lock.lock_cond() {|c|
@@ -127,10 +123,8 @@ type get_chan<T: const send> = chan<chan<arc<T>>>;
127123
// (terminate, get)
128124
type shared_arc<T: const send> = (shared_arc_res, get_chan<T>);
129125

130-
class shared_arc_res {
131-
let c: comm::chan<()>;
132-
new(c: comm::chan<()>) { self.c = c; }
133-
drop { self.c.send(()); }
126+
resource shared_arc_res(c: comm::chan<()>) {
127+
c.send(());
134128
}
135129

136130
fn shared_arc<T: send const>(-data: T) -> shared_arc<T> {

trunk/src/libcore/box.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
export ptr_eq;
44

5-
pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
5+
pure fn ptr_eq<T>(a: @T, b: @T) -> bool unchecked {
66
#[doc = "Determine if two shared boxes point to the same object"];
7-
unsafe { ptr::addr_of(*a) == ptr::addr_of(*b) }
7+
ptr::addr_of(*a) == ptr::addr_of(*b)
88
}
99

1010
#[test]

trunk/src/libcore/char.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ fn test_to_digit() {
231231
}
232232

233233
#[test]
234-
fn test_is_ascii() {
234+
fn test_is_ascii() unsafe {
235235
assert str::all("banana", char::is_ascii);
236236
assert ! str::all("ประเทศไทย中华Việt Nam", char::is_ascii);
237237
}

trunk/src/libcore/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,13 @@ fn recv_<T: send>(p: *rust_port) -> T {
210210
ret res;
211211
}
212212

213-
fn peek_(p: *rust_port) -> bool {
213+
fn peek_(p: *rust_port) -> bool unsafe {
214214
rustrt::rust_port_size(p) != 0u as libc::size_t
215215
}
216216

217217
#[doc = "Receive on one of two ports"]
218218
fn select2<A: send, B: send>(p_a: port<A>, p_b: port<B>)
219-
-> either<A, B> {
219+
-> either<A, B> unsafe {
220220
let ports = [(**p_a).po, (**p_b).po];
221221
let n_ports = 2 as libc::size_t;
222222
let yield = 0u, yieldp = ptr::addr_of(yield);

trunk/src/libcore/core.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,9 @@ import option_iter::extensions;
1212
import ptr::extensions;
1313
import rand::extensions;
1414
import result::extensions;
15-
import int::num;
16-
import i8::num;
17-
import i16::num;
18-
import i32::num;
19-
import i64::num;
20-
import uint::num;
21-
import u8::num;
22-
import u16::num;
23-
import u32::num;
24-
import u64::num;
25-
import float::num;
26-
import f32::num;
27-
import f64::num;
2815

2916
export path, option, some, none, unreachable;
3017
export extensions;
31-
// The following exports are the extension impls for numeric types
32-
export num;
3318

3419
// Export the log levels as global constants. Higher levels mean
3520
// more-verbosity. Error is the bottom level, default logging level is

trunk/src/libcore/extfmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ mod ct {
8181
enum piece { piece_string(str), piece_conv(conv), }
8282
type error_fn = fn@(str) -> ! ;
8383

84-
fn parse_fmt_string(s: str, error: error_fn) -> [piece] {
84+
fn parse_fmt_string(s: str, error: error_fn) -> [piece] unsafe {
8585
let mut pieces: [piece] = [];
8686
let lim = str::len(s);
8787
let mut buf = "";
@@ -225,7 +225,7 @@ mod ct {
225225
} else { {count: count_implied, next: i} };
226226
}
227227
fn parse_type(s: str, i: uint, lim: uint, error: error_fn) ->
228-
{ty: ty, next: uint} {
228+
{ty: ty, next: uint} unsafe {
229229
if i >= lim { error("missing type in conversion"); }
230230
let tstr = str::slice(s, i, i+1u);
231231
// TODO: Do we really want two signed types here?
@@ -314,7 +314,7 @@ mod rt {
314314
let mut s = str::from_char(c);
315315
ret pad(cv, s, pad_nozero);
316316
}
317-
fn conv_str(cv: conv, s: str) -> str {
317+
fn conv_str(cv: conv, s: str) -> str unsafe {
318318
// For strings, precision is the maximum characters
319319
// displayed
320320
let mut unpadded = alt cv.precision {
@@ -378,7 +378,7 @@ mod rt {
378378
};
379379
}
380380
enum pad_mode { pad_signed, pad_unsigned, pad_nozero, pad_float }
381-
fn pad(cv: conv, &s: str, mode: pad_mode) -> str {
381+
fn pad(cv: conv, &s: str, mode: pad_mode) -> str unsafe {
382382
let uwidth : uint = alt cv.width {
383383
count_implied { ret s; }
384384
count_is(width) {

trunk/src/libcore/f32.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
import cmath::c_float::*;
66
import cmath::c_float_targ_consts::*;
7+
import num::num;
78

8-
export add, sub, mul, div, rem, lt, le, gt, eq, ne;
9+
export add, sub, mul, div, rem, lt, le, gt, eq, eq, ne;
910
export is_positive, is_negative, is_nonpositive, is_nonnegative;
1011
export is_zero, is_infinite, is_finite;
1112
export NaN, is_NaN, infinity, neg_infinity;
@@ -17,7 +18,6 @@ export mul_add, fmax, fmin, nextafter, frexp, hypot, ldexp;
1718
export lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix;
1819
export modf, pow, round, sin, sinh, sqrt, tan, tanh, tgamma, trunc;
1920
export signbit;
20-
2121
export num;
2222

2323
// These are not defined inside consts:: for consistency with
@@ -173,7 +173,7 @@ pure fn log2(n: f32) -> f32 {
173173
ret ln(n) / consts::ln_2;
174174
}
175175

176-
impl num of num::num for f32 {
176+
impl num of num for f32 {
177177
fn add(&&other: f32) -> f32 { ret self + other; }
178178
fn sub(&&other: f32) -> f32 { ret self - other; }
179179
fn mul(&&other: f32) -> f32 { ret self * other; }

0 commit comments

Comments
 (0)