Skip to content

Commit 6d05942

Browse files
committed
---
yaml --- r: 7369 b: refs/heads/master c: 54d5a98 h: refs/heads/master i: 7367: aaca739 v: v3
1 parent 72ad4ed commit 6d05942

File tree

5 files changed

+62
-75
lines changed

5 files changed

+62
-75
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: 9be247b9b87d7a5c22c6c37e06038523711160f7
2+
refs/heads/master: 54d5a9846f6bfe0fe37e2a81c9bd74178ff1f3b4

trunk/Makefile.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@ else
148148
endif
149149
endif
150150

151-
ifeq ($(CFG_NODE),)
152-
$(info cfg: no node found, omitting doc/tutorial/web)
153-
else
154-
DOCS += doc/tutorial/web/index.html
155-
endif
156-
157151
ifeq ($(CFG_NATURALDOCS),)
158152
$(info cfg: no naturaldocs found, omitting library doc build)
159153
else

trunk/configure

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ probe CFG_NATURALDOCS naturaldocs
289289
probe CFG_LLNEXTGEN LLnextgen
290290
probe CFG_PANDOC pandoc
291291
probe CFG_PDFLATEX pdflatex
292-
probe CFG_NODE node
293292

294293
if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
295294
then

trunk/mk/docs.mk

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,6 @@ doc/rust.pdf: doc/rust.tex
4242

4343
endif
4444

45-
ifdef CFG_NODE
46-
47-
doc/tutorial/web/index.html: doc/tutorial/args.md \
48-
doc/tutorial/control.md \
49-
doc/tutorial/data.md \
50-
doc/tutorial/ffi.md \
51-
doc/tutorial/func.md \
52-
doc/tutorial/generic.md \
53-
doc/tutorial/iface.md \
54-
doc/tutorial/index.md \
55-
doc/tutorial/intro.md \
56-
doc/tutorial/mod.md \
57-
doc/tutorial/setup.md \
58-
doc/tutorial/syntax.md \
59-
doc/tutorial/task.md \
60-
doc/tutorial/test.md
61-
$(Q)cd doc/tutorial && $(CFG_NODE) build.js
62-
63-
endif
64-
6545
endif
6646

6747
ifdef CFG_LLNEXTGEN

trunk/src/comp/driver/driver.rs

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import back::{x86, x86_64};
2020

2121
tag pp_mode { ppm_normal; ppm_expanded; ppm_typed; ppm_identified; }
2222

23-
fn default_configuration(sess: session::session, argv0: str, input: str) ->
23+
fn default_configuration(sess: session, argv0: str, input: str) ->
2424
ast::crate_cfg {
2525
let libc =
2626
alt sess.targ_cfg.os {
@@ -48,7 +48,7 @@ fn default_configuration(sess: session::session, argv0: str, input: str) ->
4848
mk("build_input", input)];
4949
}
5050

51-
fn build_configuration(sess: session::session, argv0: str, input: str) ->
51+
fn build_configuration(sess: session, argv0: str, input: str) ->
5252
ast::crate_cfg {
5353
// Combine the configuration requested by the session (command line) with
5454
// some default and generated configuration items
@@ -76,31 +76,26 @@ fn parse_cfgspecs(cfgspecs: [str]) -> ast::crate_cfg {
7676

7777
fn input_is_stdin(filename: str) -> bool { filename == "-" }
7878

79-
fn parse_input(sess: session::session, cfg: ast::crate_cfg, input: str) ->
79+
fn parse_input(sess: session, cfg: ast::crate_cfg, input: str) ->
8080
@ast::crate {
8181
if !input_is_stdin(input) {
8282
parser::parse_crate_from_file(input, cfg, sess.parse_sess)
83-
} else { parse_input_src(sess, cfg, input).crate }
83+
} else {
84+
let src = get_input_str(sess, input);
85+
parser::parse_crate_from_source_str(input, src, cfg, sess.parse_sess)
86+
}
8487
}
8588

86-
fn parse_input_src(sess: session::session, cfg: ast::crate_cfg, infile: str)
87-
-> {crate: @ast::crate, src: str} {
88-
let src_stream = if infile != "-" {
89+
fn get_input_str(sess: session, infile: str) -> str {
90+
let stream = if !input_is_stdin(infile) {
8991
alt io::file_reader(infile) {
9092
result::ok(reader) { reader }
9193
result::err(e) {
9294
sess.fatal(e)
9395
}
9496
}
95-
} else {
96-
io::stdin()
97-
};
98-
let srcbytes = src_stream.read_whole_stream();
99-
let src = str::unsafe_from_bytes(srcbytes);
100-
let crate =
101-
parser::parse_crate_from_source_str(infile, src, cfg,
102-
sess.parse_sess);
103-
ret {crate: crate, src: src};
97+
} else { io::stdin() };
98+
str::unsafe_from_bytes(stream.read_whole_stream())
10499
}
105100

106101
fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
@@ -113,7 +108,7 @@ fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
113108
ret rv;
114109
}
115110

116-
fn inject_libcore_reference(sess: session::session,
111+
fn inject_libcore_reference(sess: session,
117112
crate: @ast::crate) -> @ast::crate {
118113

119114
fn spanned<T: copy>(x: T) -> @ast::spanned<T> {
@@ -134,14 +129,22 @@ fn inject_libcore_reference(sess: session::session,
134129
with crate.node} with *crate }
135130
}
136131

132+
enum compile_upto {
133+
cu_parse;
134+
cu_expand;
135+
cu_typeck;
136+
cu_no_trans;
137+
cu_everything;
138+
}
137139

138-
fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
139-
outdir: option::t<str>, output: option::t<str>) {
140-
140+
fn compile_upto(sess: session, cfg: ast::crate_cfg,
141+
input: str, upto: compile_upto,
142+
outputs: option::t<output_filenames>)
143+
-> {crate: @ast::crate, tcx: option::t<ty::ctxt>} {
141144
let time_passes = sess.opts.time_passes;
142145
let crate =
143146
time(time_passes, "parsing", bind parse_input(sess, cfg, input));
144-
if sess.opts.parse_only { ret; }
147+
if upto == cu_parse { ret {crate: crate, tcx: none}; }
145148

146149
sess.building_library =
147150
session::building_library(sess.opts.crate_type, crate);
@@ -156,6 +159,7 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
156159
time(time_passes, "expansion",
157160
bind syntax::ext::expand::expand_crate(sess, crate));
158161

162+
if upto == cu_expand { ret {crate: crate, tcx: none}; }
159163
if sess.opts.libcore {
160164
crate = inject_libcore_reference(sess, crate);
161165
}
@@ -177,6 +181,9 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
177181
let (method_map, dict_map) =
178182
time(time_passes, "typechecking",
179183
bind typeck::check_crate(ty_cx, impl_map, crate));
184+
185+
if upto == cu_typeck { ret {crate: crate, tcx: some(ty_cx)}; }
186+
180187
time(time_passes, "block-use checking",
181188
bind middle::block_use::check_crate(ty_cx, crate));
182189
time(time_passes, "function usage",
@@ -195,9 +202,9 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
195202
bind last_use::find_last_uses(crate, def_map, ref_map, ty_cx));
196203
time(time_passes, "kind checking",
197204
bind kind::check_crate(ty_cx, method_map, last_uses, crate));
198-
if sess.opts.no_trans { ret; }
199205

200-
let outputs = build_output_filenames(input, outdir, output, sess);
206+
if upto == cu_no_trans { ret {crate: crate, tcx: some(ty_cx)}; }
207+
let outputs = option::get(outputs);
201208

202209
let (llmod, link_meta) =
203210
time(time_passes, "translation",
@@ -212,14 +219,25 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
212219
sess.opts.output_type != link::output_type_exe ||
213220
sess.opts.static && sess.building_library;
214221

215-
if stop_after_codegen { ret; }
222+
if stop_after_codegen { ret {crate: crate, tcx: some(ty_cx)}; }
216223

217224
time(time_passes, "Linking",
218225
bind link::link_binary(sess, outputs.obj_filename,
219226
outputs.out_filename, link_meta));
227+
ret {crate: crate, tcx: some(ty_cx)};
220228
}
221229

222-
fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
230+
fn compile_input(sess: session, cfg: ast::crate_cfg, input: str,
231+
outdir: option::t<str>, output: option::t<str>) {
232+
233+
let upto = if sess.opts.parse_only { cu_parse }
234+
else if sess.opts.no_trans { cu_no_trans }
235+
else { cu_everything };
236+
let outputs = build_output_filenames(input, outdir, output, sess);
237+
compile_upto(sess, cfg, input, upto, some(outputs));
238+
}
239+
240+
fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
223241
ppm: pp_mode) {
224242
fn ann_paren_for_expr(node: pprust::ann_node) {
225243
alt node { pprust::node_expr(s, expr) { pprust::popen(s); } _ { } }
@@ -260,30 +278,24 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
260278
// to collect comments and literals, and we need to support reading
261279
// from stdin, we're going to just suck the source into a string
262280
// so both the parser and pretty-printer can use it.
263-
let crate_src = parse_input_src(sess, cfg, input);
264-
let crate = crate_src.crate;
265-
let src = crate_src.src;
281+
let upto = alt ppm {
282+
ppm_expanded. { cu_expand }
283+
ppm_typed. { cu_typeck }
284+
_ { cu_parse }
285+
};
286+
let {crate, tcx} = compile_upto(sess, cfg, input, upto, none);
287+
let src = get_input_str(sess, input);
266288

267-
let ann;
289+
let ann: pprust::pp_ann = pprust::no_ann();
268290
alt ppm {
269-
ppm_expanded. {
270-
crate = syntax::ext::expand::expand_crate(sess, crate);
271-
ann = pprust::no_ann();
272-
}
273291
ppm_typed. {
274-
crate = syntax::ext::expand::expand_crate(sess, crate);
275-
let amap = middle::ast_map::map_crate(*crate);
276-
let {def_map, impl_map, _} =
277-
resolve::resolve_crate(sess, amap, crate);
278-
let freevars = freevars::annotate_freevars(def_map, crate);
279-
let ty_cx = ty::mk_ctxt(sess, def_map, amap, freevars);
280-
typeck::check_crate(ty_cx, impl_map, crate);
281-
ann = {pre: ann_paren_for_expr, post: bind ann_typed_post(ty_cx, _)};
292+
ann = {pre: ann_paren_for_expr,
293+
post: bind ann_typed_post(option::get(tcx), _)};
282294
}
283295
ppm_identified. {
284296
ann = {pre: ann_paren_for_expr, post: ann_identified_post};
285297
}
286-
ppm_normal. { ann = pprust::no_ann(); }
298+
ppm_expanded. | ppm_normal. {}
287299
}
288300
pprust::print_crate(sess.codemap, sess.diagnostic, crate, input,
289301
io::string_reader(src), io::stdout(), ann);
@@ -453,7 +465,7 @@ fn build_session_options(match: getopts::match,
453465
}
454466

455467
fn build_session(sopts: @session::options, input: str,
456-
demitter: diagnostic::emitter) -> session::session {
468+
demitter: diagnostic::emitter) -> session {
457469
let target_cfg = build_target_config(sopts, demitter);
458470
let cstore = cstore::mk_cstore();
459471
let filesearch = filesearch::mk_filesearch(
@@ -480,7 +492,7 @@ fn build_session(sopts: @session::options, input: str,
480492
working_dir: fs::dirname(input)}
481493
}
482494

483-
fn parse_pretty(sess: session::session, &&name: str) -> pp_mode {
495+
fn parse_pretty(sess: session, &&name: str) -> pp_mode {
484496
if str::eq(name, "normal") {
485497
ret ppm_normal;
486498
} else if str::eq(name, "expanded") {
@@ -509,11 +521,13 @@ fn opts() -> [getopts::opt] {
509521
optflag("warn-unused-imports")];
510522
}
511523

524+
type output_filenames = @{out_filename: str, obj_filename:str};
525+
512526
fn build_output_filenames(ifile: str,
513527
odir: option::t<str>,
514528
ofile: option::t<str>,
515-
sess: session::session)
516-
-> @{out_filename: str, obj_filename:str} {
529+
sess: session)
530+
-> output_filenames {
517531
let obj_path = "";
518532
let out_path: str = "";
519533
let sopts = sess.opts;
@@ -599,7 +613,7 @@ fn early_error(emitter: diagnostic::emitter, msg: str) -> ! {
599613
fail;
600614
}
601615

602-
fn list_metadata(sess: session::session, path: str, out: io::writer) {
616+
fn list_metadata(sess: session, path: str, out: io::writer) {
603617
metadata::creader::list_file_metadata(sess, path, out);
604618
}
605619

0 commit comments

Comments
 (0)