diff options
| author | jmoenig <jens@moenig.org> | 2014-09-22 15:21:56 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2014-09-22 15:21:56 +0200 |
| commit | 5605df3dd5451766ce8ec5836852fe00b0794faf (patch) | |
| tree | 3526bff9bb04204d8be16272527161252bf67832 /blocks.js | |
| parent | 5695dd141b4d81260dbd449bfe29c348e0b9e548 (diff) | |
| download | snap-byow-5605df3dd5451766ce8ec5836852fe00b0794faf.tar.gz snap-byow-5605df3dd5451766ce8ec5836852fe00b0794faf.zip | |
Mutable upvars
allow upvars to be SET and CHANGEd
Diffstat (limited to 'blocks.js')
| -rw-r--r-- | blocks.js | 45 |
1 files changed, 20 insertions, 25 deletions
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2014-August-13'; +modules.blocks = '2014-September-22'; var SyntaxElementMorph; @@ -6755,9 +6755,6 @@ InputSlotMorph.prototype.soundsMenu = function () { InputSlotMorph.prototype.getVarNamesDict = function () { var block = this.parentThatIsA(BlockMorph), rcvr, - proto, - rings, - declarations, tempVars = [], dict; @@ -6765,28 +6762,26 @@ InputSlotMorph.prototype.getVarNamesDict = function () { return {}; } rcvr = block.receiver(); - - proto = detect(block.allParents(), function (morph) { - return morph instanceof PrototypeHatBlockMorph; - }); - if (proto) { - tempVars = proto.inputs()[0].inputFragmentNames(); - } - - rings = block.allParents().filter(function (block) { - return block instanceof RingMorph; - }); - rings.forEach(function (block) { - tempVars = tempVars.concat(block.inputs()[1].evaluate()); - }); - - declarations = block.allParents().filter(function (block) { - return block.selector === 'doDeclareVariables'; - }); - declarations.forEach(function (block) { - tempVars = tempVars.concat(block.inputs()[0].evaluate()); + block.allParents().forEach(function (morph) { + if (morph instanceof PrototypeHatBlockMorph) { + tempVars.push.apply( + tempVars, + morph.inputs()[0].inputFragmentNames() + ); + } else if (morph instanceof BlockMorph) { + morph.inputs().forEach(function (inp) { + if (inp instanceof TemplateSlotMorph) { + tempVars.push(inp.contents()); + } else if (inp instanceof MultiArgMorph) { + inp.children.forEach(function (m) { + if (m instanceof TemplateSlotMorph) { + tempVars.push(m.contents()); + } + }); + } + }); + } }); - if (rcvr) { dict = rcvr.variables.allNamesDict(); tempVars.forEach(function (name) { |
