UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMClassInline.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__)
6#include "Templates/Casts.h"
7#include "UObject/Class.h"
9#include "VerseVM/VVMClass.h"
11#include "VerseVM/VVMFunction.h"
12#include "VerseVM/VVMPackage.h"
13#include "VerseVM/VVMShape.h"
16
17namespace Verse
18{
19inline bool FEmergentTypesCacheKeyFuncs::Matches(FEmergentTypesCacheKeyFuncs::KeyInitType A, FEmergentTypesCacheKeyFuncs::KeyInitType B)
20{
21 return A == B;
22}
23
24inline bool FEmergentTypesCacheKeyFuncs::Matches(FEmergentTypesCacheKeyFuncs::KeyInitType A, const VUniqueStringSet& B)
25{
26 return *(A.Get()) == B;
27}
28
29inline uint32 FEmergentTypesCacheKeyFuncs::GetKeyHash(FEmergentTypesCacheKeyFuncs::KeyInitType Key)
30{
31 return GetTypeHash(Key);
32}
33
34inline uint32 FEmergentTypesCacheKeyFuncs::GetKeyHash(const VUniqueStringSet& Key)
35{
36 return GetTypeHash(Key);
37}
38
39inline VArchetype& VArchetype::New(FAllocationContext Context, VValue InNextArchetype, const TArray<VEntry>& InEntries)
40{
41 size_t NumBytes = offsetof(VArchetype, Entries) + InEntries.Num() * sizeof(Entries[0]);
42 return *new (Context.AllocateFastCell(NumBytes)) VArchetype(Context, InNextArchetype, InEntries);
43}
44
45inline VArchetype::VArchetype(FAllocationContext Context, VValue InNextArchetype, const TArray<VEntry>& InEntries)
47 , NumEntries(InEntries.Num())
48{
49 Class.SetNonCellNorPlaceholder(VValue());
51 for (uint32 Index = 0; Index < NumEntries; ++Index)
52 {
53 new (&Entries[Index]) VEntry(InEntries[Index]);
54 }
55}
56
57inline VArchetype::VArchetype(FAllocationContext Context, const uint32 InNumEntries)
59 , NumEntries(InNumEntries)
60{
61 for (uint32 Index = 0; Index < NumEntries; ++Index)
62 {
63 new (&Entries[Index]) VEntry{};
64 }
65}
66
67inline VArchetype::VEntry VArchetype::VEntry::Constant(FAllocationContext Context, VUniqueString& InQualifiedField, VValue InType, VValue InValue)
68{
69 checkSlow(InQualifiedField.AsStringView().Len() > 0);
70 return {
71 .Name = {Context, InQualifiedField},
72 .Type = {Context, InType},
73 .Value = {Context, InValue},
74 .Flags = EArchetypeEntryFlags::HasDefaultValueExpression,
75 };
76}
77
78inline VArchetype::VEntry VArchetype::VEntry::Field(FAllocationContext Context, VUniqueString& InQualifiedField, VValue InType)
79{
80 checkSlow(InQualifiedField.AsStringView().Len() > 0);
81 return {
82 .Name = {Context, InQualifiedField},
83 .Type = {Context, InType},
84 .Value = {},
85 .Flags = EArchetypeEntryFlags::None,
86 };
87}
88
89inline VArchetype::VEntry VArchetype::VEntry::InitializedField(FAllocationContext Context, VUniqueString& InQualifiedField, VValue InType)
90{
91 checkSlow(InQualifiedField.AsStringView().Len() > 0);
92 return {
93 .Name = {Context, InQualifiedField},
94 .Type = {Context, InType},
95 .Value = {}, // Uninitialized `VValue` here since the field data is just set by `UnifyField` when the class body procedure runs.
96 .Flags = EArchetypeEntryFlags::HasDefaultValueExpression,
97 };
98}
99
100inline VArchetype::VEntry VArchetype::VEntry::ObjectField(FAllocationContext Context, VUniqueString& InQualifiedField)
101{
102 checkSlow(InQualifiedField.AsStringView().Len() > 0);
103 return {
104 .Name = {Context, InQualifiedField},
105 .Type = {},
106 .Value = {},
107 .Flags = EArchetypeEntryFlags::None,
108 };
109}
110
111inline bool VArchetype::VEntry::IsConstant() const
112{
113 return !Value.Get().IsUninitialized();
114}
115
116inline bool VArchetype::VEntry::IsNativeRepresentation() const
117{
118 return EnumHasAnyFlags(Flags, EArchetypeEntryFlags::NativeRepresentation);
119}
120
121inline bool VArchetype::VEntry::UseCRCName() const
122{
123 return EnumHasAnyFlags(Flags, EArchetypeEntryFlags::UseCRCName);
124}
125
126inline bool VArchetype::VEntry::HasDefaultValueExpression() const
127{
128 // It's not enough to check that the value is uninitialized, since there could be bytecode run later on in the body function
129 // that initializes the field.
130 return EnumHasAnyFlags(Flags, EArchetypeEntryFlags::HasDefaultValueExpression);
131}
132
133inline bool VArchetype::VEntry::IsInstanced() const
134{
135 return EnumHasAnyFlags(Flags, EArchetypeEntryFlags::Instanced);
136}
137
138inline bool VArchetype::VEntry::IsPredicts() const
139{
140 return EnumHasAnyFlags(Flags, EArchetypeEntryFlags::Predicts);
141}
142
143inline bool VArchetype::VEntry::IsVar() const
144{
145 return EnumHasAnyFlags(Flags, EArchetypeEntryFlags::Var);
146}
147
148template <class CppStructType>
149inline VNativeStruct& VClass::NewNativeStruct(FAllocationContext Context, CppStructType&& Struct)
150{
152 return VNativeStruct::New(Context, EmergentType, Forward<CppStructType>(Struct));
153}
154
155inline VClass& VClass::New(
156 FAllocationContext InContext,
157 VPackage* InPackage,
163 bool bInNativeBound,
164 EKind InKind,
165 EFlags InFlags,
169{
170 const size_t NumBytes = offsetof(VClass, Inherited) + InInherited.Num() * sizeof(Inherited[0]);
171 return *new (InContext.Allocate(FHeap::DestructorSpace, NumBytes)) VClass(
172 InContext,
173 InPackage,
180 InKind,
181 InFlags,
185}
186} // namespace Verse
187#endif // WITH_VERSE_VM
#define checkSlow(expr)
Definition AssertionMacros.h:332
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:35
@ Num
Definition MetalRHIPrivate.h:234
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Array.h:670
Definition Class.h:480
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
Definition Archive.h:36
uint32 GetTypeHash(TPtrVariant< Ts... > Ptr)
Definition VVMPtrVariant.h:83
U16 Index
Definition radfft.cpp:71