copy terms to global variable blackboard, fix attribute_goals//1

This commit is contained in:
Mark Thom
2019-10-09 14:11:31 -06:00
parent 3409db010f
commit f898b98b06
12 changed files with 113 additions and 76 deletions

View File

@@ -21,7 +21,7 @@ use std::io::{stdout, Write};
use std::mem;
use std::ops::{Index, IndexMut};
pub(super) struct Ball {
pub struct Ball {
pub(super) boundary: usize, // ball.0
pub(super) stub: MachineStub, // ball.1
}
@@ -48,6 +48,22 @@ impl Ball {
stub: mem::replace(&mut self.stub, vec![]),
}
}
pub(super) fn copy_and_align(&self, h: usize) -> MachineStub {
let diff = self.boundary as i64 - h as i64;
let mut stub = vec![];
for index in 0..self.stub.len() {
let heap_value = self.stub[index].clone();
stub.push(match heap_value {
HeapCellValue::Addr(addr) => HeapCellValue::Addr(addr - diff),
_ => heap_value,
});
}
stub
}
}
pub(super) struct CopyTerm<'a> {