CommonLibSSE (powerof3)
UnlinkedTypes.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSFixedString.h"
4 #include "RE/B/BSTArray.h"
5 #include "RE/B/BSTHashMap.h"
6 #include "RE/L/LinkerProcessor.h"
7 #include "RE/T/TypeInfo.h"
8 #include "RE/V/VirtualMachine.h"
9 
10 namespace RE
11 {
12  namespace BSScript
13  {
14  namespace ByteCode
15  {
16 #pragma pack(push, 4)
17  struct Argument
18  {
19  enum class Type : std::uint32_t
20  {
21  kNone,
22  kIdentifier, // Identifier of object variables (Forms, Actors, etc.)
23  kString,
24  kInt,
25  kFloat,
26  kBool,
27  kLocalVarIdx, // index of local variable in function
28  kMemberVarIdx, // index of member variable in script instance
29  };
30  static_assert(sizeof(Type) == 0x4);
31 
32  union Value
33  {
34  int i;
35  float f;
36  bool b;
37  std::uint32_t idx;
39 
40  ~Value(){};
41  };
42  static_assert(sizeof(Value) == 0x8);
43 
45  {
48  }
49  };
50  // members
51  Type type; // 00
52  Value value; // 04
53  };
54  static_assert(sizeof(Argument) == 0xC);
55 #pragma pack(pop)
56 
58  {
59  public:
60  // members
61  std::uint64_t unk00; // 00
62  const char* opCodeName; // 08 - ex: iadd
63  const char* opCodeArgs; // 10 - ex: SII
64  std::byte majorVersion; // 18 - Papyrus major version when opCode was made
65  std::byte minorVersion; // 19 - Papyrus minor version when opCode was made
66  std::uint16_t pad1A; // 1A
67  std::uint32_t pad1C; // 1C
68  };
69  static_assert(sizeof(InstructionDefinition) == 0x20);
70  }
71  namespace UnlinkedTypes
72  {
74  {
75  public:
78 
79  virtual ~ConvertTypeFunctor(); // 00
80 
81  virtual bool ConvertVariableType(BSFixedString* a_typeAsString, TypeInfo& a_typeOut) = 0; // 01
82  };
83  static_assert(sizeof(ConvertTypeFunctor) == 0x8);
84 
86  {
87  public:
88  ~LinkerConvertTypeFunctor() override; // 00
89 
90  bool ConvertVariableType(BSFixedString* a_typeAsString, TypeInfo& a_typeOut) override; // 01 - This just jumps to LinkerProcessor::ConvertVariableType
91 
92  // members
94  };
95  static_assert(sizeof(LinkerConvertTypeFunctor) == 0x10);
96 
98  {
99  public:
100  inline static constexpr auto RTTI = RTTI_BSScript____VMTypeResolveFunctor;
101  inline static constexpr auto VTABLE = VTABLE_BSScript____VMTypeResolveFunctor;
102  ~VMTypeResolveFunctor() override; // 00
103 
104  bool ConvertVariableType(BSFixedString* a_typeAsString, TypeInfo& a_typeOut) override; // 01
105  // members
107  };
108  static_assert(sizeof(VMTypeResolveFunctor) == 0x10);
109 
111  {
112  public:
113  // members
115  std::uint32_t functionCodeSize; // 08
116  std::uint32_t unk0C; // 0C
117  std::uint32_t pad10; // 10
118  std::uint32_t unk14; // 14
119  void* unk18; // 18 - Holds arguments
120  void* unk20; // 20
121  void* unk28; // 28
122  std::uint64_t unk30; // 30
123  void* unk38; // 38
124  std::uint64_t unk40; // 40
125  };
126  static_assert(sizeof(InstructionStream) == 0x48);
127 
128  class Function
129  {
130  public:
131  // members
134  bool isNative; // 10
135  bool isGlobal; // 11
136  std::uint16_t pad12; // 12
137  std::uint32_t isPropertyFunction; // 14
138  std::uint32_t userFlags; // 18
139  BSScrapArray<BSFixedString> paramNameArray; // 20 - index i holds the name of the parameter
140  BSScrapArray<BSFixedString> paramTypeArray; // 40 - index i holds the type of said parameter from above
141  BSScrapArray<BSFixedString> localNameArray; // 60 - index i holds the name of the local var
142  BSScrapArray<BSFixedString> localTypeArray; // 80 - index i holds the type of said local var from above
144  };
145  static_assert(sizeof(Function) == 0xE8);
146 
148  {
149  public:
150  // members
151  std::uint32_t functionType; // 00
156  };
157  static_assert(sizeof(FunctionDebugInfo) == 0x40);
158 
159  struct Property
160  {
161  public:
162  // members
163  std::uint32_t flags; // 00
164  std::uint32_t pad04; // 04
166  Function* readHandler; // 10 - get() function for the property
167  Function* writeHandler; // 18 - set() function for the property
169  BSFixedString docString; // 28 - Requires loadDocStrings in CompiledScriptLoader to be true
170  std::uint32_t userFlags; // 30
171  std::uint32_t pad34; // 34
172  };
173  static_assert(sizeof(Property) == 0x38);
174 
175  // Usage: Create an object with Create(), then pass to CompiledScriptLoader::GetClass() to fill it with information of a script class
176  // See: https://en.uesp.net/wiki/Skyrim_Mod:Compiled_Script_File_Format
177  // Note: This will only grab the raw unlinked data from the script, the game won't use the object when called like this
178  class Object
179  {
180  struct VariableData
181  {
182  public:
183  // members
184  BSFixedString typeName; // 00
185  std::uint64_t flags; // 08
186  };
187  static_assert(sizeof(VariableData) == 0x10);
188 
189  public:
191 
192  static Object* Create();
193 
195 
196  // members
198  std::uint64_t compilationTime; // 08
201  std::byte loadDebugInformation; // 20 - is set to loadDebugInfo from CompiledScriptLoader
202  std::uint64_t modificationTime; // 28
203  RE::BSScrapArray<FunctionDebugInfo*> functionDebugInfoList; // 30 - requires loadDebugInfo in CompiledScriptLoader to be true
207  BSFixedString docString; // 90 - requires loadDocStrings in CompiledScriptLoader to be true
208  std::uint32_t userFlags; // 98
209  std::uint32_t pad_9C; // 9C
213  BSTScrapHashMap<BSFixedString, Function*> memberFunctions; // 130 - Only has functions in empty state
214  BSTScrapHashMap<BSFixedString, BSTScrapHashMap<BSFixedString, Function*>*> stateMap; // 160 - Does not include the empty state functions
215  std::uint32_t totalFunctions; // 190 - staticFunctions size + memberFunctions size + all the state function variants in stateMap
216  std::uint32_t pad_194; // 194
218  BSFixedString autoStateName; // 1C8 - Is blank if no auto state in script
219 
220  private:
221  void Dtor();
222  Object* Ctor();
223  };
224  static_assert(sizeof(Object) == 0x1D0);
225  }
226  }
227 }
Definition: VirtualMachine.h:46
Definition: LinkerProcessor.h:18
Definition: TypeInfo.h:10
virtual bool ConvertVariableType(BSFixedString *a_typeAsString, TypeInfo &a_typeOut)=0
static constexpr auto VTABLE
Definition: UnlinkedTypes.h:77
static constexpr auto RTTI
Definition: UnlinkedTypes.h:76
Definition: UnlinkedTypes.h:129
BSScrapArray< BSFixedString > paramNameArray
Definition: UnlinkedTypes.h:139
BSScrapArray< BSFixedString > paramTypeArray
Definition: UnlinkedTypes.h:140
std::uint16_t pad12
Definition: UnlinkedTypes.h:136
bool isNative
Definition: UnlinkedTypes.h:134
BSScrapArray< BSFixedString > localNameArray
Definition: UnlinkedTypes.h:141
bool isGlobal
Definition: UnlinkedTypes.h:135
BSFixedString docString
Definition: UnlinkedTypes.h:133
BSScrapArray< BSFixedString > localTypeArray
Definition: UnlinkedTypes.h:142
BSFixedString returnTypeName
Definition: UnlinkedTypes.h:132
std::uint32_t userFlags
Definition: UnlinkedTypes.h:138
InstructionStream instructionStream
Definition: UnlinkedTypes.h:143
std::uint32_t isPropertyFunction
Definition: UnlinkedTypes.h:137
Definition: UnlinkedTypes.h:111
std::uint32_t unk14
Definition: UnlinkedTypes.h:118
void * unk28
Definition: UnlinkedTypes.h:121
std::uint32_t unk0C
Definition: UnlinkedTypes.h:116
void * unk38
Definition: UnlinkedTypes.h:123
std::uint32_t functionCodeSize
Definition: UnlinkedTypes.h:115
ScrapHeap * threadScrapHeap
Definition: UnlinkedTypes.h:114
std::uint64_t unk30
Definition: UnlinkedTypes.h:122
void * unk18
Definition: UnlinkedTypes.h:119
std::uint32_t pad10
Definition: UnlinkedTypes.h:117
std::uint64_t unk40
Definition: UnlinkedTypes.h:124
void * unk20
Definition: UnlinkedTypes.h:120
LinkerProcessor * linker
Definition: UnlinkedTypes.h:93
bool ConvertVariableType(BSFixedString *a_typeAsString, TypeInfo &a_typeOut) override
Definition: UnlinkedTypes.h:179
BSTScrapHashMap< BSFixedString, Function * > staticFunctions
Definition: UnlinkedTypes.h:212
std::uint32_t pad_194
Definition: UnlinkedTypes.h:216
std::uint64_t modificationTime
Definition: UnlinkedTypes.h:202
BSFixedString userName
Definition: UnlinkedTypes.h:199
std::uint32_t totalFunctions
Definition: UnlinkedTypes.h:215
std::uint32_t userFlags
Definition: UnlinkedTypes.h:208
BSTScrapHashMap< BSFixedString, VariableData > variables
Definition: UnlinkedTypes.h:210
BSTScrapHashMap< BSFixedString, BSTScrapHashMap< BSFixedString, Function * > * > stateMap
Definition: UnlinkedTypes.h:214
BSTHashMap< BSFixedString, std::byte > userFlagMap
Definition: UnlinkedTypes.h:204
BSFixedString parentClassName
Definition: UnlinkedTypes.h:206
BSFixedString autoStateName
Definition: UnlinkedTypes.h:218
RE::BSScrapArray< FunctionDebugInfo * > functionDebugInfoList
Definition: UnlinkedTypes.h:203
BSFixedString fileName
Definition: UnlinkedTypes.h:197
BSFixedString computerName
Definition: UnlinkedTypes.h:200
BSTScrapHashMap< BSFixedString, Property * > properties
Definition: UnlinkedTypes.h:211
BSTScrapHashMap< BSFixedString, ByteCode::Argument > initialVariableValues
Definition: UnlinkedTypes.h:217
BSFixedString docString
Definition: UnlinkedTypes.h:207
std::uint32_t pad_9C
Definition: UnlinkedTypes.h:209
std::byte loadDebugInformation
Definition: UnlinkedTypes.h:201
std::uint64_t compilationTime
Definition: UnlinkedTypes.h:198
BSFixedString className
Definition: UnlinkedTypes.h:205
BSTScrapHashMap< BSFixedString, Function * > memberFunctions
Definition: UnlinkedTypes.h:213
bool ConvertVariableType(BSFixedString *a_typeAsString, TypeInfo &a_typeOut) override
Internal::VirtualMachine * vm
Definition: UnlinkedTypes.h:106
static constexpr auto VTABLE
Definition: UnlinkedTypes.h:101
static constexpr auto RTTI
Definition: UnlinkedTypes.h:100
Definition: BSTArray.h:378
Definition: BSTHashMap.h:21
Definition: ScrapHeap.h:10
~BSFixedString()
Definition: BSFixedString.h:58
Definition: AbsorbEffect.h:6
constexpr REL::ID RTTI_BSScript__UnlinkedTypes__Function__ConvertTypeFunctor(static_cast< std::uint64_t >(691838))
constexpr std::array< REL::ID, 1 > VTABLE_BSScript____VMTypeResolveFunctor
Definition: Offsets_VTABLE.h:9830
constexpr REL::ID RTTI_BSScript____VMTypeResolveFunctor(static_cast< std::uint64_t >(691839))
constexpr std::array< REL::ID, 1 > VTABLE_BSScript__UnlinkedTypes__Function__ConvertTypeFunctor
Definition: Offsets_VTABLE.h:9821
Definition: UnlinkedTypes.h:18
Type type
Definition: UnlinkedTypes.h:49
~Argument()
Definition: UnlinkedTypes.h:44
Type
Definition: UnlinkedTypes.h:20
Value value
Definition: UnlinkedTypes.h:52
Definition: UnlinkedTypes.h:58
std::uint64_t unk00
Definition: UnlinkedTypes.h:61
std::uint16_t pad1A
Definition: UnlinkedTypes.h:66
const char * opCodeArgs
Definition: UnlinkedTypes.h:63
std::byte minorVersion
Definition: UnlinkedTypes.h:65
std::byte majorVersion
Definition: UnlinkedTypes.h:64
std::uint32_t pad1C
Definition: UnlinkedTypes.h:67
const char * opCodeName
Definition: UnlinkedTypes.h:62
Definition: UnlinkedTypes.h:148
std::uint32_t functionType
Definition: UnlinkedTypes.h:151
BSFixedString stateName
Definition: UnlinkedTypes.h:153
BSFixedString className
Definition: UnlinkedTypes.h:152
BSFixedString functionName
Definition: UnlinkedTypes.h:154
BSScrapArray< std::uint16_t > instructionLineNumbers
Definition: UnlinkedTypes.h:155
Definition: UnlinkedTypes.h:160
std::uint32_t flags
Definition: UnlinkedTypes.h:163
BSFixedString docString
Definition: UnlinkedTypes.h:169
BSFixedString typeName
Definition: UnlinkedTypes.h:165
Function * readHandler
Definition: UnlinkedTypes.h:166
Function * writeHandler
Definition: UnlinkedTypes.h:167
std::uint32_t userFlags
Definition: UnlinkedTypes.h:170
std::uint32_t pad04
Definition: UnlinkedTypes.h:164
BSFixedString autoVarName
Definition: UnlinkedTypes.h:168
std::uint32_t pad34
Definition: UnlinkedTypes.h:171
Definition: UnlinkedTypes.h:33
BSFixedString string
Definition: UnlinkedTypes.h:38
std::uint32_t idx
Definition: UnlinkedTypes.h:37
~Value()
Definition: UnlinkedTypes.h:40
int i
Definition: UnlinkedTypes.h:34
float f
Definition: UnlinkedTypes.h:35
bool b
Definition: UnlinkedTypes.h:36