UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMPlaceholder.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_VERSE_VM || defined(__INTELLISENSE__)
6
7#include "VVMSuspension.h"
8
9namespace Verse
10{
11struct VPlaceholder : public VCell
12{
15
16 enum class EMode : uint8
17 {
19 HasValue,
20 HasParent,
21 };
22
24
25 static VPlaceholder& New(FAllocationContext Context, uint16 SplitDepth)
26 {
27 return *new (Context.AllocateFastCell(sizeof(VPlaceholder))) VPlaceholder(Context, SplitDepth);
28 }
29
30 uint16 SplitDepth() const { return Misc2And3; }
31 bool HasSuspension() const { return Mode() == EMode::HasSuspension; }
32 bool HasValue() const { return Mode() == EMode::HasValue; }
33 bool HasParent() const { return Mode() == EMode::HasParent; }
34
35 VSuspension* GetSuspension() const
36 {
38 if (Value.Get().IsUninitialized())
39 {
40 return nullptr;
41 }
42 else
43 {
44 return &Value.Get().AsCell().StaticCast<VSuspension>();
45 }
46 }
47
48 VValue GetValue() const
49 {
50 checkSlow(HasValue());
51 return Value.Get();
52 }
53
54 VPlaceholder* GetParent() const
55 {
56 checkSlow(HasParent());
57 return &Value.Get().AsPlaceholder();
58 }
59
60 void Unify(FAllocationContext Context, VPlaceholder& Other)
61 {
62 checkSlow(HasSuspension() && Other.HasSuspension());
63 if (this == &Other)
64 {
65 return;
66 }
67 if (!GetSuspension())
68 {
70 return;
71 }
72 if (!Other.GetSuspension())
73 {
74 Other.SetParentTrailed(Context, *this);
75 return;
76 }
77 // No need to trail the copying of suspensions. Any unification that
78 // needs to be undone will also result in all related suspensions
79 // having `bFailed` failure contexts.
80 GetSuspension()->Last().Next.Set(Context, Other.GetSuspension());
81 Other.SetParentTrailed(Context, *this);
82 }
83
85 {
86 checkSlow(!InValue.IsPlaceholder());
87 VSuspension* Result = GetSuspension();
88 Mode() = EMode::HasValue;
89 Value.Set(Context, InValue);
90 return Result;
91 }
92
93 VSuspension* SetValueTrailed(FAllocationContext Context, VValue InValue)
94 {
95 checkSlow(!InValue.IsPlaceholder());
96 VSuspension* Result = GetSuspension();
97 SetModeTrailed(Context, EMode::HasValue);
98 Value.SetTrailed(Context, InValue);
99 return Result;
100 }
101
102 COREUOBJECT_API VValue Follow();
103
104 // TODO: For perf, think through if FIFO or LIFO will be faster.
106 {
107 VPlaceholder& Root = Follow().GetRootPlaceholder();
108 if (VSuspension* PreviousSuspension = Root.GetSuspension())
109 {
110 Suspension.Next.Set(Context, PreviousSuspension);
111 }
112 Root.Value.Set(Context, Suspension);
113 }
114
115private:
116 void SetParent(FAccessContext Context, VPlaceholder& Other)
117 {
118 Mode() = EMode::HasParent;
119 Value.Set(Context, VValue::Placeholder(Other));
120 }
121
122 void SetParentTrailed(FAllocationContext Context, VPlaceholder& Other)
123 {
124 SetModeTrailed(Context, EMode::HasParent);
125 Value.SetTrailed(Context, VValue::Placeholder(Other));
126 }
127
128 EMode& Mode() const { return *BitCast<EMode*>(&Misc3); }
129
130 void SetModeTrailed(FAllocationContext Context, EMode InMode);
131
132 VPlaceholder(FAllocationContext Context, uint16 InputSplitDepth)
134 {
137 Mode() = EMode::HasSuspension;
138 checkSlow(!GetSuspension());
139 }
140};
141} // namespace Verse
142#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
T * New(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:259
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
IAnalyticsPropertyStore::EStatusCode SetValue(TGetter &&GetterFn, TSetter &&SetterFn, const T &ProposedValue, TCompare &&ConditionFn)
Definition AnalyticsPropertyStore.cpp:34
Mode
Definition AnimNode_TransitionPoseEvaluator.h:28
T::FDataType GetValue(const UBlackboardComponent &Blackboard, const FName &Name, FBlackboard::FKey &InOutCachedKey, const typename T::FDataType &DefaultValue)
Definition ValueOrBBKey.h:51
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
UE_STRING_CLASS Result(Forward< LhsType >(Lhs), RhsLen)
Definition String.cpp.inl:732
Definition Archive.h:36