Skip to content

Commit b4a0ac5

Browse files
committed
---
yaml --- r: 14184 b: refs/heads/try c: 8e55d31 h: refs/heads/master v: v3
1 parent 959631f commit b4a0ac5

File tree

13 files changed

+52
-148
lines changed

13 files changed

+52
-148
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: f9a63efb8214a36b13545b158bf27c1b6540b650
5+
refs/heads/try: 8e55d3130a1b8eab3b80c85e71a2a800fb9442f0
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/comp/driver/diagnostic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ fn emit(cmsp: option<(codemap::codemap, span)>,
175175
msg: str, lvl: level) {
176176
alt cmsp {
177177
some((cm, sp)) {
178-
let sp = codemap::adjust_span(cm,sp);
179178
let ss = codemap::span_to_str(sp, cm);
180179
let lines = codemap::span_to_lines(sp, cm);
181180
print_diagnostic(ss, lvl, msg);

branches/try/src/comp/syntax/codemap.rs

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ type file_pos = {ch: uint, byte: uint};
88
* compiler.
99
*/
1010

11-
enum file_substr {
12-
fss_none,
13-
fss_internal(span),
14-
fss_external({filename: str, line: uint, col: uint})
15-
}
11+
type file_substr_ = {lo: uint, hi: uint, col: uint, line: uint};
12+
type file_substr = option<file_substr_>;
1613

1714
type filemap =
1815
@{name: filename, substr: file_substr, src: @str,
@@ -36,14 +33,16 @@ fn new_filemap_w_substr(filename: filename, substr: file_substr,
3633
fn new_filemap(filename: filename, src: @str,
3734
start_pos_ch: uint, start_pos_byte: uint)
3835
-> filemap {
39-
ret new_filemap_w_substr(filename, fss_none, src,
36+
ret new_filemap_w_substr(filename, none, src,
4037
start_pos_ch, start_pos_byte);
4138
}
4239

43-
fn mk_substr_filename(cm: codemap, sp: span) -> str
40+
fn get_substr_info(cm: codemap, lo: uint, hi: uint)
41+
-> (filename, file_substr_)
4442
{
45-
let pos = lookup_char_pos(cm, sp.lo);
46-
ret #fmt("<%s:%u:%u>", pos.file.name, pos.line, pos.col);
43+
let pos = lookup_char_pos(cm, lo);
44+
let name = #fmt("<%s:%u:%u>", pos.file.name, pos.line, pos.col);
45+
ret (name, {lo: lo, hi: hi, col: pos.col, line: pos.line});
4746
}
4847

4948
fn next_line(file: filemap, chpos: uint, byte_pos: uint) {
@@ -90,66 +89,26 @@ fn lookup_byte_pos(map: codemap, pos: uint) -> loc {
9089
ret lookup_pos(map, pos, lookup);
9190
}
9291

93-
fn lookup_char_pos_adj(map: codemap, pos: uint)
94-
-> {filename: str, line: uint, col: uint, file: option<filemap>}
95-
{
96-
let loc = lookup_char_pos(map, pos);
97-
alt (loc.file.substr) {
98-
fss_none {
99-
{filename: loc.file.name, line: loc.line, col: loc.col,
100-
file: some(loc.file)}
101-
}
102-
fss_internal(sp) {
103-
lookup_char_pos_adj(map, sp.lo + (pos - loc.file.start_pos.ch))
104-
}
105-
fss_external(eloc) {
106-
{filename: eloc.filename,
107-
line: eloc.line + loc.line - 1u,
108-
col: if loc.line == 1u {eloc.col + loc.col} else {loc.col},
109-
file: none}
110-
}
111-
}
112-
}
113-
114-
fn adjust_span(map: codemap, sp: span) -> span {
115-
fn lookup(pos: file_pos) -> uint { ret pos.ch; }
116-
let line = lookup_line(map, sp.lo, lookup);
117-
alt (line.fm.substr) {
118-
fss_none {sp}
119-
fss_internal(s) {
120-
adjust_span(map, {lo: s.lo + (sp.lo - line.fm.start_pos.ch),
121-
hi: s.lo + (sp.hi - line.fm.start_pos.ch),
122-
expn_info: sp.expn_info})}
123-
fss_external(_) {sp}
124-
}
125-
}
126-
12792
enum expn_info_ {
12893
expanded_from({call_site: span,
12994
callie: {name: str, span: option<span>}})
13095
}
13196
type expn_info = option<@expn_info_>;
13297
type span = {lo: uint, hi: uint, expn_info: expn_info};
13398

134-
fn span_to_str_no_adj(sp: span, cm: codemap) -> str {
99+
fn span_to_str(sp: span, cm: codemap) -> str {
135100
let lo = lookup_char_pos(cm, sp.lo);
136101
let hi = lookup_char_pos(cm, sp.hi);
137102
ret #fmt("%s:%u:%u: %u:%u", lo.file.name,
138103
lo.line, lo.col, hi.line, hi.col)
139104
}
140105

141-
fn span_to_str(sp: span, cm: codemap) -> str {
142-
let lo = lookup_char_pos_adj(cm, sp.lo);
143-
let hi = lookup_char_pos_adj(cm, sp.hi);
144-
ret #fmt("%s:%u:%u: %u:%u", lo.filename,
145-
lo.line, lo.col, hi.line, hi.col)
146-
}
147-
148106
type file_lines = {file: filemap, lines: [uint]};
149107

150108
fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
151109
let lo = lookup_char_pos(cm, sp.lo);
152110
let hi = lookup_char_pos(cm, sp.hi);
111+
// FIXME: Check for filemap?
153112
let lines = [];
154113
uint::range(lo.line - 1u, hi.line as uint) {|i| lines += [i]; };
155114
ret @{file: lo.file, lines: lines};

branches/try/src/comp/syntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import std::map::hashmap;
55
import syntax::ast::{crate, expr_, expr_mac, mac_invoc};
66
import syntax::fold::*;
77
import syntax::ext::base::*;
8-
import syntax::ext::qquote::{qq_helper};
8+
import syntax::ext::qquote::{expand_qquote,qq_helper};
99
import syntax::parse::parser::parse_expr_from_source_str;
1010

1111
import codemap::{span, expanded_from};

branches/try/src/comp/syntax/ext/qquote.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
143143
}
144144
}
145145
let body = get_mac_body(ecx,_sp,body);
146+
fn finish<T: qq_helper>(ecx: ext_ctxt, body: ast::mac_body_,
147+
f: fn (p: parser) -> T)
148+
-> @ast::expr
149+
{
150+
let cm = ecx.session().parse_sess.cm;
151+
let str = @codemap::span_to_snippet(body.span, cm);
152+
let (fname, ss) = codemap::get_substr_info
153+
(cm, body.span.lo, body.span.hi);
154+
let node = parse_from_source_str
155+
(f, fname, some(ss), str,
156+
ecx.session().opts.cfg, ecx.session().parse_sess);
157+
ret expand_qquote(ecx, node.span(), *str, node);
158+
}
146159

147160
ret alt what {
148161
"expr" {finish(ecx, body, parser::parse_expr)}
@@ -169,19 +182,10 @@ fn parse_item(p: parser) -> @ast::item {
169182
}
170183
}
171184

172-
fn finish<T: qq_helper>
173-
(ecx: ext_ctxt, body: ast::mac_body_, f: fn (p: parser) -> T)
185+
fn expand_qquote<N: qq_helper>
186+
(ecx: ext_ctxt, sp: span, str: str, node: N)
174187
-> @ast::expr
175188
{
176-
let cm = ecx.session().parse_sess.cm;
177-
let str = @codemap::span_to_snippet(body.span, cm);
178-
let fname = codemap::mk_substr_filename(cm, body.span);
179-
let node = parse_from_source_str
180-
(f, fname, codemap::fss_internal(body.span), str,
181-
ecx.session().opts.cfg, ecx.session().parse_sess);
182-
let loc = codemap::lookup_char_pos(cm, body.span.lo);
183-
184-
let sp = node.span();
185189
let qcx = gather_anti_quotes(sp.lo, node);
186190
let cx = qcx;
187191
let prev = 0u;
@@ -194,7 +198,7 @@ fn finish<T: qq_helper>
194198
let state = active;
195199
let i = 0u, j = 0u;
196200
let g_len = vec::len(cx.gather);
197-
str::chars_iter(*str) {|ch|
201+
str::chars_iter(str) {|ch|
198202
if (j < g_len && i == cx.gather[j].lo) {
199203
assert ch == '$';
200204
let repl = #fmt("$%u ", j);
@@ -224,12 +228,8 @@ fn finish<T: qq_helper>
224228
["syntax", "parse", "parser",
225229
"parse_from_source_str"],
226230
[node.mk_parse_fn(cx,sp),
227-
mk_str(cx,sp, fname),
228-
mk_call(cx,sp,
229-
["syntax","ext","qquote", "mk_file_substr"],
230-
[mk_str(cx,sp, loc.file.name),
231-
mk_uint(cx,sp, loc.line),
232-
mk_uint(cx,sp, loc.col)]),
231+
mk_str(cx,sp, "<anon>"),
232+
mk_path(cx,sp, ["option","none"]),
233233
mk_unary(cx,sp, ast::box(ast::imm),
234234
mk_str(cx,sp, str2)),
235235
mk_access_(cx,sp,
@@ -306,10 +306,6 @@ fn print_expr(expr: @ast::expr) {
306306
stdout.write_str("\n");
307307
}
308308

309-
fn mk_file_substr(fname: str, line: uint, col: uint) -> codemap::file_substr {
310-
codemap::fss_external({filename: fname, line: line, col: col})
311-
}
312-
313309
// Local Variables:
314310
// mode: rust
315311
// fill-column: 78;

branches/try/src/comp/syntax/parse/lexer.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ impl reader for reader {
4343
let next = str::char_range_at(*self.src, self.pos);
4444
self.pos = next.next;
4545
self.curr = next.ch;
46-
} else {
47-
if (self.curr != -1 as char) {
48-
self.col += 1u;
49-
self.chpos += 1u;
50-
self.curr = -1 as char;
51-
}
52-
}
46+
} else { self.curr = -1 as char; }
5347
}
5448
fn fatal(m: str) -> ! {
5549
self.span_diagnostic.span_fatal(

branches/try/src/comp/syntax/parse/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import std::{io, fs};
22
import either::{left, right};
33
import std::map::{hashmap, new_str_hash};
44
import token::can_begin_expr;
5-
import codemap::{span,fss_none};
5+
import codemap::span;
66
import util::interner;
77
import ast::{node_id, spanned};
88
import ast_util::{mk_sp, ident_to_path};
@@ -2607,7 +2607,7 @@ fn parse_crate_from_source_file(input: str, cfg: ast::crate_cfg,
26072607

26082608
fn parse_expr_from_source_str(name: str, source: @str, cfg: ast::crate_cfg,
26092609
sess: parse_sess) -> @ast::expr {
2610-
let p = new_parser_from_source_str(sess, cfg, name, fss_none, source);
2610+
let p = new_parser_from_source_str(sess, cfg, name, none, source);
26112611
let r = parse_expr(p);
26122612
sess.chpos = p.reader.chpos;
26132613
sess.byte_pos = sess.byte_pos + p.reader.pos;
@@ -2629,7 +2629,7 @@ fn parse_from_source_str<T>(f: fn (p: parser) -> T,
26292629

26302630
fn parse_crate_from_source_str(name: str, source: @str, cfg: ast::crate_cfg,
26312631
sess: parse_sess) -> @ast::crate {
2632-
let p = new_parser_from_source_str(sess, cfg, name, fss_none, source);
2632+
let p = new_parser_from_source_str(sess, cfg, name, none, source);
26332633
let r = parse_crate_mod(p, cfg);
26342634
sess.chpos = p.reader.chpos;
26352635
sess.byte_pos = sess.byte_pos + p.reader.pos;

branches/try/src/rt/rust_task_thread.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ pthread_key_t rust_task_thread::task_key;
1313
DWORD rust_task_thread::task_key;
1414
#endif
1515

16-
const size_t C_STACK_SIZE = (1024*1024);
16+
const size_t SCHED_STACK_SIZE = 1024*100;
17+
const size_t C_STACK_SIZE = 1024*1024;
1718

1819
bool rust_task_thread::tls_initialized = false;
1920

2021
rust_task_thread::rust_task_thread(rust_scheduler *sched,
2122
rust_srv *srv,
2223
int id) :
24+
rust_thread(SCHED_STACK_SIZE),
2325
ref_count(1),
2426
_log(srv, this),
2527
log_lvl(log_debug),

branches/try/src/rt/sync/rust_thread.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#include "globals.h"
22
#include "rust_thread.h"
33

4-
rust_thread::rust_thread() : thread(0) {
4+
const size_t default_stack_sz = 1024*1024;
5+
6+
rust_thread::rust_thread() : thread(0), stack_sz(default_stack_sz) {
7+
}
8+
9+
rust_thread::rust_thread(size_t stack_sz)
10+
: thread(0), stack_sz(stack_sz) {
511
}
612

713
rust_thread::~rust_thread() {
@@ -23,11 +29,11 @@ rust_thread_start(void *ptr) {
2329
void
2430
rust_thread::start() {
2531
#if defined(__WIN32__)
26-
thread = CreateThread(NULL, 0, rust_thread_start, this, 0, NULL);
32+
thread = CreateThread(NULL, stack_sz, rust_thread_start, this, 0, NULL);
2733
#else
2834
pthread_attr_t attr;
2935
pthread_attr_init(&attr);
30-
pthread_attr_setstacksize(&attr, 1024 * 1024);
36+
pthread_attr_setstacksize(&attr, stack_sz);
3137
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
3238
pthread_create(&thread, &attr, rust_thread_start, (void *) this);
3339
#endif

branches/try/src/rt/sync/rust_thread.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
* Thread utility class. Derive and implement your own run() method.
66
*/
77
class rust_thread {
8-
public:
8+
private:
99
#if defined(__WIN32__)
1010
HANDLE thread;
1111
#else
1212
pthread_t thread;
1313
#endif
14+
size_t stack_sz;
15+
public:
16+
1417
rust_thread();
18+
rust_thread(size_t stack_sz);
1519
virtual ~rust_thread();
1620

1721
void start();

branches/try/src/rustdoc/attr_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ mod test {
9393
mutable byte_pos: 0u
9494
};
9595
let parser = parser::new_parser_from_source_str(
96-
parse_sess, [], "-", codemap::fss_none, @source);
96+
parse_sess, [], "-", none, @source);
9797

9898
parser::parse_outer_attributes(parser)
9999
}

branches/try/src/test/compile-fail/qquote.rs

Lines changed: 0 additions & 51 deletions
This file was deleted.

branches/try/src/test/run-pass/qquote.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ fn main() {
7676

7777
let pat = #ast(pat){some(_)};
7878
check_pp(pat, pprust::print_pat, "some(_)");
79-
80-
// issue #1785
81-
let x = #ast{1};
82-
let test1 = #ast{1+$(x)};
83-
check_pp(test1, pprust::print_expr, "1 + 1");
8479
}
8580

8681
fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) {

0 commit comments

Comments
 (0)