UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMShape.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 "Containers/Map.h"
7#include "VVMCell.h"
8#include "VVMUniqueString.h"
9#include "VVMWriteBarrier.h"
10
12class FProperty;
13
14namespace Verse
15{
16struct FAccessContext;
17struct VUniqueString;
18struct VEmergentType;
19
20template <Verse::VCppClassInfo* ClassInfo>
22
23enum class EFieldType : int8
24{
25 // The field's value is stored in a VObject.
26 // e.g. `c := class{ X:int }` or `c := class{ var X:int = 0 }`
27 Offset,
28
29 // The field's value is a native type stored in a UObject or VNativeStruct.
31 // The field's value is a mutable native type stored in a UObject or VNativeStruct.
33 // The field's value is a VRestValue stored in a UObject or VNativeStruct.
35
36 // The field's value is stored in the shape.
37 // This is used for fields default-initialized to a constant, such as methods.
38 // e.g. `a := class{ X:int = 3, Y:int = 5, F(Z:int):int = X + Y + Z }; A := a{ X := 8 }
39 // Here, `A.Y` and `A.F` are stored in the shape, while `A.X` is stored in the object.
41};
42
44struct VShape : VCell
45{
46 struct VEntry
47 {
48 union
49 {
52
56
59 };
60
62
63 // Must have a copy/move constructor in order to be used with `TMap` as the value type.
64 VEntry(const VEntry& Other);
66 : VEntry(Other) {}
67
68 static VEntry Offset() { return {}; }
69 // TODO: (yiliang.siew) Should these initialize to `VRestValue`s? Otherwise `Def` won't work correctly.
70 static VEntry Property(FProperty* InProperty = nullptr) { return {InProperty, EFieldType::FProperty}; }
71 static VEntry PropertyVar(FProperty* InProperty = nullptr) { return {InProperty, EFieldType::FPropertyVar}; }
72 static VEntry VerseProperty(FProperty* InProperty = nullptr) { return {InProperty, EFieldType::FVerseProperty}; }
74
75 bool operator==(const VEntry& Other) const;
76
77 bool IsProperty() const { return Type == EFieldType::FProperty || Type == EFieldType::FPropertyVar || Type == EFieldType::FVerseProperty; }
78 bool IsAccessor() const;
79
80 private:
81 VEntry();
82 VEntry(FProperty* InProperty, EFieldType InType);
84 };
85
88 struct FFieldsMapKeyFuncs : TDefaultMapKeyFuncs<TWriteBarrier<VUniqueString>, VEntry, /*bInAllowDuplicateKeys*/ false>
89 {
90 static bool Matches(KeyInitType A, KeyInitType B);
91 static bool Matches(KeyInitType A, const VUniqueString& B);
92 static uint32 GetKeyHash(KeyInitType Key);
93 static uint32 GetKeyHash(const VUniqueString& Key);
94 };
95
97
100
103 COREUOBJECT_API static VShape* New(FAllocationContext Context, FieldsMap&& InFields);
104
105 const VEntry* GetField(const VUniqueString& Name) const;
106 const VEntry& GetField(int32 FieldIndex) const;
107 const int32 GetFieldIndex(FAllocationContext Context, VUniqueString& Name) const
108 {
109 return Fields.FindId({Context, Name}).AsInteger();
110 }
112 {
113 return Fields.FindId(Name).AsInteger();
114 }
115 const int32 GetMaxFieldIndex() const
116 {
117 return Fields.GetMaxIndex();
118 }
119
120 uint64 GetNumFields() const;
121
122 bool operator==(const VShape& Other) const;
123
124 VShape& CopyToMeltedShape(FAllocationContext);
125
126 FieldsMap::TIterator CreateFieldsIterator() { return Fields.CreateIterator(); }
127
128 VShape(FAllocationContext Context, FieldsMap&& InFields);
129
134 FieldsMap Fields;
135
137
138 // Perhaps we should store this as a bit in the VCell header
139 bool bHasAccessors = false;
140};
141
142} // namespace Verse
143#endif // WITH_VERSE_VM
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
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
void ENGINE_API GetFieldIndex(const uint32 FieldType, int32 &FieldIndex, EFieldOutputType &FieldOutput)
Definition PhysicsFieldComponent.cpp:1099
uint32 Offset
Definition VulkanMemory.cpp:4033
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ContainerAllocationPolicies.h:1660
Definition UnrealType.h:174
Definition UnrealString.h.inl:34
Definition UnrealTypePrivate.h:18
Type
Definition PawnAction_Move.h:11
bool operator==(const FCachedAssetKey &A, const FCachedAssetKey &B)
Definition AssetDataMap.h:501
EFieldType
Definition Protocol0.h:52
Definition Archive.h:36
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
U16 Index
Definition radfft.cpp:71
Definition Map.h:77