UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMOpResult.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 "CoreTypes.h"
8#include "VVMValue.h"
9
10#define V_RETURN(...) \
11 return ::Verse::FOpResult \
12 { \
13 ::Verse::FOpResult::Return, (__VA_ARGS__) \
14 }
15#define V_REQUIRE_CONCRETE(...) \
16 if (VValue MaybePlaceholderVal = (__VA_ARGS__); MaybePlaceholderVal.IsPlaceholder()) \
17 { \
18 return ::Verse::FOpResult{::Verse::FOpResult::Block, MaybePlaceholderVal}; \
19 }
20#define V_FAIL_IF(...) \
21 if (__VA_ARGS__) \
22 { \
23 return ::Verse::FOpResult{::Verse::FOpResult::Fail}; \
24 }
25#define V_FAIL_UNLESS(...) \
26 if (!(__VA_ARGS__)) \
27 { \
28 return ::Verse::FOpResult{::Verse::FOpResult::Fail}; \
29 }
30#define V_YIELD() \
31 return ::Verse::FOpResult \
32 { \
33 ::Verse::FOpResult::Yield \
34 }
35
36namespace Verse
37{
38
39// Represents the result of a single VM operation
40struct FOpResult
41{
42 enum EKind
43 {
44 Return, // All went well, and Value is the result.
45 Block, // A placeholder was encountered, and this operation should be enqueued on Value.
46 Fail, // The current choice failed. Value is undefined.
47 Yield, // The task suspended, and execution should continue in the resumer. Value is undefined.
48 Error, // A runtime error occurred, and an exception was raised. Value is undefined.
49 };
50
51 FOpResult()
52 : Kind(FOpResult::Error)
53 {
54 }
55
56 FOpResult(EKind Kind, VValue Value = VValue())
57 : Kind(Kind)
58 , Value(Value)
59 {
60 }
61
62 bool IsReturn() const
63 {
64 return Kind == Return;
65 }
66
67 bool IsError() const
68 {
69 return Kind == Error;
70 }
71
72 static void AutoRTFMAssignFromOpenToClosed(FOpResult& Closed, const FOpResult& Open)
73 {
74 Closed = Open;
75 }
76
77 EKind Kind;
78 VValue Value;
79};
80
81} // namespace Verse
82#endif // WITH_VERSE_VM
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
@ Return
Definition KismetSystemLibrary.h:68
Definition Archive.h:36