UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMBytecodeDispatcher.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
8#include "VVMBytecode.h"
9#include "VVMBytecodeOps.h"
11#include "VVMLog.h"
12#include "VVMProcedure.h"
13
14namespace Verse
15{
16template <typename HandlerType>
17decltype(auto) DispatchOp(FOp& Op, HandlerType&& Handler)
18{
19 switch (Op.Opcode)
20 {
21#define VISIT_OP(Name) \
22 case EOpcode::Name: \
23 return Handler(static_cast<FOp##Name&>(Op));
24
26
27#undef VISIT_OP
28 }
29 V_DIE("Invalid opcode: %u", static_cast<FOpcodeInt>(Op.Opcode));
30}
31
32template <typename HandlerType>
33void DispatchOps(FOp* OpsBegin, FOp* OpsEnd, HandlerType&& Handler)
34{
35 FOp* Op = OpsBegin;
36 while (Op < OpsEnd)
37 {
38 Op = DispatchOp(*Op, [&](auto&& Op) -> FOp* {
39 Handler(Op);
40 return &Op + 1;
41 });
42 }
43}
44
45// HandlerType can take in an FOp& or an auto& and descriminate on the actual
46// subtype of FOp being passed in.
47template <typename HandlerType>
49{
50 DispatchOps(Procedure.GetOpsBegin(), Procedure.GetOpsEnd(), Forward<HandlerType>(Handler));
51}
52
53} // namespace Verse
54#endif // WITH_VERSE_VM
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Archive.h:36