1
0

30 lines
692 B
Rust
Raw Normal View History

2024-11-26 07:14:30 -05:00
use crate::{Argument, Instruction, Operation};
pub struct Test {
pub argument: Argument,
2024-11-28 05:36:10 -05:00
pub test_value: bool,
2024-11-26 07:14:30 -05:00
}
impl From<&Instruction> for Test {
fn from(instruction: &Instruction) -> Self {
2024-12-08 08:01:15 -05:00
let argument = instruction.b_as_argument();
let test_value = instruction.c != 0;
2024-11-26 07:14:30 -05:00
Test {
2024-12-08 08:01:15 -05:00
argument,
test_value,
2024-11-26 07:14:30 -05:00
}
}
}
impl From<Test> for Instruction {
fn from(test: Test) -> Self {
let a = 0;
2024-12-08 08:01:15 -05:00
let (b, options) = test.argument.as_index_and_b_options();
let c = test.test_value as u8;
let metadata = Operation::Test as u8 | options.bits();
2024-12-08 08:01:15 -05:00
Instruction { metadata, a, b, c }
2024-11-26 07:14:30 -05:00
}
}