// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "MuR/SystemPrivate.h" namespace UE::Mutable::Private { class FProgramCache; class FInstance; class FExtensionData; struct FProgram; class FModel; class FParameters; class FSystem; class String; struct FScheduledOpInline { explicit FScheduledOpInline(OP::ADDRESS InAt = 0, const uint16 InStage = 0, const uint16 InExecutionIndex = 0) : At(InAt), Stage(InStage), ExecutionIndex(InExecutionIndex) { } explicit FScheduledOpInline(OP::ADDRESS InAt, const FScheduledOpInline& InOpTemplate) : At(InAt), ExecutionIndex(InOpTemplate.ExecutionIndex) { } FScheduledOpInline(const FScheduledOpInline& InOpTemplate, uint16 InStage) : At(InOpTemplate.At), Stage(InStage), ExecutionIndex(InOpTemplate.ExecutionIndex) { } bool operator==(const FScheduledOpInline& Other) const; OP::ADDRESS At = 0; uint16 Stage = 0; uint16 ExecutionIndex = 0; OP::ADDRESS CustomState = 0; }; uint32 GetTypeHash(const FScheduledOpInline& Op); struct FCacheAddressInline { FCacheAddressInline(const OP::ADDRESS& InAt) { At = InAt; } FCacheAddressInline(const FScheduledOpInline& Item) { At = Item.At; ExecutionIndex = Item.ExecutionIndex; } OP::ADDRESS At = 0; uint16 ExecutionIndex = 0; bool operator==(const FCacheAddressInline&) const = default; }; uint32 GetTypeHash(const FCacheAddressInline& Address); class FOpSet { public: FOpSet(int32 NumElements); bool Contains(const FCacheAddressInline& Item); void Add(const FCacheAddressInline& Item); private: TBitArray<> Index0; TSet IndexOther; }; using FStackValue = TVariant, TSharedPtr, TSharedPtr>; class FStack : public TArray> { public: FStackValue Pop(); }; class CodeRunnerBegin { public: CodeRunnerBegin(FSystem& InSystem, const TSharedPtr& InModel, const TSharedPtr& InParams, uint32 InLodMask); TSharedPtr RunCode(const FScheduledOpInline& Root); FProgramCache& GetMemory() const; FScheduledOpInline PopOp(); void PushOp(const FScheduledOpInline& Item); void StoreInt(const FCacheAddressInline& To, int32 Value); void StoreFloat(const FCacheAddressInline& To, float Value); void StoreBool(const FCacheAddressInline& To, bool Value); void StoreInstance(const FCacheAddressInline& To, const TSharedPtr& Value); void StoreString(const FCacheAddressInline& To, const TSharedPtr& Value); void StoreExtensionData(const FCacheAddressInline& To, const TSharedPtr& Value); void StoreNone(const FCacheAddressInline& To); int32 LoadInt(const FCacheAddressInline& To); float LoadFloat(const FCacheAddressInline& To); bool LoadBool(const FCacheAddressInline& To); TSharedPtr LoadInstance(const FCacheAddressInline& To); TSharedPtr LoadString(const FCacheAddressInline& To); TSharedPtr LoadExtensionData(const FCacheAddressInline& To); TSharedPtr Model; TSharedPtr Params; FSystem& System; FProgram& Program; uint32 LodMask; TArray>> Items; FStack Stack; FOpSet Executed; TMap ResultsFloat; TMap ResultsBool; TMap ResultsInt; TMap> ResultsInstance; TMap> ResultsString; TMap> ResultsExtensionData; TArray MI_REFERENCE_ID; TArray IM_REFERENCE_ID; TArray ME_REFERENCE_ID; TArray ME_SKELETON_ID; }; }