aboutsummaryrefslogtreecommitdiff
path: root/patio-to-cranelift/src/patio/flatbuffers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'patio-to-cranelift/src/patio/flatbuffers.rs')
-rw-r--r--patio-to-cranelift/src/patio/flatbuffers.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/patio-to-cranelift/src/patio/flatbuffers.rs b/patio-to-cranelift/src/patio/flatbuffers.rs
index ad667963..69720b19 100644
--- a/patio-to-cranelift/src/patio/flatbuffers.rs
+++ b/patio-to-cranelift/src/patio/flatbuffers.rs
@@ -9,7 +9,8 @@ use crate::{
PatioBlock, PatioBoolToInt, PatioCall, PatioCallPointer, PatioDataPtrToInt, PatioIf,
PatioInstruction, PatioIntAdd, PatioIntEquals, PatioIntNotEqual, PatioIntSub,
PatioIntToBool, PatioIntToDataPtr, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore,
- PatioResume, PatioReturn, PatioReturnVoid, PatioVarLoad, PatioVarStore,
+ PatioResume, PatioReturn, PatioReturnVoid, PatioSwitch, PatioSwitchCase, PatioVarLoad,
+ PatioVarStore,
},
operands::{PatioLocalRef, PatioOperand},
types::{PatioDataLayout, PatioType},
@@ -303,6 +304,17 @@ impl From<patio_generated::patio::PatioInstruction<'_>> for PatioInstruction {
Self::ReturnVoid(PatioReturnVoid)
}
+ patio_generated::patio::PatioInstructionValue::PatioSwitch => {
+ let switch = value.value_as_patio_switch().unwrap();
+
+ Self::Switch(PatioSwitch {
+ destinations: switch.destinations().iter().map(Into::into).collect(),
+ value: switch.value().into(),
+ cases: switch.cases().iter().map(Into::into).collect(),
+ default_body: switch.default_body().into(),
+ })
+ }
+
patio_generated::patio::PatioInstructionValue::PatioVarLoad => {
let var_load = value.value_as_patio_var_load().unwrap();
@@ -339,6 +351,15 @@ impl From<patio_generated::patio::PatioBlock<'_>> for PatioBlock {
}
}
+impl From<patio_generated::patio::PatioSwitchCase<'_>> for PatioSwitchCase {
+ fn from(value: patio_generated::patio::PatioSwitchCase<'_>) -> Self {
+ Self {
+ value: value.value(),
+ body: value.body().into(),
+ }
+ }
+}
+
// == Operands ==
impl From<patio_generated::patio::PatioOperand<'_>> for PatioOperand {