remove Addr::PStrTail (#276)

This commit is contained in:
Mark Thom
2020-03-17 02:03:29 -06:00
parent f9c4a40d60
commit b1d8eff019
11 changed files with 181 additions and 431 deletions

View File

@@ -89,7 +89,7 @@ impl<'a> HCPreOrderIterator<'a> {
if pstr.len() > n + c.len_utf8() {
self.state_stack.push(Addr::PStrLocation(h, n + c.len_utf8()));
} else {
self.state_stack.push(Addr::PStrTail(h, n + c.len_utf8()));
self.state_stack.push(Addr::HeapCell(h + 1));
}
self.state_stack.push(Addr::Con(Constant::Char(c)));
@@ -102,7 +102,7 @@ impl<'a> HCPreOrderIterator<'a> {
Addr::PStrLocation(h, n)
}
Addr::AttrVar(_) | Addr::HeapCell(_) | Addr::StackCell(_, _) | Addr::PStrTail(..) => {
Addr::AttrVar(_) | Addr::HeapCell(_) | Addr::StackCell(_, _) => {
da
}
Addr::Str(s) => {
@@ -130,20 +130,6 @@ impl<'a> Iterator for HCPreOrderIterator<'a> {
}
}
}
Addr::PStrTail(h, n) => {
match &self.machine_st.heap[h] {
HeapCellValue::PartialString(ref pstr) => {
if pstr.len() > n {
HeapCellValue::Addr(Addr::PStrLocation(h, n))
} else {
HeapCellValue::Addr(pstr.tail_addr().clone())
}
}
_ => {
unreachable!()
}
}
}
Addr::StackCell(fr, sc) => {
HeapCellValue::Addr(self.machine_st.stack.index_and_frame(fr)[sc].clone())
}