Skip to content

Commit 280f7ce

Browse files
committed
unparser working
1 parent e4c039e commit 280f7ce

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

editor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ namespace microcode {
9494
if (this.programChanged) {
9595
this.programChanged = false
9696
this.app.save(SAVESLOT_AUTO, this.progdef.toBuffer())
97+
console.log(this.progdef.toString())
9798
}
9899
// runProgram(this.progdef)
99100
}

language.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,19 @@ namespace microcode {
279279
return defn
280280
}
281281

282+
// TODO: deal with field editors
282283
public toString() {
283-
return ""
284+
const toToken = (tile: Tile) =>
285+
resolveTooltip("T" + getTid(tile)).replaceAll(" ", "-")
286+
return toToken(this.sensor) +
287+
" " +
288+
this.filters.map(toToken).join(" ") +
289+
" " +
290+
this.actuators.length
291+
? toToken(this.actuators[0]) +
292+
" " +
293+
this.modifiers.map(toToken).join(" ")
294+
: ""
284295
}
285296
}
286297

@@ -335,7 +346,8 @@ namespace microcode {
335346
}
336347

337348
public toString() {
338-
return ""
349+
const res = this.rules.map(rule => rule.toString())
350+
return res.join("\n")
339351
}
340352
}
341353

0 commit comments

Comments
 (0)