UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMClass.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#if WITH_VERSE_VM || defined(__INTELLISENSE__)
5
9#include "VerseVM/VVMArray.h"
14#include "VerseVM/VVMShape.h"
15
16class UObject;
17class UVerseClass;
18class UVerseStruct;
19
20namespace Verse
21{
22enum class EValueStringFormat;
23struct FAbstractVisitor;
24struct VObject;
25struct VValueObject;
26struct VNativeStruct;
27struct VProcedure;
28struct VPackage;
29struct VFunction;
30struct VScope;
35
37struct FEmergentTypesCacheKeyFuncs : TDefaultMapKeyFuncs<TWriteBarrier<VUniqueStringSet>, TWriteBarrier<VEmergentType>, /*bInAllowDuplicateKeys*/ false>
38{
39public:
40 static bool Matches(KeyInitType A, KeyInitType B);
41 static bool Matches(KeyInitType A, const VUniqueStringSet& B);
42 static uint32 GetKeyHash(KeyInitType Key);
43 static uint32 GetKeyHash(const VUniqueStringSet& Key);
44};
45
46enum class EArchetypeEntryFlags : uint8
47{
48 None = 0,
50 NativeRepresentation = 1 << 0,
54 Instanced = 1 << 2,
56 UseCRCName = 1 << 3,
58 Predicts = 1 << 4,
60 Var = 1 << 5
61};
63
64
65struct VArchetype : VCell
66{
69
70 struct VEntry
71 {
72 static VEntry Constant(FAllocationContext Context, VUniqueString& InQualifiedField, VValue InType, VValue InValue);
73 static VEntry Field(FAllocationContext Context, VUniqueString& InQualifiedField, VValue InType);
74 static VEntry InitializedField(FAllocationContext Context, VUniqueString& InQualifiedField, VValue InType);
75
76 static VEntry ObjectField(FAllocationContext Context, VUniqueString& InQualifiedField);
77
78 bool IsConstant() const;
79 bool IsNativeRepresentation() const;
80 bool UseCRCName() const;
81 bool HasDefaultValueExpression() const;
82 bool IsInstanced() const;
83 bool IsPredicts() const;
84 bool IsVar() const;
85
87 COREUOBJECT_API bool IsMethod() const;
88
90
93
94 /*
95 `Value` should be one of the following:
96
97 - An uninitialized `VValue`, for a field initializer (regardless of whether or not the field is actually uninitialized).
98
99 - A constant `VValue` representing a default field value. (This may be a `VFunction` without the `Self` member
100 for methods, since they will bind `Self` lazily).
101 */
103
105 };
106
110 VRestValue Class{0};
111
117
119 uint32 NumEntries;
120 VEntry Entries[];
121
122 static VArchetype& New(FAllocationContext Context, VValue InNextArchetype, const TArray<VEntry>& InEntries);
123
124 COREUOBJECT_API void AppendToStringImpl(FAllocationContext Context, FUtf8StringBuilderBase& Builder, EValueStringFormat Format, TSet<const void*>& VisitedObjects, uint32 RecursionDepth);
125
126 static void SerializeLayout(FAllocationContext Context, VArchetype*& This, FStructuredArchiveVisitor& Visitor);
127 void SerializeImpl(FAllocationContext Context, FStructuredArchiveVisitor& Visitor);
128
130 COREUOBJECT_API VValue LoadFunction(FAllocationContext Context, VUniqueString& FieldName, VValue SelfObject);
131
132private:
133 static VArchetype& NewUninitialized(FAllocationContext Context, const uint32 InNumEntries)
134 {
135 size_t NumBytes = offsetof(VArchetype, Entries) + InNumEntries * sizeof(Entries[0]);
136 return *new (Context.AllocateFastCell(NumBytes)) VArchetype(Context, InNumEntries);
137 }
138
139 VArchetype(FAllocationContext Context, VValue InNextArchetype, const TArray<VEntry>& InEntries);
140 VArchetype(FAllocationContext Context, const uint32 InNumEntries);
141
142 friend struct VClass;
143};
144
145struct VClass : VNamedType
146{
149
150 enum class EKind : uint8
151 {
152 Class,
153 Struct,
155 };
156 enum class EFlags : uint16
157 {
158 None = 0,
159 NativeRepresentation = 1 << 0,
161 Concrete = 1 << 2,
162 FinalSuper = 1 << 3,
163 ExplicitlyCastable = 1 << 4,
164 Parametric = 1 << 5,
165 UniversallyAccessible = 1 << 6,
166 EpicInternal = 1 << 7,
167 VNIEpicInternal = 1 << 8,
168 Predicts = 1 << 9,
169 };
170
171 EKind GetKind() const { return Kind; }
172 bool IsStruct() const { return GetKind() == EKind::Struct; }
173 bool IsInterface() const { return GetKind() == EKind::Interface; }
174
175 bool IsNativeRepresentation() const { return EnumHasAllFlags(Flags, EFlags::NativeRepresentation); }
176 bool IsNativeStruct() const { return IsNativeRepresentation() && IsStruct(); }
177 bool IsNativeStructWithObjectReferences() const { return EnumHasAllFlags(Flags, EFlags::NativeStructWithObjectReferences); }
178 bool IsPredicts() const { return EnumHasAllFlags(Flags, EFlags::Predicts); }
179
181 VArchetype& GetArchetype() const { return *Archetype.Get(); }
182 VFunction& GetConstructor() const { return *Constructor.Get(); }
183
188
190
192 template <class CppStructType>
194
197
201
218 static VClass& New(
219 FAllocationContext Context,
226 bool bNativeBound,
227 EKind InKind,
228 EFlags InFlags,
232
233 bool SubsumesImpl(FAllocationContext, VValue);
234
235 static void SerializeLayout(FAllocationContext Context, VClass*& This, FStructuredArchiveVisitor& Visitor);
236 void SerializeImpl(FAllocationContext Context, FStructuredArchiveVisitor& Visitor);
237
240
241private:
243 FAllocationContext Context,
250 bool bInNativeBound,
251 EKind InKind,
252 EFlags InFlags,
256
257 COREUOBJECT_API VClass(FAllocationContext Context, int32 NumInherited);
258
261 static void WalkArchetypeFields(
262 FAllocationContext Context,
266 int32& BaseIndex,
267 TFunction<void(int32&)> WalkSuper,
268 TFunction<void(VArchetype::VEntry&, int32, VClass&)> FieldCallbackProc);
269
271 VShape* BindNativeClass(FAllocationContext Context, bool bImported);
272
273 void CommonPrepare(FAllocationContext Context, FInitOrValidateUStruct& InitOrValidate, UStruct* Type);
274 void Prepare(FAllocationContext Context, FInitOrValidateUVerseStruct& InitOrValidate, UVerseStruct* Type);
275 void Prepare(FAllocationContext Context, FInitOrValidateUVerseClass& InitOrValidate, UVerseClass* Type);
276
278 FAllocationContext Context,
279 TFunction<FProperty*(VArchetype::VEntry&, int32)>&& CreateProperty,
280 TFunction<UFunction*(VArchetype::VEntry&)>&& CreateFunction);
281 VShape* CreateShapeForExistingUStruct(FAllocationContext Context);
282 UFunction* MaybeCreateUFunctionForCallee(Verse::FAllocationContext Context, VValue Callee);
283
286
287 EKind Kind;
288 EFlags Flags;
289
290 // Super classes and interfaces. The single superclass is always first.
292
296
300
301 // TODO: (yiliang.siew) This should be a weak map when we can support it in the GC. https://jira.it.epicgames.com/browse/SOL-5312
305
308
309 friend class FInterpreter;
310 friend ::UVerseClass;
311 friend ::UVerseStruct;
312};
313
314ENUM_CLASS_FLAGS(VClass::EFlags)
315} // namespace Verse
316#endif // WITH_VERSE_VM
return Self
Definition CocoaThread.cpp:337
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
constexpr bool EnumHasAllFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:28
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
T * New(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:259
@ IsStruct
Indicates the property is eligible for shared serialization.
UEBinkAudioDecodeInterface * Interface
Definition binka_ue_decode_test.cpp:24
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ContainerAllocationPolicies.h:1660
Definition JsonObject.h:23
Definition JsonValue.h:22
Definition UnrealType.h:174
Definition ArrayView.h:139
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition StringBuilder.h:79
Definition Class.h:2476
Definition Object.h:95
Definition Class.h:480
Definition VVMVerseClass.h:137
Definition VVMVerseStruct.h:33
@ IsInstanced
Definition ImplicitObjectType.h:35
Type
Definition PawnAction_Move.h:11
Definition FieldSystemNoiseAlgo.cpp:6
bool SerializeImpl(const UScriptStruct *InSourceEventType, const void *InSourceEventData, FLiveLinkSerializedFrameData &OutSerializedData)
Definition LiveLinkCompression.cpp:126
@ Instanced
Property is a component reference. Implies EditInline and Export.
Definition ObjectMacros.h:1101
Definition Archive.h:36
EValueStringFormat
Definition VVMValuePrinting.h:17
VERSECOMPILER_API bool Matches(const CTypeBase *PositiveType1, const CTypeBase *NegativeType2, const uint32_t UploadedAtFnVersion)
Determine if argument PositiveType1 is a match for parameter NegativeType2
Definition SemanticTypes.cpp:2971
Definition Map.h:77