From 6ca746d9af3243b461c3d035139e1d138996f94a Mon Sep 17 00:00:00 2001 From: BrownBear2 Date: Mon, 31 Aug 2015 12:20:09 +0200 Subject: [PATCH 1/2] Allow user to give callback function to Interpreter::run --- interpreter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interpreter.js b/interpreter.js index 0802d16b..667e8ca8 100644 --- a/interpreter.js +++ b/interpreter.js @@ -60,8 +60,11 @@ Interpreter.prototype.step = function() { * @return {boolean} True if a execution is asynchonously blocked, * false if no more instructions. */ -Interpreter.prototype.run = function() { +Interpreter.prototype.run = function(callback) { + if (!this.callback) this.callback = callback; while(!this.paused_ && this.step()) {}; + if (typeof this.callback == "function") + this.callback(); return this.paused_; }; From 392a29606ff25f9c8e335e21fb2103ca13affc6d Mon Sep 17 00:00:00 2001 From: BrownBear2 Date: Mon, 31 Aug 2015 15:35:13 +0200 Subject: [PATCH 2/2] Forgot to check whether the interpreter is paused --- interpreter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interpreter.js b/interpreter.js index 667e8ca8..f9090fc5 100644 --- a/interpreter.js +++ b/interpreter.js @@ -63,7 +63,7 @@ Interpreter.prototype.step = function() { Interpreter.prototype.run = function(callback) { if (!this.callback) this.callback = callback; while(!this.paused_ && this.step()) {}; - if (typeof this.callback == "function") + if (typeof this.callback == "function" && !this.paused_) this.callback(); return this.paused_; };