mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -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
|
* 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
|
* @return {?string} the opcode corresponding to that block
|
||||||
*/
|
*/
|
||||||
Blocks.prototype.getOpcode = function (id) {
|
Blocks.prototype.getOpcode = function (block) {
|
||||||
var block = this._blocks[id];
|
|
||||||
return (typeof block === 'undefined') ? null : block.opcode;
|
return (typeof block === 'undefined') ? null : block.opcode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,7 +94,6 @@ Blocks.prototype.getOpcode = function (id) {
|
||||||
* @return {?object} All fields and their values.
|
* @return {?object} All fields and their values.
|
||||||
*/
|
*/
|
||||||
Blocks.prototype.getFields = function (block) {
|
Blocks.prototype.getFields = function (block) {
|
||||||
// var block = this._blocks[id];
|
|
||||||
return (typeof block === 'undefined') ? null : block.fields;
|
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.
|
* @return {!object} All non-branch inputs and their associated blocks.
|
||||||
*/
|
*/
|
||||||
Blocks.prototype.getInputs = function (block) {
|
Blocks.prototype.getInputs = function (block) {
|
||||||
// var block = this._blocks[id];
|
|
||||||
if (typeof block === 'undefined') return null;
|
if (typeof block === 'undefined') return null;
|
||||||
var inputs = {};
|
var inputs = {};
|
||||||
for (var input in block.inputs) {
|
for (var input in block.inputs) {
|
||||||
|
@ -124,7 +121,6 @@ Blocks.prototype.getInputs = function (block) {
|
||||||
* @return {?object} Mutation for the block.
|
* @return {?object} Mutation for the block.
|
||||||
*/
|
*/
|
||||||
Blocks.prototype.getMutation = function (block) {
|
Blocks.prototype.getMutation = function (block) {
|
||||||
// var block = this._blocks[id];
|
|
||||||
return (typeof block === 'undefined') ? null : block.mutation;
|
return (typeof block === 'undefined') ? null : block.mutation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,8 @@ var execute = function (sequencer, thread) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (eCount++ % 1000==0) { // 603,000 times!!
|
var opcode = blockContainer.getOpcode(block);
|
||||||
// console.log('Execute x' + eCount);
|
var fields = blockContainer.getFields(block);
|
||||||
// }
|
|
||||||
|
|
||||||
// var block = blockContainer.getBlock(currentBlockId);
|
|
||||||
var opcode = block.opcode; // blockContainer.getOpcode(currentBlockId);
|
|
||||||
var fields = block.fields; // blockContainer.getFields(currentBlockId);
|
|
||||||
var inputs = blockContainer.getInputs(block);
|
var inputs = blockContainer.getInputs(block);
|
||||||
var blockFunction = runtime.getOpcodeFunction(opcode);
|
var blockFunction = runtime.getOpcodeFunction(opcode);
|
||||||
var isHat = runtime.getIsHat(opcode);
|
var isHat = runtime.getIsHat(opcode);
|
||||||
|
|
|
@ -218,18 +218,20 @@ test('getBranch with none', function (t) {
|
||||||
|
|
||||||
test('getOpcode', function (t) {
|
test('getOpcode', function (t) {
|
||||||
var b = new Blocks();
|
var b = new Blocks();
|
||||||
b.createBlock({
|
var block = {
|
||||||
id: 'foo',
|
id: 'foo',
|
||||||
opcode: 'TEST_BLOCK',
|
opcode: 'TEST_BLOCK',
|
||||||
next: null,
|
next: null,
|
||||||
fields: {},
|
fields: {},
|
||||||
inputs: {},
|
inputs: {},
|
||||||
topLevel: true
|
topLevel: true
|
||||||
});
|
};
|
||||||
var opcode = b.getOpcode('foo');
|
b.createBlock(block);
|
||||||
|
var opcode = b.getOpcode(block);
|
||||||
t.equals(opcode, 'TEST_BLOCK');
|
t.equals(opcode, 'TEST_BLOCK');
|
||||||
var notOpcode = b.getOpcode('?');
|
var undefinedBlock = b.getBlock('?');
|
||||||
t.equals(notOpcode, null);
|
var undefinedOpcode = b.getOpcode(undefinedBlock);
|
||||||
|
t.equals(undefinedOpcode, null);
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue