Recompile August 11

This commit is contained in:
Tim Mickel 2016-08-11 11:11:35 -04:00
parent 4faaf1b685
commit 8af657627b
2 changed files with 46 additions and 46 deletions

88
vm.js
View file

@ -1585,11 +1585,11 @@
this._blocks = {};
/**
* All stacks in the workspace.
* A list of block IDs that represent stacks (first block in stack).
* All top-level scripts in the workspace.
* A list of block IDs that represent scripts (i.e., first block in script).
* @type {Array.<String>}
*/
this._stacks = [];
this._scripts = [];
}
/**
@ -1609,11 +1609,11 @@
};
/**
* Get all known top-level blocks that start stacks.
* Get all known top-level blocks that start scripts.
* @return {Array.<string>} List of block IDs.
*/
Blocks.prototype.getStacks = function () {
return this._stacks;
Blocks.prototype.getScripts = function () {
return this._scripts;
};
/**
@ -1706,10 +1706,10 @@
if (typeof e !== 'object') return;
if (typeof e.blockId !== 'string') return;
// UI event: clicked stacks toggle in the runtime.
// UI event: clicked scripts toggle in the runtime.
if (e.element === 'stackclick') {
if (opt_runtime) {
opt_runtime.toggleStack(e.blockId);
opt_runtime.toggleScript(e.blockId);
}
return;
}
@ -1752,7 +1752,7 @@
// ---------------------------------------------------------------------
/**
* Block management: create blocks and stacks from a `create` event
* Block management: create blocks and scripts from a `create` event
* @param {!Object} block Blockly create event to be processed
* @param {boolean} opt_isFlyoutBlock Whether the block is in the flyout.
*/
@ -1760,12 +1760,12 @@
// Create new block
this._blocks[block.id] = block;
// Push block id to stacks array.
// Push block id to scripts array.
// Blocks are added as a top-level stack if they are marked as a top-block
// (if they were top-level XML in the event) and if they are not
// flyout blocks.
if (!opt_isFlyoutBlock && block.topLevel) {
this._addStack(block.id);
this._addScript(block.id);
}
};
@ -1803,10 +1803,10 @@
// Has the block become a top-level block?
if (e.newParent === undefined) {
this._addStack(e.id);
this._addScript(e.id);
} else {
// Remove stack, if one exists.
this._deleteStack(e.id);
// Remove script, if one exists.
this._deleteScript(e.id);
// Otherwise, try to connect it in its new place.
if (e.newInput !== undefined) {
// Moved to the new parent's input.
@ -1822,11 +1822,11 @@
};
/**
* Block management: delete blocks and their associated stacks
* @param {!Object} e Blockly delete event to be processed
* Block management: delete blocks and their associated scripts.
* @param {!Object} e Blockly delete event to be processed.
*/
Blocks.prototype.deleteBlock = function (e) {
// @todo In runtime, stop threads running on this stack
// @todo In runtime, stop threads running on this script.
// Get block
var block = this._blocks[e.id];
@ -1844,34 +1844,34 @@
}
}
// Delete stack
this._deleteStack(e.id);
// Delete any script starting with this block.
this._deleteScript(e.id);
// Delete block
// Delete block itself.
delete this._blocks[e.id];
};
// ---------------------------------------------------------------------
/**
* Helper to add a stack to `this._stacks`
* @param {?string} id ID of block that starts the stack
* Helper to add a stack to `this._scripts`.
* @param {?string} id ID of block that starts the script.
*/
Blocks.prototype._addStack = function (id) {
var i = this._stacks.indexOf(id);
if (i > -1) return; // Already in stacks.
this._stacks.push(id);
Blocks.prototype._addScript = function (id) {
var i = this._scripts.indexOf(id);
if (i > -1) return; // Already in scripts.
this._scripts.push(id);
// Update `topLevel` property on the top block.
this._blocks[id].topLevel = true;
};
/**
* Helper to remove a stack from `this._stacks`
* @param {?string} id ID of block that starts the stack
* Helper to remove a stack from `this._scripts`.
* @param {?string} id ID of block that starts the script.
*/
Blocks.prototype._deleteStack = function (id) {
var i = this._stacks.indexOf(id);
if (i > -1) this._stacks.splice(i, 1);
var i = this._scripts.indexOf(id);
if (i > -1) this._scripts.splice(i, 1);
// Update `topLevel` property on the top block.
if (this._blocks[id]) this._blocks[id].topLevel = false;
};
@ -11279,7 +11279,7 @@
};
/**
* Manages targets, stacks, and the sequencer.
* Manages targets, scripts, and the sequencer.
* @param {!Array.<Target>} targets List of targets for this runtime.
*/
function Runtime (targets) {
@ -11413,39 +11413,39 @@
};
/**
* Toggle a stack
* @param {!string} stackId ID of block that starts the stack
* Toggle a script.
* @param {!string} topBlockId ID of block that starts the script.
*/
Runtime.prototype.toggleStack = function (stackId) {
// Remove any existing thread
Runtime.prototype.toggleScript = function (topBlockId) {
// Remove any existing thread.
for (var i = 0; i < this.threads.length; i++) {
if (this.threads[i].topBlock == stackId) {
if (this.threads[i].topBlock == topBlockId) {
this._removeThread(this.threads[i]);
return;
}
}
// Otherwise add it
this._pushThread(stackId);
// Otherwise add it.
this._pushThread(topBlockId);
};
/**
* Green flag, which stops currently running threads
* and adds all top-level stacks that start with the green flag
* and adds all top-level scripts that start with the green flag
*/
Runtime.prototype.greenFlag = function () {
// Remove all existing threads
for (var i = 0; i < this.threads.length; i++) {
this._removeThread(this.threads[i]);
}
// Add all top stacks with green flag
// Add all top scripts with green flag
for (var t = 0; t < this.targets.length; t++) {
var target = this.targets[t];
var stacks = target.blocks.getStacks();
for (var j = 0; j < stacks.length; j++) {
var topBlock = stacks[j];
var scripts = target.blocks.getScripts();
for (var j = 0; j < scripts.length; j++) {
var topBlock = scripts[j];
if (target.blocks.getBlock(topBlock).opcode ===
'event_whenflagclicked') {
this._pushThread(stacks[j]);
this._pushThread(scripts[j]);
}
}
}

4
vm.min.js vendored

File diff suppressed because one or more lines are too long