1#[non_exhaustive]
6#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
7pub enum Profile {
8 LuauCompat,
10 #[default]
12 ReproducibleStandard,
13 DeterministicSim,
15 Puc51Compat,
17}
18
19impl Profile {
20 pub const fn is_deterministic_sim(self) -> bool {
21 matches!(self, Self::DeterministicSim)
22 }
23
24 pub const fn is_luau_compat(self) -> bool {
25 matches!(self, Self::LuauCompat)
26 }
27
28 pub const fn is_puc51_compat(self) -> bool {
29 matches!(self, Self::Puc51Compat)
30 }
31
32 pub(crate) const fn to_core(self) -> rustia_vm::Profile {
33 match self {
34 Self::LuauCompat => rustia_vm::Profile::LuauCompat,
35 Self::ReproducibleStandard => rustia_vm::Profile::ReproducibleStandard,
36 Self::DeterministicSim => rustia_vm::Profile::DeterministicSim,
37 Self::Puc51Compat => rustia_vm::Profile::Puc51Compat,
38 }
39 }
40
41 pub(crate) const fn from_core(profile: rustia_vm::Profile) -> Self {
42 match profile {
43 rustia_vm::Profile::LuauCompat => Self::LuauCompat,
44 rustia_vm::Profile::ReproducibleStandard => Self::ReproducibleStandard,
45 rustia_vm::Profile::DeterministicSim => Self::DeterministicSim,
46 rustia_vm::Profile::Puc51Compat => Self::Puc51Compat,
47 }
48 }
49}
50
51#[non_exhaustive]
53#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
54pub enum GuestSurface {
55 #[default]
57 Standard,
58 HardenedLeaf,
60}
61
62impl GuestSurface {
63 pub const fn is_hardened_leaf(self) -> bool {
64 matches!(self, Self::HardenedLeaf)
65 }
66
67 pub(crate) const fn to_core(self) -> rustia_vm::GuestSurface {
68 match self {
69 Self::Standard => rustia_vm::GuestSurface::Standard,
70 Self::HardenedLeaf => rustia_vm::GuestSurface::HardenedLeaf,
71 }
72 }
73
74 pub(crate) const fn from_core(surface: rustia_vm::GuestSurface) -> Self {
75 match surface {
76 rustia_vm::GuestSurface::Standard => Self::Standard,
77 rustia_vm::GuestSurface::HardenedLeaf => Self::HardenedLeaf,
78 }
79 }
80}
81
82#[non_exhaustive]
87#[derive(Clone, Copy, Debug, Eq, PartialEq)]
88pub enum OpCapability {
89 Pure,
90 ReadsDeterministicInput,
91 ReadsSlotState,
92 EmitsDeterministicEffect,
93 WritesSlotEffect,
94 ReadsExternalMutableState,
95 NondeterministicEffect,
96}
97
98impl OpCapability {
99 pub const fn identity_tag(self) -> u32 {
101 match self {
102 Self::Pure => 1,
103 Self::ReadsDeterministicInput => 2,
104 Self::ReadsSlotState => 3,
105 Self::EmitsDeterministicEffect => 4,
106 Self::WritesSlotEffect => 5,
107 Self::ReadsExternalMutableState => 6,
108 Self::NondeterministicEffect => 7,
109 }
110 }
111
112 pub(crate) const fn to_core(self) -> rustia_vm::OpCapability {
113 match self {
114 Self::Pure => rustia_vm::OpCapability::Pure,
115 Self::ReadsDeterministicInput => rustia_vm::OpCapability::ReadsDeterministicInput,
116 Self::ReadsSlotState => rustia_vm::OpCapability::ReadsSlotState,
117 Self::EmitsDeterministicEffect => rustia_vm::OpCapability::EmitsDeterministicEffect,
118 Self::WritesSlotEffect => rustia_vm::OpCapability::WritesSlotEffect,
119 Self::ReadsExternalMutableState => rustia_vm::OpCapability::ReadsExternalMutableState,
120 Self::NondeterministicEffect => rustia_vm::OpCapability::NondeterministicEffect,
121 }
122 }
123
124 pub(crate) const fn from_core(capability: rustia_vm::OpCapability) -> Self {
125 match capability {
126 rustia_vm::OpCapability::Pure => Self::Pure,
127 rustia_vm::OpCapability::ReadsDeterministicInput => Self::ReadsDeterministicInput,
128 rustia_vm::OpCapability::ReadsSlotState => Self::ReadsSlotState,
129 rustia_vm::OpCapability::EmitsDeterministicEffect => Self::EmitsDeterministicEffect,
130 rustia_vm::OpCapability::WritesSlotEffect => Self::WritesSlotEffect,
131 rustia_vm::OpCapability::ReadsExternalMutableState => Self::ReadsExternalMutableState,
132 rustia_vm::OpCapability::NondeterministicEffect => Self::NondeterministicEffect,
133 }
134 }
135}