1mod container;
2mod function;
3
4use crate::{
5 naive::{container::Container, function::Function},
6 sign::Sign,
7 vm::{Any, Array, IVm, Property, StaticCode, Unpacked},
8};
9
10#[derive(Clone)]
13pub struct Naive(Unpacked<Naive>);
14
15impl<T: Into<Unpacked<Naive>>> From<T> for Naive {
16 fn from(value: T) -> Self {
17 Naive(value.into())
18 }
19}
20
21impl IVm for Naive {
22 type InternalString = Container<(), u16>;
23 type InternalBigInt = Container<Sign, u64>;
24 type InternalObject = Container<(), Property<Naive>>;
25 type InternalArray = Container<(), Any<Naive>>;
26 type InternalFunction = Function;
27
28 fn to_unpacked(self) -> Unpacked<Self> {
29 self.0
30 }
31
32 fn with_unpacked<R>(&self, f: impl FnOnce(&Unpacked<Self>) -> R) -> R {
33 f(&self.0)
34 }
35
36 fn static_function(
38 code: StaticCode<Naive>,
39 length: u32,
40 frame: Array<Naive>,
41 text: Option<&'static str>,
42 ) -> crate::vm::Function<Naive> {
43 crate::vm::Function::new(Function::new(code, length, frame, text))
44 }
45
46 fn frame(self_: &Function) -> &Array<Naive> {
47 self_.frame()
48 }
49}