Implement AHEAD, CS-PICK, CS-ROLL (Programming-Tools word set)
Three compile-time words for unstructured control flow: - AHEAD: unconditional forward branch (code to THEN skipped) - CS-PICK: duplicate control-flow stack entries (enables multi-exit loops) - CS-ROLL: rotate control-flow stack entries (reorder IF/THEN resolution) Also adds POSTPONE support for compile-time keywords (IF, UNTIL, etc.) via a __CTRL__ host function and unified pending_actions queue. Key design: - LoopRestartIfFalse IR op desugars into nested If nodes for CS-PICK'd BEGIN+UNTIL patterns (multiple backward branches in one loop) - Flat Block/BranchIfFalse/EndBlock IR ops for CS-ROLL'd IF/THEN patterns where structured If nesting would consume wrong flags - First-iteration flag local for AHEAD-into-BEGIN patterns (PT8) Enables 12th compliance test (compliance_tools): all 11+1 now pass.
This commit is contained in:
@@ -111,6 +111,17 @@ pub enum IrOp {
|
||||
},
|
||||
/// Return from current word.
|
||||
Exit,
|
||||
/// Conditional restart of enclosing loop (used by CS-PICK'd BEGIN + UNTIL).
|
||||
/// Pops flag; if false, restart the loop. Desugared into nested `If` before codegen.
|
||||
LoopRestartIfFalse,
|
||||
|
||||
// -- Flat forward branches (for CS-ROLL'd IF/THEN patterns) --
|
||||
/// Open a WASM `block`. `BranchIfFalse` can target this to skip to `EndBlock`.
|
||||
Block(u32),
|
||||
/// Pop flag; if false, branch to matching `EndBlock` with this label.
|
||||
BranchIfFalse(u32),
|
||||
/// Close the `block` with this label.
|
||||
EndBlock(u32),
|
||||
|
||||
// -- Return stack --
|
||||
/// Move to return stack: ( x -- ) ( R: -- x )
|
||||
|
||||
Reference in New Issue
Block a user