// Generated API outline. Implementation bodies omitted.
#nullable enable
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using System;
using nfloat = System.Runtime.InteropServices.NFloat;
using static Xui.Core.Math2D.Constants;
namespace Xui.GPU.IR
{
///
/// Binary operator kind.
///
public enum BinaryOperator
{
/// Addition operator (+).
Add,
/// Subtraction operator (-).
Subtract,
/// Multiplication operator (*).
Multiply,
/// Division operator (/).
Divide,
/// Modulo operator (%).
Modulo,
/// Equality comparison (==).
Equal,
/// Inequality comparison (!=).
NotEqual,
/// Less-than comparison (<).
LessThan,
/// Less-than-or-equal comparison (<=).
LessThanOrEqual,
/// Greater-than comparison (>).
GreaterThan,
/// Greater-than-or-equal comparison (>=).
GreaterThanOrEqual,
/// Logical AND.
LogicalAnd,
/// Logical OR.
LogicalOr,
/// Bitwise AND (&).
BitwiseAnd,
/// Bitwise OR (|).
BitwiseOr,
/// Bitwise XOR (^).
BitwiseXor,
/// Left bit shift (<<).
ShiftLeft,
/// Right bit shift (>>).
ShiftRight
}
///
/// Built-in semantic kinds.
///
public enum BuiltInSemantic
{
/// Vertex position output semantic.
Position,
/// Fragment depth output semantic.
FragDepth,
/// Instance identifier semantic.
InstanceId,
/// Vertex identifier semantic.
VertexId
}
///
/// Interpolation mode for varyings.
///
public enum InterpolationMode
{
/// Linear interpolation without perspective correction.
Linear,
/// No interpolation; value is constant across the primitive.
Flat,
/// Perspective-correct interpolation (default).
Perspective
}
///
/// Represents an assignment statement.
///
public class IrAssignment : IrStatement
{
/// Gets the IR node kind for this statement.
public override IrNodeKind Kind { get; }
/// Gets the assignment target expression.
public IrExpression Target { get; }
/// Gets the value expression to assign.
public IrExpression Value { get; }
///
/// Initializes a new instance of with the specified target and value.
///
public IrAssignment(IrExpression target, IrExpression value);
}
///
/// Represents a binary operation.
///
public class IrBinaryOp : IrExpression
{
/// Gets the node kind for this binary operation.
public override IrNodeKind Kind { get; }
/// Gets the result type of the binary operation.
public override IrType Type { get; }
/// Gets the binary operator.
public BinaryOperator Operator { get; }
/// Gets the left-hand operand.
public IrExpression Left { get; }
/// Gets the right-hand operand.
public IrExpression Right { get; }
/// Initializes a new instance of the class.
public IrBinaryOp(BinaryOperator op, IrExpression left, IrExpression right, IrType type);
}
///
/// Represents a binding decoration for resources.
///
public class IrBindingDecoration : IrDecoration
{
/// Gets the IR node kind for this decoration.
public override IrNodeKind Kind { get; }
/// Gets the binding group index.
public int Group { get; }
/// Gets the binding slot index within the group.
public int Binding { get; }
///
/// Initializes a new instance of with the specified group and binding.
///
public IrBindingDecoration(int group, int binding);
}
///
/// Represents a block of statements.
///
public class IrBlock : IrStatement
{
/// Gets the IR node kind for this block.
public override IrNodeKind Kind { get; }
/// Gets the list of statements in this block.
public List Statements { get; }
///
/// Initializes a new empty block.
///
public IrBlock();
///
/// Initializes a new block with the specified statements.
///
public IrBlock(IEnumerable statements);
}
///
/// Represents a built-in semantic decoration.
///
public class IrBuiltInDecoration : IrDecoration
{
/// Gets the IR node kind for this decoration.
public override IrNodeKind Kind { get; }
/// Gets the built-in semantic.
public BuiltInSemantic Semantic { get; }
///
/// Initializes a new instance of with the specified semantic.
///
public IrBuiltInDecoration(BuiltInSemantic semantic);
}
///
/// Represents a constant value.
///
public class IrConstant : IrExpression
{
/// Gets the node kind for this constant.
public override IrNodeKind Kind { get; }
/// Gets the type of the constant.
public override IrType Type { get; }
/// Gets the constant value.
public object Value { get; }
/// Initializes a new instance of the class.
public IrConstant(IrType type, object value);
}
///
/// Represents a constructor call.
///
public class IrConstructor : IrExpression
{
/// Gets the node kind for this constructor call.
public override IrNodeKind Kind { get; }
/// Gets the type being constructed.
public override IrType Type { get; }
/// Gets the list of arguments passed to the constructor.
public List Arguments { get; }
/// Initializes a new instance of the class.
public IrConstructor(IrType type, List arguments);
}
///
/// Base class for decoration nodes (attributes).
///
public abstract class IrDecoration : IrNode
{
}
///
/// Base class for all expression nodes in the IR.
///
public abstract class IrExpression : IrNode
{
///
/// Gets the type of this expression.
///
public abstract IrType Type { get; }
}
///
/// Represents a field access.
///
public class IrFieldAccess : IrExpression
{
/// Gets the node kind for this field access.
public override IrNodeKind Kind { get; }
/// Gets the result type of the field access.
public override IrType Type { get; }
/// Gets the expression representing the object being accessed.
public IrExpression Object { get; }
/// Gets the name of the field being accessed.
public string FieldName { get; }
/// Initializes a new instance of the class.
public IrFieldAccess(IrExpression obj, string fieldName, IrType type);
}
///
/// Represents a fragment shader stage.
///
public class IrFragmentStage : IrNode
{
/// Gets the IR node kind for this stage.
public override IrNodeKind Kind { get; }
/// Gets or sets the stage name.
public string Name { get; set; }
/// Gets or sets the input struct type.
public IrStructType InputType { get; set; }
/// Gets or sets the output struct type.
public IrStructType OutputType { get; set; }
/// Gets or sets the optional bindings struct type.
public IrStructType? BindingsType { get; set; }
/// Gets or sets the body block of this stage.
public IrBlock Body { get; set; }
}
///
/// Represents a function declaration.
///
public class IrFunctionDecl : IrNode
{
/// Gets the IR node kind for this declaration.
public override IrNodeKind Kind { get; }
/// Gets or sets the function name.
public string Name { get; set; }
/// Gets or sets the return type.
public IrType ReturnType { get; set; }
/// Gets the list of function parameters.
public List Parameters { get; }
/// Gets or sets the function body block.
public IrBlock Body { get; set; }
}
///
/// Represents an if statement.
///
public class IrIf : IrStatement
{
/// Gets the IR node kind for this statement.
public override IrNodeKind Kind { get; }
/// Gets the condition expression.
public IrExpression Condition { get; }
/// Gets the block executed when the condition is true.
public IrBlock ThenBlock { get; }
/// Gets the optional block executed when the condition is false.
public IrBlock? ElseBlock { get; }
///
/// Initializes a new instance of with the specified condition and blocks.
///
public IrIf(IrExpression condition, IrBlock thenBlock, IrBlock? elseBlock = null);
}
///
/// Represents an interpolation mode decoration.
///
public class IrInterpolationDecoration : IrDecoration
{
/// Gets the IR node kind for this decoration.
public override IrNodeKind Kind { get; }
/// Gets the interpolation mode.
public InterpolationMode Mode { get; }
///
/// Initializes a new instance of with the specified mode.
///
public IrInterpolationDecoration(InterpolationMode mode);
}
///
/// Represents a location decoration for vertex inputs/outputs.
///
public class IrLocationDecoration : IrDecoration
{
/// Gets the IR node kind for this decoration.
public override IrNodeKind Kind { get; }
/// Gets the location index.
public int Location { get; }
///
/// Initializes a new instance of with the specified location.
///
public IrLocationDecoration(int location);
}
///
/// Represents a matrix type (Float4x4, etc.).
///
public class IrMatrixType : IrType
{
/// Gets the IR node kind for this type.
public override IrNodeKind Kind { get; }
/// Gets the display name of this matrix type.
public override string Name { get; }
/// Gets the scalar element type of the matrix.
public IrScalarType ElementType { get; }
/// Gets the number of rows.
public int Rows { get; }
/// Gets the number of columns.
public int Columns { get; }
///
/// Initializes a new instance of with the specified element type and dimensions.
///
public IrMatrixType(IrScalarType elementType, int rows, int columns);
}
///
/// Represents a method call (shader intrinsic or user function).
///
public class IrMethodCall : IrExpression
{
/// Gets the node kind for this method call.
public override IrNodeKind Kind { get; }
/// Gets the return type of the method call.
public override IrType Type { get; }
/// Gets the name of the method being called.
public string MethodName { get; }
/// Gets the list of arguments passed to the method.
public List Arguments { get; }
/// Gets the optional target expression for instance method calls.
public IrExpression? Target { get; }
/// Initializes a new instance of the class.
public IrMethodCall(string methodName, List arguments, IrType type, IrExpression? target = null);
}
///
/// Base class for all IR nodes in the intermediate representation.
///
public abstract class IrNode
{
///
/// Gets the node kind for pattern matching and visitors.
///
public abstract IrNodeKind Kind { get; }
///
/// Gets or sets the source location where this node originates from.
/// Used to generate accurate error messages mapping back to C# source.
///
public SourceLocation? SourceLocation { get; set; }
}
///
/// Enumeration of all IR node kinds.
///
public enum IrNodeKind
{
/// Scalar type node.
ScalarType,
/// Vector type node.
VectorType,
/// Matrix type node.
MatrixType,
/// Struct type node.
StructType,
/// Texture type node.
TextureType,
/// Sampler type node.
SamplerType,
/// Constant expression.
Constant,
/// Parameter reference expression.
Parameter,
/// Field access expression.
Field,
/// Binary operation expression.
BinaryOp,
/// Unary operation expression.
UnaryOp,
/// Method call expression.
MethodCall,
/// Constructor call expression.
Constructor,
/// Variable declaration statement.
VarDecl,
/// Assignment statement.
Assignment,
/// Return statement.
Return,
/// Conditional statement.
If,
/// Block of statements.
Block,
/// Location decoration.
Location,
/// Built-in semantic decoration.
BuiltIn,
/// Resource binding decoration.
Binding,
/// Interpolation mode decoration.
Interpolation,
/// Shader module node.
ShaderModule,
/// Vertex shader stage.
VertexStage,
/// Fragment shader stage.
FragmentStage,
/// Struct declaration.
StructDecl,
/// Function declaration.
FunctionDecl,
}
///
/// Represents a parameter reference.
///
public class IrParameter : IrExpression
{
/// Gets the node kind for this parameter reference.
public override IrNodeKind Kind { get; }
/// Gets the type of the parameter.
public override IrType Type { get; }
/// Gets the name of the parameter.
public string Name { get; }
/// Initializes a new instance of the class.
public IrParameter(string name, IrType type);
}
///
/// Represents a return statement.
///
public class IrReturn : IrStatement
{
/// Gets the IR node kind for this statement.
public override IrNodeKind Kind { get; }
/// Gets the optional return value expression.
public IrExpression? Value { get; }
///
/// Initializes a new instance of with an optional return value.
///
public IrReturn(IrExpression? value = null);
}
///
/// Represents a sampler type.
///
public class IrSamplerType : IrType
{
/// Gets the IR node kind for this type.
public override IrNodeKind Kind { get; }
/// Gets the display name of this sampler type.
public override string Name { get; }
/// Shared singleton instance of the sampler type.
public static readonly IrSamplerType Instance;
}
///
/// Represents a scalar type (F32, I32, U32, Bool).
///
public class IrScalarType : IrType
{
/// Gets the IR node kind for this type.
public override IrNodeKind Kind { get; }
/// Gets the display name of this scalar type.
public override string Name { get; }
/// Gets the scalar kind.
public ScalarKind ScalarKind { get; }
///
/// Initializes a new instance of with the specified scalar kind.
///
public IrScalarType(ScalarKind kind);
}
///
/// Represents a complete shader module with all stages and declarations.
///
public class IrShaderModule : IrNode
{
/// Gets the IR node kind for this module.
public override IrNodeKind Kind { get; }
/// Gets or sets the module name.
public string Name { get; set; }
/// Gets the list of struct declarations.
public List Structs { get; }
/// Gets the list of function declarations.
public List Functions { get; }
/// Gets or sets the optional vertex shader stage.
public IrVertexStage? VertexStage { get; set; }
/// Gets or sets the optional fragment shader stage.
public IrFragmentStage? FragmentStage { get; set; }
}
///
/// Base class for all statement nodes in the IR.
///
public abstract class IrStatement : IrNode
{
}
///
/// Represents a struct declaration.
///
public class IrStructDecl : IrNode
{
/// Gets the IR node kind for this declaration.
public override IrNodeKind Kind { get; }
/// Gets the struct type being declared.
public IrStructType Type { get; }
///
/// Initializes a new instance of with the specified struct type.
///
public IrStructDecl(IrStructType type);
}
///
/// Represents a field in a struct.
///
public class IrStructField
{
/// Gets or sets the field name.
public string Name { get; set; }
/// Gets or sets the field type.
public IrType Type { get; set; }
/// Gets the list of decorations applied to this field.
public List Decorations { get; }
}
///
/// Represents a struct type.
///
public class IrStructType : IrType
{
/// Gets the IR node kind for this type.
public override IrNodeKind Kind { get; }
/// Gets the name of this struct type.
public override string Name { get; }
/// Gets the list of fields in this struct.
public List Fields { get; }
///
/// Initializes a new instance of with the specified name.
///
public IrStructType(string name);
}
///
/// Represents a texture type.
///
public class IrTextureType : IrType
{
/// Gets the IR node kind for this type.
public override IrNodeKind Kind { get; }
/// Gets the display name of this texture type.
public override string Name { get; }
/// Gets the pixel element type of the texture.
public IrType PixelType { get; }
///
/// Initializes a new instance of with the specified pixel type.
///
public IrTextureType(IrType pixelType);
}
///
/// Base class for all type nodes in the IR.
///
public abstract class IrType : IrNode
{
///
/// Gets the name of this type.
///
public abstract string Name { get; }
}
///
/// Represents a unary operation.
///
public class IrUnaryOp : IrExpression
{
/// Gets the node kind for this unary operation.
public override IrNodeKind Kind { get; }
/// Gets the result type of the unary operation.
public override IrType Type { get; }
/// Gets the unary operator.
public UnaryOperator Operator { get; }
/// Gets the operand of the unary operation.
public IrExpression Operand { get; }
/// Initializes a new instance of the class.
public IrUnaryOp(UnaryOperator op, IrExpression operand, IrType type);
}
///
/// Represents a variable declaration.
///
public class IrVarDecl : IrStatement
{
/// Gets the IR node kind for this statement.
public override IrNodeKind Kind { get; }
/// Gets the variable name.
public string Name { get; }
/// Gets the variable type.
public IrType Type { get; }
/// Gets the optional initializer expression.
public IrExpression? Initializer { get; }
///
/// Initializes a new instance of with the specified name, type, and optional initializer.
///
public IrVarDecl(string name, IrType type, IrExpression? initializer = null);
}
///
/// Represents a vector type (Float2, Float3, Float4, Int2, etc.).
///
public class IrVectorType : IrType
{
/// Gets the IR node kind for this type.
public override IrNodeKind Kind { get; }
/// Gets the display name of this vector type.
public override string Name { get; }
/// Gets the scalar element type of the vector.
public IrScalarType ElementType { get; }
/// Gets the number of components (2-4).
public int Dimension { get; }
///
/// Initializes a new instance of with the specified element type and dimension.
///
public IrVectorType(IrScalarType elementType, int dimension);
}
///
/// Represents a vertex shader stage.
///
public class IrVertexStage : IrNode
{
/// Gets the IR node kind for this stage.
public override IrNodeKind Kind { get; }
/// Gets or sets the stage name.
public string Name { get; set; }
/// Gets or sets the input struct type.
public IrStructType InputType { get; set; }
/// Gets or sets the output struct type.
public IrStructType OutputType { get; set; }
/// Gets or sets the optional bindings struct type.
public IrStructType? BindingsType { get; set; }
/// Gets or sets the body block of this stage.
public IrBlock Body { get; set; }
}
///
/// Kind of scalar type.
///
public enum ScalarKind
{
/// 32-bit floating point.
F32,
/// 32-bit signed integer.
I32,
/// 32-bit unsigned integer.
U32,
/// Boolean value.
Bool
}
///
/// Represents a location in source code.
/// Used to map IR nodes back to original C# source for error reporting.
///
public class SourceLocation
{
///
/// Gets the source file path.
///
public string FilePath { get; set; }
///
/// Gets the line number (1-based).
///
public int Line { get; set; }
///
/// Gets the column number (1-based).
///
public int Column { get; set; }
///
/// Gets a formatted string representation of this location.
///
public string ToDisplayString();
}
///
/// Unary operator kind.
///
public enum UnaryOperator
{
/// Arithmetic negation (-).
Negate,
/// Logical NOT (!).
LogicalNot,
/// Bitwise NOT (~).
BitwiseNot
}
}