mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-15 07:51:04 -04:00
Recursive evaluation for block arguments
This commit is contained in:
parent
c4517a451b
commit
1d16a97115
1 changed files with 16 additions and 0 deletions
|
@ -98,8 +98,24 @@ var execute = function (sequencer, thread, blockId, isInput) {
|
|||
switchedStack = true;
|
||||
};
|
||||
|
||||
// Generate values for arguments (inputs).
|
||||
var argValues = {};
|
||||
|
||||
// Add all fields on this block to the argValues.
|
||||
var fields = runtime.blocks.getFields(blockId);
|
||||
for (var fieldName in fields) {
|
||||
argValues[fieldName] = fields[fieldName];
|
||||
}
|
||||
|
||||
// Recursively evaluate input blocks.
|
||||
var inputs = runtime.blocks.getInputs(blockId);
|
||||
for (var inputName in inputs) {
|
||||
var input = inputs[inputName];
|
||||
var inputBlockId = input.block;
|
||||
var result = execute(sequencer, thread, inputBlockId, true);
|
||||
argValues[input.name] = result;
|
||||
}
|
||||
|
||||
// Start showing run feedback in the editor.
|
||||
runtime.glowBlock(blockId, true);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue