Add tests

This commit is contained in:
Jeehoon Kang
2020-06-09 14:45:11 +00:00
parent ea97330e03
commit ea9e6afcf8
258 changed files with 149921 additions and 26 deletions

View File

@@ -1346,12 +1346,17 @@ impl<'i> State<'i> {
assert!(a.dtype().set_const(false) == d.deref().clone().set_const(false));
}
for (i, a) in arg.args.iter().enumerate() {
let v = self.interp_operand(a.clone()).unwrap();
self.stack_frame
.registers
.write(RegisterId::arg(arg.bid, i), v);
}
arg.args
.iter()
.map(|a| self.interp_operand(a.clone()).unwrap())
.collect::<Vec<_>>()
.into_iter()
.enumerate()
.for_each(|(i, v)| {
self.stack_frame
.registers
.write(RegisterId::arg(arg.bid, i), v);
});
self.stack_frame.pc = Pc::new(arg.bid);
Ok(None)

View File

@@ -423,6 +423,14 @@ impl RegisterId {
pub fn temp(bid: BlockId, iid: usize) -> Self {
Self::Temp { bid, iid }
}
pub fn is_const(&self, bid_init: BlockId) -> bool {
match self {
Self::Local { .. } => true,
Self::Arg { bid, .. } => bid == &bid_init,
_ => false,
}
}
}
impl fmt::Display for RegisterId {