1
0

29 lines
701 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_field() != 0;
2024-12-08 08:01:15 -05:00
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 operation = Operation::Test;
let (b, b_is_constant) = test.argument.as_index_and_constant_flag();
let c = test.test_value as u8;
2024-12-08 08:01:15 -05:00
Instruction::new(operation, 0, b, c, b_is_constant, false, false)
2024-11-26 07:14:30 -05:00
}
}