Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

things priroda needs to be public or changed #40

Merged
merged 1 commit into from
Jun 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}
}

pub fn memory(&self) -> &Memory {
pub fn memory(&self) -> &Memory<'a, 'tcx> {
&self.memory
}

pub fn memory_mut(&mut self) -> &mut Memory<'a, 'tcx> {
&mut self.memory
}

pub fn stack(&self) -> &[Frame] {
pub fn stack(&self) -> &[Frame<'a, 'tcx>] {
&self.stack
}

Expand Down Expand Up @@ -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 => {
Expand All @@ -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)
}
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ pub use interpreter::{
eval_main,
};

pub use memory::Memory;
pub use memory::{
Memory,
Pointer,
AllocId,
};
8 changes: 6 additions & 2 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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; }
Expand Down