From 39fdbaf98354c6807e772178092f72cad95d3e29 Mon Sep 17 00:00:00 2001 From: Tim Mickel <tim.mickel@gmail.com> Date: Tue, 23 Aug 2016 18:12:19 -0400 Subject: [PATCH] Add atStackTop helper to Thread --- src/engine/thread.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/thread.js b/src/engine/thread.js index d1bd73fc0..07a98b862 100644 --- a/src/engine/thread.js +++ b/src/engine/thread.js @@ -123,6 +123,14 @@ Thread.prototype.pushReportedValue = function (value) { } }; +/** + * Whether the current execution of a thread is at the top of the stack. + * @return {Boolean} True if execution is at top of the stack. + */ +Thread.prototype.atStackTop = function () { + return this.peekStack() === this.topBlock; +}; + /** * Set thread status. * @param {number} status Enum representing thread status.