1use std::cmp::Ordering;
25
26use aluvm::LibSite;
27use amplify::confinement::ConfinedBlob;
28use strict_types::{SemId, StrictDumb, StrictVal, TypeSystem};
29use ultrasonic::{StateData, StateValue};
30
31use crate::api::TOTAL_BYTES;
32use crate::{
33 ApiVm, StateAdaptor, StateArithm, StateAtom, StateCalc, StateCalcError, StateName, StateReader, VmType,
34 LIB_NAME_SONIC,
35};
36
37impl ApiVm for aluvm::Vm {
38 type Arithm = AluVMArithm;
39 type Reader = AluReader;
40 type Adaptor = AluAdaptor;
41
42 fn vm_type(&self) -> VmType { VmType::AluVM }
43}
44
45#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
46#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
47#[strict_type(lib = LIB_NAME_SONIC)]
48#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(transparent))]
49pub struct AluReader(LibSite);
50
51impl StateReader for AluReader {
52 fn read<'s, I: IntoIterator<Item = &'s StateAtom>>(&self, state: impl Fn(&StateName) -> I) -> StrictVal { todo!() }
53}
54
55#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
56#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
57#[strict_type(lib = LIB_NAME_SONIC)]
58#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
59pub struct AluAdaptor {
60 pub converter: LibSite,
61 pub builder: LibSite,
62}
63
64impl StateAdaptor for AluAdaptor {
65 fn convert_immutable(
66 &self,
67 sem_id: SemId,
68 raw_sem_id: SemId,
69 data: &StateData,
70 sys: &TypeSystem,
71 ) -> Option<StateAtom> {
72 todo!()
73 }
74
75 fn convert_destructible(&self, sem_id: SemId, value: StateValue, sys: &TypeSystem) -> Option<StrictVal> { todo!() }
76
77 fn build_immutable(&self, value: ConfinedBlob<0, TOTAL_BYTES>) -> StateValue { todo!() }
78
79 fn build_destructible(&self, value: ConfinedBlob<0, TOTAL_BYTES>) -> StateValue { todo!() }
80}
81
82#[derive(Clone, Debug)]
83#[derive(StrictType, StrictEncode, StrictDecode)]
84#[strict_type(lib = LIB_NAME_SONIC)]
85#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
86pub struct AluVMArithm {
87 #[strict_type(skip)]
88 #[cfg_attr(feature = "serde", serde(skip))]
89 pub vm: Option<aluvm::Vm>,
90 pub accumulate: LibSite,
91 pub lessen: LibSite,
92 pub diff: LibSite,
93}
94
95impl StrictDumb for AluVMArithm {
96 fn strict_dumb() -> Self {
97 Self {
98 vm: None,
99 accumulate: LibSite::strict_dumb(),
100 lessen: LibSite::strict_dumb(),
101 diff: LibSite::strict_dumb(),
102 }
103 }
104}
105
106impl StateArithm for AluVMArithm {
107 fn calculator(&self) -> Box<dyn StateCalc> { todo!() }
108}
109
110impl StateCalc for () {
111 fn compare(&self, a: &StrictVal, b: &StrictVal) -> Option<Ordering> { todo!() }
112
113 fn accumulate(&mut self, state: &StrictVal) -> Result<(), StateCalcError> { Err(StateCalcError::UncountableState) }
114
115 fn lessen(&mut self, state: &StrictVal) -> Result<(), StateCalcError> { Err(StateCalcError::UncountableState) }
116
117 fn diff(&self) -> Result<Vec<StrictVal>, StateCalcError> { Err(StateCalcError::UncountableState) }
118
119 fn is_satisfied(&self, state: &StrictVal) -> bool { todo!() }
120}