2024-11-28 01:10:49 -05:00
|
|
|
use crate::{Destination, Instruction, Operation};
|
2024-11-26 07:14:30 -05:00
|
|
|
|
|
|
|
pub struct GetLocal {
|
2024-11-28 01:10:49 -05:00
|
|
|
pub destination: Destination,
|
2024-11-26 07:14:30 -05:00
|
|
|
pub local_index: u16,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<&Instruction> for GetLocal {
|
|
|
|
fn from(instruction: &Instruction) -> Self {
|
2024-12-08 08:01:15 -05:00
|
|
|
let destination = instruction.a_as_destination();
|
2024-11-28 01:10:49 -05:00
|
|
|
|
2024-11-26 07:14:30 -05:00
|
|
|
GetLocal {
|
2024-11-28 01:10:49 -05:00
|
|
|
destination,
|
2024-12-08 08:01:15 -05:00
|
|
|
local_index: instruction.b,
|
2024-11-26 07:14:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<GetLocal> for Instruction {
|
|
|
|
fn from(get_local: GetLocal) -> Self {
|
2024-12-08 08:01:15 -05:00
|
|
|
let (a, a_options) = get_local.destination.as_index_and_a_options();
|
2024-11-28 01:10:49 -05:00
|
|
|
|
2024-12-08 08:01:15 -05:00
|
|
|
Instruction {
|
|
|
|
operation: Operation::GET_LOCAL,
|
|
|
|
options: a_options,
|
|
|
|
a,
|
|
|
|
b: get_local.local_index,
|
|
|
|
c: 0,
|
|
|
|
}
|
2024-11-26 07:14:30 -05:00
|
|
|
}
|
|
|
|
}
|