Skip to content

Commit 6a6cd68

Browse files
committed
early exit
1 parent 19fe6e4 commit 6a6cd68

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

interpreter.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ namespace microcode {
9393
this.loopIndex = 0
9494
}
9595

96+
private waitingOnTimer() {
97+
return this.wakeTime > 0
98+
}
99+
96100
kill() {
97101
const resource = this.getOutputResource()
98102
if (resource == OutputResource.LEDScreen) {
@@ -173,13 +177,15 @@ namespace microcode {
173177
if (this.wakeTime > 0) {
174178
basic.pause(this.wakeTime)
175179
this.wakeTime = 0
176-
this.interp.addEvent({
177-
kind: MicroCodeEventKind.TimerFire,
178-
ruleIndex: this.index,
179-
} as TimerEvent)
180-
this.timerGoAhead = false
181-
while (this.ok() && !this.timerGoAhead) {
182-
basic.pause(1)
180+
if (this.ok()) {
181+
this.interp.addEvent({
182+
kind: MicroCodeEventKind.TimerFire,
183+
ruleIndex: this.index,
184+
} as TimerEvent)
185+
this.timerGoAhead = false
186+
while (this.ok() && !this.timerGoAhead) {
187+
basic.pause(1)
188+
}
183189
}
184190
}
185191

@@ -333,10 +339,6 @@ namespace microcode {
333339
this.interp.processNewState()
334340
}
335341

336-
private waitingOnTimer() {
337-
return this.wakeTime > 0
338-
}
339-
340342
private getWakeTime() {
341343
this.wakeTime = 0
342344
const sensor = this.rule.sensor

0 commit comments

Comments
 (0)