diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-30 13:38:38 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-11-30 13:38:38 +0100 |
| commit | b40c6773c2f1a5a34990004cbe9b29a7575e2f7e (patch) | |
| tree | e806179dd1c8f102bbc44d7268e3e855f7b97333 /src/comp/middle | |
| parent | 586a685eecd7786679e93cf0040a0558f47877da (diff) | |
| download | rust-b40c6773c2f1a5a34990004cbe9b29a7575e2f7e.tar.gz rust-b40c6773c2f1a5a34990004cbe9b29a7575e2f7e.zip | |
Box ast::path values
It seems inefficient to copy them around. Let's measure whether that's actually > the case
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/alias.rs | 7 | ||||
| -rw-r--r-- | src/comp/middle/resolve.rs | 12 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/tstate/auxiliary.rs | 6 | ||||
| -rw-r--r-- | src/comp/middle/tstate/pre_post_conditions.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/tstate/states.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/ty.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/typeck.rs | 7 |
8 files changed, 20 insertions, 20 deletions
diff --git a/src/comp/middle/alias.rs b/src/comp/middle/alias.rs index e3353e3d483..5cd05a833f4 100644 --- a/src/comp/middle/alias.rs +++ b/src/comp/middle/alias.rs @@ -16,8 +16,7 @@ tag copied { not_allowed; copied; not_copied; } tag invalid_reason { overwritten; val_taken; } type invalid = {reason: invalid_reason, node_id: node_id, - sp: span, path: - ast::path}; + sp: span, path: @ast::path}; tag unsafe_ty { contains(ty::t); mut_contains(ty::t); } @@ -374,7 +373,7 @@ fn check_for(cx: ctx, local: @ast::local, seq: @ast::expr, blk: ast::blk, visit::visit_block(blk, {bs: new_bs with sc}, v); } -fn check_var(cx: ctx, ex: @ast::expr, p: ast::path, id: ast::node_id, +fn check_var(cx: ctx, ex: @ast::expr, p: @ast::path, id: ast::node_id, assign: bool, sc: scope) { let def = cx.tcx.def_map.get(id); if !def_is_local(def, false) { ret; } @@ -445,7 +444,7 @@ fn check_loop(cx: ctx, sc: scope, checker: block()) { *sc.invalid = new_invalid; } -fn test_scope(cx: ctx, sc: scope, b: binding, p: ast::path) { +fn test_scope(cx: ctx, sc: scope, b: binding, p: @ast::path) { let prob = find_invalid(b.node_id, *sc.invalid); alt b.root_var { some(dn) { diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 94d76e46d6c..1807085ffc4 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -44,7 +44,7 @@ tag scope { type scopes = list<scope>; tag import_state { - todo(ast::node_id, ast::ident, [ast::ident], codemap::span, scopes); + todo(ast::node_id, ast::ident, @[ast::ident], codemap::span, scopes); resolving(span); resolved(option::t<def>, /* value */ option::t<def>, /* type */ @@ -172,7 +172,7 @@ fn map_crate(e: @env, c: @ast::crate) { for ident in idents { e.imports.insert(ident.node.id, todo(ident.node.id, ident.node.name, - mod_path + [ident.node.name], + @(*mod_path + [ident.node.name]), ident.span, sc)); } } @@ -214,7 +214,7 @@ fn map_crate(e: @env, c: @ast::crate) { alt vi.node { //if it really is a glob import, that is ast::view_item_import_glob(path, _) { - let imp = follow_import(*e, sc, path, vi.span); + let imp = follow_import(*e, sc, *path, vi.span); if option::is_some(imp) { let glob = {def: option::get(imp), item: vi};; alt list::head(sc) { @@ -243,7 +243,7 @@ fn resolve_imports(e: env) { e.imports.values {|v| alt v { todo(node_id, name, path, span, scopes) { - resolve_import(e, local_def(node_id), name, path, span, scopes); + resolve_import(e, local_def(node_id), name, *path, span, scopes); } resolved(_, _, _, _, _) { } } @@ -304,7 +304,7 @@ fn resolve_names(e: @env, c: @ast::crate) { _ { } } } - fn walk_constr(e: @env, p: ast::path, sp: span, id: node_id, sc: scopes, + fn walk_constr(e: @env, p: @ast::path, sp: span, id: node_id, sc: scopes, _v: vt<scopes>) { maybe_insert(e, id, lookup_path_strict(*e, sc, sp, p.node, ns_value)); } @@ -966,7 +966,7 @@ fn found_view_item(e: env, vi: @ast::view_item) -> option::t<def> { fn lookup_import(e: env, defid: def_id, ns: namespace) -> option::t<def> { alt e.imports.get(defid.node) { todo(node_id, name, path, span, scopes) { - resolve_import(e, local_def(node_id), name, path, span, scopes); + resolve_import(e, local_def(node_id), name, *path, span, scopes); ret lookup_import(e, defid, ns); } resolving(sp) { diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 2d8ad55b284..237b0089953 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -2967,7 +2967,7 @@ fn trans_local_var(cx: @block_ctxt, def: ast::def) -> lval_result { } } -fn trans_path(cx: @block_ctxt, p: ast::path, id: ast::node_id) +fn trans_path(cx: @block_ctxt, p: @ast::path, id: ast::node_id) -> lval_maybe_callee { ret trans_var(cx, p.span, bcx_tcx(cx).def_map.get(id), id); } diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index e7c17665628..b910dce220f 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -194,7 +194,7 @@ tag constraint { // FIXME: really only want it to be mutable during collect_locals. // freeze it after that. - cpred(path, @mutable [pred_args]); + cpred(@path, @mutable [pred_args]); } // An ninit variant has a node_id because it refers to a local var. @@ -204,7 +204,7 @@ tag constraint { // and give ninit a constraint saying it's local. tag tsconstr { ninit(node_id, ident); - npred(path, def_id, [@constr_arg_use]); + npred(@path, def_id, [@constr_arg_use]); } type sp_constr = spanned<tsconstr>; @@ -773,7 +773,7 @@ fn replace(subst: subst, d: pred_args) -> [constr_arg_general_<inst>] { ret rslt; } -fn path_to_ident(cx: ty::ctxt, p: path) -> ident { +fn path_to_ident(cx: ty::ctxt, p: @path) -> ident { alt vec::last(p.node.idents) { none. { cx.sess.span_fatal(p.span, "Malformed path"); } some(i) { ret i; } diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index 1da6346f739..d0ac63704d7 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -191,7 +191,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, } fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id, - new_var: node_id, pth: path) { + new_var: node_id, pth: @path) { alt node_id_to_def(fcx.ccx, new_var) { some(d) { alt d { diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs index 598a49a8762..ed84520a6b9 100644 --- a/src/comp/middle/tstate/states.rs +++ b/src/comp/middle/tstate/states.rs @@ -27,7 +27,7 @@ fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) { } } -fn handle_move_or_copy(fcx: fn_ctxt, post: poststate, rhs_path: path, +fn handle_move_or_copy(fcx: fn_ctxt, post: poststate, rhs_path: @path, rhs_id: node_id, instlhs: inst, init_op: init_op) { forbid_upvar(fcx, rhs_id, rhs_path.span, op_to_oper_ty(init_op)); diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 33d261dc83f..5a290f7efc6 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -274,7 +274,7 @@ tag sty { // In the middle end, constraints have a def_id attached, referring // to the definition of the operator in the constraint. type constr_general<ARG> = spanned<constr_general_<ARG, def_id>>; -type type_constr = constr_general<path>; +type type_constr = constr_general<@path>; type constr = constr_general<uint>; // Data structures used in type unification diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 64bce9da750..fc0a4de5245 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -130,8 +130,9 @@ fn ty_param_kinds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> // Instantiates the given path, which must refer to an item with the given // number of type parameters and type. -fn instantiate_path(fcx: @fn_ctxt, pth: ast::path, tpt: ty_param_kinds_and_ty, - sp: span) -> ty_param_substs_opt_and_ty { +fn instantiate_path(fcx: @fn_ctxt, pth: @ast::path, + tpt: ty_param_kinds_and_ty, sp: span) + -> ty_param_substs_opt_and_ty { let ty_param_count = vec::len(tpt.kinds); let bind_result = bind_params_in_type(sp, fcx.ccx.tcx, bind next_ty_var_id(fcx), tpt.ty, @@ -2586,7 +2587,7 @@ fn check_constraints(fcx: @fn_ctxt, cs: [@ast::constr], args: [ast::arg]) { ast::def_arg(local_def(args[i].id), args[i].mode)); {id: arg_occ_node_id, - node: ast::expr_path(respan(a.span, p)), + node: ast::expr_path(@respan(a.span, p)), span: a.span} } else { fcx.ccx.tcx.sess.span_bug(a.span, |
