Skip to content

Commit d3956a9

Browse files
committed
---
yaml --- r: 7380 b: refs/heads/master c: f14ee0b h: refs/heads/master v: v3
1 parent 872a112 commit d3956a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1807
-672
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: 93be00f99594464fc753796395ce0cfb8ee790ea
2+
refs/heads/master: f14ee0b1b6c36528f14661a8f67d6808ba895978

trunk/Makefile.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ 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+
151157
ifeq ($(CFG_NATURALDOCS),)
152158
$(info cfg: no naturaldocs found, omitting library doc build)
153159
else

trunk/configure

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

293294
if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
294295
then
@@ -363,6 +364,16 @@ then
363364
err "either clang or gcc is required"
364365
fi
365366

367+
if [ ! -z "$CFG_PERF" ]
368+
then
369+
HAVE_PERF_LOGFD=`$CFG_PERF stat --log-fd 2>&1 | grep 'unknown option'`
370+
if [ -z "$HAVE_PERF_LOGFD" ];
371+
then
372+
CFG_PERF_WITH_LOGFD=1
373+
putvar CFG_PERF_WITH_LOGFD
374+
fi
375+
fi
376+
366377
step_msg "making directories"
367378

368379
for i in \

trunk/mk/docs.mk

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ 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+
4565
endif
4666

4767
ifdef CFG_LLNEXTGEN

trunk/mk/platform.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ ifneq ($(findstring linux,$(CFG_OSTYPE)),)
5858
CFG_LDENV := LD_LIBRARY_PATH
5959
CFG_DEF_SUFFIX := .linux.def
6060
ifdef CFG_PERF
61-
CFG_PERF_TOOL := $(CFG_PERF) stat -r 3
61+
ifneq ($(CFG_PERF_WITH_LOGFD),)
62+
CFG_PERF_TOOL := $(CFG_PERF) stat -r 3 --log-fd 2
63+
else
64+
CFG_PERF_TOOL := $(CFG_PERF) stat -r 3
65+
endif
6266
else
6367
ifdef CFG_VALGRIND
6468
CFG_PERF_TOOL :=\

trunk/src/comp/back/link.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,10 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
445445
let name =
446446
{
447447
let os = str::split(fs::basename(output), '.' as u8);
448-
assert (vec::len(os) >= 2u);
448+
if (vec::len(os) < 2u) {
449+
sess.fatal(#fmt("Output file name %s doesn't\
450+
appear to have an extension", output));
451+
}
449452
vec::pop(os);
450453
str::connect(os, ".")
451454
};

trunk/src/comp/back/upcall.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type upcalls =
1616
free: ValueRef,
1717
shared_malloc: ValueRef,
1818
shared_free: ValueRef,
19+
memset: ValueRef,
1920
mark: ValueRef,
2021
create_shared_type_desc: ValueRef,
2122
free_shared_type_desc: ValueRef,
@@ -64,6 +65,7 @@ fn declare_upcalls(targ_cfg: @session::config,
6465
T_ptr(T_i8())),
6566
shared_free:
6667
dv("shared_free", [T_ptr(T_i8())]),
68+
memset: dv("memset", [T_ptr(T_i8()), T_i8(), T_i32(), T_i32()]),
6769
mark:
6870
d("mark", [T_ptr(T_i8())], int_t),
6971
create_shared_type_desc:

trunk/src/comp/driver/driver.rs

Lines changed: 64 additions & 50 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,27 @@ 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) ->
80-
@ast::crate {
81-
if !input_is_stdin(input) {
79+
fn parse_input(sess: session, cfg: ast::crate_cfg, input: str)
80+
-> {crate: @ast::crate, src: str} {
81+
let src = get_input_str(sess, input);
82+
let crate = if !input_is_stdin(input) {
8283
parser::parse_crate_from_file(input, cfg, sess.parse_sess)
83-
} else { parse_input_src(sess, cfg, input).crate }
84+
} else {
85+
parser::parse_crate_from_source_str(input, src, cfg, sess.parse_sess)
86+
};
87+
{crate: crate, src: src}
8488
}
8589

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 != "-" {
90+
fn get_input_str(sess: session, infile: str) -> str {
91+
let stream = if !input_is_stdin(infile) {
8992
alt io::file_reader(infile) {
9093
result::ok(reader) { reader }
9194
result::err(e) {
9295
sess.fatal(e)
9396
}
9497
}
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};
98+
} else { io::stdin() };
99+
str::unsafe_from_bytes(stream.read_whole_stream())
104100
}
105101

106102
fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
@@ -113,7 +109,7 @@ fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
113109
ret rv;
114110
}
115111

116-
fn inject_libcore_reference(sess: session::session,
112+
fn inject_libcore_reference(sess: session,
117113
crate: @ast::crate) -> @ast::crate {
118114

119115
fn spanned<T: copy>(x: T) -> @ast::spanned<T> {
@@ -134,14 +130,22 @@ fn inject_libcore_reference(sess: session::session,
134130
with crate.node} with *crate }
135131
}
136132

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

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

146150
sess.building_library =
147151
session::building_library(sess.opts.crate_type, crate);
@@ -156,6 +160,7 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
156160
time(time_passes, "expansion",
157161
bind syntax::ext::expand::expand_crate(sess, crate));
158162

163+
if upto == cu_expand { ret {crate: crate, tcx: none, src: src}; }
159164
if sess.opts.libcore {
160165
crate = inject_libcore_reference(sess, crate);
161166
}
@@ -177,6 +182,9 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
177182
let (method_map, dict_map) =
178183
time(time_passes, "typechecking",
179184
bind typeck::check_crate(ty_cx, impl_map, crate));
185+
186+
if upto == cu_typeck { ret {crate: crate, tcx: some(ty_cx), src: src}; }
187+
180188
time(time_passes, "block-use checking",
181189
bind middle::block_use::check_crate(ty_cx, crate));
182190
time(time_passes, "function usage",
@@ -195,9 +203,9 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
195203
bind last_use::find_last_uses(crate, def_map, ref_map, ty_cx));
196204
time(time_passes, "kind checking",
197205
bind kind::check_crate(ty_cx, method_map, last_uses, crate));
198-
if sess.opts.no_trans { ret; }
199206

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

202210
let (llmod, link_meta) =
203211
time(time_passes, "translation",
@@ -212,14 +220,25 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
212220
sess.opts.output_type != link::output_type_exe ||
213221
sess.opts.static && sess.building_library;
214222

215-
if stop_after_codegen { ret; }
223+
if stop_after_codegen { ret {crate: crate, tcx: some(ty_cx), src: src}; }
216224

217225
time(time_passes, "Linking",
218226
bind link::link_binary(sess, outputs.obj_filename,
219227
outputs.out_filename, link_meta));
228+
ret {crate: crate, tcx: some(ty_cx), src: src};
220229
}
221230

222-
fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
231+
fn compile_input(sess: session, cfg: ast::crate_cfg, input: str,
232+
outdir: option::t<str>, output: option::t<str>) {
233+
234+
let upto = if sess.opts.parse_only { cu_parse }
235+
else if sess.opts.no_trans { cu_no_trans }
236+
else { cu_everything };
237+
let outputs = build_output_filenames(input, outdir, output, sess);
238+
compile_upto(sess, cfg, input, upto, some(outputs));
239+
}
240+
241+
fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
223242
ppm: pp_mode) {
224243
fn ann_paren_for_expr(node: pprust::ann_node) {
225244
alt node { pprust::node_expr(s, expr) { pprust::popen(s); } _ { } }
@@ -260,30 +279,23 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
260279
// to collect comments and literals, and we need to support reading
261280
// from stdin, we're going to just suck the source into a string
262281
// 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;
282+
let upto = alt ppm {
283+
ppm_expanded. { cu_expand }
284+
ppm_typed. { cu_typeck }
285+
_ { cu_parse }
286+
};
287+
let {crate, tcx, src} = compile_upto(sess, cfg, input, upto, none);
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)