Commit Graph
7 Commits
Author SHA1 Message Date
adrien d760c272f2 feat: remove code output footer, move actions to top bar, download .ll
- Remove global-toolbar (footer with code display) entirely
- Move Generate, Save, Load, New, Tests buttons to algorithm pane toolbar
- Replace prog.generateCode() with prog.generateAndDownload() — creates
  a Blob from the IR and triggers a program.ll download via a temp <a>
- Remove copyCode function from helpers.js (no longer needed)
- Remove global-toolbar and .code-output CSS rules
- Add .action-btn styling for the text buttons in pane-toolbar
2026-06-23 20:40:42 +02:00
adrien d53f92482d feat: switch from C to LLVM IR code generation
- Replace all C code generation with LLVM IR (flat DFA model with
  bb_ prefix labels to avoid SSA value name collisions)
- Remove c.min.js, add llvm.min.js highlight.js language definition
- Update shell.nix: gcc -> clang, remove sdl3/mesa deps
- Download LLVM Language Reference to docs/llvm/LangRef.html
- Rename #c-code to #ir-code in HTML, JS, and CSS
- Replace _generateIncludes with _generateLLVMDecls for extern
  function declarations using LLVM_DECL_MAP
- Add string pool (CodeGen.allocString, stringGlobal, llvmStringArg)
  for LLVM IR global string constants with getelementptr references
2026-06-23 03:39:22 +02:00
adrien 35959784de refactor: flat DFA code generation — every block is a label, every edge is a goto
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.
2026-06-23 03:21:22 +02:00
adrien 82627a3852 refactor: only emit labels for blocks that are actual back-edge targets
- 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
2026-06-23 02:51:17 +02:00
adrien 7451defb60 fix: double return 0 in generated C 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.
2026-06-23 01:19:53 +02:00
adrien b8e8ef9113 overhaul: modular architecture, tests, doc generation, warning system, and UX improvements
- Modular block files: split into blocks-algo, blocks-data, blocks-proc
- New modules: sections.js (labelled canvas areas), proc-browser.js (procedure tree modal), lib-loader.js (lazy library loading), templates.js (project templates), errno-data.js (errno table)
- Test infrastructure: browser test suite (28 tests) and Node pure-function tests (75 tests)
- Warning system: unified .block-warn for disconnected inputs, unconnected error hooks, and zero-exit-in-error-path
- Error path highlighting: red flow paths and block borders for error-only subgraphs
- Input hooks: hidden by default, shown during linking; outputs always at bottom
- Block editor modal: pencil icon, colour picker for accent, compact field labels
- Doc generation: standalone node script extracts JSDoc -> docs/API.md (124 declarations)
- Persistence: save/restore sections, errno selection, block colours
- Fixes: _segmentsIntersect bug, WCEnd crash from closest(this), drawpath guard on detached elements
2026-06-22 18:31:23 +02:00
adrien 36fc63780a early version: modular block files, full template set, tab UI, OpenGL defaults 2026-06-19 01:18:36 +02:00