|
|
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.
|
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 IrType & | type () 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. | |
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.
| 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. |
| 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. |
|
strong |
Expression node kind.
|
strong |
| 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).
| out | Destination list. |
| 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.
| out | Destination list. |
| 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.
| out | Destination list. |
|
friend |
Ostream output operator.
| os | Output stream. |
| expr | Expression to output. |