feat: loop support via goto labels on each block

- Every block now emits a C label (its id) before its code
- generateNextCode emits goto label; for back-edges (visited targets)
- _emitBranch delegates to generateCode (not generateOwnCode), so labels
  are emitted consistently in both main and branch traversals
- generateCallWithError threads a shared visited set across all three
  emitBranch calls, preventing duplicate label emission for shared blocks
- emitBranch skips roots already visited by previous roots in the same
  branch (prevents spurious gotos from shared-block traversal)
This commit is contained in:
2026-06-23 01:16:14 +02:00
parent f1eed2d4e0
commit 439cc6e7ba
5 changed files with 69 additions and 44 deletions
+2 -2
View File
@@ -502,9 +502,9 @@ class WCProcCall extends WCBlock {
}
generateCode(visited = new Set()) {
if (visited.has(this)) return "";
if (visited.has(this)) return "\n goto " + this.id + ";\n";
visited.add(this);
const own = this.generateOwnCode();
const own = "\n" + this.id + ":\n" + this.generateOwnCode();
if (this._el.errHook && this._el.errHook.classList.contains("visible") &&
Array.from(this.wcNextFlow).some(p => p.fromHook === this._el.errHook)) {
return own;