UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMScopeInline.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/VVMScope.h"
7
8#include <type_traits>
9
10namespace Verse
11{
12inline size_t VScope::NumBytes(uint32 NumCaptures)
13{
14 static_assert(std::is_array_v<decltype(Captures)>);
15 return offsetof(VScope, Captures) + sizeof(std::remove_extent_t<decltype(Captures)>) * NumCaptures;
16}
17
18inline VScope& VScope::New(FAllocationContext Context, VScope* ParentScope, uint32 NumCaptures)
19{
20 return *new (Context.AllocateFastCell(NumBytes(NumCaptures))) VScope{Context, ParentScope, NumCaptures};
21}
22
23inline VScope& VScope::New(FAllocationContext Context, VClass* SuperClass)
24{
25 if (!SuperClass)
26 {
27 return New(Context);
28 }
29 VScope& Scope = New(Context, nullptr, 1);
30 Scope.Captures[0].Set(Context, *SuperClass);
31 return Scope;
32}
33
34inline VScope& VScope::New(FAllocationContext Context)
35{
36 return New(Context, nullptr, 0);
37}
38
39inline VScope& VScope::NewUninitialized(FAllocationContext Context, uint32 NumCaptures)
40{
41 return *new (Context.AllocateFastCell(NumBytes(NumCaptures))) VScope{Context, nullptr, NumCaptures};
42}
43
44inline VScope& VScope::GetRootScope()
45{
46 for (auto I = this;;)
47 {
48 auto J = I->ParentScope.Get();
49 if (!J)
50 {
51 return *I;
52 }
53 I = J;
54 }
55}
56
57inline VScope::VScope(FAllocationContext Context, VScope* ParentScope, uint32 NumCaptures)
60 , NumCaptures{NumCaptures}
61{
62 for (auto I = Captures, Last = Captures + NumCaptures; I != Last; ++I)
63 {
64 static_assert(std::is_array_v<decltype(Captures)>);
65 new (I) std::remove_extent_t<decltype(Captures)>{};
66 }
67}
68} // namespace Verse
69
70#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
uint32_t uint32
Definition binka_ue_file_header.h:6
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
Definition Archive.h:36