UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMEmergentType.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
6#include "VerseVM/VVMBitMap.h"
7#include "VerseVM/VVMCell.h"
10#include <new>
11
12namespace Verse
13{
14struct VShape;
15struct VType;
16struct VMap;
17
18struct VEmergentType final : VCell
19{
21
22 TWriteBarrier<VShape> Shape; // This is immutable. If you need to change an object's shape, transition to a new emergent type that points to your new shape instead.
25 VCppClassInfo* CppClassInfo = nullptr;
26
27 // We use this to track what fields have been created for objects
29
30 // A cache of types made when calling `MarkFieldAsCreated`
32
33 static VEmergentType* New(FAllocationContext Context, VType* Type, VCppClassInfo* CppClassInfo)
34 {
35 return new (Context.AllocateEmergentType(sizeof(VEmergentType))) VEmergentType(Context, VEmergentTypeCreator::EmergentTypeForEmergentType.Get(), Type, CppClassInfo);
36 }
37
38 static VEmergentType* New(FAllocationContext Context, VShape* InShape, VType* Type, VCppClassInfo* CppClassInfo)
39 {
40 return new (Context.AllocateEmergentType(sizeof(VEmergentType))) VEmergentType(Context, InShape, VEmergentTypeCreator::EmergentTypeForEmergentType.Get(), Type, CppClassInfo);
41 }
42
43 static VEmergentType* New(FAllocationContext Context, const VEmergentType* Other, const VBitMap* InCreatedFields)
44 {
45 return new (Context.AllocateEmergentType(sizeof(VEmergentType))) VEmergentType(Context, Other, InCreatedFields);
46 }
47
49 {
50 if (VEmergentType* Transition = MeltTransition.Get())
51 {
52 return *Transition;
53 }
55 }
56
57 static bool Equals(const VEmergentType& EmergentType, VType* Type, VCppClassInfo* CppClassInfo)
58 {
59 return EmergentType.Shape.Get() == nullptr && EmergentType.Type.Get() == Type && EmergentType.CppClassInfo == CppClassInfo;
60 }
61
62 static bool Equals(const VEmergentType& EmergentType, const VShape* InShape, VType* Type, VCppClassInfo* CppClassInfo)
63 {
64 return EmergentType.Shape.Get() == InShape && EmergentType.Type.Get() == Type && EmergentType.CppClassInfo == CppClassInfo;
65 }
66
67 static bool Equals(FAllocationContext Context, const VEmergentType& EmergentType, const VEmergentType* Other, const VBitMap* InCreatedFields);
68
70 {
71 uint32 Hash = HashCombineFast(::GetTypeHash(EmergentType.Shape.Get()), ::GetTypeHash(EmergentType.Type.Get()));
72 Hash = HashCombineFast(Hash, ::GetTypeHash(EmergentType.CppClassInfo));
74 return Hash;
75 }
76
77 COREUOBJECT_API bool IsFieldCreated(uint32 FieldIndex);
78 COREUOBJECT_API VEmergentType* MarkFieldAsCreated(FAllocationContext Context, uint32 FieldIndex);
79
80 // Emergent types are not serialized; this also prevents them from being recorded.
81 static constexpr bool SerializeIdentity = false;
82
83private:
84 friend class VEmergentTypeCreator;
85
86 // Need this for the EmergentType of EmergentType.
87 static VEmergentType* NewIncomplete(FAllocationContext Context, VCppClassInfo* CppClassInfo)
88 {
89 return new (Context.AllocateEmergentType(sizeof(VEmergentType))) VEmergentType(Context, CppClassInfo);
90 }
91
93
95 {
96 VCell::SetEmergentType(Context, EmergentType);
97 }
98
99 VEmergentType(FAllocationContext Context, VCppClassInfo* CppClassInfo)
100 : VCell()
101 , CppClassInfo(CppClassInfo)
102 {
103 }
104
105 VEmergentType(FAllocationContext Context, VEmergentType* EmergentType, VType* T, VCppClassInfo* CppClassInfo)
107 , Type(Context, T)
108 , CppClassInfo(CppClassInfo)
109 {
110 }
111
113
114 VEmergentType(FAllocationContext Context, const VEmergentType* Other, const VBitMap* InCreatedFields);
115};
116
117}; // namespace Verse
118
119#endif // WITH_VERSE_VM
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
T * New(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:259
constexpr uint32 HashCombineFast(uint32 A, uint32 B)
Definition TypeHash.h:74
uint32_t uint32
Definition binka_ue_file_header.h:6
Type
Definition PawnAction_Move.h:11
uint32 GetTypeHash(const FKey &Key)
Definition BlackboardKey.h:35
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
Definition Archive.h:36