|
|
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.
|
Builds one function or entry point. More...
#include "donner/gpu/shader/IrModule.h"
Public Member Functions | |
| FunctionBuilder (FunctionBuilder &&other) noexcept | |
Move constructor; other becomes an inert moved-from shell. | |
| FunctionBuilder (const FunctionBuilder &)=delete | |
| FunctionBuilder & | operator= (const FunctionBuilder &)=delete |
| FunctionBuilder & | operator= (FunctionBuilder &&)=delete |
| ~FunctionBuilder () | |
| Destructor. Destroying an unfinished builder abandons the function, letting the module builder start a new one (the abandoned function is not registered). | |
| ShaderResult< IrExpr > | ref (const RcString &name) const |
Resolves name to a reference expression: function parameters, lets, vars, then module-scope constants and resource bindings. | |
| ShaderResult< IrExpr > | addLet (const RcString &name, const IrExpr &value) |
| Declares let name = value; and returns a reference to it. | |
| ShaderResult< IrExpr > | addVar (const RcString &name, const IrType &type, const std::optional< IrExpr > &init=std::nullopt) |
| Declares var name: type (= init); and returns a (mutable) reference to it. | |
| ShaderStatus | assign (const IrExpr &lhs, const IrExpr &rhs) |
| Records lhs = rhs;. | |
| ShaderStatus | beginIf (const IrExpr &condition) |
| Opens if (condition) { ... }. | |
| ShaderStatus | elseBranch () |
| Switches the innermost open if to its else-branch. | |
| ShaderStatus | endIf () |
| Closes the innermost open if. | |
| ShaderResult< IrExpr > | beginFor (const RcString &name, const IrExpr &init) |
| Opens for (var name = init; ...) and returns a reference to the loop variable. | |
| ShaderStatus | forCondition (const IrExpr &condition) |
| Sets the condition of the innermost open for. | |
| ShaderStatus | forContinuing (const IrExpr &lhs, const IrExpr &rhs) |
| Sets the continuing assignment of the innermost open for. | |
| ShaderStatus | endFor () |
| Closes the innermost open for. | |
| ShaderStatus | breakStmt () |
| Records break; (valid inside a loop). | |
| ShaderStatus | continueStmt () |
| Records continue; (valid inside a loop). | |
| ShaderStatus | returnValue (const IrExpr &value) |
| Records return expr; for a plain function with a return type. | |
| ShaderStatus | returnVoid () |
| Records return; for a void plain function. | |
| ShaderStatus | returnOutputs (std::vector< IrExpr > outputs) |
| Records the entry point return: one expression per declared output member, in order. | |
| ShaderStatus | discard () |
| Records discard; (fragment entry points only). | |
| ShaderResult< IrExpr > | callFunction (const RcString &name, std::vector< IrExpr > args) |
| Calls a previously finished module function. | |
| ShaderStatus | finish () |
| Finishes the function, registering it with the module builder. Fails if any prior operation failed or a block is still open. | |
Friends | |
| class | ModuleBuilder |
Builds one function or entry point.
Created by ModuleBuilder; validates scope, types, loop/stage context, and stage IO before recording statements. The first error latches: every subsequent operation and finish return it, so an ill-typed build cannot silently succeed.
|
noexcept |
Move constructor; other becomes an inert moved-from shell.
| other | Builder to move from. |
| ShaderResult< IrExpr > donner::gpu::shader::FunctionBuilder::addLet | ( | const RcString & | name, |
| const IrExpr & | value ) |
Declares let name = value; and returns a reference to it.
| name | Binding name; must be unique within the function. |
| value | Initializer. |
| ShaderResult< IrExpr > donner::gpu::shader::FunctionBuilder::addVar | ( | const RcString & | name, |
| const IrType & | type, | ||
| const std::optional< IrExpr > & | init = std::nullopt ) |
Declares var name: type (= init); and returns a (mutable) reference to it.
| name | Variable name; must be unique within the function. |
| type | Declared type; must be plain data. |
| init | Optional initializer; must match type. |
| ShaderStatus donner::gpu::shader::FunctionBuilder::assign | ( | const IrExpr & | lhs, |
| const IrExpr & | rhs ) |
Records lhs = rhs;.
lhs must be a mutable lvalue (a var or a member/index/ single-component-swizzle chain rooted at one) and types must match.
| lhs | Assignment target. |
| rhs | Value. |
| ShaderResult< IrExpr > donner::gpu::shader::FunctionBuilder::beginFor | ( | const RcString & | name, |
| const IrExpr & | init ) |
Opens for (var name = init; ...) and returns a reference to the loop variable.
Follow with forCondition and forContinuing, then body statements, then endFor.
| name | Loop variable name; must be unique within the function. |
| init | Loop variable initializer. |
| ShaderStatus donner::gpu::shader::FunctionBuilder::beginIf | ( | const IrExpr & | condition | ) |
Opens if (condition) { ... }.
Statements recorded until elseBranch or endIf go to the then-branch.
| condition | Bool condition. |
| ShaderResult< IrExpr > donner::gpu::shader::FunctionBuilder::callFunction | ( | const RcString & | name, |
| std::vector< IrExpr > | args ) |
Calls a previously finished module function.
| name | Callee name. |
| args | Arguments; must match the callee's parameter types. |
| ShaderStatus donner::gpu::shader::FunctionBuilder::forCondition | ( | const IrExpr & | condition | ) |
Sets the condition of the innermost open for.
| condition | Bool condition. |
| ShaderStatus donner::gpu::shader::FunctionBuilder::forContinuing | ( | const IrExpr & | lhs, |
| const IrExpr & | rhs ) |
Sets the continuing assignment of the innermost open for.
The update expression may reference the loop variable and enclosing scope only, never body-block locals: this builder models for (init; cond; update) where the body block closes before the update runs, unlike a raw WGSL loop/continuing where the continuing block is nested inside the body scope.
| lhs | Continuing assignment target (normally the loop variable). |
| rhs | Continuing assignment value. |
| ShaderResult< IrExpr > donner::gpu::shader::FunctionBuilder::ref | ( | const RcString & | name | ) | const |
Resolves name to a reference expression: function parameters, lets, vars, then module-scope constants and resource bindings.
| name | Name to resolve. |
| ShaderStatus donner::gpu::shader::FunctionBuilder::returnOutputs | ( | std::vector< IrExpr > | outputs | ) |
Records the entry point return: one expression per declared output member, in order.
| outputs | Output values matching the entry point's output member types. |
| ShaderStatus donner::gpu::shader::FunctionBuilder::returnValue | ( | const IrExpr & | value | ) |
Records return expr; for a plain function with a return type.
| value | Return value; must match the declared return type. |