Files
UnrealEngineUWP/Engine/Source/Programs/Shared/EpicGames.BuildGraph/Expressions/BgGraph.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

79 lines
1.9 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
namespace EpicGames.BuildGraph.Expressions
{
/// <summary>
/// Specification for a graph in fluent syntax
/// </summary>
public class BgGraph : BgExpr
{
/// <summary>
/// Nodes for the graph
/// </summary>
public BgList<BgNode> Nodes { get; }
/// <summary>
/// Aggregates for the graph
/// </summary>
public BgList<BgAggregate> Aggregates { get; }
/// <summary>
/// Constructor
/// </summary>
public BgGraph(BgList<BgNode> nodes, BgList<BgAggregate> aggregates)
: base(BgExprFlags.ForceFragment)
{
Nodes = nodes;
Aggregates = aggregates;
}
/// <summary>
/// Implicit conversion from a node spec
/// </summary>
public static implicit operator BgGraph(BgNode node)
{
return new BgGraph(node, BgList<BgAggregate>.Empty);
}
/// <summary>
/// Implicit conversion from a list of node specs
/// </summary>
public static implicit operator BgGraph(BgList<BgNode> nodes)
{
return new BgGraph(nodes, BgList<BgAggregate>.Empty);
}
/// <summary>
/// Implicit conversion from an aggregate spec
/// </summary>
public static implicit operator BgGraph(BgAggregate aggregate)
{
return new BgGraph(BgList<BgNode>.Empty, aggregate);
}
/// <summary>
/// Implicit conversion from a list of node specs
/// </summary>
public static implicit operator BgGraph(BgList<BgAggregate> aggregates)
{
return new BgGraph(BgList<BgNode>.Empty, aggregates);
}
/// <inheritdoc/>
public override void Write(BgBytecodeWriter writer)
{
BgObject<BgGraphExpressionDef> obj = BgObject<BgGraphExpressionDef>.Empty;
obj = obj.Set(x => x.Nodes, Nodes);
obj = obj.Set(x => x.Aggregates, Aggregates);
writer.WriteExpr(obj);
}
/// <inheritdoc/>
public override BgString ToBgString() => "{Graph}";
}
}