UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMVerseClassInline.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/VVMLog.h"
15
16inline Verse::FOpResult UVerseClass::LoadField(Verse::FAllocationContext Context, UObject* Object, Verse::VUniqueString& FieldName, Verse::VNativeConstructorWrapper* Wrapper)
17{
18 using namespace Verse;
19
21 VShape& Shape = Class->Shape.Get(Context).StaticCast<VShape>();
22 const VShape::VEntry* Field = Shape.GetField(FieldName);
23
24 switch (Field->Type)
25 {
26 case EFieldType::FProperty:
27 return VNativeRef::Get(Context, Object, Field->UProperty);
28 case EFieldType::FPropertyVar:
29 V_RETURN(VNativeRef::New(Context, Object, Field->UProperty));
30 case EFieldType::FVerseProperty:
31 {
32 VRestValue& Slot = *Field->UProperty->ContainerPtrToValuePtr<VRestValue>(Object);
33
34 if (LIKELY(Slot.CanDefQuickly()) && GUObjectArray.IsDisregardForGC(Object))
35 {
36 VValue Placeholder = Slot.Get(Context);
37 Placeholder.AsPlaceholder().AddRef(Context);
38 V_RETURN(Placeholder);
39 }
40
41 V_RETURN(Slot.Get(Context));
42 }
43 case EFieldType::Constant:
44 {
45 VValue FieldValue = Field->Value.Get();
46 V_DIE_IF(FieldValue.IsCellOfType<VProcedure>());
47 // TODO: Bind to Wrapper?
48 if (VFunction* Function = FieldValue.DynamicCast<VFunction>(); Function && !Function->HasSelf())
49 {
50 // NOTE: (yiliang.siew) Update the function-without-`Self` to point to the current object instance.
51 // We only do this if the function doesn't already have a `Self` bound - in the case of fields that
52 // are pointing to functions, we don't want to overwrite that `Self` which was already previously-bound.
54 }
56 {
58 }
59 else if (VAccessor* Accessor = FieldValue.DynamicCast<VAccessor>())
60 {
61 if (Wrapper)
62 {
63 V_RETURN(VAccessChain::New(Context, Accessor, *Wrapper));
64 }
65 else
66 {
67 V_RETURN(VAccessChain::New(Context, Accessor, Object));
68 }
69 }
71 }
72 case EFieldType::Offset:
73 default:
75 }
76}
77
78#endif // WITH_VERSE_VM
#define LIKELY(x)
Definition CityHash.cpp:107
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FUObjectArray GUObjectArray
Definition UObjectHash.cpp:55
#define VERSE_UNREACHABLE()
Definition VVMUnreachable.h:8
UE_FORCEINLINE_HINT bool IsDisregardForGC(const class UObjectBase *Object) const
Definition UObjectArray.h:1234
Definition Object.h:95
Definition VVMVerseClass.h:137
Definition FieldSystemNoiseAlgo.cpp:6
Definition Archive.h:36