// - trans_args
fn type_of_fn(cx: @crate_ctxt, sp: span, proto: ast::proto,
is_method: bool, ret_ref: bool, inputs: [ty::arg],
- output: ty::t, ty_param_count: uint) -> TypeRef {
+ output: ty::t, ty_param_count: uint)
+ : non_ty_var(cx, output) -> TypeRef {
let atys: [TypeRef] = [];
// Arg 0: Output pointer.
- check non_ty_var(cx, output);
let out_ty = T_ptr(type_of_inner(cx, sp, output));
atys += [ret_ref ? T_ptr(out_ty) : out_ty];
// If we're here, it must be a temporary.
ret revoke_clean(cx, src_val, t);
}
+ /* FIXME: suggests a type constraint */
bcx_ccx(cx).sess.bug("unexpected type in trans::move_val: " +
ty_to_str(tcx, t));
}
let v = GEP(r.bcx, vtbl, [C_int(0), C_int(ix as int)]);
let tcx = bcx_tcx(cx);
+ let ccx = bcx_ccx(cx);
+
let fn_ty: ty::t = ty::method_ty_to_fn_ty(tcx, methods[ix]);
+ let ret_ty = ty::ty_fn_ret(tcx, fn_ty);
let ret_ref = ast_util::ret_by_ref(ty::ty_fn_ret_style(tcx, fn_ty));
+ // FIXME: constrain ty_obj?
+ check non_ty_var(ccx, ret_ty);
+
let ll_fn_ty =
- type_of_fn(bcx_ccx(cx), sp, ty::ty_fn_proto(tcx, fn_ty),
+ type_of_fn(ccx, sp, ty::ty_fn_proto(tcx, fn_ty),
true, ret_ref, ty::ty_fn_args(tcx, fn_ty),
- ty::ty_fn_ret(tcx, fn_ty), 0u);
+ ret_ty, 0u);
v = PointerCast(r.bcx, v, T_ptr(T_ptr(ll_fn_ty)));
let lvo = lval_mem(r.bcx, v);
ret {llobj: some::<ValueRef>(r.val) with lvo};
}
_ { bcx_ccx(cx).sess.unimpl("stmt variant"); }
}
- ret rslt(bcx, C_nil());
+ rslt(bcx, C_nil())
}
// You probably don't want to use this one. See the
let vecarg_ty: ty::arg =
{mode: ast::by_ref,
ty: ty::mk_vec(ccx.tcx, {ty: unit_ty, mut: ast::imm})};
- // FIXME: mk_nil should have a post condition
+ // FIXME: mk_nil should have a postcondition
let nt = ty::mk_nil(ccx.tcx);
check non_ty_var(ccx, nt);
ty_params: [ast::ty_param]) -> ValueRef {
let llfnty = T_nil();
+ let ccx = cx.ccx;
alt ty::struct(cx.ccx.tcx, node_id_type(cx.ccx, m.node.id)) {
ty::ty_fn(proto, inputs, output, rs, _) {
- let ccx = cx.ccx;
check non_ty_var(ccx, output);
llfnty = type_of_fn(ccx, m.span, proto, true,
ast_util::ret_by_ref(rs), inputs, output,
let mcx: @local_ctxt =
@{path: cx.path + ["method", m.node.ident] with *cx};
let s: str = mangle_internal_name_by_path(mcx.ccx, mcx.path);
- let llfn: ValueRef = decl_internal_fastcall_fn(cx.ccx.llmod, s, llfnty);
+ let llfn: ValueRef = decl_internal_fastcall_fn(ccx.llmod, s, llfnty);
// Every method on an object gets its node_id inserted into the crate-wide
// item_ids map, together with the ValueRef that points to where that
// method's definition will be in the executable.
- cx.ccx.item_ids.insert(m.node.id, llfn);
- cx.ccx.item_symbols.insert(m.node.id, s);
+ ccx.item_ids.insert(m.node.id, llfn);
+ ccx.item_symbols.insert(m.node.id, s);
trans_fn(mcx, m.span, m.node.meth, llfn, some(self_ty), ty_params,
m.node.id);