add support for copying attributed variables in copy_term
This commit is contained in:
@@ -30,16 +30,26 @@ pub(crate) trait CopierTarget: IndexMut<usize, Output=HeapCellValue>
|
|||||||
|
|
||||||
fn reinstantiate_var(&mut self, ra: Addr, scan: usize, trail: &mut Trail)
|
fn reinstantiate_var(&mut self, ra: Addr, scan: usize, trail: &mut Trail)
|
||||||
{
|
{
|
||||||
self[scan] = HeapCellValue::Addr(Addr::HeapCell(scan));
|
match ra {
|
||||||
|
Addr::HeapCell(hc) => {
|
||||||
if let Addr::HeapCell(hc) = ra.clone() {
|
self[scan] = HeapCellValue::Addr(Addr::HeapCell(scan));
|
||||||
self[hc] = HeapCellValue::Addr(Addr::HeapCell(scan));
|
self[hc] = HeapCellValue::Addr(Addr::HeapCell(scan));
|
||||||
trail.push((Ref::HeapCell(hc),
|
trail.push((Ref::HeapCell(hc),
|
||||||
HeapCellValue::Addr(Addr::HeapCell(hc))));
|
HeapCellValue::Addr(Addr::HeapCell(hc))));
|
||||||
} else if let Addr::StackCell(fr, sc) = ra {
|
},
|
||||||
self.stack()[fr][sc] = Addr::HeapCell(scan);
|
Addr::StackCell(fr, sc) => {
|
||||||
trail.push((Ref::StackCell(fr, sc),
|
self[scan] = HeapCellValue::Addr(Addr::HeapCell(scan));
|
||||||
HeapCellValue::Addr(Addr::StackCell(fr, sc))));
|
self.stack()[fr][sc] = Addr::HeapCell(scan);
|
||||||
|
trail.push((Ref::StackCell(fr, sc),
|
||||||
|
HeapCellValue::Addr(Addr::StackCell(fr, sc))));
|
||||||
|
},
|
||||||
|
Addr::AttrVar(hc) => {
|
||||||
|
self[scan] = HeapCellValue::Addr(Addr::AttrVar(scan));
|
||||||
|
self[hc] = HeapCellValue::Addr(Addr::AttrVar(scan));
|
||||||
|
trail.push((Ref::AttrVar(hc),
|
||||||
|
HeapCellValue::Addr(Addr::AttrVar(hc))));
|
||||||
|
},
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +121,12 @@ pub(crate) trait CopierTarget: IndexMut<usize, Output=HeapCellValue>
|
|||||||
},
|
},
|
||||||
_ if ra == rd => {
|
_ if ra == rd => {
|
||||||
self.reinstantiate_var(ra, scan, &mut trail);
|
self.reinstantiate_var(ra, scan, &mut trail);
|
||||||
|
|
||||||
|
if let Addr::AttrVar(h) = rd {
|
||||||
|
let value = self[h + 1].clone();
|
||||||
|
self.push(value);
|
||||||
|
}
|
||||||
|
|
||||||
scan += 1;
|
scan += 1;
|
||||||
},
|
},
|
||||||
_ => self[scan] = HeapCellValue::Addr(rd)
|
_ => self[scan] = HeapCellValue::Addr(rd)
|
||||||
|
|||||||
@@ -1588,7 +1588,7 @@ impl MachineState {
|
|||||||
for (v1, v2) in iter {
|
for (v1, v2) in iter {
|
||||||
match (v1, v2) {
|
match (v1, v2) {
|
||||||
(HeapCellValue::Addr(Addr::Lis(_)), HeapCellValue::Addr(Addr::Con(Constant::String(_))))
|
(HeapCellValue::Addr(Addr::Lis(_)), HeapCellValue::Addr(Addr::Con(Constant::String(_))))
|
||||||
| (HeapCellValue::Addr(Addr::Con(Constant::String(_))), HeapCellValue::Addr(Addr::Lis(_)))
|
| (HeapCellValue::Addr(Addr::Con(Constant::String(_))), HeapCellValue::Addr(Addr::Lis(_)))
|
||||||
if self.flags.double_quotes.is_chars() => {},
|
if self.flags.double_quotes.is_chars() => {},
|
||||||
(HeapCellValue::Addr(Addr::Con(Constant::EmptyList)),
|
(HeapCellValue::Addr(Addr::Con(Constant::EmptyList)),
|
||||||
HeapCellValue::Addr(Addr::Con(Constant::String(ref s))))
|
HeapCellValue::Addr(Addr::Con(Constant::String(ref s))))
|
||||||
|
|||||||
Reference in New Issue
Block a user