Skip to content

Commit ed89f2f

Browse files
committed
---
yaml --- r: 6964 b: refs/heads/master c: 36c55b2 h: refs/heads/master v: v3
1 parent b782c8e commit ed89f2f

File tree

13 files changed

+95
-83
lines changed

13 files changed

+95
-83
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d07c6e8a0ede3114ebfd8c3ea6cc161cf009f072
2+
refs/heads/master: 36c55b20a89d45f394fceb5e83dd3a032e37810a

trunk/doc/rust.texi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,10 @@ otherwise defined as keywords or reserved
595595
tokens. @xref{Ref.Lex.Key}. @xref{Ref.Lex.Res}.
596596

597597
That is: an identifier starts with any character having derived property
598-
@code{XID_Start} and continues with zero or more characters having derived
599-
property @code{XID_Continue}; and such an identifier is NFKC-normalized during
600-
lexing, such that all subsequent comparison of identifiers is performed on the
598+
@code{XID_Start}, or the character U+005F (underscore, @code{_}), and
599+
continues with zero or more characters having derived property
600+
@code{XID_Continue}. An identifier is NFKC-normalized during lexing, such
601+
that all subsequent comparison of identifiers is performed on the
601602
NFKC-normalized forms.
602603

603604
@emph{TODO: define relationship between Unicode and Rust versions}.

trunk/src/comp/middle/last_use.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import syntax::{visit, ast_util};
22
import syntax::ast::*;
33
import syntax::codemap::span;
4-
import std::list::{is_not_empty, list, nil, cons, tail};
4+
import std::list::{list, nil, cons, tail};
55
import core::{vec, option};
66
import std::list;
77

@@ -177,9 +177,7 @@ fn visit_block(tp: block_type, cx: ctx, visit: block()) {
177177
visit();
178178
local.second = true;
179179
visit();
180-
let cx_blocks = cx.blocks;
181-
check is_not_empty(cx_blocks);
182-
cx.blocks = tail(cx_blocks);
180+
cx.blocks = tail(cx.blocks);
183181
cx.current = join_branches(local.exits);
184182
}
185183

trunk/src/comp/middle/resolve.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ fn map_crate(e: @env, c: @ast::crate) {
266266
let imp = follow_import(*e, sc, *path, vi.span);
267267
if option::is_some(imp) {
268268
let glob = {def: option::get(imp), item: vi};
269-
check list::is_not_empty(sc);
270269
alt list::head(sc) {
271270
scope_item(i) {
272271
e.mod_map.get(i.id).glob_imports += [glob];
@@ -456,7 +455,6 @@ fn visit_block_with_scope(b: ast::blk, sc: scopes, v: vt<scopes>) {
456455
}
457456

458457
fn visit_decl_with_scope(d: @decl, sc: scopes, v: vt<scopes>) {
459-
check list::is_not_empty(sc);
460458
let loc_pos = alt list::head(sc) {
461459
scope_block(_, _, pos) { pos }
462460
_ { @mutable 0u }

trunk/src/comp/syntax/parse/lexer.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,16 @@ fn next_token(rdr: reader) -> {tok: token::token, chpos: uint, bpos: uint} {
309309
fn next_token_inner(rdr: reader) -> token::token {
310310
let accum_str = "";
311311
let c = rdr.curr();
312-
if is_alpha(c) || c == '_' {
313-
while is_alnum(c) || c == '_' {
312+
if char::is_XID_start(c) || c == '_' {
313+
while char::is_XID_continue(c) {
314314
str::push_char(accum_str, c);
315315
rdr.bump();
316316
c = rdr.curr();
317317
}
318318
if str::eq(accum_str, "_") { ret token::UNDERSCORE; }
319319
let is_mod_name = c == ':' && rdr.next() == ':';
320+
321+
// FIXME: perform NFKC normalization here.
320322
ret token::IDENT(interner::intern::<str>(*rdr.get_interner(),
321323
accum_str), is_mod_name);
322324
}

trunk/src/libcore/char.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ Utilities for manipulating the char type
3737
Cn Unassigned a reserved unassigned code point or a noncharacter
3838
*/
3939

40+
export is_alphabetic,
41+
is_XID_start, is_XID_continue,
42+
is_lowercase, is_uppercase,
43+
is_whitespace, is_alphanumeric,
44+
to_digit, maybe_digit, cmp;
45+
4046
import is_alphabetic = unicode::derived_property::Alphabetic;
4147
import is_XID_start = unicode::derived_property::XID_Start;
4248
import is_XID_continue = unicode::derived_property::XID_Continue;

trunk/src/libstd/list.rs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,6 @@ fn has<copy T>(ls: list<T>, elt: T) -> bool {
9797
ret false;
9898
}
9999

100-
/*
101-
Function: is_empty
102-
103-
Returns true if the list is empty.
104-
*/
105-
pure fn is_empty<copy T>(ls: list<T>) -> bool {
106-
alt ls {
107-
nil. { true }
108-
_ { false }
109-
}
110-
}
111-
112-
/*
113-
Function: is_not_empty
114-
115-
Returns true if the list is not empty.
116-
*/
117-
pure fn is_not_empty<copy T>(ls: list<T>) -> bool {
118-
ret !is_empty(ls);
119-
}
120-
121100
/*
122101
Function: len
123102
@@ -133,23 +112,17 @@ Function: tail
133112
134113
Returns all but the first element of a list
135114
*/
136-
pure fn tail<copy T>(ls: list<T>) : is_not_empty(ls) -> list<T> {
137-
alt ls {
138-
cons(_, tl) { ret *tl; }
139-
nil. { fail "list empty" }
140-
}
115+
pure fn tail<copy T>(ls: list<T>) -> list<T> {
116+
alt ls { cons(_, tl) { ret *tl; } nil. { fail "list empty" } }
141117
}
142118

143119
/*
144120
Function: head
145121
146122
Returns the first element of a list
147123
*/
148-
pure fn head<copy T>(ls: list<T>) : is_not_empty(ls) -> T {
149-
alt ls {
150-
cons(hd, _) { ret hd; }
151-
nil. { fail "list empty" }
152-
}
124+
pure fn head<copy T>(ls: list<T>) -> T {
125+
alt ls { cons(hd, _) { ret hd; } nil. { fail "list empty" } }
153126
}
154127

155128
/*

trunk/src/rt/arch/i386/morestack.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ MORESTACK:
150150
movl %ecx, 16(%esp)
151151
movl %edx, 12(%esp)
152152

153+
// FIXME (1388): it's possible we also need to save/restore some
154+
// SSE2 registers here, if floats-go-in-regs on x86+SSE2. Unclear.
155+
153156
// FIXME (1226): main is compiled with the split-stack prologue,
154157
// causing it to call __morestack, so we have to jump back out
155158
calll RUST_GET_TASK
@@ -201,9 +204,6 @@ MORESTACK:
201204
// Save the return value of the function we allocated space for
202205
movl %eax, (%esp)
203206

204-
// Now that we're on the return path we want to avoid
205-
// stomping on %eax. FIXME: Need to save and restore %eax to
206-
// actually preserve it across the call to delete the stack
207207
call UPCALL_DEL_STACK
208208

209209
// And restore it

trunk/src/rt/arch/x86_64/morestack.S

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ MORESTACK:
6161
pushq %r8
6262
pushq %r9
6363

64+
pushq $0 // Alignment
65+
pushq $0 // Alignment
66+
67+
subq $128, %rsp
68+
movdqa %xmm0, (%rsp)
69+
movdqa %xmm1, 16(%rsp)
70+
movdqa %xmm2, 32(%rsp)
71+
movdqa %xmm3, 48(%rsp)
72+
movdqa %xmm4, 64(%rsp)
73+
movdqa %xmm5, 80(%rsp)
74+
movdqa %xmm6, 96(%rsp)
75+
movdqa %xmm7, 112(%rsp)
76+
6477
// Calculate the address of the stack arguments.
6578
// We have the base pointer, __morestack's return address,
6679
// and __morestack's caller's return address to skip
@@ -72,7 +85,7 @@ MORESTACK:
7285
movq %r11, %rdx // Size of stack arguments
7386
movq %rax, %rsi // Address of stack arguments
7487
movq %r10, %rdi // The amount of stack needed
75-
88+
7689
#ifdef __APPLE__
7790
call UPCALL_NEW_STACK
7891
#endif
@@ -81,6 +94,19 @@ MORESTACK:
8194
#endif
8295

8396
// Pop the saved arguments
97+
movdqa (%rsp), %xmm0
98+
movdqa 16(%rsp), %xmm1
99+
movdqa 32(%rsp), %xmm2
100+
movdqa 48(%rsp), %xmm3
101+
movdqa 64(%rsp), %xmm4
102+
movdqa 80(%rsp), %xmm5
103+
movdqa 96(%rsp), %xmm6
104+
movdqa 112(%rsp), %xmm7
105+
addq $128, %rsp
106+
107+
popq %r9 // Alignment
108+
popq %r9 // Alignment
109+
84110
popq %r9
85111
popq %r8
86112
popq %rcx
@@ -103,7 +129,6 @@ MORESTACK:
103129
// Save the return value
104130
pushq %rax
105131

106-
// FIXME: Should preserve %rax here
107132
#ifdef __APPLE__
108133
call UPCALL_DEL_STACK
109134
#endif

trunk/src/test/run-pass/non-boolean-pure-fns.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ pure fn nonempty_list<copy T>(ls: list<T>) -> bool { pure_length(ls) > 0u }
1414
// knowledge that ls is a cons node. Future work.
1515
// Also, this is pretty contrived since nonempty_list
1616
// could be a "tag refinement", if we implement those.
17-
fn safe_head<copy T>(ls: list<T>) : nonempty_list(ls) -> T {
18-
check is_not_empty(ls);
19-
ret head(ls);
20-
}
17+
fn safe_head<copy T>(ls: list<T>) : nonempty_list(ls) -> T { head(ls) }
2118

2219
fn main() {
2320
let mylist = cons(@1u, @nil);

trunk/src/test/run-pass/unchecked-predicates.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
// Uses foldl to exhibit the unchecked block syntax.
2-
// TODO: since list's head/tail require the predicate "is_not_empty" now and
3-
// we have unit tests for list, this test might me not necessary anymore?
42
use std;
53

64
import std::list::*;
75

86
// Can't easily be written as a "pure fn" because there's
97
// no syntax for specifying that f is pure.
108
fn pure_foldl<copy T, copy U>(ls: list<T>, u: U, f: block(T, U) -> U) -> U {
11-
alt ls {
12-
nil. { u }
13-
cons(hd, tl) { f(hd, pure_foldl(*tl, f(hd, u), f)) }
14-
}
9+
alt ls { nil. { u } cons(hd, tl) { f(hd, pure_foldl(*tl, f(hd, u), f)) } }
1510
}
1611

1712
// Shows how to use an "unchecked" block to call a general
@@ -27,10 +22,7 @@ pure fn nonempty_list<copy T>(ls: list<T>) -> bool { pure_length(ls) > 0u }
2722
// knowledge that ls is a cons node. Future work.
2823
// Also, this is pretty contrived since nonempty_list
2924
// could be a "tag refinement", if we implement those.
30-
fn safe_head<copy T>(ls: list<T>) : nonempty_list(ls) -> T {
31-
check is_not_empty(ls);
32-
ret head(ls)
33-
}
25+
fn safe_head<copy T>(ls: list<T>) : nonempty_list(ls) -> T { head(ls) }
3426

3527
fn main() {
3628
let mylist = cons(@1u, @nil);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
fn main() {
2+
let Π = 3.14;
3+
let लंच = Π * Π + 1.54;
4+
assert लंच - 1.54 == Π * Π;
5+
assert საჭმელად_გემრიელი_სადილი() == 0;
6+
}
7+
8+
fn საჭმელად_გემრიელი_სადილი() -> int {
9+
10+
// Lunch in several languages.
11+
12+
let ランチ = 10;
13+
let 午餐 = 10;
14+
15+
let ארוחת_צהריי = 10;
16+
let غداء = 10;
17+
let լանչ = 10;
18+
let обед = 10;
19+
let абед = 10;
20+
let μεσημεριανό = 10;
21+
let hádegismatur = 10;
22+
let ручек = 10;
23+
24+
let ăn_trưa = 10;
25+
let อาหารกลางวัน = 10;
26+
27+
// Lunchy arithmetic, mm.
28+
29+
assert hádegismatur * ручек * обед == 1000;
30+
assert 10 == ארוחת_צהריי;
31+
assert ランチ + 午餐 + μεσημεριανό == 30;
32+
assert ăn_trưa + อาหารกลางวัน == 20;
33+
ret (абед + լանչ) >> غداء;
34+
}

trunk/src/test/stdtest/list.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@ import core::*;
22

33
use std;
44
import std::list;
5-
import std::list::{from_vec, head, is_not_empty, tail};
5+
import std::list::head;
6+
import std::list::tail;
7+
import std::list::from_vec;
68
import option;
79

810
#[test]
911
fn test_from_vec() {
1012
let l = from_vec([0, 1, 2]);
11-
12-
check is_not_empty(l);
1313
assert (head(l) == 0);
14-
15-
let tail_l = tail(l);
16-
check is_not_empty(tail_l);
17-
assert (head(tail_l) == 1);
18-
19-
let tail_tail_l = tail(tail_l);
20-
check is_not_empty(tail_tail_l);
21-
assert (head(tail_tail_l) == 2);
14+
assert (head(tail(l)) == 1);
15+
assert (head(tail(tail(l))) == 2);
2216
}
2317

2418
#[test]
@@ -30,17 +24,9 @@ fn test_from_vec_empty() {
3024
#[test]
3125
fn test_from_vec_mut() {
3226
let l = from_vec([mutable 0, 1, 2]);
33-
34-
check is_not_empty(l);
3527
assert (head(l) == 0);
36-
37-
let tail_l = tail(l);
38-
check is_not_empty(tail_l);
39-
assert (head(tail_l) == 1);
40-
41-
let tail_tail_l = tail(tail_l);
42-
check is_not_empty(tail_tail_l);
43-
assert (head(tail_tail_l) == 2);
28+
assert (head(tail(l)) == 1);
29+
assert (head(tail(tail(l))) == 2);
4430
}
4531

4632
#[test]

0 commit comments

Comments
 (0)