ast::ExprAssignOp(_, _, dest, _) => {
this.check_assignment(dest);
}
- ast::ExprCall(f, ref args, _) => {
+ ast::ExprCall(f, ref args) => {
this.check_call(expr, Some(f), f.id, f.span, *args);
}
- ast::ExprMethodCall(callee_id, _, _, ref args, _) => {
+ ast::ExprMethodCall(callee_id, _, _, ref args) => {
this.check_call(expr, None, callee_id, expr.span, *args);
}
ast::ExprIndex(callee_id, _, rval) |
self.straightline(expr, pred, *elems)
}
- ast::ExprCall(func, ref args, _) => {
+ ast::ExprCall(func, ref args) => {
self.call(expr, pred, func, *args)
}
- ast::ExprMethodCall(_, _, _, ref args, _) => {
+ ast::ExprMethodCall(_, _, _, ref args) => {
self.call(expr, pred, args[0], args.slice_from(1))
}
}
}
}
- ExprCall(callee, _, NoSugar) => {
+ ExprCall(callee, _) => {
let def_map = def_map.borrow();
match def_map.get().find(&callee.id) {
Some(&DefStruct(..)) => {} // OK.
self.walk_opt_expr(with_expr, in_out, loop_scopes);
}
- ast::ExprCall(f, ref args, _) => {
+ ast::ExprCall(f, ref args) => {
self.walk_expr(f, in_out, loop_scopes);
self.walk_call(f.id, expr.id, *args, in_out, loop_scopes);
}
- ast::ExprMethodCall(callee_id, _, _, ref args, _) => {
+ ast::ExprMethodCall(callee_id, _, _, ref args) => {
self.walk_call(callee_id, expr.id, *args, in_out, loop_scopes);
}
fn visit_expr(&mut self, expr: &ast::Expr, _:()) {
match expr.node {
- ast::ExprMethodCall(callee_id, _, _, _, _) => {
+ ast::ExprMethodCall(callee_id, _, _, _) => {
let base_type = ty::node_id_to_type(self.tcx, callee_id);
debug!("effect: method call case, base type is {}",
ppaux::ty_to_str(self.tcx, base_type));
"invocation of unsafe method")
}
}
- ast::ExprCall(base, _, _) => {
+ ast::ExprCall(base, _) => {
let base_type = ty::node_id_to_type(self.tcx, base.id);
debug!("effect: call case, base type is {}",
ppaux::ty_to_str(self.tcx, base_type));
})
}
- ExprCall(f, ref args, _) => {
+ ExprCall(f, ref args) => {
// calling a fn with bot return type means that the fn
// will fail, and hence the successors can be ignored
let t_ret = ty::ty_fn_ret(ty::expr_ty(self.tcx, f));
self.propagate_through_expr(f, succ)
}
- ExprMethodCall(callee_id, _, _, ref args, _) => {
+ ExprMethodCall(callee_id, _, _, ref args) => {
// calling a method with bot return type means that the method
// will fail, and hence the successors can be ignored
let t_ret = ty::ty_fn_ret(ty::node_id_to_type(self.tcx, callee_id));
}
}
- ExprCall(callee, ref args, _) => { // callee(args)
+ ExprCall(callee, ref args) => { // callee(args)
// Figure out whether the called function is consumed.
let mode = match ty::get(ty::expr_ty(self.tcx, callee)).sty {
ty::ty_closure(ref cty) => {
self.use_fn_args(callee.id, *args);
}
- ExprMethodCall(callee_id, _, _, ref args, _) => { // callee.m(args)
+ ExprMethodCall(callee_id, _, _, ref args) => { // callee.m(args)
self.use_fn_args(callee_id, *args);
}
_ => {}
}
}
- ast::ExprMethodCall(_, ident, _, ref args, _) => {
+ ast::ExprMethodCall(_, ident, _, ref args) => {
// see above
let t = ty::type_autoderef(ty::expr_ty(self.tcx, args[0]));
match ty::get(t).sty {
let traits = self.search_for_traits_containing_method(ident);
self.trait_map.insert(expr.id, @RefCell::new(traits));
}
- ExprMethodCall(_, ident, _, _, _) => {
+ ExprMethodCall(_, ident, _, _) => {
debug!("(recording candidate traits for expr) recording \
traits for {}",
expr.id);
}
}
}
- ast::ExprCall(callee, ref args, _) => {
+ ast::ExprCall(callee, ref args) => {
let tcx = cx.tcx;
let opt_def = {
let def_map = tcx.def_map.borrow();
})
}
- ast::ExprCall(fn_exp, ref args, _) => {
+ ast::ExprCall(fn_exp, ref args) => {
walk_expr(cx, fn_exp, scope_stack, scope_map);
for arg_exp in args.iter() {
}
}
- ast::ExprMethodCall(node_id, _, _, ref args, _) => {
+ ast::ExprMethodCall(node_id, _, _, ref args) => {
scope_map.insert(node_id, scope_stack.last().unwrap().scope_metadata);
for arg_exp in args.iter() {
expr_to_str(expr), expr_ty.repr(tcx));
closure::trans_expr_fn(bcx, sigil, decl, body, expr.id, dest)
}
- ast::ExprCall(f, ref args, _) => {
+ ast::ExprCall(f, ref args) => {
callee::trans_call(bcx, expr, f,
callee::ArgExprs(*args), expr.id, dest)
}
- ast::ExprMethodCall(callee_id, _, _, ref args, _) => {
+ ast::ExprMethodCall(callee_id, _, _, ref args) => {
callee::trans_method_call(bcx, expr, callee_id, args[0],
callee::ArgExprs(*args), dest)
}
method_fn_ty: ty::t,
callee_expr: &ast::Expr,
args: &[@ast::Expr],
- sugar: ast::CallSugar,
- deref_args: DerefArgs) -> ty::t
- {
+ deref_args: DerefArgs) -> ty::t {
// HACK(eddyb) ignore provided self (it has special typeck rules).
let args = args.slice_from(1);
if ty::type_is_error(method_fn_ty) {
let err_inputs = err_args(args.len());
check_argument_types(fcx, sp, err_inputs, callee_expr,
- args, sugar, deref_args, false);
+ args, deref_args, false);
method_fn_ty
} else {
match ty::get(method_fn_ty).sty {
ty::ty_bare_fn(ref fty) => {
// HACK(eddyb) ignore self in the definition (see above).
check_argument_types(fcx, sp, fty.sig.inputs.slice_from(1),
- callee_expr, args, sugar, deref_args,
+ callee_expr, args, deref_args,
fty.sig.variadic);
fty.sig.output
}
fn_inputs: &[ty::t],
callee_expr: &ast::Expr,
args: &[@ast::Expr],
- sugar: ast::CallSugar,
deref_args: DerefArgs,
variadic: bool) {
/*!
err_args(supplied_arg_count)
}
} else {
- let suffix = match sugar {
- ast::NoSugar => "",
- ast::ForSugar => " (including the closure passed by \
- the `for` keyword)"
- };
let msg = format!(
"this function takes {} parameter{} \
- but {} parameter{} supplied{}",
+ but {} parameter{} supplied",
expected_arg_count, if expected_arg_count == 1 {""} else {"s"},
supplied_arg_count,
- if supplied_arg_count == 1 {" was"} else {"s were"},
- suffix);
+ if supplied_arg_count == 1 {" was"} else {"s were"});
tcx.sess.span_err(sp, msg);
// The callee checks for bot / err, we don't need to
}
- fn write_call(fcx: @FnCtxt,
- call_expr: &ast::Expr,
- output: ty::t,
- sugar: ast::CallSugar) {
- let ret_ty = match sugar {
- ast::ForSugar => {
- match ty::get(output).sty {
- ty::ty_bool => {}
- _ => fcx.type_error_message(call_expr.span, |actual| {
- format!("expected `for` closure to return `bool`, \
- but found `{}`", actual) },
- output, None)
- }
- ty::mk_nil()
- }
- _ => output
- };
- fcx.write_ty(call_expr.id, ret_ty);
+ fn write_call(fcx: @FnCtxt, call_expr: &ast::Expr, output: ty::t) {
+ fcx.write_ty(call_expr.id, output);
}
// A generic function for doing all of the checking for call expressions
callee_id: ast::NodeId,
call_expr: &ast::Expr,
f: &ast::Expr,
- args: &[@ast::Expr],
- sugar: ast::CallSugar) {
+ args: &[@ast::Expr]) {
// Index expressions need to be handled separately, to inform them
// that they appear in call position.
check_expr(fcx, f);
// Call the generic checker.
check_argument_types(fcx, call_expr.span, fn_sig.inputs, f,
- args, sugar, DontDerefArgs, fn_sig.variadic);
+ args, DontDerefArgs, fn_sig.variadic);
- write_call(fcx, call_expr, fn_sig.output, sugar);
+ write_call(fcx, call_expr, fn_sig.output);
}
// Checks a method call.
expr: &ast::Expr,
method_name: ast::Ident,
args: &[@ast::Expr],
- tps: &[ast::P<ast::Ty>],
- sugar: ast::CallSugar) {
+ tps: &[ast::P<ast::Ty>]) {
let rcvr = args[0];
check_expr(fcx, rcvr);
// Call the generic checker.
let fn_ty = fcx.node_ty(callee_id);
let ret_ty = check_method_argument_types(fcx, expr.span,
- fn_ty, expr, args, sugar,
+ fn_ty, expr, args,
DontDerefArgs);
- write_call(fcx, expr, ret_ty, sugar);
+ write_call(fcx, expr, ret_ty);
}
// A generic function for checking the then and else in an if
method_map.get().insert(op_ex.id, *origin);
}
check_method_argument_types(fcx, op_ex.span,
- method_ty, op_ex, args,
- ast::NoSugar, deref_args)
+ method_ty, op_ex,
+ args, deref_args)
}
_ => {
unbound_method();
// so we get all the error messages
let expected_ty = ty::mk_err();
check_method_argument_types(fcx, op_ex.span,
- expected_ty, op_ex, args,
- ast::NoSugar, deref_args);
+ expected_ty, op_ex,
+ args, deref_args);
ty::mk_err()
}
}
check_block_with_expected(fcx, b, expected);
fcx.write_ty(id, fcx.node_ty(b.id));
}
- ast::ExprCall(f, ref args, sugar) => {
- check_call(fcx, expr.id, expr, f, *args, sugar);
+ ast::ExprCall(f, ref args) => {
+ check_call(fcx, expr.id, expr, f, *args);
let f_ty = fcx.expr_ty(f);
let (args_bot, args_err) = args.iter().fold((false, false),
|(rest_bot, rest_err), a| {
fcx.write_bot(id);
}
}
- ast::ExprMethodCall(callee_id, ident, ref tps, ref args, sugar) => {
- check_method_call(fcx, callee_id, expr, ident, *args, *tps, sugar);
+ ast::ExprMethodCall(callee_id, ident, ref tps, ref args) => {
+ check_method_call(fcx, callee_id, expr, ident, *args, *tps);
let arg_tys = args.map(|a| fcx.expr_ty(*a));
let (args_bot, args_err) = arg_tys.iter().fold((false, false),
|(rest_bot, rest_err), a| {
}
match expr.node {
- ast::ExprCall(callee, ref args, _) => {
+ ast::ExprCall(callee, ref args) => {
constrain_callee(rcx, callee.id, expr, callee);
constrain_call(rcx, callee.id, expr, None, *args, false);
visit::walk_expr(rcx, expr, ());
}
- ast::ExprMethodCall(callee_id, _, _, ref args, _) => {
+ ast::ExprMethodCall(callee_id, _, _, ref args) => {
constrain_call(rcx, callee_id, expr, Some(args[0]),
args.slice_from(1), false);
ast::ExprUnary(callee_id, _, _) |
ast::ExprAssignOp(callee_id, _, _, _) |
ast::ExprIndex(callee_id, _, _) |
- ast::ExprMethodCall(callee_id, _, _, _, _) => {
+ ast::ExprMethodCall(callee_id, _, _, _) => {
match ty::method_call_type_param_defs(cx.tcx, fcx.inh.method_map, ex.id) {
Some(type_param_defs) => {
debug!("vtable resolution on parameter bounds for method call {}",
maybe_resolve_type_vars_for_node(wbcx, e.span, callee_id);
}
- ast::ExprMethodCall(callee_id, _, _, _, _) => {
+ ast::ExprMethodCall(callee_id, _, _, _) => {
// We must always have written in a callee ID type for these.
resolve_type_vars_for_node(wbcx, e.span, callee_id);
}
impl Expr {
pub fn get_callee_id(&self) -> Option<NodeId> {
match self.node {
- ExprMethodCall(callee_id, _, _, _, _) |
+ ExprMethodCall(callee_id, _, _, _) |
ExprIndex(callee_id, _, _) |
ExprBinary(callee_id, _, _, _) |
ExprAssignOp(callee_id, _, _, _) |
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
-pub enum CallSugar {
- NoSugar,
- ForSugar
-}
-
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub enum Expr_ {
ExprVstore(@Expr, ExprVstore),
// First expr is the place; second expr is the value.
ExprBox(@Expr, @Expr),
ExprVec(~[@Expr], Mutability),
- ExprCall(@Expr, ~[@Expr], CallSugar),
- ExprMethodCall(NodeId, Ident, ~[P<Ty>], ~[@Expr], CallSugar),
+ ExprCall(@Expr, ~[@Expr]),
+ ExprMethodCall(NodeId, Ident, ~[P<Ty>], ~[@Expr]),
ExprTup(~[@Expr]),
ExprBinary(NodeId, BinOp, @Expr, @Expr),
ExprUnary(NodeId, UnOp, @Expr),
}
fn expr_call(&self, span: Span, expr: @ast::Expr, args: ~[@ast::Expr]) -> @ast::Expr {
- self.expr(span, ast::ExprCall(expr, args, ast::NoSugar))
+ self.expr(span, ast::ExprCall(expr, args))
}
fn expr_call_ident(&self, span: Span, id: ast::Ident, args: ~[@ast::Expr]) -> @ast::Expr {
- self.expr(span,
- ast::ExprCall(self.expr_ident(span, id), args, ast::NoSugar))
+ self.expr(span, ast::ExprCall(self.expr_ident(span, id), args))
}
fn expr_call_global(&self, sp: Span, fn_path: ~[ast::Ident],
args: ~[@ast::Expr]) -> @ast::Expr {
ident: ast::Ident,
mut args: ~[@ast::Expr]) -> @ast::Expr {
args.unshift(expr);
- self.expr(span, ast::ExprMethodCall(ast::DUMMY_NODE_ID, ident, ~[], args, ast::NoSugar))
+ self.expr(span, ast::ExprMethodCall(ast::DUMMY_NODE_ID, ident, ~[], args))
}
fn expr_block(&self, b: P<ast::Block>) -> @ast::Expr {
self.expr(b.span, ast::ExprBlock(b))
ExprRepeat(folder.fold_expr(expr), folder.fold_expr(count), mutt)
}
ExprTup(ref elts) => ExprTup(elts.map(|x| folder.fold_expr(*x))),
- ExprCall(f, ref args, blk) => {
+ ExprCall(f, ref args) => {
ExprCall(folder.fold_expr(f),
- args.map(|&x| folder.fold_expr(x)),
- blk)
+ args.map(|&x| folder.fold_expr(x)))
}
- ExprMethodCall(callee_id, i, ref tps, ref args, blk) => {
+ ExprMethodCall(callee_id, i, ref tps, ref args) => {
ExprMethodCall(
folder.new_id(callee_id),
folder.fold_ident(i),
tps.map(|&x| folder.fold_ty(x)),
- args.map(|&x| folder.fold_expr(x)),
- blk
- )
+ args.map(|&x| folder.fold_expr(x)))
}
ExprBinary(callee_id, binop, lhs, rhs) => {
ExprBinary(folder.new_id(callee_id),
// isn't parsed as (if true {...} else {...} | x) | 5
pub fn expr_requires_semi_to_be_stmt(e: @ast::Expr) -> bool {
match e.node {
- ast::ExprIf(..)
- | ast::ExprMatch(..)
- | ast::ExprBlock(_)
- | ast::ExprWhile(..)
- | ast::ExprLoop(..)
- | ast::ExprForLoop(..)
- | ast::ExprCall(_, _, ast::ForSugar)
- | ast::ExprMethodCall(_, _, _, _, ast::ForSugar) => false,
- _ => true
+ ast::ExprIf(..)
+ | ast::ExprMatch(..)
+ | ast::ExprBlock(_)
+ | ast::ExprWhile(..)
+ | ast::ExprLoop(..)
+ | ast::ExprForLoop(..) => false,
+ _ => true
}
}
use abi;
use abi::AbiSet;
use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil};
-use ast::{CallSugar, NoSugar};
use ast::{BareFnTy, ClosureTy};
use ast::{RegionTyParamBound, TraitTyParamBound};
use ast::{Provided, Public, Purity};
ExprBinary(ast::DUMMY_NODE_ID, binop, lhs, rhs)
}
- pub fn mk_call(&mut self, f: @Expr, args: ~[@Expr], sugar: CallSugar) -> ast::Expr_ {
- ExprCall(f, args, sugar)
+ pub fn mk_call(&mut self, f: @Expr, args: ~[@Expr]) -> ast::Expr_ {
+ ExprCall(f, args)
}
- fn mk_method_call(&mut self, ident: Ident, tps: ~[P<Ty>], args: ~[@Expr],
- sugar: CallSugar) -> ast::Expr_ {
- ExprMethodCall(ast::DUMMY_NODE_ID, ident, tps, args, sugar)
+ fn mk_method_call(&mut self, ident: Ident, tps: ~[P<Ty>], args: ~[@Expr]) -> ast::Expr_ {
+ ExprMethodCall(ast::DUMMY_NODE_ID, ident, tps, args)
}
pub fn mk_index(&mut self, expr: @Expr, idx: @Expr) -> ast::Expr_ {
hi = self.last_span.hi;
es.unshift(e);
- let nd = self.mk_method_call(i, tys, es, NoSugar);
+ let nd = self.mk_method_call(i, tys, es);
e = self.mk_expr(lo, hi, nd);
}
_ => {
);
hi = self.last_span.hi;
- let nd = self.mk_call(e, es, NoSugar);
+ let nd = self.mk_call(e, es);
e = self.mk_expr(lo, hi, nd);
}
}
}
-pub fn print_call_pre(s: &mut State,
- sugar: ast::CallSugar,
- base_args: &mut ~[@ast::Expr])
- -> io::IoResult<Option<@ast::Expr>> {
- match sugar {
- ast::ForSugar => {
- if_ok!(head(s, "for"));
- Ok(Some(base_args.pop().unwrap()))
- }
- ast::NoSugar => Ok(None)
- }
-}
-
-pub fn print_call_post(s: &mut State,
- sugar: ast::CallSugar,
- blk: &Option<@ast::Expr>,
- base_args: &mut ~[@ast::Expr]) -> io::IoResult<()> {
- if sugar == ast::NoSugar || !base_args.is_empty() {
- if_ok!(popen(s));
- if_ok!(commasep_exprs(s, Inconsistent, *base_args));
- if_ok!(pclose(s));
- }
- if sugar != ast::NoSugar {
- if_ok!(nbsp(s));
- // not sure if this can happen
- if_ok!(print_expr(s, blk.unwrap()));
- }
+fn print_call_post(s: &mut State, args: &[@ast::Expr]) -> io::IoResult<()> {
+ if_ok!(popen(s));
+ if_ok!(commasep_exprs(s, Inconsistent, args));
+ if_ok!(pclose(s));
Ok(())
}
}
if_ok!(pclose(s));
}
- ast::ExprCall(func, ref args, sugar) => {
- let mut base_args = (*args).clone();
- let blk = if_ok!(print_call_pre(s, sugar, &mut base_args));
+ ast::ExprCall(func, ref args) => {
if_ok!(print_expr(s, func));
- if_ok!(print_call_post(s, sugar, &blk, &mut base_args));
+ if_ok!(print_call_post(s, *args));
}
- ast::ExprMethodCall(_, ident, ref tys, ref args, sugar) => {
- let mut base_args = args.slice_from(1).to_owned();
- let blk = if_ok!(print_call_pre(s, sugar, &mut base_args));
+ ast::ExprMethodCall(_, ident, ref tys, ref args) => {
+ let base_args = args.slice_from(1);
if_ok!(print_expr(s, args[0]));
if_ok!(word(&mut s.s, "."));
if_ok!(print_ident(s, ident));
if_ok!(commasep(s, Inconsistent, *tys, print_type_ref));
if_ok!(word(&mut s.s, ">"));
}
- if_ok!(print_call_post(s, sugar, &blk, &mut base_args));
+ if_ok!(print_call_post(s, base_args));
}
ast::ExprBinary(_, op, lhs, rhs) => {
if_ok!(print_expr(s, lhs));
visitor.visit_expr(*subexpression, env.clone())
}
}
- ExprCall(callee_expression, ref arguments, _) => {
+ ExprCall(callee_expression, ref arguments) => {
for argument in arguments.iter() {
visitor.visit_expr(*argument, env.clone())
}
visitor.visit_expr(callee_expression, env.clone())
}
- ExprMethodCall(_, _, ref types, ref arguments, _) => {
+ ExprMethodCall(_, _, ref types, ref arguments) => {
walk_exprs(visitor, *arguments, env.clone());
for &typ in types.iter() {
visitor.visit_ty(typ, env.clone())