Recursive evaluation for block arguments

This commit is contained in:
Tim Mickel 2016-06-09 13:28:50 -04:00
parent c4517a451b
commit 1d16a97115

View file

@ -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);