Skip to content

Commit

Permalink
Update for changes in rustc.
Browse files Browse the repository at this point in the history
  • Loading branch information
solson committed Nov 7, 2016
1 parent 33b1676 commit a8d90ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
23 changes: 13 additions & 10 deletions src/interpreter/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,24 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

fn cast_ptr(&self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, PrimVal> {
use primval::PrimValKind::*;
use rustc::ty::TypeVariants::*;
match ty.sty {
TyRef(..) | TyRawPtr(_) => Ok(PrimVal::from_ptr(ptr)),
TyFnPtr(_) => Ok(PrimVal::from_fn_ptr(ptr)),

TyInt(IntTy::I8) => Ok(PrimVal::new(ptr.to_int()? as u64, I8)),
TyInt(IntTy::I16) => Ok(PrimVal::new(ptr.to_int()? as u64, I16)),
TyInt(IntTy::I32) => Ok(PrimVal::new(ptr.to_int()? as u64, I32)),
TyInt(IntTy::I64) => Ok(PrimVal::new(ptr.to_int()? as u64, I64)),

TyUint(UintTy::U8) => Ok(PrimVal::new(ptr.to_int()? as u64, U8)),
TyUint(UintTy::U16) => Ok(PrimVal::new(ptr.to_int()? as u64, U16)),
TyUint(UintTy::U32) => Ok(PrimVal::new(ptr.to_int()? as u64, U32)),
TyUint(UintTy::U64) => Ok(PrimVal::new(ptr.to_int()? as u64, U64)),
TyInt(IntTy::I8) |
TyInt(IntTy::I16) |
TyInt(IntTy::I32) |
TyInt(IntTy::I64) |
TyInt(IntTy::Is) |
TyUint(UintTy::U8) |
TyUint(UintTy::U16) |
TyUint(UintTy::U32) |
TyUint(UintTy::U64) |
TyUint(UintTy::Us) => {
let val = PrimVal::from_ptr(ptr);
self.transmute_primval(val, ty)
}

_ => Err(EvalError::Unimplemented(format!("ptr to {:?} cast", ty))),
}
Expand Down
4 changes: 2 additions & 2 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1699,13 +1699,13 @@ pub fn run_mir_passes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut passes = ::rustc::mir::transform::Passes::new();
passes.push_hook(Box::new(::rustc_mir::transform::dump_mir::DumpMir));
passes.push_pass(Box::new(::rustc_mir::transform::no_landing_pads::NoLandingPads));
passes.push_pass(Box::new(::rustc_mir::transform::simplify_cfg::SimplifyCfg::new("no-landing-pads")));
passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyCfg::new("no-landing-pads")));

passes.push_pass(Box::new(::rustc_mir::transform::erase_regions::EraseRegions));

passes.push_pass(Box::new(::rustc_borrowck::ElaborateDrops));
passes.push_pass(Box::new(::rustc_mir::transform::no_landing_pads::NoLandingPads));
passes.push_pass(Box::new(::rustc_mir::transform::simplify_cfg::SimplifyCfg::new("elaborate-drops")));
passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyCfg::new("elaborate-drops")));
passes.push_pass(Box::new(::rustc_mir::transform::dump_mir::Marker("PreMiri")));

passes.run_passes(tcx);
Expand Down

0 comments on commit a8d90ff

Please sign in to comment.