Navigation
API > API/Plugins > API/Plugins/RigVMDeveloper
Converts RigVM bytecode into a JSON representation for template rendering.
FRigVMCodeConverter is the core of the nativization pipeline. It parses a compiled RigVM's bytecode and produces a comprehensive JSON structure that Inja templates can use to generate C++ source code.Conversion Pipeline
Construction: Parses the VM's bytecode in a 14-step process:
- External variables, memory layouts (literal/work)
- Property paths, callables, blocks, entries
- Instructions with operand resolution
- Dependency tracking (includes, libraries)
Render: Combines the JSON with an Inja template to produce C++ code.JSON Structure Overview
The generated JSON contains:
- `AssetName_: Name of the source asset
- `VMHash_: Hash for validation
- `Variables_: External variable definitions
- `Memory.Literal_: Constant/default values
- `Memory.Work_: Runtime temporaries
- `Functions_: Unit functions and dispatch factories
- `Blocks_: Control flow blocks (branches)
- `Callables_: User-defined callable functions
- `Entries_: Entry points into the VM
- `Instructions_: Bytecode instructions with resolved operands
- `Includes_: Required C++ header files
- `Libraries_: Required UE module dependencies Usage
FRigVMCodeConversionSettingsSettings;Settings.TargetModule=TEXT("MyGame");Settings.OutputFolder=TEXT("Source/MyGame/Generated");autoConverter=MakeShared
| Name | FRigVMCodeConverter |
| Type | class |
| Header File | /Engine/Plugins/Runtime/RigVM/Source/RigVMDeveloper/Public/RigVMCompiler/RigVMCodeConverter.h |
| Include Path | #include "RigVMCompiler/RigVMCodeConverter.h" |
Syntax
class FRigVMCodeConverter
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FRigVMCodeConverter
(
IRigVMEditorAssetInterface* InEditorAsset, |
Constructs a converter and parses the VM's bytecode into JSON. | RigVMCompiler/RigVMCodeConverter.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bHasError | bool | True if an error occurred during conversion. | RigVMCompiler/RigVMCodeConverter.h | |
| BlockIndexPerInstruction | TArray< int32 > | Maps instruction index -> containing block index. | RigVMCompiler/RigVMCodeConverter.h | |
| Blocks | TArray< FRigVMBranchInfo > | All blocks (branches) including synthesized RunInstruction blocks. | RigVMCompiler/RigVMCodeConverter.h | |
| ByteCode | const FRigVMByteCode * | Direct reference to VM's bytecode. | RigVMCompiler/RigVMCodeConverter.h | |
| CallableArgumentMap | TMap< TTuple< int32, int32 >, TTuple< int32, int32, FName > > | Maps (memory type, register index) -> (callable index, argument index, argument name). | RigVMCompiler/RigVMCodeConverter.h | |
| CallableIndexPerInstruction | TArray< int32 > | Maps instruction index -> containing callable index. | RigVMCompiler/RigVMCodeConverter.h | |
| EditorAsset | IRigVMEditorAssetInterface * | ============================================================================ State | RigVMCompiler/RigVMCodeConverter.h | |
| FunctionIndexMap | TMap< const void *, int32 > | Maps function pointer -> function index (for deduplication). | RigVMCompiler/RigVMCodeConverter.h | |
| HashToCustomFunction | TMap< uint32, TSharedPtr< FRigVMFunction > > | Maps type hash -> custom function (for dispatch permutations). | RigVMCompiler/RigVMCodeConverter.h | |
| Includes | TArray< FString > | Accumulated include paths for generated code. | RigVMCompiler/RigVMCodeConverter.h | |
| Instructions | FRigVMInstructionArray | All instructions from bytecode. | RigVMCompiler/RigVMCodeConverter.h | |
| InstructionToCustomFunction | TMap< int32, TSharedPtr< FRigVMFunction > > | Maps instruction index -> custom function (for dispatch permutations). | RigVMCompiler/RigVMCodeConverter.h | |
| Json | inja::json | The complete JSON representation of the VM. | RigVMCompiler/RigVMCodeConverter.h | |
| KnownDependencies | TSet< const UObject * > | Set of already-processed dependencies (avoids duplicates). | RigVMCompiler/RigVMCodeConverter.h | |
| LazyFunctionArguments | TSet< TTuple< int32, int32 > > | Set of (function index, argument index) pairs that are lazy values. | RigVMCompiler/RigVMCodeConverter.h | |
| LazyProperties | TArray< TTuple< FString, FString > > | Accumulated lazy property definitions. | RigVMCompiler/RigVMCodeConverter.h | |
| Libraries | TArray< FString > | Accumulated library/module dependencies. | RigVMCompiler/RigVMCodeConverter.h | |
| NativePathMap | TMap< FString, const UObject * > | Cache: native path string -> UObject. | RigVMCompiler/RigVMCodeConverter.h | |
| NativeTypeMap | TMap< FString, FString > | Cache: original type -> sanitized type (for 2D array remapping). | RigVMCompiler/RigVMCodeConverter.h | |
| PackageName | FString | Sanitized package name (used for class naming). | RigVMCompiler/RigVMCodeConverter.h | |
| PropertyMap | TMap< TTuple< int32, int32 >, int32 > | Maps (memory type, register index) -> exported property index. | RigVMCompiler/RigVMCodeConverter.h | |
| PropertyPathMap | TMap< uint32, int32 > | Maps property path hash -> property path index. | RigVMCompiler/RigVMCodeConverter.h | |
| RunInstructionBranches | TMap< TTuple< int32, int32 >, int32 > | Maps (first instruction, last instruction) -> branch info index for RunInstruction blocks. | RigVMCompiler/RigVMCodeConverter.h | |
| Settings | FRigVMCodeConversionSettings | Conversion settings. | RigVMCompiler/RigVMCodeConverter.h | |
| UniquePropertyNames | TSet< TTuple< int32, FString > > | Tracks unique property names per memory type for deduplication. | RigVMCompiler/RigVMCodeConverter.h | |
| VM | URigVM * | The RigVM being converted. | RigVMCompiler/RigVMCodeConverter.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FString GetAssetName() |
Returns the sanitized asset name used for generated class names. | RigVMCompiler/RigVMCodeConverter.h | |
const inja::json & GetJson() |
Returns the parsed JSON representation of the VM (for debugging/inspection). | RigVMCompiler/RigVMCodeConverter.h | |
bool HasError() |
Returns true if an error occurred during construction or rendering. | RigVMCompiler/RigVMCodeConverter.h | |
TSharedPtr< FRigVMCodeOutput > Render
(
const TSharedPtr< FRigVMCodeTemplate >& InTemplate |
Renders a template using the parsed JSON data. | RigVMCompiler/RigVMCodeConverter.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Converts std::string to FString. | RigVMCompiler/RigVMCodeConverter.h | ||
| Converts inja::json to FString. | RigVMCompiler/RigVMCodeConverter.h | ||
static uint32 GetPropertyPathHash
(
const FRigVMPropertyPath& InPropertyPath |
============================================================================ Type/Path Resolution | RigVMCompiler/RigVMCodeConverter.h | |
static FString SanitizeName
(
const FString& InString |
============================================================================ Name Sanitization | RigVMCompiler/RigVMCodeConverter.h | |
| Converts FString to inja::json (UTF-8 encoded). | RigVMCompiler/RigVMCodeConverter.h | ||
static inja::json ToJson
(
int64 InEnumValue, |
============================================================================ Enum/Primitive JSON Conversion | RigVMCompiler/RigVMCodeConverter.h | |
| Converts FText to inja::json. | RigVMCompiler/RigVMCodeConverter.h | ||
| Converts FName to inja::json. | RigVMCompiler/RigVMCodeConverter.h | ||
| Converts an enum value to its display name as JSON. | RigVMCompiler/RigVMCodeConverter.h |