Skip to content

Commit e4d5449

Browse files
committed
---
yaml --- r: 141231 b: refs/heads/try2 c: 2706271 h: refs/heads/master i: 141229: 6352457 141227: bf39afa 141223: 0e5aeb9 141215: 55fed12 v: v3
1 parent 58ae4f5 commit e4d5449

File tree

17 files changed

+550
-312
lines changed

17 files changed

+550
-312
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: 523360415cca24ac0cbd198804d797dd05c48559
8+
refs/heads/try2: 270627131753c5fe742943e02ff21446aabca103
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ src/.DS_Store
7373
/doc/html
7474
/doc/latex
7575
/doc/std
76+
/doc/extra
7677
/nd/
7778
/llvm/
7879
version.md
@@ -81,7 +82,6 @@ keywords.md
8182
x86_64-apple-darwin/
8283
x86_64-unknown-linux-gnu/
8384
i686-unknown-linux-gnu/
84-
doc/core/
8585
tmp.*.rs
8686
config.stamp
8787
.DS_Store

branches/try2/mk/platform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $(foreach t,$(CFG_TARGET_TRIPLES),$(info cfg: os for $(t) is $(OSTYPE_$(t))))
2929
# FIXME: no-omit-frame-pointer is just so that task_start_wrapper
3030
# has a frame pointer and the stack walker can understand it. Turning off
3131
# frame pointers everywhere is overkill
32-
CFG_GCCISH_CFLAGS += -fno-omit-frame-pointer
32+
CFG_GCCISH_CFLAGS += -fno-omit-frame-pointer -DUSE_UTF8
3333

3434
# On Darwin, we need to run dsymutil so the debugging information ends
3535
# up in the right place. On other platforms, it automatically gets

branches/try2/src/libextra/arc.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub impl<'self> Condvar<'self> {
107107
****************************************************************************/
108108

109109
/// An atomically reference counted wrapper for shared immutable state.
110-
struct ARC<T> { x: UnsafeAtomicRcBox<T> }
110+
pub struct ARC<T> { x: UnsafeAtomicRcBox<T> }
111111

112112
/// Create an atomically reference counted wrapper.
113113
pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
@@ -118,29 +118,22 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
118118
* Access the underlying data in an atomically reference counted
119119
* wrapper.
120120
*/
121-
pub fn get<'a, T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
122-
rc.get()
123-
}
124-
125-
impl<T:Const+Owned> ARC<T> {
126-
pub fn get<'a>(&'a self) -> &'a T {
121+
pub impl<T:Const+Owned> ARC<T> {
122+
fn get<'a>(&'a self) -> &'a T {
127123
unsafe { &*self.x.get_immut() }
128124
}
129125
}
126+
130127
/**
131128
* Duplicate an atomically reference counted wrapper.
132129
*
133130
* The resulting two `arc` objects will point to the same underlying data
134131
* object. However, one of the `arc` objects can be sent to another task,
135132
* allowing them to share the underlying data.
136133
*/
137-
pub fn clone<T:Const + Owned>(rc: &ARC<T>) -> ARC<T> {
138-
ARC { x: rc.x.clone() }
139-
}
140-
141134
impl<T:Const + Owned> Clone for ARC<T> {
142135
fn clone(&self) -> ARC<T> {
143-
clone(self)
136+
ARC { x: self.x.clone() }
144137
}
145138
}
146139

@@ -512,34 +505,31 @@ pub impl<'self, T:Const + Owned> RWReadMode<'self, T> {
512505
#[cfg(test)]
513506
mod tests {
514507
use core::prelude::*;
515-
508+
use core::cell::Cell;
516509
use arc::*;
517510
use arc;
518511

519-
use core::cell::Cell;
520-
use core::task;
521-
522512
#[test]
523513
fn manually_share_arc() {
524514
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
525-
let arc_v = arc::ARC(v);
515+
let arc_v = ARC(v);
526516

527517
let (p, c) = comm::stream();
528518

529519
do task::spawn() || {
530520
let p = comm::PortSet::new();
531521
c.send(p.chan());
532522

533-
let arc_v = p.recv();
523+
let arc_v : ARC<~[int]> = p.recv();
534524

535-
let v = copy *arc::get::<~[int]>(&arc_v);
525+
let v = copy (*arc_v.get());
536526
assert_eq!(v[3], 4);
537527
};
538528

539529
let c = p.recv();
540-
c.send(arc::clone(&arc_v));
530+
c.send(arc_v.clone());
541531

542-
assert_eq!((*arc::get(&arc_v))[2], 3);
532+
assert_eq!(arc_v.get()[2], 3);
543533
assert_eq!(arc_v.get()[4], 5);
544534

545535
info!(arc_v);

branches/try2/src/librust/rust.rc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ extern mod rustc;
3232
use core::prelude::*;
3333

3434
use core::run;
35+
use core::libc::exit;
3536

3637
enum ValidUsage {
37-
Valid, Invalid
38+
Valid(int), Invalid
3839
}
3940

4041
impl ValidUsage {
4142
fn is_valid(&self) -> bool {
4243
match *self {
43-
Valid => true,
44-
Invalid => false
44+
Valid(_) => true,
45+
Invalid => false
4546
}
4647
}
4748
}
@@ -144,7 +145,7 @@ fn cmd_help(args: &[~str]) -> ValidUsage {
144145
UsgStr(msg) => io::println(fmt!("%s\n", msg)),
145146
UsgCall(f) => f(),
146147
}
147-
Valid
148+
Valid(0)
148149
},
149150
None => Invalid
150151
}
@@ -162,8 +163,8 @@ fn cmd_test(args: &[~str]) -> ValidUsage {
162163
let test_exec = Path(filename).filestem().unwrap() + "test~";
163164
invoke("rustc", &[~"--test", filename.to_owned(),
164165
~"-o", test_exec.to_owned()], rustc::main);
165-
run::run_program(~"./" + test_exec, []);
166-
Valid
166+
let exit_code = run::run_program(~"./" + test_exec, []);
167+
Valid(exit_code)
167168
}
168169
_ => Invalid
169170
}
@@ -175,8 +176,8 @@ fn cmd_run(args: &[~str]) -> ValidUsage {
175176
let exec = Path(filename).filestem().unwrap() + "~";
176177
invoke("rustc", &[filename.to_owned(), ~"-o", exec.to_owned()],
177178
rustc::main);
178-
run::run_program(~"./"+exec, prog_args);
179-
Valid
179+
let exit_code = run::run_program(~"./"+exec, prog_args);
180+
Valid(exit_code)
180181
}
181182
_ => Invalid
182183
}
@@ -194,7 +195,7 @@ fn do_command(command: &Command, args: &[~str]) -> ValidUsage {
194195
Call(f) => f(args),
195196
CallMain(prog, f) => {
196197
invoke(prog, args, f);
197-
Valid
198+
Valid(0)
198199
}
199200
}
200201
}
@@ -233,7 +234,10 @@ pub fn main() {
233234
if !args.is_empty() {
234235
for find_cmd(*args.head()).each |command| {
235236
let result = do_command(command, args.tail());
236-
if result.is_valid() { return; }
237+
match result {
238+
Valid(exit_code) => unsafe { exit(exit_code.to_i32()) },
239+
_ => loop
240+
}
237241
}
238242
}
239243

branches/try2/src/librustc/front/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ fn fold_block(
136136
) -> ast::blk_ {
137137
let filtered_stmts =
138138
b.stmts.filter_mapped(|a| filter_stmt(cx, *a));
139+
let filtered_view_items =
140+
b.view_items.filter_mapped(|a| filter_view_item(cx, *a));
139141
ast::blk_ {
140-
view_items: /*bad*/copy b.view_items,
142+
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
141143
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
142144
expr: b.expr.map(|x| fld.fold_expr(*x)),
143145
id: b.id,

branches/try2/src/libsyntax/ext/trace_macros.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use ext::base::ExtCtxt;
1616
use ext::base;
1717
use parse::lexer::{new_tt_reader, reader};
1818
use parse::parser::Parser;
19+
use parse::token::keywords;
1920

2021
pub fn expand_trace_macros(cx: @ExtCtxt,
2122
sp: span,
@@ -36,9 +37,9 @@ pub fn expand_trace_macros(cx: @ExtCtxt,
3637
rdr.dup()
3738
);
3839

39-
if rust_parser.is_keyword("true") {
40+
if rust_parser.is_keyword(keywords::True) {
4041
cx.set_trace_macros(true);
41-
} else if rust_parser.is_keyword("false") {
42+
} else if rust_parser.is_keyword(keywords::False) {
4243
cx.set_trace_macros(false);
4344
} else {
4445
cx.span_fatal(sp, "trace_macros! only accepts `true` or `false`")

branches/try2/src/libsyntax/parse/common.rs

Lines changed: 13 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use ast;
1414
use codemap::{BytePos, spanned};
1515
use parse::lexer::reader;
1616
use parse::parser::Parser;
17+
use parse::token::keywords;
1718
use parse::token;
1819

1920
use opt_vec;
@@ -133,54 +134,15 @@ pub impl Parser {
133134
return if *self.token == *tok { self.bump(); true } else { false };
134135
}
135136

136-
// Storing keywords as interned idents instead of strings would be nifty.
137-
138-
// A sanity check that the word we are asking for is a known keyword
139-
// NOTE: this could be done statically....
140-
fn require_keyword(&self, word: &str) {
141-
if !self.keywords.contains_equiv(&word) {
142-
self.bug(fmt!("unknown keyword: %s", word));
143-
}
144-
}
145-
146-
// return true when this token represents the given string, and is not
147-
// followed immediately by :: .
148-
fn token_is_word(&self, word: &str, tok: &token::Token) -> bool {
149-
match *tok {
150-
token::IDENT(sid, false) => { word == *self.id_to_str(sid) }
151-
_ => { false }
152-
}
153-
}
154-
155-
fn token_is_keyword(&self, word: &str, tok: &token::Token) -> bool {
156-
self.require_keyword(word);
157-
self.token_is_word(word, tok)
158-
}
159-
160-
fn is_keyword(&self, word: &str) -> bool {
161-
self.token_is_keyword(word, &copy *self.token)
162-
}
163-
164-
fn id_is_any_keyword(&self, id: ast::ident) -> bool {
165-
self.keywords.contains(self.id_to_str(id))
166-
}
167-
168-
fn is_any_keyword(&self, tok: &token::Token) -> bool {
169-
match *tok {
170-
token::IDENT(sid, false) => {
171-
self.keywords.contains(self.id_to_str(sid))
172-
}
173-
_ => false
174-
}
137+
fn is_keyword(&self, kw: keywords::Keyword) -> bool {
138+
token::is_keyword(kw, self.token)
175139
}
176140

177-
// if the given word is not a keyword, signal an error.
178141
// if the next token is the given keyword, eat it and return
179142
// true. Otherwise, return false.
180-
fn eat_keyword(&self, word: &str) -> bool {
181-
self.require_keyword(word);
143+
fn eat_keyword(&self, kw: keywords::Keyword) -> bool {
182144
let is_kw = match *self.token {
183-
token::IDENT(sid, false) => word == *self.id_to_str(sid),
145+
token::IDENT(sid, false) => kw.to_ident().repr == sid.repr,
184146
_ => false
185147
};
186148
if is_kw { self.bump() }
@@ -190,63 +152,30 @@ pub impl Parser {
190152
// if the given word is not a keyword, signal an error.
191153
// if the next token is not the given word, signal an error.
192154
// otherwise, eat it.
193-
fn expect_keyword(&self, word: &str) {
194-
self.require_keyword(word);
195-
if !self.eat_keyword(word) {
155+
fn expect_keyword(&self, kw: keywords::Keyword) {
156+
if !self.eat_keyword(kw) {
196157
self.fatal(
197158
fmt!(
198159
"expected `%s`, found `%s`",
199-
word,
160+
*self.id_to_str(kw.to_ident()),
200161
self.this_token_to_str()
201162
)
202163
);
203164
}
204165
}
205166

206-
// return true if the given string is a strict keyword
207-
fn is_strict_keyword(&self, word: &str) -> bool {
208-
self.strict_keywords.contains_equiv(&word)
209-
}
210-
211-
// signal an error if the current token is a strict keyword
212-
fn check_strict_keywords(&self) {
213-
match *self.token {
214-
token::IDENT(_, false) => {
215-
let w = token_to_str(self.reader, &copy *self.token);
216-
self.check_strict_keywords_(w);
217-
}
218-
_ => ()
219-
}
220-
}
221-
222167
// signal an error if the given string is a strict keyword
223-
fn check_strict_keywords_(&self, w: &str) {
224-
if self.is_strict_keyword(w) {
168+
fn check_strict_keywords(&self) {
169+
if token::is_strict_keyword(self.token) {
225170
self.span_err(*self.last_span,
226-
fmt!("found `%s` in ident position", w));
171+
fmt!("found `%s` in ident position", self.this_token_to_str()));
227172
}
228173
}
229174

230-
// return true if this is a reserved keyword
231-
fn is_reserved_keyword(&self, word: &str) -> bool {
232-
self.reserved_keywords.contains_equiv(&word)
233-
}
234-
235175
// signal an error if the current token is a reserved keyword
236176
fn check_reserved_keywords(&self) {
237-
match *self.token {
238-
token::IDENT(_, false) => {
239-
let w = token_to_str(self.reader, &copy *self.token);
240-
self.check_reserved_keywords_(w);
241-
}
242-
_ => ()
243-
}
244-
}
245-
246-
// signal an error if the given string is a reserved keyword
247-
fn check_reserved_keywords_(&self, w: &str) {
248-
if self.is_reserved_keyword(w) {
249-
self.fatal(fmt!("`%s` is a reserved keyword", w));
177+
if token::is_reserved_keyword(self.token) {
178+
self.fatal(fmt!("`%s` is a reserved keyword", self.this_token_to_str()));
250179
}
251180
}
252181

branches/try2/src/libsyntax/parse/obsolete.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use ast::{expr, expr_lit, lit_nil, attribute};
2323
use ast;
2424
use codemap::{span, respan};
2525
use parse::parser::Parser;
26-
use parse::token::Token;
26+
use parse::token::{keywords, Token};
2727
use parse::token;
2828

2929
use core::to_bytes;
@@ -295,9 +295,9 @@ pub impl Parser {
295295
}
296296

297297
fn try_parse_obsolete_priv_section(&self, attrs: &[attribute]) -> bool {
298-
if self.is_keyword("priv") && self.look_ahead(1) == token::LBRACE {
298+
if self.is_keyword(keywords::Priv) && self.look_ahead(1) == token::LBRACE {
299299
self.obsolete(copy *self.span, ObsoletePrivSection);
300-
self.eat_keyword("priv");
300+
self.eat_keyword(keywords::Priv);
301301
self.bump();
302302
while *self.token != token::RBRACE {
303303
self.parse_single_struct_field(ast::private, attrs.to_owned());

0 commit comments

Comments
 (0)