Box ast::path values

It seems inefficient to copy them around. Let's measure whether that's actually
> the case
This commit is contained in:
Marijn Haverbeke 2011-11-30 13:38:38 +01:00
parent 586a685eec
commit b40c6773c2
20 changed files with 102 additions and 103 deletions

View File

@ -235,17 +235,17 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
let test_fn_ty: ast::ty = nospan( let test_fn_ty: ast::ty = nospan(
ast::ty_path( ast::ty_path(
nospan({ @nospan({
global: false, global: false,
idents: ["std", "test", "default_test_fn"], idents: ["std", "test", "default_test_fn"],
types: [] types: []
}), }),
cx.next_node_id())); cx.next_node_id()));
let test_desc_ty_path: ast::path = let test_desc_ty_path =
nospan({global: false, @nospan({global: false,
idents: ["std", "test", "test_desc"], idents: ["std", "test", "test_desc"],
types: [@test_fn_ty]}); types: [@test_fn_ty]});
let test_desc_ty: ast::ty = let test_desc_ty: ast::ty =
nospan(ast::ty_path(test_desc_ty_path, cx.next_node_id())); nospan(ast::ty_path(test_desc_ty_path, cx.next_node_id()));
@ -284,7 +284,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
let name_field: ast::field = let name_field: ast::field =
nospan({mut: ast::imm, ident: "name", expr: @name_expr}); nospan({mut: ast::imm, ident: "name", expr: @name_expr});
let fn_path: ast::path = nospan({global: false, idents: path, types: []}); let fn_path = @nospan({global: false, idents: path, types: []});
let fn_expr: ast::expr = let fn_expr: ast::expr =
{id: cx.next_node_id(), {id: cx.next_node_id(),
@ -414,8 +414,8 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
// Get the args passed to main so we can pass the to test_main // Get the args passed to main so we can pass the to test_main
let args_path: ast::path = let args_path =
nospan({global: false, idents: ["args"], types: []}); @nospan({global: false, idents: ["args"], types: []});
let args_path_expr_: ast::expr_ = ast::expr_path(args_path); let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
@ -423,8 +423,8 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
{id: cx.next_node_id(), node: args_path_expr_, span: dummy_sp()}; {id: cx.next_node_id(), node: args_path_expr_, span: dummy_sp()};
// Call __test::test to generate the vector of test_descs // Call __test::test to generate the vector of test_descs
let test_path: ast::path = let test_path =
nospan({global: false, idents: ["tests"], types: []}); @nospan({global: false, idents: ["tests"], types: []});
let test_path_expr_: ast::expr_ = ast::expr_path(test_path); let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
@ -437,10 +437,10 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
{id: cx.next_node_id(), node: test_call_expr_, span: dummy_sp()}; {id: cx.next_node_id(), node: test_call_expr_, span: dummy_sp()};
// Call std::test::test_main // Call std::test::test_main
let test_main_path: ast::path = let test_main_path =
nospan({global: false, @nospan({global: false,
idents: ["std", "test", "test_main"], idents: ["std", "test", "test_main"],
types: []}); types: []});
let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path); let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);

View File

@ -83,7 +83,7 @@ fn parse_ty_constrs(st: @pstate, sd: str_def) -> [@ty::type_constr] {
do { do {
next(st); next(st);
let one: @ty::type_constr = let one: @ty::type_constr =
parse_constr::<path>(st, sd, parse_ty_constr_arg); parse_constr::<@path>(st, sd, parse_ty_constr_arg);
rslt += [one]; rslt += [one];
} while peek(st) as char == ';' } while peek(st) as char == ';'
} }
@ -92,7 +92,7 @@ fn parse_ty_constrs(st: @pstate, sd: str_def) -> [@ty::type_constr] {
ret rslt; ret rslt;
} }
fn parse_path(st: @pstate, sd: str_def) -> ast::path { fn parse_path(st: @pstate, sd: str_def) -> @ast::path {
let idents: [ast::ident] = []; let idents: [ast::ident] = [];
fn is_last(c: char) -> bool { ret c == '(' || c == ':'; } fn is_last(c: char) -> bool { ret c == '(' || c == ':'; }
idents += [parse_ident_(st, sd, is_last)]; idents += [parse_ident_(st, sd, is_last)];
@ -101,8 +101,8 @@ fn parse_path(st: @pstate, sd: str_def) -> ast::path {
':' { next(st); next(st); } ':' { next(st); next(st); }
c { c {
if c == '(' { if c == '(' {
ret respan(ast_util::dummy_sp(), ret @respan(ast_util::dummy_sp(),
{global: false, idents: idents, types: []}); {global: false, idents: idents, types: []});
} else { idents += [parse_ident_(st, sd, is_last)]; } } else { idents += [parse_ident_(st, sd, is_last)]; }
} }
} }
@ -138,7 +138,7 @@ fn parse_constr_arg(st: @pstate, _sd: str_def) -> ast::fn_constr_arg {
} }
fn parse_ty_constr_arg(st: @pstate, sd: str_def) -> fn parse_ty_constr_arg(st: @pstate, sd: str_def) ->
ast::constr_arg_general_<path> { ast::constr_arg_general_<@path> {
alt peek(st) as char { alt peek(st) as char {
'*' { st.pos += 1u; ret ast::carg_base; } '*' { st.pos += 1u; ret ast::carg_base; }
c { ret ast::carg_ident(parse_path(st, sd)); } c { ret ast::carg_ident(parse_path(st, sd)); }
@ -149,9 +149,9 @@ fn parse_constr<copy T>(st: @pstate, sd: str_def, pser: arg_parser<T>) ->
@ty::constr_general<T> { @ty::constr_general<T> {
let sp = ast_util::dummy_sp(); // FIXME: use a real span let sp = ast_util::dummy_sp(); // FIXME: use a real span
let args: [@sp_constr_arg<T>] = []; let args: [@sp_constr_arg<T>] = [];
let pth: path = parse_path(st, sd); let pth = parse_path(st, sd);
let ignore: char = next(st) as char; let ignore: char = next(st) as char;
assert (ignore as char == '('); assert (ignore == '(');
let def = parse_def(st, sd); let def = parse_def(st, sd);
let an_arg: constr_arg_general_<T>; let an_arg: constr_arg_general_<T>;
do { do {

View File

@ -16,8 +16,7 @@ tag copied { not_allowed; copied; not_copied; }
tag invalid_reason { overwritten; val_taken; } tag invalid_reason { overwritten; val_taken; }
type invalid = {reason: invalid_reason, type invalid = {reason: invalid_reason,
node_id: node_id, node_id: node_id,
sp: span, path: sp: span, path: @ast::path};
ast::path};
tag unsafe_ty { contains(ty::t); mut_contains(ty::t); } 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); 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) { assign: bool, sc: scope) {
let def = cx.tcx.def_map.get(id); let def = cx.tcx.def_map.get(id);
if !def_is_local(def, false) { ret; } if !def_is_local(def, false) { ret; }
@ -445,7 +444,7 @@ fn check_loop(cx: ctx, sc: scope, checker: block()) {
*sc.invalid = new_invalid; *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); let prob = find_invalid(b.node_id, *sc.invalid);
alt b.root_var { alt b.root_var {
some(dn) { some(dn) {

View File

@ -44,7 +44,7 @@ tag scope {
type scopes = list<scope>; type scopes = list<scope>;
tag import_state { 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); resolving(span);
resolved(option::t<def>, /* value */ resolved(option::t<def>, /* value */
option::t<def>, /* type */ option::t<def>, /* type */
@ -172,7 +172,7 @@ fn map_crate(e: @env, c: @ast::crate) {
for ident in idents { for ident in idents {
e.imports.insert(ident.node.id, e.imports.insert(ident.node.id,
todo(ident.node.id, ident.node.name, todo(ident.node.id, ident.node.name,
mod_path + [ident.node.name], @(*mod_path + [ident.node.name]),
ident.span, sc)); ident.span, sc));
} }
} }
@ -214,7 +214,7 @@ fn map_crate(e: @env, c: @ast::crate) {
alt vi.node { alt vi.node {
//if it really is a glob import, that is //if it really is a glob import, that is
ast::view_item_import_glob(path, _) { 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) { if option::is_some(imp) {
let glob = {def: option::get(imp), item: vi};; let glob = {def: option::get(imp), item: vi};;
alt list::head(sc) { alt list::head(sc) {
@ -243,7 +243,7 @@ fn resolve_imports(e: env) {
e.imports.values {|v| e.imports.values {|v|
alt v { alt v {
todo(node_id, name, path, span, scopes) { 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(_, _, _, _, _) { } 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>) { _v: vt<scopes>) {
maybe_insert(e, id, lookup_path_strict(*e, sc, sp, p.node, ns_value)); 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> { fn lookup_import(e: env, defid: def_id, ns: namespace) -> option::t<def> {
alt e.imports.get(defid.node) { alt e.imports.get(defid.node) {
todo(node_id, name, path, span, scopes) { 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); ret lookup_import(e, defid, ns);
} }
resolving(sp) { resolving(sp) {

View File

@ -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 { -> lval_maybe_callee {
ret trans_var(cx, p.span, bcx_tcx(cx).def_map.get(id), id); ret trans_var(cx, p.span, bcx_tcx(cx).def_map.get(id), id);
} }

View File

@ -194,7 +194,7 @@ tag constraint {
// FIXME: really only want it to be mutable during collect_locals. // FIXME: really only want it to be mutable during collect_locals.
// freeze it after that. // 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. // 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. // and give ninit a constraint saying it's local.
tag tsconstr { tag tsconstr {
ninit(node_id, ident); ninit(node_id, ident);
npred(path, def_id, [@constr_arg_use]); npred(@path, def_id, [@constr_arg_use]);
} }
type sp_constr = spanned<tsconstr>; type sp_constr = spanned<tsconstr>;
@ -773,7 +773,7 @@ fn replace(subst: subst, d: pred_args) -> [constr_arg_general_<inst>] {
ret rslt; 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) { alt vec::last(p.node.idents) {
none. { cx.sess.span_fatal(p.span, "Malformed path"); } none. { cx.sess.span_fatal(p.span, "Malformed path"); }
some(i) { ret i; } some(i) { ret i; }

View File

@ -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, 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) { alt node_id_to_def(fcx.ccx, new_var) {
some(d) { some(d) {
alt d { alt d {

View File

@ -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) { rhs_id: node_id, instlhs: inst, init_op: init_op) {
forbid_upvar(fcx, rhs_id, rhs_path.span, op_to_oper_ty(init_op)); forbid_upvar(fcx, rhs_id, rhs_path.span, op_to_oper_ty(init_op));

View File

@ -274,7 +274,7 @@ tag sty {
// In the middle end, constraints have a def_id attached, referring // In the middle end, constraints have a def_id attached, referring
// to the definition of the operator in the constraint. // to the definition of the operator in the constraint.
type constr_general<ARG> = spanned<constr_general_<ARG, def_id>>; 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>; type constr = constr_general<uint>;
// Data structures used in type unification // Data structures used in type unification

View File

@ -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 // Instantiates the given path, which must refer to an item with the given
// number of type parameters and type. // number of type parameters and type.
fn instantiate_path(fcx: @fn_ctxt, pth: ast::path, tpt: ty_param_kinds_and_ty, fn instantiate_path(fcx: @fn_ctxt, pth: @ast::path,
sp: span) -> ty_param_substs_opt_and_ty { tpt: ty_param_kinds_and_ty, sp: span)
-> ty_param_substs_opt_and_ty {
let ty_param_count = vec::len(tpt.kinds); let ty_param_count = vec::len(tpt.kinds);
let bind_result = let bind_result =
bind_params_in_type(sp, fcx.ccx.tcx, bind next_ty_var_id(fcx), tpt.ty, 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), ast::def_arg(local_def(args[i].id),
args[i].mode)); args[i].mode));
{id: arg_occ_node_id, {id: arg_occ_node_id,
node: ast::expr_path(respan(a.span, p)), node: ast::expr_path(@respan(a.span, p)),
span: a.span} span: a.span}
} else { } else {
fcx.ccx.tcx.sess.span_bug(a.span, fcx.ccx.tcx.sess.span_bug(a.span,

View File

@ -61,7 +61,7 @@ tag crate_directive_ {
cdir_src_mod(ident, [attribute]); cdir_src_mod(ident, [attribute]);
cdir_dir_mod(ident, [@crate_directive], [attribute]); cdir_dir_mod(ident, [@crate_directive], [attribute]);
cdir_view_item(@view_item); cdir_view_item(@view_item);
cdir_syntax(path); cdir_syntax(@path);
} }
type crate_directive = spanned<crate_directive_>; type crate_directive = spanned<crate_directive_>;
@ -87,7 +87,7 @@ tag pat_ {
pat_wild; pat_wild;
pat_bind(ident); pat_bind(ident);
pat_lit(@lit); pat_lit(@lit);
pat_tag(path, [@pat]); pat_tag(@path, [@pat]);
pat_rec([field_pat], bool); pat_rec([field_pat], bool);
pat_tup([@pat]); pat_tup([@pat]);
pat_box(@pat); pat_box(@pat);
@ -208,7 +208,7 @@ tag expr_ {
expr_assign_op(binop, @expr, @expr); expr_assign_op(binop, @expr, @expr);
expr_field(@expr, ident); expr_field(@expr, ident);
expr_index(@expr, @expr); expr_index(@expr, @expr);
expr_path(path); expr_path(@path);
expr_fail(option::t<@expr>); expr_fail(option::t<@expr>);
expr_break; expr_break;
expr_cont; expr_cont;
@ -241,7 +241,7 @@ tag blk_sort {
type mac = spanned<mac_>; type mac = spanned<mac_>;
tag mac_ { tag mac_ {
mac_invoc(path, @expr, option::t<str>); mac_invoc(@path, @expr, option::t<str>);
mac_embed_type(@ty); mac_embed_type(@ty);
mac_embed_block(blk); mac_embed_block(blk);
mac_ellipsis; mac_ellipsis;
@ -328,7 +328,7 @@ tag ty_ {
ty_fn(proto, [ty_arg], @ty, ret_style, [@constr]); ty_fn(proto, [ty_arg], @ty, ret_style, [@constr]);
ty_obj([ty_method]); ty_obj([ty_method]);
ty_tup([@ty]); ty_tup([@ty]);
ty_path(path, node_id); ty_path(@path, node_id);
ty_type; ty_type;
ty_constr(@ty, [@ty_constr]); ty_constr(@ty, [@ty_constr]);
ty_mac(mac); ty_mac(mac);
@ -352,7 +352,7 @@ tag constr_arg_general_<T> { carg_base; carg_ident(T); carg_lit(@lit); }
type fn_constr_arg = constr_arg_general_<uint>; type fn_constr_arg = constr_arg_general_<uint>;
type sp_constr_arg<T> = spanned<constr_arg_general_<T>>; type sp_constr_arg<T> = spanned<constr_arg_general_<T>>;
type ty_constr_arg = sp_constr_arg<path>; type ty_constr_arg = sp_constr_arg<@path>;
type constr_arg = spanned<fn_constr_arg>; type constr_arg = spanned<fn_constr_arg>;
// Constrained types' args are parameterized by paths, since // Constrained types' args are parameterized by paths, since
@ -361,14 +361,14 @@ type constr_arg = spanned<fn_constr_arg>;
// constrained type, is * (referring to the base record) // constrained type, is * (referring to the base record)
type constr_general_<ARG, ID> = type constr_general_<ARG, ID> =
{path: path, args: [@spanned<constr_arg_general_<ARG>>], id: ID}; {path: @path, args: [@spanned<constr_arg_general_<ARG>>], id: ID};
// In the front end, constraints have a node ID attached. // In the front end, constraints have a node ID attached.
// Typeck turns this to a def_id, using the output of resolve. // Typeck turns this to a def_id, using the output of resolve.
type constr_general<ARG> = spanned<constr_general_<ARG, node_id>>; type constr_general<ARG> = spanned<constr_general_<ARG, node_id>>;
type constr_ = constr_general_<uint, node_id>; type constr_ = constr_general_<uint, node_id>;
type constr = spanned<constr_general_<uint, node_id>>; type constr = spanned<constr_general_<uint, node_id>>;
type ty_constr_ = ast::constr_general_<ast::path, ast::node_id>; type ty_constr_ = constr_general_<@path, node_id>;
type ty_constr = spanned<ty_constr_>; type ty_constr = spanned<ty_constr_>;
/* The parser generates ast::constrs; resolve generates /* The parser generates ast::constrs; resolve generates
@ -447,9 +447,9 @@ type import_ident = spanned<import_ident_>;
tag view_item_ { tag view_item_ {
view_item_use(ident, [@meta_item], node_id); view_item_use(ident, [@meta_item], node_id);
view_item_import(ident, simple_path, node_id); view_item_import(ident, @simple_path, node_id);
view_item_import_glob(simple_path, node_id); view_item_import_glob(@simple_path, node_id);
view_item_import_from(simple_path, [import_ident], node_id); view_item_import_from(@simple_path, [import_ident], node_id);
view_item_export([ident], node_id); view_item_export([ident], node_id);
} }

View File

@ -14,7 +14,7 @@ fn mk_sp(lo: uint, hi: uint) -> span {
// make this a const, once the compiler supports it // make this a const, once the compiler supports it
fn dummy_sp() -> span { ret mk_sp(0u, 0u); } fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
fn path_name(p: path) -> str { path_name_i(p.node.idents) } fn path_name(p: @path) -> str { path_name_i(p.node.idents) }
fn path_name_i(idents: [ident]) -> str { str::connect(idents, "::") } fn path_name_i(idents: [ident]) -> str { str::connect(idents, "::") }

View File

@ -17,8 +17,8 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: @ast::expr,
} }
ret @{id: cx.next_id(), ret @{id: cx.next_id(),
node: node: ast::expr_path(@{node: {global: false, idents: [res],
ast::expr_path({node: {global: false, idents: [res], types: []}, types: []},
span: sp}), span: sp}),
span: sp}; span: sp};
} }

View File

@ -67,7 +67,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
fn make_path_expr(cx: ext_ctxt, sp: span, idents: [ast::ident]) -> fn make_path_expr(cx: ext_ctxt, sp: span, idents: [ast::ident]) ->
@ast::expr { @ast::expr {
let path = {global: false, idents: idents, types: []}; let path = {global: false, idents: idents, types: []};
let sp_path = {node: path, span: sp}; let sp_path = @{node: path, span: sp};
let pathexpr = ast::expr_path(sp_path); let pathexpr = ast::expr_path(sp_path);
ret @{id: cx.next_id(), node: pathexpr, span: sp}; ret @{id: cx.next_id(), node: pathexpr, span: sp};
} }

View File

@ -14,7 +14,7 @@ import ast::{ident, path, ty, blk_, expr, path_, expr_path,
export add_new_extension; export add_new_extension;
fn path_to_ident(pth: path) -> option::t<ident> { fn path_to_ident(pth: @path) -> option::t<ident> {
if vec::len(pth.node.idents) == 1u && vec::len(pth.node.types) == 0u { if vec::len(pth.node.idents) == 1u && vec::len(pth.node.types) == 0u {
ret some(pth.node.idents[0u]); ret some(pth.node.idents[0u]);
} }
@ -30,7 +30,7 @@ tag arb_depth<T> { leaf(T); seq(@[arb_depth<T>], span); }
tag matchable { tag matchable {
match_expr(@expr); match_expr(@expr);
match_path(path); match_path(@path);
match_ident(ast::spanned<ident>); match_ident(ast::spanned<ident>);
match_ty(@ty); match_ty(@ty);
match_block(ast::blk); match_block(ast::blk);
@ -360,10 +360,10 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mutable [uint],
} }
alt follow_for_trans(cx, b.find(p.node.idents[0]), idx_path) { alt follow_for_trans(cx, b.find(p.node.idents[0]), idx_path) {
some(match_ident(id)) { some(match_ident(id)) {
expr_path(respan(id.span, expr_path(@respan(id.span,
{global: false, {global: false,
idents: [id.node], idents: [id.node],
types: []})) types: []}))
} }
some(match_path(a_pth)) { expr_path(a_pth) } some(match_path(a_pth)) { expr_path(a_pth) }
some(match_expr(a_exp)) { a_exp.node } some(match_expr(a_exp)) { a_exp.node }
@ -502,7 +502,7 @@ fn specialize_match(m: matchable) -> matchable {
} }
/* pattern_to_selectors helper functions */ /* pattern_to_selectors helper functions */
fn p_t_s_r_path(cx: ext_ctxt, p: path, s: selector, b: binders) { fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) {
alt path_to_ident(p) { alt path_to_ident(p) {
some(p_id) { some(p_id) {
fn select(cx: ext_ctxt, m: matchable) -> match_result { fn select(cx: ext_ctxt, m: matchable) -> match_result {

View File

@ -67,7 +67,7 @@ type a_f =
fold_native_mod: fn@(native_mod) -> native_mod, fold_native_mod: fn@(native_mod) -> native_mod,
fold_variant: fn@(variant) -> variant, fold_variant: fn@(variant) -> variant,
fold_ident: fn@(&&ident) -> ident, fold_ident: fn@(&&ident) -> ident,
fold_path: fn@(path) -> path, fold_path: fn@(@path) -> @path,
fold_local: fn@(&&@local) -> @local, fold_local: fn@(&&@local) -> @local,
map_exprs: fn@(fn@(&&@expr) -> @expr, [@expr]) -> [@expr], map_exprs: fn@(fn@(&&@expr) -> @expr, [@expr]) -> [@expr],
new_id: fn@(node_id) -> node_id, new_id: fn@(node_id) -> node_id,
@ -97,7 +97,7 @@ fn nf_mod_dummy(_m: _mod) -> _mod { fail; }
fn nf_native_mod_dummy(_n: native_mod) -> native_mod { fail; } fn nf_native_mod_dummy(_n: native_mod) -> native_mod { fail; }
fn nf_variant_dummy(_v: variant) -> variant { fail; } fn nf_variant_dummy(_v: variant) -> variant { fail; }
fn nf_ident_dummy(&&_i: ident) -> ident { fail; } fn nf_ident_dummy(&&_i: ident) -> ident { fail; }
fn nf_path_dummy(_p: path) -> path { fail; } fn nf_path_dummy(_p: @path) -> @path { fail; }
fn nf_obj_field_dummy(_o: obj_field) -> obj_field { fail; } fn nf_obj_field_dummy(_o: obj_field) -> obj_field { fail; }
fn nf_local_dummy(&&_o: @local) -> @local { fail; } fn nf_local_dummy(&&_o: @local) -> @local { fail; }
@ -630,8 +630,8 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
fn f_ident(afp: ast_fold_precursor, f: ast_fold, &&x: ident) -> ident { fn f_ident(afp: ast_fold_precursor, f: ast_fold, &&x: ident) -> ident {
ret afp.fold_ident(x, f); ret afp.fold_ident(x, f);
} }
fn f_path(afp: ast_fold_precursor, f: ast_fold, x: path) -> path { fn f_path(afp: ast_fold_precursor, f: ast_fold, x: @path) -> @path {
ret {node: afp.fold_path(x.node, f), span: afp.new_span(x.span)}; ret @{node: afp.fold_path(x.node, f), span: afp.new_span(x.span)};
} }
fn f_local(afp: ast_fold_precursor, f: ast_fold, &&x: @local) -> @local { fn f_local(afp: ast_fold_precursor, f: ast_fold, &&x: @local) -> @local {
ret @{node: afp.fold_local(x.node, f), span: afp.new_span(x.span)}; ret @{node: afp.fold_local(x.node, f), span: afp.new_span(x.span)};

View File

@ -354,7 +354,7 @@ fn parse_type_constr_arg(p: parser) -> @ast::ty_constr_arg {
if p.peek() == token::DOT { if p.peek() == token::DOT {
// "*..." notation for record fields // "*..." notation for record fields
p.bump(); p.bump();
let pth: ast::path = parse_path(p); let pth = parse_path(p);
carg = ast::carg_ident(pth); carg = ast::carg_ident(pth);
} }
// No literals yet, I guess? // No literals yet, I guess?
@ -430,10 +430,10 @@ fn parse_ty_postfix(orig_t: ast::ty_, p: parser, colons_before_params: bool)
ast::ty_path(pth, ann) { ast::ty_path(pth, ann) {
let hi = p.get_hi_pos(); let hi = p.get_hi_pos();
ret @spanned(lo, hi, ret @spanned(lo, hi,
ast::ty_path(spanned(lo, hi, ast::ty_path(@spanned(lo, hi,
{global: pth.node.global, {global: pth.node.global,
idents: pth.node.idents, idents: pth.node.idents,
types: seq}), ann)); types: seq}), ann));
} }
_ { p.fatal("type parameter instantiation only allowed for paths"); } _ { p.fatal("type parameter instantiation only allowed for paths"); }
} }
@ -697,7 +697,7 @@ fn is_plain_ident(p: parser) -> bool {
ret alt p.peek() { token::IDENT(_, false) { true } _ { false } }; ret alt p.peek() { token::IDENT(_, false) { true } _ { false } };
} }
fn parse_path(p: parser) -> ast::path { fn parse_path(p: parser) -> @ast::path {
let lo = p.get_lo_pos(); let lo = p.get_lo_pos();
let hi = lo; let hi = lo;
@ -722,10 +722,10 @@ fn parse_path(p: parser) -> ast::path {
_ { break; } _ { break; }
} }
} }
ret spanned(lo, hi, {global: global, idents: ids, types: []}); ret @spanned(lo, hi, {global: global, idents: ids, types: []});
} }
fn parse_path_and_ty_param_substs(p: parser) -> ast::path { fn parse_path_and_ty_param_substs(p: parser) -> @ast::path {
let lo = p.get_lo_pos(); let lo = p.get_lo_pos();
let path = parse_path(p); let path = parse_path(p);
if p.peek() == token::MOD_SEP { if p.peek() == token::MOD_SEP {
@ -734,11 +734,10 @@ fn parse_path_and_ty_param_substs(p: parser) -> ast::path {
let seq = let seq =
parse_seq_lt_gt(some(token::COMMA), {|p| parse_ty(p, false)}, p); parse_seq_lt_gt(some(token::COMMA), {|p| parse_ty(p, false)}, p);
let hi = seq.span.hi; let hi = seq.span.hi;
path = path = @spanned(lo, hi,
spanned(lo, hi, {global: path.node.global,
{global: path.node.global, idents: path.node.idents,
idents: path.node.idents, types: seq.node});
types: seq.node});
} }
ret path; ret path;
} }
@ -2331,18 +2330,18 @@ fn parse_rest_import_name(p: parser, first: ast::ident,
if option::is_some(from_idents) { if option::is_some(from_idents) {
p.fatal("can't rename import list"); p.fatal("can't rename import list");
} }
ret ast::view_item_import(i, identifiers, p.get_id()); ret ast::view_item_import(i, @identifiers, p.get_id());
} }
_ { _ {
if glob { if glob {
ret ast::view_item_import_glob(identifiers, p.get_id()); ret ast::view_item_import_glob(@identifiers, p.get_id());
} else if option::is_some(from_idents) { } else if option::is_some(from_idents) {
ret ast::view_item_import_from(identifiers, ret ast::view_item_import_from(@identifiers,
option::get(from_idents), option::get(from_idents),
p.get_id()); p.get_id());
} else { } else {
let len = vec::len(identifiers); let len = vec::len(identifiers);
ret ast::view_item_import(identifiers[len - 1u], identifiers, ret ast::view_item_import(identifiers[len - 1u], @identifiers,
p.get_id()); p.get_id());
} }
} }

View File

@ -86,7 +86,7 @@ fn stmt_to_str(s: ast::stmt) -> str { be to_str(s, print_stmt); }
fn item_to_str(i: @ast::item) -> str { be to_str(i, print_item); } fn item_to_str(i: @ast::item) -> str { be to_str(i, print_item); }
fn path_to_str(p: ast::path) -> str { fn path_to_str(&&p: @ast::path) -> str {
be to_str(p, bind print_path(_, _, false)); be to_str(p, bind print_path(_, _, false));
} }
@ -1038,7 +1038,7 @@ fn print_for_decl(s: ps, loc: @ast::local, coll: @ast::expr) {
print_expr(s, coll); print_expr(s, coll);
} }
fn print_path(s: ps, path: ast::path, colons_before_params: bool) { fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) {
maybe_print_comment(s, path.span.lo); maybe_print_comment(s, path.span.lo);
if path.node.global { word(s.s, "::"); } if path.node.global { word(s.s, "::"); }
let first = true; let first = true;
@ -1213,19 +1213,19 @@ fn print_view_item(s: ps, item: @ast::view_item) {
} }
ast::view_item_import(id, ids, _) { ast::view_item_import(id, ids, _) {
head(s, "import"); head(s, "import");
if !str::eq(id, ids[vec::len(ids) - 1u]) { if !str::eq(id, ids[vec::len(*ids) - 1u]) {
word_space(s, id); word_space(s, id);
word_space(s, "="); word_space(s, "=");
} }
let first = true; let first = true;
for elt: ast::ident in ids { for elt: ast::ident in *ids {
if first { first = false; } else { word(s.s, "::"); } if first { first = false; } else { word(s.s, "::"); }
word(s.s, elt); word(s.s, elt);
} }
} }
ast::view_item_import_from(mod_path, idents, _) { ast::view_item_import_from(mod_path, idents, _) {
head(s, "import"); head(s, "import");
for elt: ast::ident in mod_path { word(s.s, elt); word(s.s, "::"); } for elt: ast::ident in *mod_path { word(s.s, elt); word(s.s, "::"); }
word(s.s, "{"); word(s.s, "{");
commasep(s, inconsistent, idents, commasep(s, inconsistent, idents,
fn (s: ps, w: ast::import_ident) { word(s.s, w.node.name) }); fn (s: ps, w: ast::import_ident) { word(s.s, w.node.name) });
@ -1234,7 +1234,7 @@ fn print_view_item(s: ps, item: @ast::view_item) {
ast::view_item_import_glob(ids, _) { ast::view_item_import_glob(ids, _) {
head(s, "import"); head(s, "import");
let first = true; let first = true;
for elt: ast::ident in ids { for elt: ast::ident in *ids {
if first { first = false; } else { word(s.s, "::"); } if first { first = false; } else { word(s.s, "::"); }
word(s.s, elt); word(s.s, elt);
} }
@ -1602,11 +1602,11 @@ fn proto_to_str(p: ast::proto) -> str {
} }
fn ty_constr_to_str(c: @ast::ty_constr) -> str { fn ty_constr_to_str(c: @ast::ty_constr) -> str {
fn ty_constr_path_to_str(p: ast::path) -> str { "*." + path_to_str(p) } fn ty_constr_path_to_str(&&p: @ast::path) -> str { "*." + path_to_str(p) }
ret path_to_str(c.node.path) + ret path_to_str(c.node.path) +
constr_args_to_str::<ast::path>(ty_constr_path_to_str, constr_args_to_str::<@ast::path>(ty_constr_path_to_str,
c.node.args); c.node.args);
} }

View File

@ -30,7 +30,7 @@ type visitor<E> =
visit_decl: fn@(@decl, E, vt<E>), visit_decl: fn@(@decl, E, vt<E>),
visit_expr: fn@(@expr, E, vt<E>), visit_expr: fn@(@expr, E, vt<E>),
visit_ty: fn@(@ty, E, vt<E>), visit_ty: fn@(@ty, E, vt<E>),
visit_constr: fn@(path, span, node_id, E, vt<E>), visit_constr: fn@(@path, span, node_id, E, vt<E>),
visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id, E, vt<E>)}; visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id, E, vt<E>)};
fn default_visitor<E>() -> visitor<E> { fn default_visitor<E>() -> visitor<E> {
@ -149,7 +149,7 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
ty_type. {/* no-op */ } ty_type. {/* no-op */ }
ty_constr(t, cs) { ty_constr(t, cs) {
v.visit_ty(t, e, v); v.visit_ty(t, e, v);
for tc: @spanned<constr_general_<path, node_id>> in cs { for tc: @spanned<constr_general_<@path, node_id>> in cs {
v.visit_constr(tc.node.path, tc.span, tc.node.id, e, v); v.visit_constr(tc.node.path, tc.span, tc.node.id, e, v);
} }
} }
@ -157,7 +157,7 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
} }
} }
fn visit_constr<E>(_operator: path, _sp: span, _id: node_id, _e: E, fn visit_constr<E>(_operator: @path, _sp: span, _id: node_id, _e: E,
_v: vt<E>) { _v: vt<E>) {
// default // default
} }
@ -354,7 +354,7 @@ type simple_visitor =
visit_decl: fn@(@decl), visit_decl: fn@(@decl),
visit_expr: fn@(@expr), visit_expr: fn@(@expr),
visit_ty: fn@(@ty), visit_ty: fn@(@ty),
visit_constr: fn@(path, span, node_id), visit_constr: fn@(@path, span, node_id),
visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id)}; visit_fn: fn@(_fn, [ty_param], span, fn_ident, node_id)};
fn simple_ignore_ty(_t: @ty) {} fn simple_ignore_ty(_t: @ty) {}
@ -372,7 +372,7 @@ fn default_simple_visitor() -> simple_visitor {
visit_decl: fn(_d: @decl) { }, visit_decl: fn(_d: @decl) { },
visit_expr: fn(_e: @expr) { }, visit_expr: fn(_e: @expr) { },
visit_ty: simple_ignore_ty, visit_ty: simple_ignore_ty,
visit_constr: fn(_p: path, _sp: span, _id: node_id) { }, visit_constr: fn(_p: @path, _sp: span, _id: node_id) { },
visit_fn: visit_fn:
fn(_f: _fn, _tps: [ty_param], _sp: span, _ident: fn_ident, fn(_f: _fn, _tps: [ty_param], _sp: span, _ident: fn_ident,
_id: node_id) { _id: node_id) {
@ -429,8 +429,8 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
f(ty); f(ty);
visit_ty(ty, e, v); visit_ty(ty, e, v);
} }
fn v_constr(f: fn@(path, span, node_id), pt: path, sp: span, id: node_id, fn v_constr(f: fn@(@path, span, node_id), pt: @path, sp: span,
&&e: (), v: vt<()>) { id: node_id, &&e: (), v: vt<()>) {
f(pt, sp, id); f(pt, sp, id);
visit_constr(pt, sp, id, e, v); visit_constr(pt, sp, id, e, v);
} }

View File

@ -161,10 +161,10 @@ fn constrs_str(constrs: [@constr]) -> str {
ret s; ret s;
} }
fn ty_constr_to_str<Q>(c: @ast::spanned<ast::constr_general_<ast::path, Q>>) fn ty_constr_to_str<Q>(c: @ast::spanned<ast::constr_general_<@ast::path, Q>>)
-> str { -> str {
ret path_to_str(c.node.path) + ret path_to_str(c.node.path) +
constr_args_to_str::<ast::path>(path_to_str, c.node.args); constr_args_to_str::<@ast::path>(path_to_str, c.node.args);
} }
// Local Variables: // Local Variables: