_ => false
}
}
-
- pub fn as_ref(&self) -> Option<Ref> {
- match self {
- &Addr::HeapCell(hc) => Some(Ref::HeapCell(hc)),
- &Addr::StackCell(fr, sc) => Some(Ref::StackCell(fr, sc)),
- &Addr::Lis(hc) => Some(Ref::HeapCell(hc)),
- &Addr::Str(hc) => Some(Ref::HeapCell(hc)),
- _ => None
- }
- }
-
+
pub fn as_var(&self) -> Option<Ref> {
match self {
&Addr::HeapCell(hc) => Some(Ref::HeapCell(hc)),
impl From<Ref> for Addr {
fn from(r: Ref) -> Self {
match r {
- Ref::HeapCell(hc) => Addr::HeapCell(hc),
+ Ref::HeapCell(hc) => Addr::HeapCell(hc),
Ref::StackCell(fr, sc) => Addr::StackCell(fr, sc)
}
}
pub(super) num_of_args: usize,
pub(super) cp: CodePtr,
pub(super) fail: bool,
- pub(super) heap: Heap,
+ pub(crate) heap: Heap,
pub(super) mode: MachineMode,
- pub(super) and_stack: AndStack,
+ pub(crate) and_stack: AndStack,
pub(super) or_stack: OrStack,
pub(super) registers: Registers,
pub(super) trail: Vec<Ref>,
if self.b > 0 { self.or_stack[self.b - 1].global_index } else { 0 }) + 1
}
- pub fn store(&self, a: Addr) -> Addr {
+ pub(super) fn store(&self, a: Addr) -> Addr {
match a {
Addr::HeapCell(r) => self.heap[r].as_addr(r),
Addr::StackCell(fr, sc) => self.and_stack[fr][sc].clone(),
}
}
- pub fn deref(&self, a: Addr) -> Addr {
- let mut a = a;
-
+ pub(crate) fn deref(&self, mut a: Addr) -> Addr {
loop {
let value = self.store(a.clone());
for heap_value in self.ball.1.iter().cloned() {
self.heap.push(match heap_value {
- HeapCellValue::Addr(Addr::Con(c)) => HeapCellValue::Addr(Addr::Con(c)),
- HeapCellValue::Addr(Addr::Lis(a)) => HeapCellValue::Addr(Addr::Lis(a - diff)),
+ HeapCellValue::Addr(Addr::Con(c)) =>
+ HeapCellValue::Addr(Addr::Con(c)),
+ HeapCellValue::Addr(Addr::Lis(a)) =>
+ HeapCellValue::Addr(Addr::Lis(a - diff)),
HeapCellValue::Addr(Addr::HeapCell(hc)) =>
HeapCellValue::Addr(Addr::HeapCell(hc - diff)),
- HeapCellValue::Addr(Addr::Str(s)) => HeapCellValue::Addr(Addr::Str(s - diff)),
+ HeapCellValue::Addr(Addr::Str(s)) =>
+ HeapCellValue::Addr(Addr::Str(s - diff)),
_ => heap_value
});
}