Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
Loading...
Searching...
No Matches
donner::gpu::shader::IrExpr Class Reference

A typed, immutable IR expression handle. More...

#include "donner/gpu/shader/IrExpr.h"

Classes

struct  RefInfo
 One name reference found inside an expression tree (see collectRefs). More...
struct  Node
 Internal storage for IrExpr nodes; public for the factory, serialization, and emitter implementations only. More...

Public Types

enum class  Kind : uint8_t {
  Literal ,
  Ref ,
  Unary ,
  Binary ,
  Member ,
  Swizzle ,
  Index ,
  Construct ,
  Convert ,
  CallBuiltin ,
  CallUser
}
 Expression node kind. More...
enum class  UnaryOp : uint8_t {
  Neg ,
  Not
}
 Unary operators. More...

Public Member Functions

const IrTypetype () const
 Result type of this expression.
Kind kind () const
 Node kind.
bool isMutableLvalue () const
 True if this expression is a valid assignment target: a var reference or a member/index/single-component-swizzle chain rooted at one.
void collectRefs (std::vector< RefInfo > &out) const
 Appends every name reference in this expression tree (depth-first, in operand order) to out.
void collectBuiltinCalls (std::vector< BuiltinFn > &out) const
 Appends every builtin function called anywhere in this expression tree to out.
void collectUserCalls (std::vector< RcString > &out) const
 Appends the name of every user function called anywhere in this expression tree to out.
std::string toString () const
 Formats this expression as a deterministic prefix string, e.g. add(ref(a), lit_f32(1)).

Friends

std::ostream & operator<< (std::ostream &os, const IrExpr &expr)
 Ostream output operator.

Detailed Description

A typed, immutable IR expression handle.

Construct through the free factory functions (LiteralF32, Add, Member, CallBuiltin, ...) or through the function builder's ref/addLet/addVar. Every handle carries its result type; assignability is tracked so only var-rooted access chains can be assignment targets.


Class Documentation

◆ donner::gpu::shader::IrExpr::RefInfo

struct donner::gpu::shader::IrExpr::RefInfo

One name reference found inside an expression tree (see collectRefs).

Class Members
RefKind kind What the name refers to.
RcString name Referenced name.
IrType type Type the reference was created with.

◆ donner::gpu::shader::IrExpr::Node

struct donner::gpu::shader::IrExpr::Node

Internal storage for IrExpr nodes; public for the factory, serialization, and emitter implementations only.

Class Members
BinaryOp binaryOp = BinaryOp::Add Binary payload.
BuiltinFn builtin = BuiltinFn::Abs Builtin payload.
vector< IrExpr > children Operands, in order.
Kind kind = Kind::Literal Node kind.
variant< bool, int32_t, uint32_t, float > literal = 0.0f Literal payload.
bool mutableLvalue = false Assignable access chain.
RcString name Ref/member/callee name.
RefKind refKind = RefKind::Let Ref payload.
string swizzle Swizzle components.
IrType type = IrType::F32() Result type.
UnaryOp unaryOp = UnaryOp::Neg Unary payload.

Member Enumeration Documentation

◆ Kind

enum class donner::gpu::shader::IrExpr::Kind : uint8_t
strong

Expression node kind.

Enumerator
Literal 

Scalar literal.

Ref 

Named reference (param/let/var/constant/resource).

Unary 

Unary minus or logical not.

Binary 

Binary operator.

Member 

Struct member access.

Swizzle 

Vector swizzle (.x, .xy, ...).

Index 

Array or vector indexing.

Construct 

Vector or matrix constructor.

Convert 

Scalar/vector element type conversion.

CallBuiltin 

Builtin function call.

CallUser 

User-defined function call.

◆ UnaryOp

enum class donner::gpu::shader::IrExpr::UnaryOp : uint8_t
strong

Unary operators.

Enumerator
Neg 

Unary minus (numeric, non-u32).

Not 

Logical not (bool).

Member Function Documentation

◆ collectBuiltinCalls()

void donner::gpu::shader::IrExpr::collectBuiltinCalls ( std::vector< BuiltinFn > & out) const

Appends every builtin function called anywhere in this expression tree to out.

Used by the function builder to enforce stage restrictions (fragment-only builtins).

Parameters
outDestination list.

◆ collectRefs()

void donner::gpu::shader::IrExpr::collectRefs ( std::vector< RefInfo > & out) const

Appends every name reference in this expression tree (depth-first, in operand order) to out.

Used by the function builder to re-verify that referenced names are still in scope when an expression is recorded into a statement.

Parameters
outDestination list.

◆ collectUserCalls()

void donner::gpu::shader::IrExpr::collectUserCalls ( std::vector< RcString > & out) const

Appends the name of every user function called anywhere in this expression tree to out.

Used to propagate stage restrictions through user calls.

Parameters
outDestination list.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const IrExpr & expr )
friend

Ostream output operator.

Parameters
osOutput stream.
exprExpression to output.

The documentation for this class was generated from the following file: