1mod component;
5mod data;
6mod display;
7mod instruction;
8mod outcome;
9pub use component::CPUMessage;
10pub use data::CPU;
11pub use instruction::{RuntimeInstruction, SurfaceInstruction, SurfaceType, SurfaceValue};
12pub use outcome::StepOutcome;
13
14#[cfg(test)]
15mod tests {
16 use super::*;
17
18 #[test]
19 fn surface_instruction_implements_surface_marker() {
20 fn require_surface_instruction<T: vihaco::SurfaceInstruction>() {}
21
22 require_surface_instruction::<SurfaceInstruction>();
23 }
24
25 #[test]
26 fn cpu_instruction_derive_exposes_explicit_canonical_syntax_entries() {
27 let variants = <RuntimeInstruction as vihaco::CanonicalInstructionSyntax>::variants();
28
29 let expect = [
30 ("cpu::const_i64", &[vihaco::OperandKind::I64][..]),
31 ("cpu::const_f64", &[vihaco::OperandKind::F64][..]),
32 ("cpu::const_bool", &[vihaco::OperandKind::Bool][..]),
33 ("cpu::const_u64", &[vihaco::OperandKind::NonNegativeU64][..]),
34 ("cpu::fn_ref", &[vihaco::OperandKind::Symbol][..]),
35 ("cpu::call_direct", &[vihaco::OperandKind::Symbol][..]),
36 ];
37
38 for (mnemonic, operands) in expect {
39 let syntax = variants
40 .iter()
41 .find(|syntax| syntax.mnemonic == mnemonic)
42 .unwrap_or_else(|| panic!("missing canonical syntax entry for {mnemonic}"));
43
44 assert_eq!(
45 syntax.operands, operands,
46 "unexpected operands for canonical syntax entry {mnemonic}"
47 );
48 }
49 }
50}