datex_core/instruction/
bytecode_item.rs1use crate::instruction::{
4 Instruction, regular_instruction::RegularInstruction,
5 type_instruction::TypeInstruction,
6};
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub struct Label(pub u32);
10
11#[derive(Debug, Clone, PartialEq)]
12pub enum BytecodeItem {
13 Instruction(Instruction),
14 Label(Label),
15 Jump { target: Label },
16 JumpIfFalse { target: Label, condition_end: Label },
17}
18impl From<Instruction> for BytecodeItem {
19 fn from(instruction: Instruction) -> Self {
20 Self::Instruction(instruction)
21 }
22}
23impl From<RegularInstruction> for BytecodeItem {
24 fn from(instruction: RegularInstruction) -> Self {
25 Self::Instruction(Instruction::Regular(instruction))
26 }
27}
28
29impl From<TypeInstruction> for BytecodeItem {
30 fn from(instruction: TypeInstruction) -> Self {
31 Self::Instruction(Instruction::Type(instruction))
32 }
33}