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
This commit is contained in:
2026-06-23 20:40:42 +02:00
parent d53f92482d
commit d760c272f2
5 changed files with 38 additions and 73 deletions
+16 -12
View File
@@ -208,12 +208,8 @@ class WCProgram extends HTMLElement {
return lines.join("\n");
}
generateCode() {
const outputEl = $id("ir-code");
if (!outputEl) { showError("Missing #ir-code output element"); return; }
_generateIR() {
const { usedQuantities, usedUnits } = this._gatherUsedTypes();
const typeDefs = this._generateTypeDefs(usedQuantities);
const unitDefs = this._generateUnitDefs(usedUnits);
const { boolDefs, scalarDefs, vectorDefs, stringDefs, arrayDefs } = this._generateVariableDeclarations();
@@ -225,24 +221,32 @@ class WCProgram extends HTMLElement {
? CodeGen.emitFlat(firstChild)
: "; no flowchart body\n";
// Collect external function declarations from used libraries
const proccalls = this.querySelectorAll("wc-proccall");
const decls = this._generateLLVMDecls(proccalls);
// Collect string globals
const strPool = CodeGen.getStringPool();
const globals = strPool.map(function (_, i) { return CodeGen.stringGlobal(i); }).join("\n");
// Variable declarations -> alloca instructions in the prologue
const dataSection = (boolDefs || scalarDefs || vectorDefs || stringDefs || arrayDefs)
? [boolDefs, scalarDefs, vectorDefs, stringDefs, arrayDefs]
.filter(Boolean).map(function (s) { return s + "\n"; }).join("")
: "";
const raw = CodeGen.generateIRFile(firstChild, decls, globals, dataSection);
outputEl.textContent = raw;
if (typeof hljs !== "undefined") hljs.highlightElement(outputEl);
outputEl.parentElement.dataset.language = "llvm";
return CodeGen.generateIRFile(firstChild, decls, globals, dataSection);
}
generateAndDownload() {
const ir = this._generateIR();
if (!ir) { showError("No IR to download"); return; }
const blob = new Blob([ir], { type: "text/plain" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "program.ll";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
}