use trans::type_::Type;
use syntax::{ast, ast_util, codemap};
-use syntax::print::pprust::{expr_to_string};
use syntax::ptr::P;
use syntax::parse::token;
use std::rc::Rc;
tvec::vec_types(bcx,
ty::sequence_element_type(bcx.tcx(),
base_datum.ty));
- base::maybe_name_value(bcx.ccx(), vt.llunit_size, "unit_sz");
let (base, len) = base_datum.get_vec_base_and_len(bcx);
// closure or an older, legacy style closure. Store this
// into a variable to ensure the the RefCell-lock is
// released before we recurse.
- let is_unboxed_closure =
- bcx.tcx().unboxed_closures.borrow().contains_key(&ast_util::local_def(expr.id));
- if is_unboxed_closure {
- closure::trans_unboxed_closure(bcx, &**decl, &**body, expr.id, dest)
- } else {
- let expr_ty = expr_ty(bcx, expr);
- let store = ty::ty_closure_store(expr_ty);
- debug!("translating block function {} with type {}",
- expr_to_string(expr), expr_ty.repr(tcx));
- closure::trans_expr_fn(bcx, store, &**decl, &**body, expr.id, dest)
- }
+ closure::trans_unboxed_closure(bcx, &**decl, &**body, expr.id, dest)
}
ast::ExprCall(ref f, ref args) => {
if bcx.tcx().is_method_call(expr.id) {
signed: bool)
-> ValueRef {
let _icx = push_ctxt("int_cast");
- unsafe {
- let srcsz = llvm::LLVMGetIntTypeWidth(llsrctype.to_ref());
- let dstsz = llvm::LLVMGetIntTypeWidth(lldsttype.to_ref());
- return if dstsz == srcsz {
- BitCast(bcx, llsrc, lldsttype)
- } else if srcsz > dstsz {
- TruncOrBitCast(bcx, llsrc, lldsttype)
- } else if signed {
- SExtOrBitCast(bcx, llsrc, lldsttype)
- } else {
- ZExtOrBitCast(bcx, llsrc, lldsttype)
- };
+ let srcsz = llsrctype.int_width();
+ let dstsz = lldsttype.int_width();
+ return if dstsz == srcsz {
+ BitCast(bcx, llsrc, lldsttype)
+ } else if srcsz > dstsz {
+ TruncOrBitCast(bcx, llsrc, lldsttype)
+ } else if signed {
+ SExtOrBitCast(bcx, llsrc, lldsttype)
+ } else {
+ ZExtOrBitCast(bcx, llsrc, lldsttype)
}
}