}
}
-#[derive(Debug, PartialOrd, Ord)]
+#[derive(Debug)]
pub struct TypedArenaPtr<T: ?Sized>(ptr::NonNull<T>);
+impl<T: ?Sized + PartialOrd> PartialOrd for TypedArenaPtr<T> {
+ fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
+ (**self).partial_cmp(&**other)
+ }
+}
+
impl<T: ?Sized + PartialEq> PartialEq for TypedArenaPtr<T> {
fn eq(&self, other: &TypedArenaPtr<T>) -> bool {
self.0 == other.0 || &**self == &**other
impl<T: ?Sized + PartialEq> Eq for TypedArenaPtr<T> {}
+impl<T: ?Sized + Ord> Ord for TypedArenaPtr<T> {
+ fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+ (**self).cmp(&**other)
+ }
+}
+
impl<T: ?Sized + Hash> Hash for TypedArenaPtr<T> {
#[inline(always)]
fn hash<H: Hasher>(&self, hasher: &mut H) {
h as u64,
));
- self.trail.push(TrailEntry::from_bytes(
- list_loc_as_cell!(l).into_bytes()
+ self.trail.push(TrailEntry::build_with(
+ TrailEntryTag::TrailedAttachedValue,
+ l as u64,
));
self.tr += 2;
value: HeapCellValue,
stub_gen: impl Fn() -> FunctorStub,
) -> Result<Vec<HeapCellValue>, MachineStub> {
- let deref_v = self.deref(value);
- let store_v = self.store(deref_v);
+ let value = self.store(self.deref(value));
- read_heap_cell!(store_v,
+ read_heap_cell!(value,
(HeapCellValueTag::Lis, l) => {
- self.try_from_inner_list(vec![], l, stub_gen, store_v)
+ self.try_from_inner_list(vec![], l, stub_gen, value)
}
(HeapCellValueTag::PStrLoc, h) => {
- self.try_from_partial_string(vec![], h, stub_gen, store_v)
+ self.try_from_partial_string(vec![], h, stub_gen, value)
}
(HeapCellValueTag::AttrVar | HeapCellValueTag::StackVar | HeapCellValueTag::Var) => {
let err = self.instantiation_error();
if name == atom!("[]") && arity == 0 {
Ok(vec![])
} else {
- let err = self.type_error(ValidType::List, store_v);
+ let err = self.type_error(ValidType::List, value);
Err(self.error_form(err, stub_gen()))
}
}
Ok(cstr.chars().map(|c| char_as_cell!(c)).collect())
}
_ => {
- let err = self.type_error(ValidType::List, store_v);
+ let err = self.type_error(ValidType::List, value);
Err(self.error_form(err, stub_gen()))
}
)
l += 1;
loop {
- let deref_v = self.deref(self.heap[l]);
- let store_v = self.store(self.heap[l]);
+ let value = self.store(self.deref(self.heap[l]));
- read_heap_cell!(store_v,
+ read_heap_cell!(value,
(HeapCellValueTag::Lis, hcp) => {
result.push(self.heap[hcp]);
l = hcp + 1;
}
- (HeapCellValueTag::PStrOffset) => {
- return self.try_from_partial_string(result, deref_v.get_value(), stub_gen, a1);
+ (HeapCellValueTag::PStrLoc, l) => {
+ return self.try_from_partial_string(result, l, stub_gen, a1);
}
(HeapCellValueTag::Atom, (name, arity)) => {
if name == atom!("[]") && arity == 0 {
}
}
_ => {
- if store_v.is_var() {
+ if value.is_var() {
let err = self.instantiation_error();
return Err(self.error_form(err, stub_gen()));
} else {
self.machine_st.heap[h] = heap_loc_as_cell!(h);
}
TrailEntryTag::TrailedAttrVarListLink => {
- let value = HeapCellValue::from_bytes(
- self.machine_st.trail[i + 1].into_bytes()
- );
+ let l = self.machine_st.trail[i + 1].get_value() as usize;
- if value.get_value() < self.machine_st.hb {
- self.machine_st.heap[h] = value;
+ if l < self.machine_st.hb {
+ self.machine_st.heap[h] = list_loc_as_cell!(l);
+ } else {
+ self.machine_st.heap[h] = heap_loc_as_cell!(h);
}
}
TrailEntryTag::TrailedBlackboardEntry => {