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