diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-06-10 00:49:59 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-06-13 11:30:45 -0700 |
| commit | ce750a7dbcd2dc68db6de89956b1de3ecf9f2d0a (patch) | |
| tree | 55c2ee5be0986c2489879022d4788d6c3ac2c964 /src/libsyntax/ext | |
| parent | bdd20000665a35e14b4ec2c54f893fc80fe451ef (diff) | |
| download | rust-ce750a7dbcd2dc68db6de89956b1de3ecf9f2d0a.tar.gz rust-ce750a7dbcd2dc68db6de89956b1de3ecf9f2d0a.zip | |
Box AST idents
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/auto_serialize.rs | 75 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat_idents.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/env.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 23 | ||||
| -rw-r--r-- | src/libsyntax/ext/qquote.rs | 34 | ||||
| -rw-r--r-- | src/libsyntax/ext/simplext.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 9 |
10 files changed, 95 insertions, 88 deletions
diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index dc632d6b6ac..888ff7d4ef2 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -92,7 +92,7 @@ fn expand(cx: ext_ctxt, _mitem: ast::meta_item, in_items: [@ast::item]) -> [@ast::item] { fn not_auto_serialize(a: ast::attribute) -> bool { - attr::get_attr_name(a) != "auto_serialize" + attr::get_attr_name(a) != @"auto_serialize" } fn filter_attrs(item: @ast::item) -> @ast::item { @@ -126,18 +126,19 @@ impl helpers for ext_ctxt { helper_name: str) -> @ast::path { let head = vec::init(base_path.idents); let tail = vec::last(base_path.idents); - self.path(base_path.span, head + [helper_name + "_" + tail]) + self.path(base_path.span, head + [@(helper_name + "_" + *tail)]) } - fn path(span: span, strs: [str]) -> @ast::path { + fn path(span: span, strs: [ast::ident]) -> @ast::path { @{span: span, global: false, idents: strs, rp: none, types: []} } - fn path_tps(span: span, strs: [str], tps: [@ast::ty]) -> @ast::path { + fn path_tps(span: span, strs: [ast::ident], + tps: [@ast::ty]) -> @ast::path { @{span: span, global: false, idents: strs, rp: none, types: tps} } - fn ty_path(span: span, strs: [str], tps: [@ast::ty]) -> @ast::ty { + fn ty_path(span: span, strs: [ast::ident], tps: [@ast::ty]) -> @ast::ty { @{id: self.next_id(), node: ast::ty_path(self.path_tps(span, strs, tps), self.next_id()), span: span} @@ -149,7 +150,7 @@ impl helpers for ext_ctxt { let args = vec::map(input_tys) {|ty| {mode: ast::expl(ast::by_ref), ty: ty, - ident: "", + ident: @"", id: self.next_id()} }; @@ -170,7 +171,7 @@ impl helpers for ext_ctxt { @{id: self.next_id(), node: node, span: span} } - fn var_ref(span: span, name: str) -> @ast::expr { + fn var_ref(span: span, name: ast::ident) -> @ast::expr { self.expr(span, ast::expr_path(self.path(span, [name]))) } @@ -192,7 +193,7 @@ impl helpers for ext_ctxt { span: expr.span} } - fn binder_pat(span: span, nm: str) -> @ast::pat { + fn binder_pat(span: span, nm: ast::ident) -> @ast::pat { let path = @{span: span, global: false, idents: [nm], rp: none, types: []}; @{id: self.next_id(), @@ -212,7 +213,7 @@ impl helpers for ext_ctxt { ast::expr_alt(v, arms, ast::alt_exhaustive))) } - fn lit_str(span: span, s: str) -> @ast::expr { + fn lit_str(span: span, s: @str) -> @ast::expr { self.expr( span, ast::expr_lit( @@ -310,7 +311,7 @@ fn ser_variant(cx: ext_ctxt, bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr, argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr) -> ast::arm { - let vnames = vec::from_fn(vec::len(tys)) {|i| #fmt["__v%u", i]}; + let vnames = vec::from_fn(vec::len(tys)) {|i| @#fmt["__v%u", i]}; let pats = vec::from_fn(vec::len(tys)) {|i| cx.binder_pat(tys[i].span, vnames[i]) }; @@ -428,7 +429,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, vec::is_empty(path.types) { let ident = path.idents[0]; - alt tps.find(ident) { + alt tps.find(*ident) { some(f) { f(v) } none { ser_path(cx, tps, path, s, v) } } @@ -474,7 +475,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } } -fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], +fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, tps: [ast::ty_param], f: fn(ext_ctxt, ser_tps_map, -@ast::expr, -@ast::expr) -> [@ast::stmt]) -> @ast::item { @@ -489,7 +490,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], ty: cx.ty_fn(span, [cx.ty_path(span, [tp.ident], [])], cx.ty_nil(span)), - ident: "__s" + tp.ident, + ident: @("__s" + *tp.ident), id: cx.next_id()}}); #debug["tp_inputs = %?", tp_inputs]; @@ -497,12 +498,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], let ser_inputs: [ast::arg] = [{mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ["__S"], []), - ident: "__s", + ty: cx.ty_path(span, [@"__S"], []), + ident: @"__s", id: cx.next_id()}, {mode: ast::expl(ast::by_ref), ty: v_ty, - ident: "__v", + ident: @"__v", id: cx.next_id()}] + tp_inputs; @@ -510,21 +511,21 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], vec::iter2(tps, tp_inputs) {|tp, arg| let arg_ident = arg.ident; tps_map.insert( - tp.ident, + *tp.ident, fn@(v: @ast::expr) -> [@ast::stmt] { let f = cx.var_ref(span, arg_ident); - #debug["serializing type arg %s", arg_ident]; + #debug["serializing type arg %s", *arg_ident]; [#ast(stmt){$(f)($(v));}] }); } let ser_bnds = @[ ast::bound_iface(cx.ty_path(span, - ["std", "serialization", "serializer"], + [@"std", @"serialization", @"serializer"], []))]; let ser_tps: [ast::ty_param] = - [{ident: "__S", + [{ident: @"__S", id: cx.next_id(), bounds: ser_bnds}] + vec::map(tps) {|tp| cx.clone_ty_param(tp) }; @@ -536,7 +537,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], let ser_blk = cx.blk(span, f(cx, tps_map, #ast{ __s }, #ast{ __v })); - @{ident: "serialize_" + name, + @{ident: @("serialize_" + *name), attrs: [], id: cx.next_id(), node: ast::item_fn({inputs: ser_inputs, @@ -651,7 +652,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, vec::is_empty(path.types) { let ident = path.idents[0]; - alt tps.find(ident) { + alt tps.find(*ident) { some(f) { f() } none { deser_path(cx, tps, path, d) } } @@ -683,7 +684,8 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, } } -fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], +fn mk_deser_fn(cx: ext_ctxt, span: span, + name: ast::ident, tps: [ast::ty_param], f: fn(ext_ctxt, deser_tps_map, -@ast::expr) -> @ast::expr) -> @ast::item { let ext_cx = cx; // required for #ast @@ -697,15 +699,15 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], ty: cx.ty_fn(span, [], cx.ty_path(span, [tp.ident], [])), - ident: "__d" + tp.ident, + ident: @("__d" + *tp.ident), id: cx.next_id()}}); #debug["tp_inputs = %?", tp_inputs]; let deser_inputs: [ast::arg] = [{mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ["__D"], []), - ident: "__d", + ty: cx.ty_path(span, [@"__D"], []), + ident: @"__d", id: cx.next_id()}] + tp_inputs; @@ -713,7 +715,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], vec::iter2(tps, tp_inputs) {|tp, arg| let arg_ident = arg.ident; tps_map.insert( - tp.ident, + *tp.ident, fn@() -> @ast::expr { let f = cx.var_ref(span, arg_ident); #ast{ $(f)() } @@ -721,12 +723,13 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], } let deser_bnds = @[ - ast::bound_iface(cx.ty_path(span, - ["std", "serialization", "deserializer"], - []))]; + ast::bound_iface(cx.ty_path( + span, + [@"std", @"serialization", @"deserializer"], + []))]; let deser_tps: [ast::ty_param] = - [{ident: "__D", + [{ident: @"__D", id: cx.next_id(), bounds: deser_bnds}] + vec::map(tps) {|tp| let cloned = cx.clone_ty_param(tp); @@ -735,7 +738,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d})); - @{ident: "deserialize_" + name, + @{ident: @("deserialize_" + *name), attrs: [], id: cx.next_id(), node: ast::item_fn({inputs: deser_inputs, @@ -749,7 +752,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param], span: span} } -fn ty_fns(cx: ext_ctxt, name: str, ty: @ast::ty, tps: [ast::ty_param]) +fn ty_fns(cx: ext_ctxt, name: ast::ident, ty: @ast::ty, tps: [ast::ty_param]) -> [@ast::item] { let span = ty.span; @@ -759,7 +762,7 @@ fn ty_fns(cx: ext_ctxt, name: str, ty: @ast::ty, tps: [ast::ty_param]) ] } -fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: str, +fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, e_span: span, variants: [ast::variant], -s: @ast::expr, -v: @ast::expr) -> [@ast::stmt] { let ext_cx = cx; @@ -808,7 +811,7 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: str, [#ast(stmt){ $(s).emit_enum($(e_name), $(lam)) }] } -fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: str, +fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident, e_span: span, variants: [ast::variant], -d: @ast::expr) -> @ast::expr { let ext_cx = cx; @@ -852,7 +855,7 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: str, #ast{ $(d).read_enum($(e_name), $(read_lambda)) } } -fn enum_fns(cx: ext_ctxt, e_name: str, e_span: span, +fn enum_fns(cx: ext_ctxt, e_name: ast::ident, e_span: span, variants: [ast::variant], tps: [ast::ty_param]) -> [@ast::item] { [ diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 29e20212d66..e39f9745249 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -9,7 +9,7 @@ type syntax_expander_ = type syntax_expander = { expander: syntax_expander_, span: option<span>}; -type macro_def = {ident: str, ext: syntax_extension}; +type macro_def = {ident: ast::ident, ext: syntax_extension}; type macro_definer = fn@(ext_ctxt, span, ast::mac_arg, ast::mac_body) -> macro_def; type item_decorator = @@ -150,7 +150,7 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: str) -> str { alt expr.node { ast::expr_lit(l) { alt l.node { - ast::lit_str(s) { ret s; } + ast::lit_str(s) { ret *s; } _ { cx.span_fatal(l.span, error); } } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 516deb1e793..69f7f2b69cd 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -6,7 +6,7 @@ fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr { ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp}; } fn mk_str(cx: ext_ctxt, sp: span, s: str) -> @ast::expr { - let lit = ast::lit_str(s); + let lit = ast::lit_str(@s); ret mk_lit(cx, sp, lit); } fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr { diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 278321ec8bc..faf8e1a0868 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -3,13 +3,13 @@ import base::*; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { let args = get_mac_args_no_max(cx,sp,arg,1u,"concat_idents"); - let mut res: ast::ident = ""; + let mut res = ""; for args.each {|e| - res += expr_to_ident(cx, e, "expected an ident"); + res += *expr_to_ident(cx, e, "expected an ident"); } ret @{id: cx.next_id(), - node: ast::expr_path(@{span: sp, global: false, idents: [res], + node: ast::expr_path(@{span: sp, global: false, idents: [@res], rp: none, types: []}), span: sp}; } diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 6a4d937f083..ebb56fa3b58 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -21,8 +21,8 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, } } -fn make_new_str(cx: ext_ctxt, sp: codemap::span, s: str) -> @ast::expr { - ret make_new_lit(cx, sp, ast::lit_str(s)); +fn make_new_str(cx: ext_ctxt, sp: codemap::span, +s: str) -> @ast::expr { + ret make_new_lit(cx, sp, ast::lit_str(@s)); } // // Local Variables: diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 90487e27956..8bc1f7a3433 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -21,21 +21,21 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, mac_invoc(pth, args, body) { assert (vec::len(pth.idents) > 0u); let extname = pth.idents[0]; - alt exts.find(extname) { + alt exts.find(*extname) { none { cx.span_fatal(pth.span, - #fmt["macro undefined: '%s'", extname]) + #fmt["macro undefined: '%s'", *extname]) } some(item_decorator(_)) { cx.span_fatal( pth.span, - #fmt["%s can only be used as a decorator", extname]); + #fmt["%s can only be used as a decorator", *extname]); } some(normal({expander: exp, span: exp_sp})) { let expanded = exp(cx, pth.span, args, body); cx.bt_push(expanded_from({call_site: s, - callie: {name: extname, span: exp_sp}})); + callie: {name: *extname, span: exp_sp}})); //keep going, outside-in let fully_expanded = fld.fold_expr(expanded).node; cx.bt_pop(); @@ -44,7 +44,7 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, } some(macro_defining(ext)) { let named_extension = ext(cx, pth.span, args, body); - exts.insert(named_extension.ident, named_extension.ext); + exts.insert(*named_extension.ident, named_extension.ext); (ast::expr_rec([], none), s) } } @@ -74,7 +74,7 @@ fn expand_mod_items(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, ast::meta_name_value(n, _) { n } ast::meta_list(n, _) { n } }; - alt exts.find(mname) { + alt exts.find(*mname) { none | some(normal(_)) | some(macro_defining(_)) { items } diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index aceeed4b9e8..4725f5a1977 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -36,9 +36,10 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) -> @ast::expr { fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> [ast::ident] { - ret ["extfmt", "rt", ident]; + ret [@"extfmt", @"rt", ident]; } - fn make_rt_path_expr(cx: ext_ctxt, sp: span, ident: str) -> @ast::expr { + fn make_rt_path_expr(cx: ext_ctxt, sp: span, + ident: ast::ident) -> @ast::expr { let path = make_path_vec(cx, ident); ret mk_path(cx, sp, path); } @@ -57,18 +58,18 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) flag_sign_always { fstr = "flag_sign_always"; } flag_alternate { fstr = "flag_alternate"; } } - flagexprs += [make_rt_path_expr(cx, sp, fstr)]; + flagexprs += [make_rt_path_expr(cx, sp, @fstr)]; } ret mk_vec_e(cx, sp, flagexprs); } fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr { alt cnt { count_implied { - ret make_rt_path_expr(cx, sp, "count_implied"); + ret make_rt_path_expr(cx, sp, @"count_implied"); } count_is(c) { let count_lit = mk_int(cx, sp, c); - let count_is_path = make_path_vec(cx, "count_is"); + let count_is_path = make_path_vec(cx, @"count_is"); let count_is_args = [count_lit]; ret mk_call(cx, sp, count_is_path, count_is_args); } @@ -88,16 +89,16 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) ty_octal { rt_type = "ty_octal"; } _ { rt_type = "ty_default"; } } - ret make_rt_path_expr(cx, sp, rt_type); + ret make_rt_path_expr(cx, sp, @rt_type); } fn make_conv_rec(cx: ext_ctxt, sp: span, flags_expr: @ast::expr, width_expr: @ast::expr, precision_expr: @ast::expr, ty_expr: @ast::expr) -> @ast::expr { ret mk_rec_e(cx, sp, - [{ident: "flags", ex: flags_expr}, - {ident: "width", ex: width_expr}, - {ident: "precision", ex: precision_expr}, - {ident: "ty", ex: ty_expr}]); + [{ident: @"flags", ex: flags_expr}, + {ident: @"width", ex: width_expr}, + {ident: @"precision", ex: precision_expr}, + {ident: @"ty", ex: ty_expr}]); } let rt_conv_flags = make_flags(cx, sp, cnv.flags); let rt_conv_width = make_count(cx, sp, cnv.width); @@ -109,7 +110,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr]) fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: str, cnv: conv, arg: @ast::expr) -> @ast::expr { let fname = "conv_" + conv_type; - let path = make_path_vec(cx, fname); + let path = make_path_vec(cx, @fname); let cnv_expr = make_rt_conv_expr(cx, sp, cnv); let args = [cnv_expr, arg]; ret mk_call(cx, arg.span, path, args); diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 1a7ae69e79d..316ac7603fb 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -35,7 +35,7 @@ impl of qq_helper for @ast::crate { fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_crate(*self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_crate"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_crate"]) } fn get_fold_fn() -> str {"fold_crate"} } @@ -49,7 +49,7 @@ impl of qq_helper for @ast::expr { } } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_expr"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_expr"]) } fn get_fold_fn() -> str {"fold_expr"} } @@ -63,7 +63,7 @@ impl of qq_helper for @ast::ty { } } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_ty"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_ty"]) } fn get_fold_fn() -> str {"fold_ty"} } @@ -72,7 +72,7 @@ impl of qq_helper for @ast::item { fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_item(self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_item"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_item"]) } fn get_fold_fn() -> str {"fold_item"} } @@ -81,7 +81,7 @@ impl of qq_helper for @ast::stmt { fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_stmt(self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_stmt"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_stmt"]) } fn get_fold_fn() -> str {"fold_stmt"} } @@ -90,7 +90,7 @@ impl of qq_helper for @ast::pat { fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_pat(self, cx, v);} fn extract_mac() -> option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { - mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_pat"]) + mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_pat"]) } fn get_fold_fn() -> str {"fold_pat"} } @@ -146,7 +146,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, } alt (args[0].node) { ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u - {what = id[0]} + {what = *id[0]} _ {ecx.span_fatal(args[0].span, "expected an identifier");} } } @@ -230,20 +230,21 @@ fn finish<T: qq_helper> let cx = ecx; let cfg_call = {|| - mk_call_(cx, sp, mk_access(cx, sp, ["ext_cx"], "cfg"), []) + mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"], @"cfg"), []) }; let parse_sess_call = {|| - mk_call_(cx, sp, mk_access(cx, sp, ["ext_cx"], "parse_sess"), []) + mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"], @"parse_sess"), []) }; let pcall = mk_call(cx,sp, - ["syntax", "parse", "parser", - "parse_from_source_str"], + [@"syntax", @"parse", @"parser", + @"parse_from_source_str"], [node.mk_parse_fn(cx,sp), mk_str(cx,sp, fname), mk_call(cx,sp, - ["syntax","ext","qquote", "mk_file_substr"], + [@"syntax",@"ext", + @"qquote", @"mk_file_substr"], [mk_str(cx,sp, loc.file.name), mk_uint(cx,sp, loc.line), mk_uint(cx,sp, loc.col)]), @@ -255,15 +256,16 @@ fn finish<T: qq_helper> let mut rcall = pcall; if (g_len > 0u) { rcall = mk_call(cx,sp, - ["syntax", "ext", "qquote", "replace"], + [@"syntax", @"ext", @"qquote", @"replace"], [pcall, mk_vec_e(cx,sp, qcx.gather.map_to_vec {|g| mk_call(cx,sp, - ["syntax", "ext", "qquote", g.constr], + [@"syntax", @"ext", + @"qquote", @g.constr], [g.e])}), mk_path(cx,sp, - ["syntax", "ext", "qquote", - node.get_fold_fn()])]); + [@"syntax", @"ext", @"qquote", + @node.get_fold_fn()])]); } ret rcall; } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 764c484c8e3..e2d16299b22 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -1,5 +1,5 @@ import codemap::span; -import std::map::{hashmap, str_hash}; +import std::map::{hashmap, str_hash, box_str_hash}; import dvec::{dvec, extensions}; import base::*; @@ -146,7 +146,7 @@ fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { } fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders { let res: binders = - {real_binders: str_hash::<selector>(), + {real_binders: box_str_hash::<selector>(), literal_ast_matchers: dvec()}; //this oughta return binders instead, but macro args are a sequence of //expressions, rather than a single expression @@ -162,7 +162,7 @@ bindings. Most of the work is done in p_t_s, which generates the selectors. */ fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> { - let res = str_hash::<arb_depth<matchable>>(); + let res = box_str_hash::<arb_depth<matchable>>(); //need to do this first, to check vec lengths. for b.literal_ast_matchers.each {|sel| alt sel(match_expr(e)) { none { ret none; } _ { } } @@ -240,7 +240,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>, /* helper for transcribe_exprs: what vars from `b` occur in `e`? */ fn free_vars(b: bindings, e: @expr, it: fn(ident)) { - let idents: hashmap<ident, ()> = str_hash::<()>(); + let idents: hashmap<ident, ()> = box_str_hash::<()>(); fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings, idents: hashmap<ident, ()>) -> ident { if b.contains_key(i) { idents.insert(i, ()); } @@ -282,8 +282,8 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut [uint], let len = vec::len(*ms); if old_len != len { let msg = - #fmt["'%s' occurs %u times, but ", fv, len] + - #fmt["'%s' occurs %u times", old_name, + #fmt["'%s' occurs %u times, but ", *fv, len] + + #fmt["'%s' occurs %u times", *old_name, old_len]; cx.span_fatal(repeat_me.span, msg); } @@ -672,7 +672,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> base::macro_def { let args = get_mac_args_no_max(cx, sp, arg, 0u, "macro"); - let mut macro_name: option<str> = none; + let mut macro_name: option<@str> = none; let mut clauses: [@clause] = []; for args.each {|arg| alt arg.node { diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 0680194ea6b..23c6a3714c3 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -36,19 +36,20 @@ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg, get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); let { file: @{ name: filename, _ }, _ } = codemap::lookup_char_pos(cx.codemap(), sp.lo); - ret make_new_lit(cx, sp, ast::lit_str(filename)); + ret make_new_lit(cx, sp, ast::lit_str(@filename)); } fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "stringify"); - ret make_new_lit(cx, sp, ast::lit_str(pprust::expr_to_str(args[0]))); + ret make_new_lit(cx, sp, ast::lit_str(@pprust::expr_to_str(args[0]))); } fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); - ret make_new_lit(cx, sp, ast::lit_str(str::connect(cx.mod_path(), "::"))); + ret make_new_lit(cx, sp, ast::lit_str( + @str::connect(cx.mod_path().map({|x|*x}), "::"))); } fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, @@ -75,7 +76,7 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, } } - ret make_new_lit(cx, sp, ast::lit_str(result::unwrap(res))); + ret make_new_lit(cx, sp, ast::lit_str(@result::unwrap(res))); } fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, |
