CommonLibSSE (Parapets fork)
Loading...
Searching...
No Matches
VirtualMachine.h
Go to the documentation of this file.
1#pragma once
2
4#include "RE/B/BSAtomic.h"
5#include "RE/B/BSTArray.h"
6#include "RE/B/BSTEvent.h"
7#include "RE/B/BSTFreeList.h"
8#include "RE/B/BSTHashMap.h"
17#include "RE/S/SuspendedStack.h"
18
19namespace RE
20{
21 namespace BSScript
22 {
23 class Array;
24 class ErrorLogger;
25 class IFreezeQuery;
26 class IProfilePolicy;
27 class ISavePatcherInterface;
28 class IStackCallbackFunctor;
29 class IStackCallbackSaveInterface;
30 class ObjectBindPolicy;
31 class Stack;
32 struct IMemoryPagePolicy;
33 struct IObjectHandlePolicy;
34 struct StatsEvent;
35
36 namespace Internal
37 {
38 class CodeTasklet;
39
41 public IVirtualMachine, // 0000
42 public IVMObjectBindInterface, // 0010
43 public IVMSaveLoadInterface, // 0018
44 public IVMDebugInterface, // 0020
45 public BSTEventSource<StatsEvent> // 0028
46 {
47 public:
48 inline static constexpr auto RTTI = RTTI_BSScript__Internal__VirtualMachine;
49
51 {
52 public:
53 // members
55 std::uint32_t refCount; // 08
56 std::uint32_t pad0C; // 0C
57 };
58 static_assert(sizeof(QueuedUnbindRefs) == 0x10);
59
60 ~VirtualMachine() override; // 00
61
62 // override (IVirtualMachine)
63 void SetLinkedCallback(ITypeLinkedCallback* a_callback) override; // 01
64 void TraceStack(const char* a_str, VMStackID a_stackID, Severity a_severity = Severity::kInfo) override; // 02
65 void Unk_03(void) override; // 03
66 void Update(float a_budget) override; // 04
67 void UpdateTasklets(float a_budget) override; // 05
68 void SetOverstressed(bool a_set) override; // 06 - { overstressed = a_set; }
69 bool IsCompletelyFrozen() const override; // 07
70 bool RegisterObjectType(VMTypeID a_typeID, const char* a_className) override; // 08
71 bool GetScriptObjectType1(const BSFixedString& a_className, BSTSmartPointer<ObjectTypeInfo>& a_outTypeInfoPtr) override; // 09
72 bool GetScriptObjectType2(VMTypeID a_typeID, BSTSmartPointer<ObjectTypeInfo>& a_outTypeInfoPtr) override; // 0A
73 bool GetScriptObjectTypeNoLoad1(const BSFixedString& a_className, BSTSmartPointer<ObjectTypeInfo>& a_typeInfoPtr) const override; // 0B
74 bool GetScriptObjectTypeNoLoad2(VMTypeID a_typeID, BSTSmartPointer<ObjectTypeInfo>& a_outTypeInfoPtr) const override; // 0C
75 bool GetTypeIDForScriptObject(const BSFixedString& a_className, VMTypeID& a_typeID) const override; // 0D
76 void GetScriptObjectsWithATypeID(BSScrapArray<BSFixedString>& a_results) const override; // 0E
77 bool GetParentNativeType(const BSFixedString& a_className, BSTSmartPointer<ObjectTypeInfo>& a_typeInfoPtr) override; // 0F
78 bool TypeIsValid(const BSFixedString& a_className) override; // 10
79 bool ReloadType(const char* a_className) override; // 11
80 void TasksToJobs(BSJobs::JobList& a_jobList) override; // 12
81 void CalculateFullReloadList(void) const override; // 13
82 bool CreateObject1(const BSFixedString& a_className, void* a_property, BSTSmartPointer<Object>& a_objPtr) override; // 14
83 bool CreateObject2(const BSFixedString& a_className, BSTSmartPointer<Object>& a_result) override; // 15
84 bool CreateArray1(const TypeInfo& a_typeInfo, std::uint32_t a_size, BSTSmartPointer<Array>& a_arrayPtr) override; // 16
85 bool CreateArray2(TypeInfo::RawType a_typeID, const BSFixedString& a_className, std::uint32_t a_size, BSTSmartPointer<Array>& a_arrayPtr) override; // 17
86 bool BindNativeMethod(IFunction* a_fn) override; // 18
87 void SetCallableFromTasklets1(const char* a_className, const char* a_stateName, const char* a_fnName, bool a_callable) override; // 19
88 void SetCallableFromTasklets2(const char* a_className, const char* a_fnName, bool a_callable) override; // 1A - { SetCallableFromTasklets1(a_className, 0, a_fnName, a_callable); }
89 void ForEachBoundObject(VMHandle a_handle, IForEachScriptObjectFunctor* a_functor) override; // 1B
90 bool FindBoundObject(VMHandle a_handle, const char* a_className, BSTSmartPointer<Object>& a_result) const override; // 1C
91 void MoveBoundObjects(VMHandle a_from, VMHandle a_to) override; // 1D
92 void ResetAllBoundObjects(VMHandle a_handle) override; // 1E
93 bool CastObject(const BSTSmartPointer<Object>& a_fromObjPtr, const BSTSmartPointer<ObjectTypeInfo>& a_toTypeInfoPtr, BSTSmartPointer<Object>& a_toObjPtr) override; // 1F
94 bool SetPropertyValue(BSTSmartPointer<Object>& a_obj, const char* a_propertyName, Variable& a_setVal) override; // 20
95 bool GetPropertyValue(BSTSmartPointer<Object>& a_obj, const char* a_propertyName, Variable& a_getVal) override; // 21
96 bool GetVariableValue1(const BSTSmartPointer<Object>& a_objPtr, std::uint32_t a_index, Variable& a_out) const override; // 22
97 bool GetVariableValue2(VMHandle a_handle, const BSFixedString& a_className, std::int32_t a_variableIndex, Variable& a_out) const override; // 23
98 void SendEvent(VMHandle a_handle, const BSFixedString& a_eventName, IFunctionArguments* a_args) override; // 24
99 void SendEventAll(const BSFixedString& a_eventName, IFunctionArguments* a_args) override; // 25
100 bool DispatchStaticCall(const BSFixedString& a_className, const BSFixedString& a_fnName, IFunctionArguments* a_args, BSTSmartPointer<IStackCallbackFunctor>& a_result) override; // 26
102 bool DispatchMethodCall2(VMHandle a_handle, const BSFixedString& a_className, const BSFixedString& a_fnName, IFunctionArguments* a_args, BSTSmartPointer<IStackCallbackFunctor>& a_result) override; // 28
103 bool DispatchUnboundMethodCall(void) override; // 29
104 bool IsWaitingOnLatent(VMStackID a_stackID) const override; // 2A
105 void ReturnFromLatent(VMStackID a_stackID, const Variable& a_val) override; // 2B
106 ErrorLogger* GetErrorLogger() override; // 2C - { return errorLogger; }
107 IObjectHandlePolicy* GetObjectHandlePolicy1() override; // 2D - { return handlePolicy; }
108 const IObjectHandlePolicy* GetObjectHandlePolicy2() const override; // 2E - { return handlePolicy; }
109 ObjectBindPolicy* GetObjectBindPolicy1() override; // 2F - { return objectBindPolicy; }
110 const ObjectBindPolicy* GetObjectBindPolicy2() const override; // 30 - { return objectBindPolicy; }
111 ISavePatcherInterface* GetSavePatcherInterface() override; // 31 - { return savePatcherInterface; }
112 void RegisterForLogEvent(BSTEventSink<LogEvent>* a_sink) override; // 32
113 void UnregisterForLogEvent(BSTEventSink<LogEvent>* a_sink) override; // 33
116
117 // override (IVMObjectBindInterface)
118 VMHandle GetBoundHandle(const BSTSmartPointer<Object>& a_objPtr) const override; // 01
119 bool TypeCanBeBound(const BSFixedString& a_className, VMHandle a_handle) override; // 02
120 void BindObject(BSTSmartPointer<Object>& a_objPtr, VMHandle a_handle, bool a_conditional) override; // 03
121 void HandleLoadedBinding(BSTSmartPointer<Object>& a_objPtr, VMHandle a_handle, bool a_conditional) override; // 04
122 void RemoveAllBoundObjects(VMHandle a_handle) override; // 05
123 void RemoveAllDiskLoadedBoundObjects(VMHandle a_handle) override; // 06
124 void HandleCObjectDeletion(VMHandle a_handle) override; // 07
125 void UnbindObject(const BSTSmartPointer<Object>& a_objPtr) override; // 08
126 bool CreateObjectWithProperties(const BSFixedString& a_className, std::uint32_t a_numProperties, BSTSmartPointer<Object>& a_objPtr) override; // 09
127 bool InitObjectProperties(BSTSmartPointer<Object>& a_objPtr, void* a_property, bool a_arg3) override; // 0A
128
130
131 // members
140 mutable BSSpinLock typeInfoLock; // 00C0
146 mutable BSSpinLock funcQueueLock; // 0200
151 std::uint32_t uiWaitingFunctionMessages; // 8278
152 bool overstressed; // 827C
153 bool initialized; // 827D
154 std::uint16_t pad827E; // 827E
161 BSTArray<SuspendedStack>* stacksToResumeOverflow; // 9300 - ref to overflowSuspendArray2
163 BSTArray<SuspendedStack>* stacksToSuspendOverflow; // 9310 - ref to overflowSuspendArray1
169 std::uint32_t unk938C; // 938C
170 std::uint64_t unk9390; // 9390
171 std::uint64_t unk9398; // 9398
174 std::uint64_t unk93D8; // 93D8
176 mutable BSSpinLock arraysLock; // 93F8
177 std::uint32_t nextArrayToClean; // 9400
178 std::uint32_t pad9404; // 9404
182 std::uint64_t unk9440; // 9440
187 std::uint64_t unk94C8; // 94C8
188 std::uint64_t unk94D0; // 94D0
189 std::uint64_t unk94D8; // 94D8
190 std::uint64_t unk94E0; // 94E0
191 std::uint64_t unk94E8; // 94E8
192 std::uint64_t unk94F0; // 94F0
193 std::uint64_t unk94F8; // 94F8
194 std::uint64_t unk9500; // 9500
195 std::uint64_t unk9508; // 9508
196 std::uint64_t unk9518; // 9510
197 };
198 static_assert(sizeof(VirtualMachine) == 0x9518);
199 }
200 }
201}
Definition: ErrorLogger.h:13
Severity
Definition: ErrorLogger.h:18
Definition: IFreezeQuery.h:8
Definition: IFunctionArguments.h:12
Definition: IFunction.h:23
Definition: IProfilePolicy.h:18
Definition: ISavePatcherInterface.h:11
Definition: IStackCallbackSaveInterface.h:8
Definition: IVMDebugInterface.h:8
Definition: IVMSaveLoadInterface.h:8
Definition: IVirtualMachine.h:39
Definition: VirtualMachine.h:46
void SendEvent(VMHandle a_handle, const BSFixedString &a_eventName, IFunctionArguments *a_args) override
bool InitObjectProperties(BSTSmartPointer< Object > &a_objPtr, void *a_property, bool a_arg3) override
std::uint16_t pad827E
Definition: VirtualMachine.h:154
bool GetScriptObjectType2(VMTypeID a_typeID, BSTSmartPointer< ObjectTypeInfo > &a_outTypeInfoPtr) override
void RegisterForStatsEvent(BSTEventSink< StatsEvent > *a_sink) override
bool IsCompletelyFrozen() const override
std::uint64_t unk94F8
Definition: VirtualMachine.h:193
ISavePatcherInterface * GetSavePatcherInterface() override
void RemoveAllDiskLoadedBoundObjects(VMHandle a_handle) override
bool GetParentNativeType(const BSFixedString &a_className, BSTSmartPointer< ObjectTypeInfo > &a_typeInfoPtr) override
void BindObject(BSTSmartPointer< Object > &a_objPtr, VMHandle a_handle, bool a_conditional) override
std::uint64_t unk94E8
Definition: VirtualMachine.h:191
void TasksToJobs(BSJobs::JobList &a_jobList) override
ISavePatcherInterface * savePatcherInterface
Definition: VirtualMachine.h:139
void Update(float a_budget) override
BSTCommonLLMessageQueue< FunctionMessage > funcMsgQueue
Definition: VirtualMachine.h:148
bool ReloadType(const char *a_className) override
BSSpinLock attachedScriptsLock
Definition: VirtualMachine.h:172
BSTArray< SuspendedStack > overflowSuspendArray2
Definition: VirtualMachine.h:158
void SetCallableFromTasklets1(const char *a_className, const char *a_stateName, const char *a_fnName, bool a_callable) override
std::uint64_t unk93D8
Definition: VirtualMachine.h:174
std::uint32_t pad9404
Definition: VirtualMachine.h:178
bool initialized
Definition: VirtualMachine.h:153
BSSpinLock typeInfoLock
Definition: VirtualMachine.h:140
ObjectBindPolicy * objectBindPolicy
Definition: VirtualMachine.h:135
std::uint64_t unk94C8
Definition: VirtualMachine.h:187
void UnregisterForStatsEvent(BSTEventSink< StatsEvent > *a_sink) override
std::uint64_t unk9398
Definition: VirtualMachine.h:171
void SetOverstressed(bool a_set) override
BSTArray< FunctionMessage > overflowFuncMsgs
Definition: VirtualMachine.h:149
bool GetScriptObjectTypeNoLoad1(const BSFixedString &a_className, BSTSmartPointer< ObjectTypeInfo > &a_typeInfoPtr) const override
BSTArray< BSTSmartPointer< ObjectTypeInfo > > typesToUnload
Definition: VirtualMachine.h:145
std::uint64_t unk94F0
Definition: VirtualMachine.h:192
bool DispatchMethodCall1(BSTSmartPointer< Object > &a_obj, const BSFixedString &a_fnName, IFunctionArguments *a_args, BSTSmartPointer< IStackCallbackFunctor > &a_result) override
BSSpinLock frozenStacksLock
Definition: VirtualMachine.h:168
void CalculateFullReloadList(void) const override
BSSpinLock suspendQueueLock
Definition: VirtualMachine.h:159
BSTArray< QueuedUnbindRefs > queuedUnbinds
Definition: VirtualMachine.h:186
void UnregisterForLogEvent(BSTEventSink< LogEvent > *a_sink) override
bool overstressed
Definition: VirtualMachine.h:152
ObjectBindPolicy * GetObjectBindPolicy1() override
BSTHashMap< VMTypeID, BSFixedString > typeIDToObjectType
Definition: VirtualMachine.h:143
IFreezeQuery * freezeQuery
Definition: VirtualMachine.h:136
void ForEachBoundObject(VMHandle a_handle, IForEachScriptObjectFunctor *a_functor) override
bool CreateObject1(const BSFixedString &a_className, void *a_property, BSTSmartPointer< Object > &a_objPtr) override
VMStackID nextStackID
Definition: VirtualMachine.h:167
void RemoveAllBoundObjects(VMHandle a_handle) override
std::uint32_t unk938C
Definition: VirtualMachine.h:169
void TraceStack(const char *a_str, VMStackID a_stackID, Severity a_severity=Severity::kInfo) override
bool CreateArray2(TypeInfo::RawType a_typeID, const BSFixedString &a_className, std::uint32_t a_size, BSTSmartPointer< Array > &a_arrayPtr) override
BSSpinLock runningStacksLock
Definition: VirtualMachine.h:164
bool GetScriptObjectType1(const BSFixedString &a_className, BSTSmartPointer< ObjectTypeInfo > &a_outTypeInfoPtr) override
IObjectHandlePolicy * handlePolicy
Definition: VirtualMachine.h:134
bool GetVariableValue1(const BSTSmartPointer< Object > &a_objPtr, std::uint32_t a_index, Variable &a_out) const override
BSTHashMap< UnkKey, UnkValue > unk9478
Definition: VirtualMachine.h:184
static VirtualMachine * GetSingleton()
BSTHashMap< BSFixedString, BSTSmartPointer< ObjectTypeInfo > > objectTypeMap
Definition: VirtualMachine.h:142
void SetLinkedCallback(ITypeLinkedCallback *a_callback) override
BSTCommonStaticMessageQueue< SuspendedStack, 128 > * stacksToSuspend
Definition: VirtualMachine.h:162
std::uint64_t unk94E0
Definition: VirtualMachine.h:190
BSTArray< SuspendedStack > * stacksToSuspendOverflow
Definition: VirtualMachine.h:163
IObjectHandlePolicy * GetObjectHandlePolicy1() override
void SendEventAll(const BSFixedString &a_eventName, IFunctionArguments *a_args) override
std::uint64_t unk9500
Definition: VirtualMachine.h:194
bool BindNativeMethod(IFunction *a_fn) override
IStackCallbackSaveInterface * stackCallbackSaveInterface
Definition: VirtualMachine.h:137
bool GetPropertyValue(BSTSmartPointer< Object > &a_obj, const char *a_propertyName, Variable &a_getVal) override
BSTHashMap< VMStackID, BSTSmartPointer< Stack > > waitingLatentReturns
Definition: VirtualMachine.h:166
BSTArray< SuspendedStack > overflowSuspendArray1
Definition: VirtualMachine.h:157
bool DispatchUnboundMethodCall(void) override
void HandleLoadedBinding(BSTSmartPointer< Object > &a_objPtr, VMHandle a_handle, bool a_conditional) override
BSSpinLock funcQueueLock
Definition: VirtualMachine.h:146
std::uint64_t unk9390
Definition: VirtualMachine.h:170
ErrorLogger * errorLogger
Definition: VirtualMachine.h:132
BSSpinLock objectResetLock
Definition: VirtualMachine.h:180
void HandleCObjectDeletion(VMHandle a_handle) override
bool FindBoundObject(VMHandle a_handle, const char *a_className, BSTSmartPointer< Object > &a_result) const override
bool TypeIsValid(const BSFixedString &a_className) override
std::uint64_t unk94D0
Definition: VirtualMachine.h:188
bool DispatchMethodCall2(VMHandle a_handle, const BSFixedString &a_className, const BSFixedString &a_fnName, IFunctionArguments *a_args, BSTSmartPointer< IStackCallbackFunctor > &a_result) override
bool CreateArray1(const TypeInfo &a_typeInfo, std::uint32_t a_size, BSTSmartPointer< Array > &a_arrayPtr) override
BSTArray< void * > unk93E0
Definition: VirtualMachine.h:175
BSTCommonStaticMessageQueue< SuspendedStack, 128 > * stacksToResume
Definition: VirtualMachine.h:160
BSSpinLock queuedUnbindLock
Definition: VirtualMachine.h:185
void MoveBoundObjects(VMHandle a_from, VMHandle a_to) override
void UpdateTasklets(float a_budget) override
void SetCallableFromTasklets2(const char *a_className, const char *a_fnName, bool a_callable) override
BSTCommonStaticMessageQueue< SuspendedStack, 128 > suspendQueue1
Definition: VirtualMachine.h:155
const ObjectBindPolicy * GetObjectBindPolicy2() const override
bool RegisterObjectType(VMTypeID a_typeID, const char *a_className) override
BSTHashMap< VMStackID, BSTSmartPointer< Stack > > allRunningStacks
Definition: VirtualMachine.h:165
LinkerProcessor linker
Definition: VirtualMachine.h:141
BSTArray< BSTSmartPointer< Array > > arrays
Definition: VirtualMachine.h:179
bool DispatchStaticCall(const BSFixedString &a_className, const BSFixedString &a_fnName, IFunctionArguments *a_args, BSTSmartPointer< IStackCallbackFunctor > &a_result) override
bool TypeCanBeBound(const BSFixedString &a_className, VMHandle a_handle) override
BSTArray< BSTSmartPointer< Object > > objectsAwaitingReset
Definition: VirtualMachine.h:181
void RegisterForLogEvent(BSTEventSink< LogEvent > *a_sink) override
VMHandle GetBoundHandle(const BSTSmartPointer< Object > &a_objPtr) const override
IProfilePolicy * profilePolicy
Definition: VirtualMachine.h:138
bool SetPropertyValue(BSTSmartPointer< Object > &a_obj, const char *a_propertyName, Variable &a_setVal) override
bool IsWaitingOnLatent(VMStackID a_stackID) const override
bool CreateObject2(const BSFixedString &a_className, BSTSmartPointer< Object > &a_result) override
std::uint32_t nextArrayToClean
Definition: VirtualMachine.h:177
bool GetScriptObjectTypeNoLoad2(VMTypeID a_typeID, BSTSmartPointer< ObjectTypeInfo > &a_outTypeInfoPtr) const override
BSTArray< CodeTasklet * > vmTasks
Definition: VirtualMachine.h:150
std::uint64_t unk9508
Definition: VirtualMachine.h:195
IMemoryPagePolicy * memoryPagePolicy
Definition: VirtualMachine.h:133
void ResetAllBoundObjects(VMHandle a_handle) override
BSTHashMap< UnkKey, UnkValue > unk9448
Definition: VirtualMachine.h:183
BSTHashMap< BSFixedString, VMTypeID > objectTypeToTypeID
Definition: VirtualMachine.h:144
void GetScriptObjectsWithATypeID(BSScrapArray< BSFixedString > &a_results) const override
const IObjectHandlePolicy * GetObjectHandlePolicy2() const override
BSTArray< SuspendedStack > * stacksToResumeOverflow
Definition: VirtualMachine.h:161
ErrorLogger * GetErrorLogger() override
bool CastObject(const BSTSmartPointer< Object > &a_fromObjPtr, const BSTSmartPointer< ObjectTypeInfo > &a_toTypeInfoPtr, BSTSmartPointer< Object > &a_toObjPtr) override
std::uint32_t uiWaitingFunctionMessages
Definition: VirtualMachine.h:151
BSSpinLock arraysLock
Definition: VirtualMachine.h:176
bool GetTypeIDForScriptObject(const BSFixedString &a_className, VMTypeID &a_typeID) const override
BSTCommonStaticMessageQueue< SuspendedStack, 128 > suspendQueue2
Definition: VirtualMachine.h:156
void UnbindObject(const BSTSmartPointer< Object > &a_objPtr) override
std::uint64_t unk94D8
Definition: VirtualMachine.h:189
static constexpr auto RTTI
Definition: VirtualMachine.h:48
bool CreateObjectWithProperties(const BSFixedString &a_className, std::uint32_t a_numProperties, BSTSmartPointer< Object > &a_objPtr) override
BSTHashMap< VMHandle, BSTSmallSharedArray< AttachedScript > > attachedScripts
Definition: VirtualMachine.h:173
std::uint64_t unk9518
Definition: VirtualMachine.h:196
void ReturnFromLatent(VMStackID a_stackID, const Variable &a_val) override
bool GetVariableValue2(VMHandle a_handle, const BSFixedString &a_className, std::int32_t a_variableIndex, Variable &a_out) const override
std::uint64_t unk9440
Definition: VirtualMachine.h:182
BSTStaticFreeList< FunctionMessage, 1024 > funcMsgPool
Definition: VirtualMachine.h:147
Definition: LinkerProcessor.h:18
Definition: BSScriptObjectBindPolicy.h:16
Definition: TypeInfo.h:10
RawType
Definition: TypeInfo.h:13
Definition: Variable.h:15
Definition: BSAtomic.h:49
Definition: BSTArray.h:377
Definition: BSTMessageQueue.h:63
Definition: BSTMessageQueue.h:81
Definition: BSTEvent.h:146
Definition: BSTEvent.h:28
Definition: BSTHashMap.h:21
Definition: BSTSmartPointer.h:37
Definition: BSTFreeList.h:28
Definition: AbsorbEffect.h:6
std::uint32_t VMTypeID
Definition: BSCoreTypes.h:9
std::uint32_t VMStackID
Definition: BSCoreTypes.h:8
std::uint64_t VMHandle
Definition: BSCoreTypes.h:7
constexpr REL::ID RTTI_BSScript__Internal__VirtualMachine
Definition: Offsets_RTTI.h:2200
Definition: IMemoryPagePolicy.h:8
Definition: IObjectHandlePolicy.h:13
Definition: IVMObjectBindInterface.h:13
BSTSmartPointer< Object > obj
Definition: VirtualMachine.h:54
std::uint32_t pad0C
Definition: VirtualMachine.h:56
std::uint32_t refCount
Definition: VirtualMachine.h:55