Skip to content

Commit bb314eb

Browse files
committed
---
yaml --- r: 1595 b: refs/heads/master c: 4ca0259 h: refs/heads/master i: 1593: 1350b5e 1591: 67418ab v: v3
1 parent b2f7e2a commit bb314eb

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: ab7b9b847acfd1151543fb6ad99967e71fddd870
2+
refs/heads/master: 4ca0259b20bfc2f33f23e8b82864908fbb3b8133

trunk/src/comp/driver/rustc.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ impure fn compile_input(session.session sess,
5454
eval.env env,
5555
str input, str output,
5656
bool shared) {
57-
auto p = parser.new_parser(sess, env, 0, input);
57+
auto def = tup(0, 0);
58+
auto p = parser.new_parser(sess, env, def, input);
5859
auto crate = parse_input(sess, p, input);
5960
crate = resolve.resolve_crate(sess, crate);
6061
crate = typeck.check_crate(sess, crate);
@@ -64,7 +65,8 @@ impure fn compile_input(session.session sess,
6465
impure fn pretty_print_input(session.session sess,
6566
eval.env env,
6667
str input) {
67-
auto p = front.parser.new_parser(sess, env, 0, input);
68+
auto def = tup(0, 0);
69+
auto p = front.parser.new_parser(sess, env, def, input);
6870
auto crate = front.parser.parse_crate_from_source_file(p);
6971
pretty.pprust.print_ast(crate.node.module, std.io.stdout_writer());
7072
}

trunk/src/comp/front/eval.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,12 @@ impure fn eval_crate_directive(parser p,
393393

394394
auto full_path = prefix + std.os.path_sep() + file_path;
395395

396-
auto p0 = new_parser(p.get_session(), e, 0, full_path);
396+
auto start_id = p.next_def_id();
397+
auto p0 = new_parser(p.get_session(), e, start_id, full_path);
397398
auto m0 = parse_mod_items(p0, token.EOF);
398-
auto im = ast.item_mod(id, m0, p.next_def_id());
399+
auto next_id = p0.next_def_id();
400+
p.set_def(next_id._1);
401+
auto im = ast.item_mod(id, m0, next_id);
399402
auto i = @spanned(cdir.span, cdir.span, im);
400403
ast.index_item(index, i);
401404
append[@ast.item](items, i);

trunk/src/comp/front/parser.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ state type parser =
3535
fn get_session() -> session.session;
3636
fn get_span() -> common.span;
3737
fn next_def_id() -> ast.def_id;
38+
fn set_def(ast.def_num);
3839
fn get_prec_table() -> vec[op_spec];
3940
};
4041

4142
impure fn new_parser(session.session sess,
4243
eval.env env,
43-
ast.crate_num crate,
44+
ast.def_id initial_def,
4445
str path) -> parser {
4546
state obj stdio_parser(session.session sess,
4647
eval.env env,
@@ -94,6 +95,10 @@ impure fn new_parser(session.session sess,
9495
ret tup(crate, def);
9596
}
9697

98+
fn set_def(ast.def_num d) {
99+
def = d;
100+
}
101+
97102
fn get_file_type() -> file_type {
98103
ret ftype;
99104
}
@@ -114,8 +119,8 @@ impure fn new_parser(session.session sess,
114119
auto rdr = lexer.new_reader(srdr, path);
115120
auto npos = rdr.get_curr_pos();
116121
ret stdio_parser(sess, env, ftype, lexer.next_token(rdr),
117-
npos, npos, 0, UNRESTRICTED, crate, rdr,
118-
prec_table());
122+
npos, npos, initial_def._1, UNRESTRICTED, initial_def._0,
123+
rdr, prec_table());
119124
}
120125

121126
impure fn unexpected(parser p, token.token t) {

0 commit comments

Comments
 (0)