From 6a7822b429b964bfb984fcc671ca40a514c19a8d Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Thu, 25 Mar 2021 20:41:45 -0500 Subject: [PATCH] Add a debug mode --- src/engine/runtime.js | 7 +++++++ src/virtual-machine.js | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index e8b9c52d..d8956586 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -409,6 +409,8 @@ class Runtime extends EventEmitter { warpTimer: false }; + this.debug = false; + this._animationFrame = this._animationFrame.bind(this); this._animationFrameId = null; this._lastStepTime = Date.now(); @@ -2387,6 +2389,11 @@ class Runtime extends EventEmitter { }); } + enableDebug () { + this.resetAllCaches(); + this.debug = true; + } + /** * Emit glows/glow clears for scripts after a single tick. * Looks at `this.threads` and notices which have turned on/off new glows. diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 89708d55..f97b2b00 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -252,6 +252,10 @@ class VirtualMachine extends EventEmitter { this.runtime.setCompilerOptions(compilerOptions); } + enableDebug () { + this.runtime.enableDebug(); + } + /** * Stop all threads and running activities. */