Skip to content

Commit ae54791

Browse files
paulstansiferbrson
authored andcommitted
---
yaml --- r: 4093 b: refs/heads/master c: e6e53af h: refs/heads/master i: 4091: bb9105a v: v3
1 parent c2b464c commit ae54791

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 63e77a3de1260e8424d46e4c46b9e6e5161fd011
2+
refs/heads/master: e6e53aff6398f9d2c6851c25acfdedd0bf47a321

trunk/src/comp/driver/rustc.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn compile_input(session::session sess, ast::crate_cfg cfg, str input,
153153
}
154154

155155
fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
156-
str input, pp_mode ppm) {
156+
str input, pp_mode ppm, bool expand) {
157157
fn ann_paren_for_expr(&pprust::ann_node node) {
158158
alt (node) {
159159
case (pprust::node_expr(?s, ?expr)) {
@@ -195,6 +195,7 @@ fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
195195
}
196196

197197
auto crate = parse_input(sess, cfg, input);
198+
if(expand) { crate = syntax::ext::expand::expand_crate(sess, crate); }
198199
auto ann;
199200
alt (ppm) {
200201
case (ppm_typed) {
@@ -238,6 +239,7 @@ options:
238239
--lib compile a library crate
239240
--static use or produce static libraries
240241
--pretty [type] pretty-print the input instead of compiling
242+
--expand [type] expand and pretty-print the input instead of compiling
241243
--ls list the symbols defined by a crate file
242244
-L <path> add a directory to the library search path
243245
--noverify suppress LLVM verification step (slight speedup)
@@ -395,15 +397,15 @@ fn parse_pretty(session::session sess, &str name) -> pp_mode {
395397
} else if (str::eq(name, "typed")) {
396398
ret ppm_typed;
397399
} else if (str::eq(name, "identified")) { ret ppm_identified; }
398-
sess.fatal("argument to `pretty` must be one of `normal`, `typed`, or " +
399-
"`identified`");
400+
sess.fatal("argument to `pretty` or `expand` must be one of `normal`, "
401+
+ "`typed`, or `identified`");
400402
}
401403

402404
fn opts() -> vec[getopts::opt] {
403405
ret [optflag("h"), optflag("help"), optflag("v"), optflag("version"),
404406
optflag("glue"), optflag("emit-llvm"), optflagopt("pretty"),
405-
optflag("ls"), optflag("parse-only"), optflag("O"),
406-
optopt("OptLevel"), optmulti("L"), optflag("S"),
407+
optflagopt("expand"), optflag("ls"), optflag("parse-only"),
408+
optflag("O"), optopt("OptLevel"), optmulti("L"), optflag("S"),
407409
optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"),
408410
optopt("sysroot"), optflag("stats"), optflag("time-passes"),
409411
optflag("time-llvm-passes"), optflag("no-typestate"),
@@ -451,18 +453,29 @@ fn main(vec[str] args) {
451453
auto ifile = match.free.(0);
452454
let str saved_out_filename = "";
453455
auto cfg = build_configuration(sess, binary, ifile);
456+
auto expand =
457+
option::map[str,
458+
pp_mode](bind parse_pretty(sess, _),
459+
getopts::opt_default(match, "expand", "normal"));
460+
alt (expand) {
461+
case (some[pp_mode](?ppm)) {
462+
pretty_print_input(sess, cfg, ifile, ppm, true);
463+
ret;
464+
}
465+
case (none[pp_mode]) {/* continue */ }
466+
}
454467
auto pretty =
455468
option::map[str,
456469
pp_mode](bind parse_pretty(sess, _),
457470
getopts::opt_default(match, "pretty", "normal"));
458-
auto ls = opt_present(match, "ls");
459471
alt (pretty) {
460472
case (some[pp_mode](?ppm)) {
461-
pretty_print_input(sess, cfg, ifile, ppm);
473+
pretty_print_input(sess, cfg, ifile, ppm, false);
462474
ret;
463475
}
464476
case (none[pp_mode]) {/* continue */ }
465477
}
478+
auto ls = opt_present(match, "ls");
466479
if (ls) {
467480
metadata::creader::list_file_metadata(ifile, ioivec::stdout());
468481
ret;

0 commit comments

Comments
 (0)