Skip to main content

luau_vm/
internal.rs

1//! Unstable, representation-level VM access.
2//!
3//! This module is the Rust equivalent of opting into Luau's private VM
4//! headers. Its layouts and operations are coupled to this implementation and
5//! targeted Luau release; they are not part of the supported embedding API.
6//!
7//! Transparent handles are non-owning identities. They carry neither a VM
8//! lifetime nor a GC root, and copying one does not copy ownership or create a
9//! borrow. Constructing a handle requires the correct address, layout, type
10//! tag, owning VM, and live allocation. Any operation that can collect,
11//! resize, relocate, close, or free VM storage may invalidate handles,
12//! cursors, record views, and pointers. Dereferencing any exposed pointer is
13//! the caller's unsafe operation.
14//!
15//! Public layout fields support source-required inspection and mutation. They
16//! do not authorize arbitrary construction of VM state or new GC object kinds.
17
18pub use crate::handle::RawHandle;
19
20pub mod api {
21    pub use crate::thread::stack::RawStackAccess;
22}
23
24pub mod buffer {
25    pub use crate::buffer::{Buffer, BufferRuntime, MAX_BUFFER_SIZE, RawBuffer};
26}
27
28pub mod builtins {
29    pub use crate::builtins::{LUAU_F_TABLE, LuauFastFunction};
30}
31
32pub mod call {
33    pub use crate::call::{
34        CallRuntime, ErrorRuntime, LuaProtectedErrorFrame, Pfunc, ProtectedCall, ThreadStack,
35    };
36}
37
38pub mod class {
39    pub use crate::class::{
40        Class, ClassRuntime, Object, ObjectMemberLookup, RawLuauClass, RawLuauObject,
41    };
42}
43
44pub mod debug {
45    pub use crate::debug::DebugRuntime;
46}
47
48pub mod function {
49    pub use crate::function::{
50        Closure, FeedbackVectorSlot, FeedbackVectorSlotCallTarget, FeedbackVectorSlotData,
51        FunctionRuntime, LocVar, Proto, RawClosure, RawLocVar, RawLuaClosure, RawNativeClosure,
52        RawProto, RawUpVal, RawUpValData, RawUpValOpen, UpVal, UpValOpen,
53    };
54}
55
56pub mod gc {
57    pub use crate::gc::{
58        BLACK_BIT, FIXED_BIT, GCS_ATOMIC, GCS_PAUSE, GCS_PROPAGATE, GCS_PROPAGATE_AGAIN, GCS_SWEEP,
59        GcBarrier, GcCategoryNamer, GcCycleMetrics, GcHeapEdge, GcHeapNode, GcHeapVisitor,
60        GcMetrics, GcObject, GcRuntime, GcStats, RawGcObject, WHITE_BITS, WHITE0_BIT, WHITE1_BIT,
61        bit_mask,
62    };
63}
64
65pub mod layout {
66    pub use crate::layout::Align8Byte;
67}
68
69pub mod memory {
70    pub use crate::memory::{
71        GCO_LINK_OFFSET, GcoPageWalk, LUA_PAGE_PADDING, LuaPage, MemoryRuntime, RawLuaPage,
72    };
73}
74
75pub mod metamethod {
76    pub use crate::metamethod::{MetamethodRuntime, TM_N, TmEvent};
77}
78
79pub mod number {
80    pub use crate::number::{
81        LUAI_MAXINT2STR, LUAI_MAXNUM2STR, clamp_f, int_to_str, lerp_f, num_to_str, sign_f,
82        str_to_long, str_to_num,
83    };
84}
85
86pub mod state {
87    pub use crate::state::{
88        BASIC_CI_SIZE, BASIC_STACK_SIZE, CallInfo, CallInfoCursor, EXTRA_STACK, EmbedderGc,
89        EmbedderMark, ExecutionCallbackStorage, ExecutionClose, ExecutionCounterData,
90        ExecutionDestroy, ExecutionDisable, ExecutionEnter, ExecutionInlineFunction,
91        ExecutionInterrupt, ExecutionMemorySize, ExecutionTypeMapping, GcInterrupt,
92        GcInterruptCallback, GcPhase, GlobalState, INITIAL_STACK_SIZE, InterruptKind,
93        InterruptRequest, LUA_BREAK, LUA_CALLINFO_HANDLE, LUA_CALLINFO_NATIVE,
94        LUA_CALLINFO_OP_YIELD, LUA_CALLINFO_RETURN, LUA_ERRERR, LUA_ERRMEM, LUA_ERRRUN,
95        LUA_ERRSYNTAX, LUA_OK, LUA_YIELD, LuaCallbacks, LuaExecutionCallbacks, PatternInterrupt,
96        ProtectedErrorAction, ProtectedErrorCallback, RawCallInfo, RawCallInfoSaved,
97        RawGlobalState, RawLuaState, RawMainState, ThreadLifecycle, ThreadState, UserAtomCallback,
98        UserThreadCallback,
99    };
100}
101
102pub mod string {
103    pub use crate::string::{
104        ATOM_UNDEFINED, MAX_STRING_SIZE, RawTString, StringFormatting, StringRuntime, StringTable,
105        TString, hash,
106    };
107}
108
109pub mod table {
110    pub use crate::table::{
111        LuaNode, LuaNodeCursor, RAW_LUA_NODE_DUMMY, RAW_TKEY_DEAD_KEY, RAW_TKEY_NIL, RawLuaNode,
112        RawLuaTable, RawLuaTableFree, RawTKey, TKey, Table, TableRuntime,
113    };
114}
115
116pub mod userdata {
117    pub use crate::userdata::{
118        LuaUserdataDirectAccessData, LuaUserdataMark, RawUserdata, TypedUserdata,
119        TypedUserdataAccess, TypedUserdataError, Userdata, UserdataRuntime,
120        UserdataTypeRegistration, UserdataTypeRegistryAccess,
121    };
122}
123
124pub mod value {
125    pub use crate::value::{
126        LUA_O_NIL_OBJECT, NilObject, RAW_TVALUE_NIL, RawTValue, RawValue, TValue, TValueCursor,
127        nil_object,
128    };
129}
130
131pub mod vm {
132    pub use crate::vm::{
133        PreCallResult, VmCallFrame, VmConversions, VmExecution, VmOperations, get_comp_tm,
134        string_compare,
135    };
136}