Some misc changes

This commit is contained in:
bjorn3 2018-08-08 10:39:10 +02:00
parent 40176e03fd
commit ece497cc84
3 changed files with 10 additions and 1 deletions

View File

@ -137,3 +137,8 @@ unsafe fn transmute(c: char) -> u32 {
unsafe fn call_uninit() -> u8 {
intrinsics::uninit()
}
// TODO: enable when fat pointers are supported
/*unsafe fn deref_str_ptr(s: *const str) -> &'static str {
&*s
}*/

View File

@ -330,7 +330,7 @@ pub fn codegen_call<'a, 'tcx: 'a>(
let nil_ty = fx.tcx.mk_nil();
let usize_layout = fx.layout_of(fx.tcx.types.usize);
let ret = return_place.unwrap();
let ret = return_place.expect("return place");
match intrinsic {
"abort" => {
fx.bcx.ins().trap(TrapCode::User(!0 - 1));

View File

@ -354,6 +354,10 @@ fn trans_stmt<'a, 'tcx: 'a>(
let res = match un_op {
UnOp::Not => fx.bcx.ins().bnot(val),
UnOp::Neg => match ty.sty {
TypeVariants::TyInt(_) => {
let zero = fx.bcx.ins().iconst(types::I64, 0);
fx.bcx.ins().isub(zero, val)
},
TypeVariants::TyFloat(_) => fx.bcx.ins().fneg(val),
_ => unimplemented!("un op Neg for {:?}", ty),
},