Expand description
Pass: ternary cond ? a : b β WGSL select(b, a, cond).
FunctionsΒ§
- assign_
op_ πtext - binop_
text π - emit_
ternary_ πaware - Render an expression to text, replacing any ternaries in its subtree
with
select(...). Non-ternary nodes that contain ternaries get rebuilt from the AST so the ternary substitution can flow up; pure non-ternary subtrees fall back to the original source slice (which preserves whitespace, comments and HLSL idioms that downstream regex passes still need to see verbatim). - rewrite_
ternary_ πto_ select - Lower every
cond ? a : btoselect(b, a, cond). WGSL has no ternary operator and the regex translator doesnβt recognise the?/:tokens. Many presets hitexpected ';'; found '?'before this pass. - scan_
block_ πfor_ ternary - scan_
expr_ πfor_ ternary - scan_
stmt_ πfor_ ternary - subtree_
has_ πternary - unop_
text π