diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index 7354602513..d17640bb67 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -154,7 +154,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } } - pub fn memory(&self) -> &Memory { + pub fn memory(&self) -> &Memory<'a, 'tcx> { &self.memory } @@ -162,7 +162,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { &mut self.memory } - pub fn stack(&self) -> &[Frame] { + pub fn stack(&self) -> &[Frame<'a, 'tcx>] { &self.stack } @@ -235,7 +235,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { ty.is_sized(self.tcx, &self.tcx.empty_parameter_environment(), DUMMY_SP) } - fn load_mir(&self, def_id: DefId) -> CachedMir<'a, 'tcx> { + pub fn load_mir(&self, def_id: DefId) -> CachedMir<'a, 'tcx> { match self.tcx.map.as_local_node_id(def_id) { Some(node_id) => CachedMir::Ref(self.mir_map.map.get(&node_id).unwrap()), None => { @@ -255,7 +255,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } } - fn monomorphize(&self, ty: Ty<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { + pub fn monomorphize(&self, ty: Ty<'tcx>, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { let substituted = ty.subst(self.tcx, substs); self.tcx.normalize_associated_type(&substituted) } diff --git a/src/lib.rs b/src/lib.rs index 3745a960a2..93dfe4e220 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,4 +38,8 @@ pub use interpreter::{ eval_main, }; -pub use memory::Memory; +pub use memory::{ + Memory, + Pointer, + AllocId, +}; diff --git a/src/memory.rs b/src/memory.rs index dd3c491e6b..e3e4279049 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -16,7 +16,7 @@ use primval::PrimVal; //////////////////////////////////////////////////////////////////////////////// #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)] -pub struct AllocId(u64); +pub struct AllocId(pub u64); impl fmt::Display for AllocId { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -77,6 +77,10 @@ impl<'a, 'tcx> Memory<'a, 'tcx> { } } + pub fn allocations<'b>(&'b self) -> ::std::collections::hash_map::Iter<'b, AllocId, Allocation> { + self.alloc_map.iter() + } + pub fn create_fn_ptr(&mut self, def_id: DefId, substs: &'tcx Substs<'tcx>, fn_ty: &'tcx BareFnTy<'tcx>) -> Pointer { let def = FunctionDefinition { def_id: def_id, @@ -576,7 +580,7 @@ impl UndefMask { } /// Check whether the range `start..end` (end-exclusive) is entirely defined. - fn is_range_defined(&self, start: usize, end: usize) -> bool { + pub fn is_range_defined(&self, start: usize, end: usize) -> bool { if end > self.len { return false; } for i in start..end { if !self.get(i) { return false; }