From 358a1aeec99ba6bf3c3f6bc5886e4dddf647a75a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 12 May 2011 13:25:18 +0200 Subject: Keep resolve data in external hash table, rather than embedded defs One step closer to removing fold and having a single, immutable AST. Resolve still uses fold, because it has to detect and transform expr_field expressions. If we go through on our plan of moving to a different syntax for module dereferencing, the parser can spit out expr_field expressions, and resolve can move to walk. (I am truly sorry for the things I did in typestate_check.rs. I expect we'll want to change that to walk as well in the near future, at which point it should probably pass around a context record, which could hold the def_map.) --- src/comp/driver/rustc.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/comp/driver') diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 1c9698bd..b38b8c9b 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -86,19 +86,21 @@ fn compile_input(session.session sess, str input, str output) { auto time_passes = sess.get_opts().time_passes; auto def = tup(ast.local_crate, 0); - auto p = parser.new_parser(sess, env, def, input, 0u); - auto crate = time[@ast.crate](time_passes, "parsing", - bind parse_input(sess, p, input)); + auto p = parser.new_parser(sess, env, def, input, 0u, 0u); + auto crate = time(time_passes, "parsing", + bind parse_input(sess, p, input)); if (sess.get_opts().output_type == Link.output_type_none) {ret;} - crate = time[@ast.crate](time_passes, "external crate reading", - bind creader.read_crates(sess, crate)); - crate = time[@ast.crate](time_passes, "resolution", - bind resolve.resolve_crate(sess, crate)); + crate = time(time_passes, "external crate reading", + bind creader.read_crates(sess, crate)); + auto res = time(time_passes, "resolution", + bind resolve.resolve_crate(sess, crate)); + crate = res._0; + auto def_map = res._1; time[()](time_passes, "capture checking", - bind capture.check_for_captures(sess, crate)); + bind capture.check_for_captures(sess, crate, def_map)); - auto ty_cx = ty.mk_ctxt(sess); + auto ty_cx = ty.mk_ctxt(sess, def_map); auto typeck_result = time[typeck.typecheck_result](time_passes, "typechecking", bind typeck.check_crate(ty_cx, crate)); @@ -106,8 +108,8 @@ fn compile_input(session.session sess, auto type_cache = typeck_result._1; if (sess.get_opts().run_typestate) { - crate = time[@ast.crate](time_passes, "typestate checking", - bind typestate_check.check_crate(crate)); + crate = time(time_passes, "typestate checking", + bind typestate_check.check_crate(crate, def_map)); } auto llmod = time[llvm.ModuleRef](time_passes, "translation", @@ -121,7 +123,7 @@ fn pretty_print_input(session.session sess, eval.env env, str input) { auto def = tup(ast.local_crate, 0); - auto p = front.parser.new_parser(sess, env, def, input, 0u); + auto p = front.parser.new_parser(sess, env, def, input, 0u, 0u); auto crate = front.parser.parse_crate_from_source_file(p); pretty.pprust.print_file(sess, crate.node.module, input, std.IO.stdout()); } -- cgit v1.2.3