Rip out old code that still structured method calls as a
expr_call(expr_field(...)) rather than an expr_method_call. There is probably more such code in trans that should be removed.
This commit is contained in:
parent
d96bbb907e
commit
e11d13f3de
7 changed files with 114 additions and 160 deletions
|
@ -1321,13 +1321,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||||
sugar: ast::CallSugar) {
|
sugar: ast::CallSugar) {
|
||||||
// Index expressions need to be handled separately, to inform them
|
// Index expressions need to be handled separately, to inform them
|
||||||
// that they appear in call position.
|
// that they appear in call position.
|
||||||
match f.node {
|
let mut bot = check_expr(fcx, f);
|
||||||
ast::expr_field(ref base, ref field, ref tys) => {
|
|
||||||
check_field(fcx, f, true, *base, *field, *tys)
|
|
||||||
}
|
|
||||||
_ => check_expr(fcx, f)
|
|
||||||
};
|
|
||||||
|
|
||||||
check_call_or_method(fcx,
|
check_call_or_method(fcx,
|
||||||
sp,
|
sp,
|
||||||
call_expr_id,
|
call_expr_id,
|
||||||
|
@ -1689,7 +1683,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||||
// Check field access expressions
|
// Check field access expressions
|
||||||
fn check_field(fcx: @mut FnCtxt,
|
fn check_field(fcx: @mut FnCtxt,
|
||||||
expr: @ast::expr,
|
expr: @ast::expr,
|
||||||
is_callee: bool,
|
|
||||||
base: @ast::expr,
|
base: @ast::expr,
|
||||||
field: ast::ident,
|
field: ast::ident,
|
||||||
tys: &[@ast::Ty]) {
|
tys: &[@ast::Ty]) {
|
||||||
|
@ -1723,7 +1716,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||||
}
|
}
|
||||||
|
|
||||||
let tps = vec::map(tys, |ty| fcx.to_ty(*ty));
|
let tps = vec::map(tys, |ty| fcx.to_ty(*ty));
|
||||||
|
|
||||||
match method::lookup(fcx,
|
match method::lookup(fcx,
|
||||||
expr,
|
expr,
|
||||||
base,
|
base,
|
||||||
|
@ -1734,34 +1726,30 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||||
DontDerefArgs,
|
DontDerefArgs,
|
||||||
CheckTraitsAndInherentMethods,
|
CheckTraitsAndInherentMethods,
|
||||||
AutoderefReceiver) {
|
AutoderefReceiver) {
|
||||||
Some(ref entry) => {
|
Some(_) => {
|
||||||
let method_map = fcx.ccx.method_map;
|
fcx.type_error_message(
|
||||||
method_map.insert(expr.id, (*entry));
|
expr.span,
|
||||||
|
|actual| {
|
||||||
// If we have resolved to a method but this is not in
|
fmt!("attempted to take value of method `%s` on type `%s` \
|
||||||
// a callee position, error
|
(try writing an anonymous function)",
|
||||||
if !is_callee {
|
*tcx.sess.str_of(field), actual)
|
||||||
tcx.sess.span_err(
|
},
|
||||||
expr.span,
|
expr_t, None);
|
||||||
~"attempted to take value of method \
|
|
||||||
(try writing an anonymous function)");
|
|
||||||
// Add error type for the result
|
|
||||||
fcx.write_error(expr.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
fcx.type_error_message(expr.span,
|
fcx.type_error_message(
|
||||||
|actual| {
|
expr.span,
|
||||||
fmt!("attempted access of field `%s` on type `%s`, but \
|
|actual| {
|
||||||
no field or method with that name was found",
|
fmt!("attempted access of field `%s` on type `%s`, \
|
||||||
*tcx.sess.str_of(field), actual)
|
but no field with that name was found",
|
||||||
},
|
*tcx.sess.str_of(field), actual)
|
||||||
expr_t, None);
|
},
|
||||||
// Add error type for the result
|
expr_t, None);
|
||||||
fcx.write_error(expr.id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fcx.write_error(expr.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
|
fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
|
||||||
|
@ -2750,15 +2738,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::expr_field(base, field, ref tys) => {
|
ast::expr_field(base, field, ref tys) => {
|
||||||
check_field(fcx, expr, false, base, field, * tys);
|
check_field(fcx, expr, base, field, *tys);
|
||||||
let base_t = fcx.expr_ty(base);
|
|
||||||
if ty::type_is_error(base_t) {
|
|
||||||
fcx.write_error(id);
|
|
||||||
}
|
|
||||||
else if ty::type_is_bot(base_t) {
|
|
||||||
fcx.write_bot(id);
|
|
||||||
}
|
|
||||||
// Otherwise, type already got written
|
|
||||||
}
|
}
|
||||||
ast::expr_index(base, idx) => {
|
ast::expr_index(base, idx) => {
|
||||||
check_expr(fcx, base);
|
check_expr(fcx, base);
|
||||||
|
|
|
@ -416,6 +416,16 @@ priv impl @ext_ctxt {
|
||||||
self.expr(span, ast::expr_call(expr, args, ast::NoSugar))
|
self.expr(span, ast::expr_call(expr, args, ast::NoSugar))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn expr_method_call(
|
||||||
|
&self,
|
||||||
|
span: span,
|
||||||
|
expr: @ast::expr,
|
||||||
|
ident: ast::ident,
|
||||||
|
+args: ~[@ast::expr]
|
||||||
|
) -> @ast::expr {
|
||||||
|
self.expr(span, ast::expr_method_call(expr, ident, ~[], args, ast::NoSugar))
|
||||||
|
}
|
||||||
|
|
||||||
fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr {
|
fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr {
|
||||||
self.lambda(self.expr_blk(expr))
|
self.lambda(self.expr_blk(expr))
|
||||||
}
|
}
|
||||||
|
@ -712,30 +722,24 @@ fn mk_struct_ser_impl(
|
||||||
let fields = do mk_struct_fields(fields).mapi |idx, field| {
|
let fields = do mk_struct_fields(fields).mapi |idx, field| {
|
||||||
// ast for `|| self.$(name).encode(__s)`
|
// ast for `|| self.$(name).encode(__s)`
|
||||||
let expr_lambda = cx.lambda_expr(
|
let expr_lambda = cx.lambda_expr(
|
||||||
cx.expr_call(
|
cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_field(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_var(span, ~"self"),
|
||||||
span,
|
field.ident
|
||||||
cx.expr_var(span, ~"self"),
|
|
||||||
field.ident
|
|
||||||
),
|
|
||||||
cx.ident_of(~"encode")
|
|
||||||
),
|
),
|
||||||
|
cx.ident_of(~"encode"),
|
||||||
~[cx.expr_var(span, ~"__s")]
|
~[cx.expr_var(span, ~"__s")]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// ast for `__s.emit_field($(name), $(idx), $(expr_lambda))`
|
// ast for `__s.emit_field($(name), $(idx), $(expr_lambda))`
|
||||||
cx.stmt(
|
cx.stmt(
|
||||||
cx.expr_call(
|
cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_var(span, ~"__s"),
|
||||||
span,
|
cx.ident_of(~"emit_field"),
|
||||||
cx.expr_var(span, ~"__s"),
|
|
||||||
cx.ident_of(~"emit_field")
|
|
||||||
),
|
|
||||||
~[
|
~[
|
||||||
cx.lit_str(span, @cx.str_of(field.ident)),
|
cx.lit_str(span, @cx.str_of(field.ident)),
|
||||||
cx.lit_uint(span, idx),
|
cx.lit_uint(span, idx),
|
||||||
|
@ -746,13 +750,10 @@ fn mk_struct_ser_impl(
|
||||||
};
|
};
|
||||||
|
|
||||||
// ast for `__s.emit_struct($(name), || $(fields))`
|
// ast for `__s.emit_struct($(name), || $(fields))`
|
||||||
let ser_body = cx.expr_call(
|
let ser_body = cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_var(span, ~"__s"),
|
||||||
span,
|
cx.ident_of(~"emit_struct"),
|
||||||
cx.expr_var(span, ~"__s"),
|
|
||||||
cx.ident_of(~"emit_struct")
|
|
||||||
),
|
|
||||||
~[
|
~[
|
||||||
cx.lit_str(span, @cx.str_of(ident)),
|
cx.lit_str(span, @cx.str_of(ident)),
|
||||||
cx.lit_uint(span, vec::len(fields)),
|
cx.lit_uint(span, vec::len(fields)),
|
||||||
|
@ -788,13 +789,10 @@ fn mk_struct_deser_impl(
|
||||||
);
|
);
|
||||||
|
|
||||||
// ast for `__d.read_field($(name), $(idx), $(expr_lambda))`
|
// ast for `__d.read_field($(name), $(idx), $(expr_lambda))`
|
||||||
let expr: @ast::expr = cx.expr_call(
|
let expr: @ast::expr = cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_var(span, ~"__d"),
|
||||||
span,
|
cx.ident_of(~"read_field"),
|
||||||
cx.expr_var(span, ~"__d"),
|
|
||||||
cx.ident_of(~"read_field")
|
|
||||||
),
|
|
||||||
~[
|
~[
|
||||||
cx.lit_str(span, @cx.str_of(field.ident)),
|
cx.lit_str(span, @cx.str_of(field.ident)),
|
||||||
cx.lit_uint(span, idx),
|
cx.lit_uint(span, idx),
|
||||||
|
@ -813,13 +811,10 @@ fn mk_struct_deser_impl(
|
||||||
};
|
};
|
||||||
|
|
||||||
// ast for `read_struct($(name), || $(fields))`
|
// ast for `read_struct($(name), || $(fields))`
|
||||||
let body = cx.expr_call(
|
let body = cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_var(span, ~"__d"),
|
||||||
span,
|
cx.ident_of(~"read_struct"),
|
||||||
cx.expr_var(span, ~"__d"),
|
|
||||||
cx.ident_of(~"read_struct")
|
|
||||||
),
|
|
||||||
~[
|
~[
|
||||||
cx.lit_str(span, @cx.str_of(ident)),
|
cx.lit_str(span, @cx.str_of(ident)),
|
||||||
cx.lit_uint(span, vec::len(fields)),
|
cx.lit_uint(span, vec::len(fields)),
|
||||||
|
@ -943,13 +938,10 @@ fn ser_variant(
|
||||||
|
|
||||||
// ast for `|| $(v).encode(__s)`
|
// ast for `|| $(v).encode(__s)`
|
||||||
let expr_encode = cx.lambda_expr(
|
let expr_encode = cx.lambda_expr(
|
||||||
cx.expr_call(
|
cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_path(span, ~[names[a_idx]]),
|
||||||
span,
|
cx.ident_of(~"encode"),
|
||||||
cx.expr_path(span, ~[names[a_idx]]),
|
|
||||||
cx.ident_of(~"encode")
|
|
||||||
),
|
|
||||||
~[cx.expr_var(span, ~"__s")]
|
~[cx.expr_var(span, ~"__s")]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -965,13 +957,10 @@ fn ser_variant(
|
||||||
};
|
};
|
||||||
|
|
||||||
// ast for `__s.emit_enum_variant($(name), $(idx), $(sz), $(lambda))`
|
// ast for `__s.emit_enum_variant($(name), $(idx), $(sz), $(lambda))`
|
||||||
let body = cx.expr_call(
|
let body = cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_var(span, ~"__s"),
|
||||||
span,
|
cx.ident_of(~"emit_enum_variant"),
|
||||||
cx.expr_var(span, ~"__s"),
|
|
||||||
cx.ident_of(~"emit_enum_variant")
|
|
||||||
),
|
|
||||||
~[
|
~[
|
||||||
cx.lit_str(span, @cx.str_of(v_name)),
|
cx.lit_str(span, @cx.str_of(v_name)),
|
||||||
cx.lit_uint(span, v_idx),
|
cx.lit_uint(span, v_idx),
|
||||||
|
@ -1019,13 +1008,10 @@ fn mk_enum_ser_body(
|
||||||
);
|
);
|
||||||
|
|
||||||
// ast for `__s.emit_enum($(name), || $(match_expr))`
|
// ast for `__s.emit_enum($(name), || $(match_expr))`
|
||||||
cx.expr_call(
|
cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_var(span, ~"__s"),
|
||||||
span,
|
cx.ident_of(~"emit_enum"),
|
||||||
cx.expr_var(span, ~"__s"),
|
|
||||||
cx.ident_of(~"emit_enum")
|
|
||||||
),
|
|
||||||
~[
|
~[
|
||||||
cx.lit_str(span, @cx.str_of(name)),
|
cx.lit_str(span, @cx.str_of(name)),
|
||||||
cx.lambda_expr(match_expr),
|
cx.lambda_expr(match_expr),
|
||||||
|
@ -1055,13 +1041,10 @@ fn mk_enum_deser_variant_nary(
|
||||||
);
|
);
|
||||||
|
|
||||||
// ast for `__d.read_enum_variant_arg($(a_idx), $(expr_lambda))`
|
// ast for `__d.read_enum_variant_arg($(a_idx), $(expr_lambda))`
|
||||||
cx.expr_call(
|
cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
cx.expr_field(
|
cx.expr_var(span, ~"__d"),
|
||||||
span,
|
cx.ident_of(~"read_enum_variant_arg"),
|
||||||
cx.expr_var(span, ~"__d"),
|
|
||||||
cx.ident_of(~"read_enum_variant_arg")
|
|
||||||
),
|
|
||||||
~[cx.lit_uint(span, idx), expr_lambda]
|
~[cx.lit_uint(span, idx), expr_lambda]
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
@ -1171,25 +1154,19 @@ fn mk_enum_deser_body(
|
||||||
|
|
||||||
// ast for `__d.read_enum_variant($(expr_lambda))`
|
// ast for `__d.read_enum_variant($(expr_lambda))`
|
||||||
let expr_lambda = ext_cx.lambda_expr(
|
let expr_lambda = ext_cx.lambda_expr(
|
||||||
ext_cx.expr_call(
|
ext_cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
ext_cx.expr_field(
|
ext_cx.expr_var(span, ~"__d"),
|
||||||
span,
|
ext_cx.ident_of(~"read_enum_variant"),
|
||||||
ext_cx.expr_var(span, ~"__d"),
|
|
||||||
ext_cx.ident_of(~"read_enum_variant")
|
|
||||||
),
|
|
||||||
~[expr_lambda]
|
~[expr_lambda]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// ast for `__d.read_enum($(e_name), $(expr_lambda))`
|
// ast for `__d.read_enum($(e_name), $(expr_lambda))`
|
||||||
ext_cx.expr_call(
|
ext_cx.expr_method_call(
|
||||||
span,
|
span,
|
||||||
ext_cx.expr_field(
|
ext_cx.expr_var(span, ~"__d"),
|
||||||
span,
|
ext_cx.ident_of(~"read_enum"),
|
||||||
ext_cx.expr_var(span, ~"__d"),
|
|
||||||
ext_cx.ident_of(~"read_enum")
|
|
||||||
),
|
|
||||||
~[
|
~[
|
||||||
ext_cx.lit_str(span, @ext_cx.str_of(name)),
|
ext_cx.lit_str(span, @ext_cx.str_of(name)),
|
||||||
expr_lambda
|
expr_lambda
|
||||||
|
|
|
@ -111,6 +111,13 @@ pub fn mk_addr_of(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
|
||||||
pub fn mk_mut_addr_of(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
|
pub fn mk_mut_addr_of(cx: @ext_ctxt, sp: span, e: @ast::expr) -> @ast::expr {
|
||||||
return mk_expr(cx, sp, ast::expr_addr_of(ast::m_mutbl, e));
|
return mk_expr(cx, sp, ast::expr_addr_of(ast::m_mutbl, e));
|
||||||
}
|
}
|
||||||
|
pub fn mk_method_call(cx: @ext_ctxt,
|
||||||
|
sp: span,
|
||||||
|
rcvr_expr: @ast::expr,
|
||||||
|
method_ident: ast::ident,
|
||||||
|
+args: ~[@ast::expr]) -> @ast::expr {
|
||||||
|
mk_expr(cx, sp, ast::expr_method_call(rcvr_expr, method_ident, ~[], args, ast::NoSugar))
|
||||||
|
}
|
||||||
pub fn mk_call_(cx: @ext_ctxt, sp: span, fn_expr: @ast::expr,
|
pub fn mk_call_(cx: @ext_ctxt, sp: span, fn_expr: @ast::expr,
|
||||||
+args: ~[@ast::expr]) -> @ast::expr {
|
+args: ~[@ast::expr]) -> @ast::expr {
|
||||||
mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar))
|
mk_expr(cx, sp, ast::expr_call(fn_expr, args, ast::NoSugar))
|
||||||
|
|
|
@ -120,8 +120,9 @@ fn call_substructure_clone_method(cx: @ext_ctxt,
|
||||||
-> @expr {
|
-> @expr {
|
||||||
// Call the substructure method.
|
// Call the substructure method.
|
||||||
let clone_ident = cx.ident_of(~"clone");
|
let clone_ident = cx.ident_of(~"clone");
|
||||||
let self_method = build::mk_access_(cx, span, self_field, clone_ident);
|
build::mk_method_call(cx, span,
|
||||||
build::mk_call_(cx, span, self_method, ~[])
|
self_field, clone_ident,
|
||||||
|
~[])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expand_deriving_clone_struct_def(cx: @ext_ctxt,
|
fn expand_deriving_clone_struct_def(cx: @ext_ctxt,
|
||||||
|
|
|
@ -147,11 +147,9 @@ fn call_substructure_eq_method(cx: @ext_ctxt,
|
||||||
junction: Junction,
|
junction: Junction,
|
||||||
chain_expr: &mut Option<@expr>) {
|
chain_expr: &mut Option<@expr>) {
|
||||||
// Call the substructure method.
|
// Call the substructure method.
|
||||||
let self_method = build::mk_access_(cx, span, self_field, method_ident);
|
let self_call = build::mk_method_call(cx, span,
|
||||||
let self_call = build::mk_call_(cx,
|
self_field, method_ident,
|
||||||
span,
|
~[ other_field_ref ]);
|
||||||
self_method,
|
|
||||||
~[ other_field_ref ]);
|
|
||||||
|
|
||||||
// Connect to the outer expression if necessary.
|
// Connect to the outer expression if necessary.
|
||||||
*chain_expr = match *chain_expr {
|
*chain_expr = match *chain_expr {
|
||||||
|
|
|
@ -125,14 +125,11 @@ fn call_substructure_iter_bytes_method(cx: @ext_ctxt,
|
||||||
|
|
||||||
// Call the substructure method.
|
// Call the substructure method.
|
||||||
let iter_bytes_ident = cx.ident_of(~"iter_bytes");
|
let iter_bytes_ident = cx.ident_of(~"iter_bytes");
|
||||||
let self_method = build::mk_access_(cx,
|
let self_call = build::mk_method_call(cx,
|
||||||
span,
|
span,
|
||||||
self_field,
|
self_field,
|
||||||
iter_bytes_ident);
|
iter_bytes_ident,
|
||||||
let self_call = build::mk_call_(cx,
|
~[ lsb0_expr, f_expr ]);
|
||||||
span,
|
|
||||||
self_method,
|
|
||||||
~[ lsb0_expr, f_expr ]);
|
|
||||||
|
|
||||||
// Create a statement out of this expression.
|
// Create a statement out of this expression.
|
||||||
build::mk_stmt(cx, span, self_call)
|
build::mk_stmt(cx, span, self_call)
|
||||||
|
|
|
@ -270,11 +270,11 @@ fn id_ext(cx: @ext_ctxt, +str: ~str) -> ast::ident {
|
||||||
|
|
||||||
// Lift an ident to the expr that evaluates to that ident.
|
// Lift an ident to the expr that evaluates to that ident.
|
||||||
fn mk_ident(cx: @ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr {
|
fn mk_ident(cx: @ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr {
|
||||||
let e_meth = build::mk_access(cx, sp,
|
|
||||||
ids_ext(cx, ~[~"ext_cx"]),
|
|
||||||
id_ext(cx, ~"ident_of"));
|
|
||||||
let e_str = build::mk_uniq_str(cx, sp, cx.str_of(ident));
|
let e_str = build::mk_uniq_str(cx, sp, cx.str_of(ident));
|
||||||
build::mk_call_(cx, sp, e_meth, ~[e_str])
|
build::mk_method_call(cx, sp,
|
||||||
|
build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
|
||||||
|
id_ext(cx, ~"ident_of"),
|
||||||
|
~[e_str])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_bytepos(cx: @ext_ctxt, sp: span, bpos: BytePos) -> @ast::expr {
|
fn mk_bytepos(cx: @ext_ctxt, sp: span, bpos: BytePos) -> @ast::expr {
|
||||||
|
@ -462,11 +462,10 @@ fn mk_tt(cx: @ext_ctxt, sp: span, tt: &ast::token_tree)
|
||||||
ids_ext(cx, ~[~"tt_tok"]),
|
ids_ext(cx, ~[~"tt_tok"]),
|
||||||
~[e_sp, mk_token(cx, sp, *tok)]);
|
~[e_sp, mk_token(cx, sp, *tok)]);
|
||||||
let e_push =
|
let e_push =
|
||||||
build::mk_call_(cx, sp,
|
build::mk_method_call(cx, sp,
|
||||||
build::mk_access(cx, sp,
|
build::mk_path(cx, sp, ids_ext(cx, ~[~"tt"])),
|
||||||
ids_ext(cx, ~[~"tt"]),
|
id_ext(cx, ~"push"),
|
||||||
id_ext(cx, ~"push")),
|
~[e_tok]);
|
||||||
~[e_tok]);
|
|
||||||
~[build::mk_stmt(cx, sp, e_push)]
|
~[build::mk_stmt(cx, sp, e_push)]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -479,21 +478,17 @@ fn mk_tt(cx: @ext_ctxt, sp: span, tt: &ast::token_tree)
|
||||||
// tt.push_all_move($ident.to_tokens(ext_cx))
|
// tt.push_all_move($ident.to_tokens(ext_cx))
|
||||||
|
|
||||||
let e_to_toks =
|
let e_to_toks =
|
||||||
build::mk_call_(cx, sp,
|
build::mk_method_call(cx, sp,
|
||||||
build::mk_access
|
build::mk_path(cx, sp, ~[ident]),
|
||||||
(cx, sp,
|
id_ext(cx, ~"to_tokens"),
|
||||||
~[ident],
|
~[build::mk_path(cx, sp,
|
||||||
id_ext(cx, ~"to_tokens")),
|
ids_ext(cx, ~[~"ext_cx"]))]);
|
||||||
~[build::mk_path(cx, sp,
|
|
||||||
ids_ext(cx, ~[~"ext_cx"]))]);
|
|
||||||
|
|
||||||
let e_push =
|
let e_push =
|
||||||
build::mk_call_(cx, sp,
|
build::mk_method_call(cx, sp,
|
||||||
build::mk_access
|
build::mk_path(cx, sp, ids_ext(cx, ~[~"tt"])),
|
||||||
(cx, sp,
|
id_ext(cx, ~"push_all_move"),
|
||||||
ids_ext(cx, ~[~"tt"]),
|
~[e_to_toks]);
|
||||||
id_ext(cx, ~"push_all_move")),
|
|
||||||
~[e_to_toks]);
|
|
||||||
|
|
||||||
~[build::mk_stmt(cx, sp, e_push)]
|
~[build::mk_stmt(cx, sp, e_push)]
|
||||||
}
|
}
|
||||||
|
@ -562,11 +557,10 @@ fn expand_tts(cx: @ext_ctxt,
|
||||||
// of quotes, for example) but at this point it seems not likely to be
|
// of quotes, for example) but at this point it seems not likely to be
|
||||||
// worth the hassle.
|
// worth the hassle.
|
||||||
|
|
||||||
let e_sp = build::mk_call_(cx, sp,
|
let e_sp = build::mk_method_call(cx, sp,
|
||||||
build::mk_access(cx, sp,
|
build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
|
||||||
ids_ext(cx, ~[~"ext_cx"]),
|
id_ext(cx, ~"call_site"),
|
||||||
id_ext(cx, ~"call_site")),
|
~[]);
|
||||||
~[]);
|
|
||||||
|
|
||||||
let stmt_let_sp = build::mk_local(cx, sp, false,
|
let stmt_let_sp = build::mk_local(cx, sp, false,
|
||||||
id_ext(cx, ~"sp"),
|
id_ext(cx, ~"sp"),
|
||||||
|
@ -590,13 +584,13 @@ fn expand_parse_call(cx: @ext_ctxt,
|
||||||
tts: &[ast::token_tree]) -> @ast::expr {
|
tts: &[ast::token_tree]) -> @ast::expr {
|
||||||
let tts_expr = expand_tts(cx, sp, tts);
|
let tts_expr = expand_tts(cx, sp, tts);
|
||||||
|
|
||||||
let cfg_call = || build::mk_call_(
|
let cfg_call = || build::mk_method_call(
|
||||||
cx, sp, build::mk_access(cx, sp, ids_ext(cx, ~[~"ext_cx"]),
|
cx, sp, build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
|
||||||
id_ext(cx, ~"cfg")), ~[]);
|
id_ext(cx, ~"cfg"), ~[]);
|
||||||
|
|
||||||
let parse_sess_call = || build::mk_call_(
|
let parse_sess_call = || build::mk_method_call(
|
||||||
cx, sp, build::mk_access(cx, sp, ids_ext(cx, ~[~"ext_cx"]),
|
cx, sp, build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
|
||||||
id_ext(cx, ~"parse_sess")), ~[]);
|
id_ext(cx, ~"parse_sess"), ~[]);
|
||||||
|
|
||||||
let new_parser_call =
|
let new_parser_call =
|
||||||
build::mk_call_global(cx, sp,
|
build::mk_call_global(cx, sp,
|
||||||
|
@ -609,9 +603,9 @@ fn expand_parse_call(cx: @ext_ctxt,
|
||||||
cfg_call(),
|
cfg_call(),
|
||||||
tts_expr]);
|
tts_expr]);
|
||||||
|
|
||||||
build::mk_call_(cx, sp,
|
build::mk_method_call(cx, sp,
|
||||||
build::mk_access_(cx, sp, new_parser_call,
|
new_parser_call,
|
||||||
id_ext(cx, parse_method)),
|
id_ext(cx, parse_method),
|
||||||
arg_exprs)
|
arg_exprs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue