Files
UnrealEngineUWP/Engine/Source/Programs/Shared/EpicGames.BuildGraph/BgBytecodeWriter.cs
Ben Marsh 38f3bc55ef BuildGraph: Various VM improvements.
* Added support for deserializing BgObject types directly into native classes.
* Removed opcodes for creating graph structures. These are now created in user code from BgObject types.
* Removed BgNodeSpecBuilder. BgNode objects can now be modified directly (returning a modified copy).
* Added concrete types for option parameters. The VM now keeps track of any parameters for evaluated options, allowing them to be added into the graph definition.
* Order dependencies now take nodes rather than outputs.
* Added explicit support for native thunks, whose bindings are saved to a sideband channel during compilation and referenced in bytecode as an index. This generalizes code that was previously specific to node definitions.
* Added a name table to bytecode, to optimize situations where we reference the same string mulitple times.

#preflight 62bf3c583f0d6beee2e8f4a6

[CL 20918762 by Ben Marsh in ue5-main branch]
2022-07-01 14:47:54 -04:00

77 lines
2.1 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using EpicGames.Core;
using EpicGames.Serialization;
using EpicGames.BuildGraph.Expressions;
namespace EpicGames.BuildGraph
{
/// <summary>
/// Helper class for writing BuildGraph bytecode to a buffer.
/// </summary>
public abstract class BgBytecodeWriter
{
/// <summary>
/// Writes an opcode to the output
/// </summary>
/// <param name="opcode"></param>
public abstract void WriteOpcode(BgOpcode opcode);
/// <summary>
/// Writes a string to the output
/// </summary>
/// <param name="str"></param>
public abstract void WriteString(string str);
/// <summary>
/// Writes a reference to an interned string to the output
/// </summary>
/// <param name="name">Name to write</param>
public abstract void WriteName(string name);
/// <summary>
/// Writes a signed integer value to the output
/// </summary>
/// <param name="value"></param>
public abstract void WriteSignedInteger(long value);
/// <summary>
/// Writes an unsigned integer to the output
/// </summary>
/// <param name="value"></param>
public void WriteUnsignedInteger(int value) => WriteUnsignedInteger((ulong)value);
/// <summary>
/// Writes an unsigned integer to the output
/// </summary>
/// <param name="value"></param>
public abstract void WriteUnsignedInteger(ulong value);
/// <summary>
/// Writes an expression to the output buffer
/// </summary>
/// <param name="expr"></param>
public abstract void WriteExpr(BgExpr expr);
/// <summary>
/// Writes an expression as a standalone fragment, encoding just the fragment index into the output stream
/// </summary>
/// <param name="expr"></param>
public abstract void WriteExprAsFragment(BgExpr expr);
/// <summary>
/// Writes a thunk to native code.
/// </summary>
/// <param name="thunk">Method to be called</param>
public abstract void WriteThunk(BgThunkDef thunk);
}
}