Replace the nested if-else branch-analysis architecture with a flat DFA
model using CodeGen.emitFlat — a single DFS walk emitting each block as
a C label followed by its code and gotos to all successors.
Removed:
- _branchDescendants / emitBranch / generateCallWithError
- _generateCallWithError, _noWalkNext, _genVisited
- generateNextCode, findBackEdges
- WCDecision._branchDescendants / _emitBranch / overridden generateCode
Added:
- CodeGen.emitFlat(entry) — flat DFS emit with labels + gotos
- WCBlock.generateFlowCode() — base emits gotos from wcNextFlow
- WCDecision.generateFlowCode() — if-goto / goto for decisions
- WCProcCall.generateFlowCode() — if (call != 0) goto err / goto ok
Output is flat — zero nested if-else for branch/error handling.
Tests use local out/ directory.
- Add CodeGen.findBackEdges(root) pre-pass — DFS-based back-edge
detection that finds all blocks targeted by at least one back-edge
- Only those blocks get C labels; only those back-edges emit goto
- emitBranch reverts to generateOwnCode + manual successor walking
(respects stop set properly for shared blocks)
- generateCode/generateNextCode accept loopTargets parameter;
visited-but-not-back-edge blocks are silently skipped
- No more -Wunused-label warnings in compiled output
- wcprogram.js.generateCode now checks if the body already contains
a return or exit statement before appending the hardcoded return 0;
This eliminates the duplicate return 0 from the END block.