Module ternary

Module ternary 

Source
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 : b to select(b, a, cond). WGSL has no ternary operator and the regex translator doesn’t recognise the ?/: tokens. Many presets hit expected ';'; found '?' before this pass.
scan_block_for_ternary πŸ”’
scan_expr_for_ternary πŸ”’
scan_stmt_for_ternary πŸ”’
subtree_has_ternary πŸ”’
unop_text πŸ”’