fix: variable blocks no longer emit labels; remove default array variable

- 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
This commit is contained in:
2026-06-23 01:22:11 +02:00
parent 7451defb60
commit e879e21b90
2 changed files with 3 additions and 11 deletions
-10
View File
@@ -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)) {
+3 -1
View File
@@ -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);