diff --git a/interpreter.js b/interpreter.js index 0802d16b..f9090fc5 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.paused_) + this.callback(); return this.paused_; };