mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-16 07:28:52 +00:00
Add tests
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user