mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
Tidy up commit and revert direct member access
This commit is contained in:
parent
a5ce0f60cf
commit
25429b1192
3 changed files with 11 additions and 18 deletions
|
@ -81,11 +81,10 @@ Blocks.prototype.getBranch = function (id, branchNum) {
|
|||
|
||||
/**
|
||||
* Get the opcode for a particular block
|
||||
* @param {?string} id ID of block to query
|
||||
* @param {?object} block The block to query
|
||||
* @return {?string} the opcode corresponding to that block
|
||||
*/
|
||||
Blocks.prototype.getOpcode = function (id) {
|
||||
var block = this._blocks[id];
|
||||
Blocks.prototype.getOpcode = function (block) {
|
||||
return (typeof block === 'undefined') ? null : block.opcode;
|
||||
};
|
||||
|
||||
|
@ -95,7 +94,6 @@ Blocks.prototype.getOpcode = function (id) {
|
|||
* @return {?object} All fields and their values.
|
||||
*/
|
||||
Blocks.prototype.getFields = function (block) {
|
||||
// var block = this._blocks[id];
|
||||
return (typeof block === 'undefined') ? null : block.fields;
|
||||
};
|
||||
|
||||
|
@ -105,7 +103,6 @@ Blocks.prototype.getFields = function (block) {
|
|||
* @return {!object} All non-branch inputs and their associated blocks.
|
||||
*/
|
||||
Blocks.prototype.getInputs = function (block) {
|
||||
// var block = this._blocks[id];
|
||||
if (typeof block === 'undefined') return null;
|
||||
var inputs = {};
|
||||
for (var input in block.inputs) {
|
||||
|
@ -124,7 +121,6 @@ Blocks.prototype.getInputs = function (block) {
|
|||
* @return {?object} Mutation for the block.
|
||||
*/
|
||||
Blocks.prototype.getMutation = function (block) {
|
||||
// var block = this._blocks[id];
|
||||
return (typeof block === 'undefined') ? null : block.mutation;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,13 +44,8 @@ var execute = function (sequencer, thread) {
|
|||
}
|
||||
}
|
||||
|
||||
// if (eCount++ % 1000==0) { // 603,000 times!!
|
||||
// console.log('Execute x' + eCount);
|
||||
// }
|
||||
|
||||
// var block = blockContainer.getBlock(currentBlockId);
|
||||
var opcode = block.opcode; // blockContainer.getOpcode(currentBlockId);
|
||||
var fields = block.fields; // blockContainer.getFields(currentBlockId);
|
||||
var opcode = blockContainer.getOpcode(block);
|
||||
var fields = blockContainer.getFields(block);
|
||||
var inputs = blockContainer.getInputs(block);
|
||||
var blockFunction = runtime.getOpcodeFunction(opcode);
|
||||
var isHat = runtime.getIsHat(opcode);
|
||||
|
|
|
@ -218,18 +218,20 @@ test('getBranch with none', function (t) {
|
|||
|
||||
test('getOpcode', function (t) {
|
||||
var b = new Blocks();
|
||||
b.createBlock({
|
||||
var block = {
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
next: null,
|
||||
fields: {},
|
||||
inputs: {},
|
||||
topLevel: true
|
||||
});
|
||||
var opcode = b.getOpcode('foo');
|
||||
};
|
||||
b.createBlock(block);
|
||||
var opcode = b.getOpcode(block);
|
||||
t.equals(opcode, 'TEST_BLOCK');
|
||||
var notOpcode = b.getOpcode('?');
|
||||
t.equals(notOpcode, null);
|
||||
var undefinedBlock = b.getBlock('?');
|
||||
var undefinedOpcode = b.getOpcode(undefinedBlock);
|
||||
t.equals(undefinedOpcode, null);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue