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:
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user