Skip to content

Commit 20ecb2d

Browse files
committed
---
yaml --- r: 2912 b: refs/heads/master c: 5cd10d2 h: refs/heads/master v: v3
1 parent 992e3b9 commit 20ecb2d

28 files changed

+297
-694
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: 12f86e6f2f5e7a5fc4ea61f3c63c790be100688f
2+
refs/heads/master: 5cd10d2fef8ffa68903b18726f19ac52a04725cc

trunk/mk/pp.mk

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
2-
PP_INPUTS := $(wildcard $(addprefix $(S)src/lib/,*.rs */*.rs)) \
3-
$(wildcard $(addprefix $(S)src/comp/,*.rs */*.rs */*/*.rs))
4-
51
reformat: $(SREQ1)
62
@$(call E, reformat [stage1]: $@)
7-
for i in $(PP_INPUTS); \
3+
for i in $(wildcard $(addprefix $(S)src/comp/, \
4+
*.rs */*.rs */*/*.rs)); \
85
do $(call CFG_RUN_TARG,stage1, stage1/rustc$(X)) \
96
--pretty $$i >$$i.tmp && mv $$i.tmp $$i; \
107
done

trunk/src/comp/driver/rustc.rs

Lines changed: 38 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,10 @@ import std::getopts;
2929
import std::getopts::optopt;
3030
import std::getopts::optmulti;
3131
import std::getopts::optflag;
32-
import std::getopts::optflagopt;
3332
import std::getopts::opt_present;
3433

3534
import back::link::output_type;
3635

37-
tag pp_mode {
38-
ppm_normal;
39-
ppm_typed;
40-
ppm_identified;
41-
}
42-
4336
fn default_environment(session::session sess,
4437
str argv0,
4538
str input) -> eval::env {
@@ -119,21 +112,19 @@ fn compile_input(session::session sess,
119112
}
120113

121114
fn pretty_print_input(session::session sess, eval::env env, str input,
122-
pp_mode ppm) {
115+
bool typed) {
123116
auto def = tup(ast::local_crate, 0);
124117
auto p = front::parser::new_parser(sess, env, def, input, 0u, 0u);
125118
auto crate = front::parser::parse_crate_from_source_file(p);
126119

127120
auto mode;
128-
alt (ppm) {
129-
case (ppm_typed) {
130-
auto def_map = resolve::resolve_crate(sess, crate);
131-
auto ty_cx = ty::mk_ctxt(sess, def_map);
132-
typeck::check_crate(ty_cx, crate);
133-
mode = pprust::mo_typed(ty_cx);
134-
}
135-
case (ppm_normal) { mode = pprust::mo_untyped; }
136-
case (ppm_identified) { mode = pprust::mo_identified; }
121+
if (typed) {
122+
auto def_map = resolve::resolve_crate(sess, crate);
123+
auto ty_cx = ty::mk_ctxt(sess, def_map);
124+
typeck::check_crate(ty_cx, crate);
125+
mode = pprust::mo_typed(ty_cx);
126+
} else {
127+
mode = pprust::mo_untyped;
137128
}
138129

139130
pprust::print_file(sess, crate.node.module, input, std::io::stdout(),
@@ -159,7 +150,8 @@ options:
159150
-o <filename> write output to <filename>
160151
--glue generate glue.bc file
161152
--shared compile a shared-library crate
162-
--pretty [type] pretty-print the input instead of compiling
153+
--pretty pretty-print the input instead of compiling
154+
--typed-pretty pretty-print the input with types instead of compiling
163155
--ls list the symbols defined by a crate file
164156
-L <path> add a directory to the library search path
165157
--noverify suppress LLVM verification step (slight speedup)
@@ -312,21 +304,12 @@ fn build_session(@session::options sopts) -> session::session {
312304
ret sess;
313305
}
314306

315-
fn parse_pretty(session::session sess, &str name) -> pp_mode {
316-
if (str::eq(name, "normal")) { ret ppm_normal; }
317-
else if (str::eq(name, "typed")) { ret ppm_typed; }
318-
else if (str::eq(name, "identified")) { ret ppm_identified; }
319-
320-
sess.err("argument to `pretty` must be one of `normal`, `typed`, or " +
321-
"`identified`");
322-
}
323-
324307
fn main(vec[str] args) {
325308

326309
auto opts = [optflag("h"), optflag("help"),
327310
optflag("v"), optflag("version"),
328311
optflag("glue"), optflag("emit-llvm"),
329-
optflagopt("pretty"),
312+
optflag("pretty"), optflag("typed-pretty"),
330313
optflag("ls"), optflag("parse-only"),
331314
optflag("O"), optopt("OptLevel"),
332315
optflag("shared"), optmulti("L"),
@@ -382,50 +365,42 @@ fn main(vec[str] args) {
382365
auto ifile = match.free.(0);
383366
let str saved_out_filename = "";
384367
auto env = default_environment(sess, binary, ifile);
385-
auto pretty = option::map[str,pp_mode](bind parse_pretty(sess, _),
386-
getopts::opt_default(match, "pretty", "normal"));
368+
auto pretty = opt_present(match, "pretty");
369+
auto typed_pretty = opt_present(match, "typed-pretty");
387370
auto ls = opt_present(match, "ls");
388-
389-
alt (pretty) {
390-
case (some[pp_mode](?ppm)) {
391-
pretty_print_input(sess, env, ifile, ppm);
392-
ret;
393-
}
394-
case (none[pp_mode]) { /* continue */ }
395-
}
396-
397-
if (ls) {
371+
if (pretty || typed_pretty) {
372+
pretty_print_input(sess, env, ifile, typed_pretty);
373+
ret;
374+
} else if (ls) {
398375
front::creader::list_file_metadata(ifile, std::io::stdout());
399376
ret;
400-
}
401-
402-
alt (output_file) {
403-
case (none) {
404-
let vec[str] parts = str::split(ifile, '.' as u8);
405-
vec::pop[str](parts);
406-
saved_out_filename = parts.(0);
407-
alt (sopts.output_type) {
408-
case (link::output_type_none) { parts += ["pp"]; }
409-
case (link::output_type_bitcode) { parts += ["bc"]; }
410-
case (link::output_type_assembly) { parts += ["s"]; }
411-
412-
// Object and exe output both use the '.o' extension here
413-
case (link::output_type_object) { parts += ["o"]; }
414-
case (link::output_type_exe) { parts += ["o"]; }
377+
} else {
378+
alt (output_file) {
379+
case (none) {
380+
let vec[str] parts = str::split(ifile, '.' as u8);
381+
vec::pop[str](parts);
382+
saved_out_filename = parts.(0);
383+
alt (sopts.output_type) {
384+
case (link::output_type_none) { parts += ["pp"]; }
385+
case (link::output_type_bitcode) { parts += ["bc"]; }
386+
case (link::output_type_assembly) { parts += ["s"]; }
387+
388+
// Object and exe output both use the '.o' extension here
389+
case (link::output_type_object) { parts += ["o"]; }
390+
case (link::output_type_exe) { parts += ["o"]; }
391+
}
392+
auto ofile = str::connect(parts, ".");
393+
compile_input(sess, env, ifile, ofile);
394+
}
395+
case (some(?ofile)) {
396+
saved_out_filename = ofile;
397+
compile_input(sess, env, ifile, ofile);
415398
}
416-
auto ofile = str::connect(parts, ".");
417-
compile_input(sess, env, ifile, ofile);
418-
}
419-
case (some(?ofile)) {
420-
saved_out_filename = ofile;
421-
compile_input(sess, env, ifile, ofile);
422399
}
423400
}
424401

425402
// If the user wants an exe generated we need to invoke
426403
// gcc to link the object file with some libs
427-
//
428-
// TODO: Factor this out of main.
429404
if (sopts.output_type == link::output_type_exe) {
430405

431406
//FIXME: Should we make the 'stage3's variable here?

trunk/src/comp/front/ast.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ tag ty_ {
338338
tag constr_arg_ {
339339
carg_base;
340340
carg_ident(ident);
341-
carg_lit(@lit);
342341
}
343342
type constr_arg = spanned[constr_arg_];
344343
type constr_ = rec(path path, vec[@constr_arg] args);
@@ -504,6 +503,14 @@ fn is_constraint_arg(@expr e) -> bool {
504503
}
505504
}
506505

506+
fn eq_ty(&@ty a, &@ty b) -> bool {
507+
ret a == b;
508+
}
509+
510+
fn hash_ty(&@ty t) -> uint {
511+
ret t.span.lo << 16u + t.span.hi;
512+
}
513+
507514
//
508515
// Local Variables:
509516
// mode: rust

trunk/src/comp/middle/trans.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
// the result of the translation to LLVM -- while others, such as trans_fn,
55
// trans_obj, and trans_item, are called only for the side effect of adding a
66
// particular definition to the LLVM IR output we're producing.
7-
//
8-
// Hopefully useful general knowledge about trans:
9-
//
10-
// * There's no way to find out the ty::t type of a ValueRef. Doing so
11-
// would be "trying to get the eggs out of an omelette" (credit:
12-
// pcwalton). You can, instead, find out its TypeRef by calling val_ty,
13-
// but many TypeRefs correspond to one ty::t; for instance, tup(int, int,
14-
// int) and rec(x=int, y=int, z=int) will have the same TypeRef.
157

168
import std::int;
179
import std::str;

trunk/src/comp/middle/tstate/annotate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import util::common::log_stmt;
5151

5252
import aux::fn_info;
5353
import aux::fn_info_map;
54-
import aux::num_constraints;
54+
import aux::num_locals;
5555
import aux::get_fn_info;
5656
import aux::crate_ctxt;
5757
import aux::add_node;
@@ -109,19 +109,19 @@ fn init_vecs(&crate_ctxt ccx, @vec[uint] node_ids, uint len) -> () {
109109
}
110110
}
111111

112-
fn visit_fn(&crate_ctxt ccx, uint num_constraints, &_fn f,
112+
fn visit_fn(&crate_ctxt ccx, uint num_locals, &_fn f,
113113
&span sp, &ident i, &def_id d, &ann a) -> () {
114114
let vec[uint] node_ids_ = [];
115115
let @vec[uint] node_ids = @node_ids_;
116116
node_ids_in_fn(f, sp, i, d, a, node_ids);
117-
init_vecs(ccx, node_ids, num_constraints);
117+
init_vecs(ccx, node_ids, num_locals);
118118
}
119119

120120
fn annotate_in_fn(&crate_ctxt ccx, &_fn f, &span sp, &ident i,
121121
&def_id f_id, &ann a)
122122
-> () {
123123
auto f_info = get_fn_info(ccx, f_id);
124-
visit_fn(ccx, num_constraints(f_info), f, sp, i, f_id, a);
124+
visit_fn(ccx, num_locals(f_info), f, sp, i, f_id, a);
125125
}
126126

127127
fn annotate_crate(&crate_ctxt ccx, &crate crate) -> () {

0 commit comments

Comments
 (0)