提交 1b9dbcc5 编写于 作者: M Michael Sullivan

Box the vec of freevars we store in the freevars cache.

上级 430cafbe
......@@ -13,7 +13,7 @@
export freevar_set;
export freevar_map;
type freevar_set = ast::node_id[];
type freevar_set = @ast::node_id[];
type freevar_map = hashmap[ast::node_id, freevar_set];
// Searches through part of the AST for all references to locals or
......@@ -23,7 +23,7 @@
// in order to start the search.
fn collect_freevars(&resolve::def_map def_map, &session::session sess,
&fn (&walk::ast_visitor) walker,
ast::node_id[] initial_decls) -> ast::node_id[] {
ast::node_id[] initial_decls) -> freevar_set {
type env =
@rec(mutable ast::node_id[] refs,
hashmap[ast::node_id, ()] decls,
......@@ -79,12 +79,12 @@ fn walk_pat(env e, &@ast::pat p) {
walker(*visitor);
// Calculate (refs - decls). This is the set of captured upvars.
let ast::node_id[] result = ~[];
auto result = ~[];
for (ast::node_id ref_id_ in e.refs) {
auto ref_id = ref_id_;
if (!decls.contains_key(ref_id)) { result += ~[ref_id]; }
}
ret result;
ret @result;
}
// Build a map from every function and for-each body to a set of the
......
......@@ -4285,7 +4285,7 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
auto decl_id = local.node.id;
auto upvars = cx.fcx.lcx.ccx.tcx.freevars.get(body.node.id);
auto environment_data = build_environment(cx, upvars);
auto environment_data = build_environment(cx, *upvars);
auto llenvptr = environment_data._0;
auto llenvptrty = environment_data._1;
......@@ -4308,7 +4308,7 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
// Generate code to load the environment out of the
// environment pointer.
load_environment(cx, fcx, llenvptrty, upvars);
load_environment(cx, fcx, llenvptrty, *upvars);
// Add an upvar for the loop variable alias.
fcx.llupvars.insert(decl_id, llvm::LLVMGetParam(fcx.llfn, 3u));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册