Add stack glow and infrastructure for block glow

This commit is contained in:
Tim Mickel 2016-05-02 13:09:38 -04:00
parent 773f2e1bbc
commit 79f6725ff3
3 changed files with 73 additions and 12 deletions

View file

@ -36,6 +36,30 @@ function Runtime () {
this.sequencer = new Sequencer(this); this.sequencer = new Sequencer(this);
} }
/**
* Event name for glowing a stack
* @const {string}
*/
Runtime.STACK_GLOW_ON = 'STACK_GLOW_ON';
/**
* Event name for unglowing a stack
* @const {string}
*/
Runtime.STACK_GLOW_OFF = 'STACK_GLOW_OFF';
/**
* Event name for glowing a block
* @const {string}
*/
Runtime.BLOCK_GLOW_ON = 'BLOCK_GLOW_ON';
/**
* Event name for unglowing a block
* @const {string}
*/
Runtime.BLOCK_GLOW_OFF = 'BLOCK_GLOW_OFF';
/** /**
* Inherit from EventEmitter * Inherit from EventEmitter
*/ */
@ -165,7 +189,10 @@ Runtime.prototype.deleteBlock = function (e) {
* @param {!string} id ID of block that starts the stack * @param {!string} id ID of block that starts the stack
*/ */
Runtime.prototype._pushThread = function (id) { Runtime.prototype._pushThread = function (id) {
if (this.stacks.indexOf(id) < -1) return; if (this.stacks.indexOf(id) < -1) {
return;
}
this.emit(Runtime.STACK_GLOW_ON, id);
var thread = new Thread(id); var thread = new Thread(id);
this.threads.push(thread); this.threads.push(thread);
}; };
@ -176,7 +203,10 @@ Runtime.prototype._pushThread = function (id) {
*/ */
Runtime.prototype._removeThread = function (thread) { Runtime.prototype._removeThread = function (thread) {
var i = this.threads.indexOf(thread); var i = this.threads.indexOf(thread);
if (i > -1) this.threads.splice(i, 1); if (i > -1) {
this.emit(Runtime.STACK_GLOW_OFF, thread.topBlock);
this.threads.splice(i, 1);
}
}; };
/** /**

41
vm.js
View file

@ -1214,6 +1214,30 @@
this.sequencer = new Sequencer(this); this.sequencer = new Sequencer(this);
} }
/**
* Event name for glowing a stack
* @const {string}
*/
Runtime.STACK_GLOW_ON = 'STACK_GLOW_ON';
/**
* Event name for unglowing a stack
* @const {string}
*/
Runtime.STACK_GLOW_OFF = 'STACK_GLOW_OFF';
/**
* Event name for glowing a block
* @const {string}
*/
Runtime.BLOCK_GLOW_ON = 'BLOCK_GLOW_ON';
/**
* Event name for unglowing a block
* @const {string}
*/
Runtime.BLOCK_GLOW_OFF = 'BLOCK_GLOW_OFF';
/** /**
* Inherit from EventEmitter * Inherit from EventEmitter
*/ */
@ -1343,7 +1367,10 @@
* @param {!string} id ID of block that starts the stack * @param {!string} id ID of block that starts the stack
*/ */
Runtime.prototype._pushThread = function (id) { Runtime.prototype._pushThread = function (id) {
if (this.stacks.indexOf(id) < -1) return; if (this.stacks.indexOf(id) < -1) {
return;
}
this.emit(Runtime.STACK_GLOW_ON, id);
var thread = new Thread(id); var thread = new Thread(id);
this.threads.push(thread); this.threads.push(thread);
}; };
@ -1354,7 +1381,10 @@
*/ */
Runtime.prototype._removeThread = function (thread) { Runtime.prototype._removeThread = function (thread) {
var i = this.threads.indexOf(thread); var i = this.threads.indexOf(thread);
if (i > -1) this.threads.splice(i, 1); if (i > -1) {
this.emit(Runtime.STACK_GLOW_OFF, thread.topBlock);
this.threads.splice(i, 1);
}
}; };
/** /**
@ -1567,12 +1597,13 @@
*/ */
function Thread (firstBlock) { function Thread (firstBlock) {
/** /**
* Top block of the thread * ID of top block of the thread
* @type {!string}
*/ */
this.topBlock = firstBlock; this.topBlock = firstBlock;
/** /**
* Next block that the thread will execute. * ID of next block that the thread will execute, or null if none.
* @type {string} * @type {?string}
*/ */
this.nextBlock = firstBlock; this.nextBlock = firstBlock;
/** /**

10
vm.min.js vendored

File diff suppressed because one or more lines are too long