From e879e21b9079abf5a2dc2204e233141f3f148789 Mon Sep 17 00:00:00 2001 From: Adrien Jaguenet Date: Tue, 23 Jun 2026 01:22:11 +0200 Subject: [PATCH] fix: variable blocks no longer emit labels; remove default array variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - WCBlock.generateCode checks _isFlowBlock (set from #draw-area presence) before emitting labels/gotos; variable blocks in #variable-area skip this - Remove unconditional vertices array creation in main() — it was only relevant for the SDL3 triangle template, which should create it itself if needed --- app.js | 10 ---------- wcblock.js | 4 +++- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index 4de3557..b540b32 100644 --- a/app.js +++ b/app.js @@ -430,16 +430,6 @@ function main() { prog.build(); createDefaultMeasurements(); - /* Create default vertex array for Hello Triangle */ - const arr = prog.newArrayNode(); - if (arr) { - arr.restoreData({ - name: "vertices", - type: "float", - values: ["-0.5", "-0.5", "0.0", "0.5", "-0.5", "0.0", "0.0", "0.5", "0.0"] - }); - } - /* Load library index and create tabs (procedures load on demand) */ initLibraries().then(() => { if (localStorage.getItem(STORAGE_KEY)) { diff --git a/wcblock.js b/wcblock.js index 2400126..44b400b 100644 --- a/wcblock.js +++ b/wcblock.js @@ -45,7 +45,8 @@ class WCBlock extends HTMLElement { this._select(); }); - const isAlgoBlock = !!this.closest("#draw-area"); + this._isFlowBlock = !!this.closest("#draw-area"); + const isAlgoBlock = this._isFlowBlock; if (!(this instanceof WCStart) && !(this instanceof WCEnd) && !this.dataset.readonly) { const btn = document.createElement("button"); btn.className = "delete-btn"; @@ -253,6 +254,7 @@ class WCBlock extends HTMLElement { * @returns {string} */ generateCode(visited = new Set()) { + if (!this._isFlowBlock) return this.generateOwnCode(); if (visited.has(this)) return "\n goto " + this.id + ";\n"; visited.add(this); return "\n" + this.id + ":\n" + this.generateOwnCode() + this.generateNextCode(visited);