1
0
dust/dust-lang/src/instruction/get_local.rs

32 lines
733 B
Rust
Raw Normal View History

use crate::{Destination, Instruction, Operation};
2024-11-26 07:14:30 -05:00
pub struct GetLocal {
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-26 07:14:30 -05:00
GetLocal {
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-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
}
}