Support prefix notation for vstore strings. Closes #2906.
This commit is contained in:
parent
e4de160222
commit
985b52be6d
46 changed files with 252 additions and 237 deletions
|
|
@ -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 {
|
||||
|
|
@ -154,7 +154,7 @@ impl helpers for ext_ctxt {
|
|||
let args = do vec::map(input_tys) |ty| {
|
||||
{mode: ast::expl(ast::by_ref),
|
||||
ty: ty,
|
||||
ident: @"",
|
||||
ident: @""/~,
|
||||
id: self.next_id()}
|
||||
};
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ fn is_vec_or_str(ty: @ast::ty) -> bool {
|
|||
// This may be wrong if the user has shadowed (!) str
|
||||
ast::ty_path(@{span: _, global: _, idents: ids,
|
||||
rp: none, types: _}, _)
|
||||
if ids == ~[@"str"] { true }
|
||||
if ids == ~[@"str"/~] { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
|
|
@ -529,12 +529,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
|
|||
|
||||
let ser_inputs: ~[ast::arg] =
|
||||
vec::append(~[{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);
|
||||
|
||||
|
|
@ -552,12 +552,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
|
|||
|
||||
let ser_bnds = @~[
|
||||
ast::bound_trait(cx.ty_path(span,
|
||||
~[@"std", @"serialization",
|
||||
@"serializer"],
|
||||
~[@"std"/~, @"serialization"/~,
|
||||
@"serializer"/~],
|
||||
~[]))];
|
||||
|
||||
let ser_tps: ~[ast::ty_param] =
|
||||
vec::append(~[{ident: @"__S",
|
||||
vec::append(~[{ident: @"__S"/~,
|
||||
id: cx.next_id(),
|
||||
bounds: ser_bnds}],
|
||||
vec::map(tps, |tp| cx.clone_ty_param(tp)));
|
||||
|
|
@ -749,8 +749,8 @@ fn mk_deser_fn(cx: ext_ctxt, span: span,
|
|||
|
||||
let deser_inputs: ~[ast::arg] =
|
||||
vec::append(~[{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);
|
||||
|
||||
|
|
@ -768,11 +768,11 @@ fn mk_deser_fn(cx: ext_ctxt, span: span,
|
|||
let deser_bnds = @~[
|
||||
ast::bound_trait(cx.ty_path(
|
||||
span,
|
||||
~[@"std", @"serialization", @"deserializer"],
|
||||
~[@"std"/~, @"serialization"/~, @"deserializer"/~],
|
||||
~[]))];
|
||||
|
||||
let deser_tps: ~[ast::ty_param] =
|
||||
vec::append(~[{ident: @"__D",
|
||||
vec::append(~[{ident: @"__D"/~,
|
||||
id: cx.next_id(),
|
||||
bounds: deser_bnds}],
|
||||
vec::map(tps, |tp| {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ 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: ast::ident) -> @ast::expr {
|
||||
|
|
@ -50,7 +50,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
|||
|
||||
fn make_rt_conv_expr(cx: ext_ctxt, sp: span, cnv: conv) -> @ast::expr {
|
||||
fn make_flags(cx: ext_ctxt, sp: span, flags: ~[flag]) -> @ast::expr {
|
||||
let mut tmp_expr = make_rt_path_expr(cx, sp, @"flag_none");
|
||||
let mut tmp_expr = make_rt_path_expr(cx, sp, @"flag_none"/~);
|
||||
for flags.each |f| {
|
||||
let fstr = alt f {
|
||||
flag_left_justify { "flag_left_justify" }
|
||||
|
|
@ -67,11 +67,11 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
|||
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);
|
||||
}
|
||||
|
|
@ -97,10 +97,10 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
|||
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);
|
||||
|
|
@ -275,7 +275,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
|
|||
}
|
||||
|
||||
let arg_vec = mk_fixed_vec_e(cx, fmt_sp, piece_exprs);
|
||||
ret mk_call(cx, fmt_sp, ~[@"str", @"concat"], ~[arg_vec]);
|
||||
ret mk_call(cx, fmt_sp, ~[@"str"/~, @"concat"/~], ~[arg_vec]);
|
||||
}
|
||||
//
|
||||
// Local Variables:
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ impl proto_parser for parser {
|
|||
};
|
||||
self.bump();
|
||||
let dir = alt dir {
|
||||
@"send" { send }
|
||||
@"recv" { recv }
|
||||
@"send"/~ { send }
|
||||
@"recv"/~ { recv }
|
||||
_ { fail }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl methods for message {
|
|||
);
|
||||
|
||||
let args_ast = vec::append(
|
||||
~[cx.arg_mode(@"pipe",
|
||||
~[cx.arg_mode(@"pipe"/~,
|
||||
cx.ty_path(path(this.data_name())
|
||||
.add_tys(cx.ty_vars(this.ty_params))),
|
||||
ast::by_copy)],
|
||||
|
|
@ -92,7 +92,7 @@ impl methods for message {
|
|||
body += #fmt("let message = %s::%s(%s);\n",
|
||||
*this.proto.name,
|
||||
*self.name(),
|
||||
str::connect(vec::append_one(arg_names, @"s")
|
||||
str::connect(vec::append_one(arg_names, @"s"/~)
|
||||
.map(|x| *x),
|
||||
", "));
|
||||
body += #fmt("pipes::send(pipe, message);\n");
|
||||
|
|
@ -158,8 +158,8 @@ impl methods for state {
|
|||
let next_name = next.data_name();
|
||||
|
||||
let dir = alt this.dir {
|
||||
send { @"server" }
|
||||
recv { @"client" }
|
||||
send { @"server"/~ }
|
||||
recv { @"client"/~ }
|
||||
};
|
||||
|
||||
let v = cx.variant(name,
|
||||
|
|
@ -190,7 +190,7 @@ impl methods for state {
|
|||
cx.item_ty_poly(
|
||||
self.data_name(),
|
||||
cx.ty_path(
|
||||
(@"pipes" + @(dir.to_str() + "_packet"))
|
||||
(@"pipes"/~ + @(dir.to_str() + "_packet"/~))
|
||||
.add_ty(cx.ty_path(
|
||||
(self.proto.name + self.data_name())
|
||||
.add_tys(cx.ty_vars(self.ty_params))))),
|
||||
|
|
@ -281,10 +281,10 @@ impl methods for protocol {
|
|||
}
|
||||
|
||||
vec::push(items,
|
||||
cx.item_mod(@"client",
|
||||
cx.item_mod(@"client"/~,
|
||||
client_states));
|
||||
vec::push(items,
|
||||
cx.item_mod(@"server",
|
||||
cx.item_mod(@"server"/~,
|
||||
server_states));
|
||||
|
||||
cx.item_mod(self.name, items)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ 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 +50,8 @@ 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 +65,8 @@ 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 +75,8 @@ 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 +85,8 @@ 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 +95,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"}
|
||||
}
|
||||
|
|
@ -228,19 +233,19 @@ fn finish<T: qq_helper>
|
|||
let cx = ecx;
|
||||
|
||||
let cfg_call = || mk_call_(
|
||||
cx, sp, mk_access(cx, sp, ~[@"ext_cx"], @"cfg"), ~[]);
|
||||
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"), ~[]);
|
||||
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)]),
|
||||
|
|
@ -252,15 +257,15 @@ 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_uniq_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",
|
||||
~[@"syntax"/~, @"ext"/~, @"qquote"/~,
|
||||
@node.get_fold_fn()])]);
|
||||
}
|
||||
ret rcall;
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
|
|||
|
||||
let argument_gram = ~[
|
||||
ms(mtc_rep(~[
|
||||
ms(mtc_bb(@"lhs",@"mtcs", 0u)),
|
||||
ms(mtc_bb(@"lhs"/~,@"mtcs"/~, 0u)),
|
||||
ms(mtc_tok(FAT_ARROW)),
|
||||
ms(mtc_bb(@"rhs",@"tt", 1u)),
|
||||
ms(mtc_bb(@"rhs"/~,@"tt"/~, 1u)),
|
||||
], some(SEMI), false))];
|
||||
|
||||
let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic,
|
||||
|
|
@ -31,11 +31,11 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
|
|||
failure(sp, msg) { cx.span_fatal(sp, msg); }
|
||||
};
|
||||
|
||||
let lhses = alt arguments.get(@"lhs") {
|
||||
let lhses = alt arguments.get(@"lhs"/~) {
|
||||
@seq(s, sp) { s }
|
||||
_ { cx.span_bug(sp, "wrong-structured lhs") }
|
||||
};
|
||||
let rhses = alt arguments.get(@"rhs") {
|
||||
let rhses = alt arguments.get(@"rhs"/~) {
|
||||
@seq(s, sp) { s }
|
||||
_ { cx.span_bug(sp, "wrong-structured rhs") }
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue