kopia lustrzana https://github.com/backface/turtlestitch
turned “definition” property of custom block instances into a double-pointer (Variable) structure
in preparation for OOP (method inheritance). This should not result in any new behavior or break anything, if it does (at this point), it’s a bug.upd4.1
rodzic
114425b421
commit
ebc29c76d5
60
blocks.js
60
blocks.js
|
@ -150,7 +150,7 @@ CustomCommandBlockMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2017-February-10';
|
||||
modules.blocks = '2017-February-16';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -571,14 +571,14 @@ SyntaxElementMorph.prototype.revertToDefaultInput = function (arg, noValues) {
|
|||
if (deflt instanceof InputSlotMorph) {
|
||||
deflt.setChoices.apply(
|
||||
deflt,
|
||||
this.definition.inputOptionsOfIdx(inp)
|
||||
this.definition.value.inputOptionsOfIdx(inp)
|
||||
);
|
||||
}
|
||||
if (deflt instanceof InputSlotMorph ||
|
||||
(deflt instanceof BooleanSlotMorph)
|
||||
) {
|
||||
deflt.setContents(
|
||||
this.definition.defaultValueOfInputIdx(inp)
|
||||
this.definition.value.defaultValueOfInputIdx(inp)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -696,10 +696,13 @@ SyntaxElementMorph.prototype.refactorVarInStack = function (
|
|||
}
|
||||
|
||||
if (this instanceof CustomCommandBlockMorph
|
||||
&& this.definition.body
|
||||
&& isNil(this.definition.declarations[oldName])
|
||||
&& !contains(this.definition.variableNames, oldName)) {
|
||||
this.definition.body.expression.refactorVarInStack(oldName, newName);
|
||||
&& this.definition.value.body
|
||||
&& isNil(this.definition.value.declarations[oldName])
|
||||
&& !contains(this.definition.value.variableNames, oldName)) {
|
||||
this.definition.value.body.expression.refactorVarInStack(
|
||||
oldName,
|
||||
newName
|
||||
);
|
||||
}
|
||||
|
||||
this.inputs().forEach(function (input) {
|
||||
|
@ -1543,7 +1546,7 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
|||
// has issues when loading costumes (asynchronously)
|
||||
// commented out for now
|
||||
|
||||
var rcvr = this.definition.receiver || this.receiver(),
|
||||
var rcvr = this.definition.value.receiver || this.receiver(),
|
||||
id = spec.slice(1),
|
||||
cst;
|
||||
if (!rcvr) {return this.labelPart('%stop'); }
|
||||
|
@ -2300,7 +2303,7 @@ BlockMorph.prototype.setSpec = function (spec, silently) {
|
|||
if (part instanceof InputSlotMorph && myself.definition) {
|
||||
part.setChoices.apply(
|
||||
part,
|
||||
myself.definition.inputOptionsOfIdx(inputIdx)
|
||||
myself.definition.value.inputOptionsOfIdx(inputIdx)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -2884,7 +2887,7 @@ BlockMorph.prototype.showHelp = function () {
|
|||
block,
|
||||
isCustomBlock = this.selector === 'evaluateCustomBlock',
|
||||
spec = isCustomBlock ?
|
||||
this.definition.helpSpec() : this.selector,
|
||||
this.definition.value.helpSpec() : this.selector,
|
||||
ctx;
|
||||
|
||||
if (!ide) {
|
||||
|
@ -2906,10 +2909,10 @@ BlockMorph.prototype.showHelp = function () {
|
|||
);
|
||||
};
|
||||
|
||||
if (isCustomBlock && this.definition.comment) {
|
||||
if (isCustomBlock && this.definition.value.comment) {
|
||||
block = this.fullCopy();
|
||||
block.addShadow();
|
||||
comment = this.definition.comment.fullCopy();
|
||||
comment = this.definition.value.comment.fullCopy();
|
||||
comment.contents.parse();
|
||||
help = '';
|
||||
comment.contents.lines.forEach(function (line) {
|
||||
|
@ -2957,7 +2960,7 @@ BlockMorph.prototype.mapToHeader = function () {
|
|||
this,
|
||||
function (code) {
|
||||
if (key === 'evaluateCustomBlock') {
|
||||
myself.definition.codeHeader = code;
|
||||
myself.definition.value.codeHeader = code;
|
||||
} else {
|
||||
StageMorph.prototype.codeHeaders[key] = code;
|
||||
}
|
||||
|
@ -2965,7 +2968,7 @@ BlockMorph.prototype.mapToHeader = function () {
|
|||
this
|
||||
).promptCode(
|
||||
'Header mapping',
|
||||
key === 'evaluateCustomBlock' ? this.definition.codeHeader || ''
|
||||
key === 'evaluateCustomBlock' ? this.definition.value.codeHeader || ''
|
||||
: StageMorph.prototype.codeHeaders[key] || '',
|
||||
this.world(),
|
||||
pic,
|
||||
|
@ -2986,7 +2989,7 @@ BlockMorph.prototype.mapToCode = function () {
|
|||
this,
|
||||
function (code) {
|
||||
if (key === 'evaluateCustomBlock') {
|
||||
myself.definition.codeMapping = code;
|
||||
myself.definition.value.codeMapping = code;
|
||||
} else {
|
||||
StageMorph.prototype.codeMappings[key] = code;
|
||||
}
|
||||
|
@ -2994,7 +2997,7 @@ BlockMorph.prototype.mapToCode = function () {
|
|||
this
|
||||
).promptCode(
|
||||
'Code mapping',
|
||||
key === 'evaluateCustomBlock' ? this.definition.codeMapping || ''
|
||||
key === 'evaluateCustomBlock' ? this.definition.value.codeMapping || ''
|
||||
: StageMorph.prototype.codeMappings[key] || '',
|
||||
this.world(),
|
||||
pic,
|
||||
|
@ -3010,7 +3013,7 @@ BlockMorph.prototype.mapHeader = function (aString, key) {
|
|||
'reify' : this.selector;
|
||||
if (aString) {
|
||||
if (this.definition) { // custom block
|
||||
this.definition.codeHeader = aString;
|
||||
this.definition.value.codeHeader = aString;
|
||||
} else {
|
||||
StageMorph.prototype.codeHeaders[sel] = aString;
|
||||
}
|
||||
|
@ -3023,7 +3026,7 @@ BlockMorph.prototype.mapCode = function (aString, key) {
|
|||
'reify' : this.selector;
|
||||
if (aString) {
|
||||
if (this.definition) { // custom block
|
||||
this.definition.codeMapping = aString;
|
||||
this.definition.value.codeMapping = aString;
|
||||
} else {
|
||||
StageMorph.prototype.codeMappings[sel] = aString;
|
||||
}
|
||||
|
@ -3041,22 +3044,24 @@ BlockMorph.prototype.mappedCode = function (definitions) {
|
|||
headerLines,
|
||||
body,
|
||||
bodyLines,
|
||||
defKey = this.definition ? this.definition.spec : key,
|
||||
defKey = this.definition ? this.definition.value.spec : key,
|
||||
defs = definitions || {},
|
||||
parts = [];
|
||||
code = key === 'reportGetVar' ? this.blockSpec
|
||||
: this.definition ? this.definition.codeMapping || ''
|
||||
: this.definition ? this.definition.value.codeMapping || ''
|
||||
: StageMorph.prototype.codeMappings[key] || '';
|
||||
|
||||
// map header
|
||||
if (key !== 'reportGetVar' && !defs.hasOwnProperty(defKey)) {
|
||||
defs[defKey] = null; // create the property for recursive definitions
|
||||
if (this.definition) {
|
||||
header = this.definition.codeHeader || '';
|
||||
header = this.definition.value.codeHeader || '';
|
||||
if (header.indexOf('<body') !== -1) { // replace with def mapping
|
||||
body = '';
|
||||
if (this.definition.body) {
|
||||
body = this.definition.body.expression.mappedCode(defs);
|
||||
if (this.definition.value.body) {
|
||||
body = this.definition.value.body.expression.mappedCode(
|
||||
defs
|
||||
);
|
||||
}
|
||||
bodyLines = body.split('\n');
|
||||
headerLines = header.split('\n');
|
||||
|
@ -3128,8 +3133,9 @@ BlockMorph.prototype.mappedCode = function (definitions) {
|
|||
};
|
||||
|
||||
BlockMorph.prototype.codeDefinitionHeader = function () {
|
||||
var block = this.definition ? new PrototypeHatBlockMorph(this.definition)
|
||||
: SpriteMorph.prototype.blockForSelector(this.selector),
|
||||
var block = this.definition ?
|
||||
new PrototypeHatBlockMorph(this.definition.value)
|
||||
: SpriteMorph.prototype.blockForSelector(this.selector),
|
||||
hat = new HatBlockMorph(),
|
||||
count = 1;
|
||||
|
||||
|
@ -3150,7 +3156,7 @@ BlockMorph.prototype.codeDefinitionHeader = function () {
|
|||
};
|
||||
|
||||
BlockMorph.prototype.codeMappingHeader = function () {
|
||||
var block = this.definition ? this.definition.blockInstance()
|
||||
var block = this.definition ? this.definition.value.blockInstance()
|
||||
: SpriteMorph.prototype.blockForSelector(this.selector),
|
||||
hat = new HatBlockMorph(),
|
||||
count = 1;
|
||||
|
@ -3677,7 +3683,7 @@ BlockMorph.prototype.reactToTemplateCopy = function () {
|
|||
|
||||
BlockMorph.prototype.hasBlockVars = function () {
|
||||
return this.anyChild(function (any) {
|
||||
return any.definition && any.definition.variableNames.length;
|
||||
return any.definition && any.definition.value.variableNames.length;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
65
byob.js
65
byob.js
|
@ -108,7 +108,7 @@ BooleanSlotMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.byob = '2017-February-14';
|
||||
modules.byob = '2017-February-16';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -373,7 +373,7 @@ CustomBlockDefinition.prototype.isDirectlyRecursive = function () {
|
|||
function (morph) {
|
||||
return morph instanceof BlockMorph &&
|
||||
morph.definition &&
|
||||
morph.definition.spec === myspec;
|
||||
morph.definition.value.spec === myspec;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ function CustomCommandBlockMorph(definition, isProto) {
|
|||
}
|
||||
|
||||
CustomCommandBlockMorph.prototype.init = function (definition, isProto) {
|
||||
this.definition = definition; // mandatory
|
||||
this.definition = new Variable(definition); // mandatory
|
||||
this.isPrototype = isProto || false; // optional
|
||||
CustomCommandBlockMorph.uber.init.call(this, true); // silently
|
||||
this.category = definition.category;
|
||||
|
@ -460,7 +460,7 @@ CustomCommandBlockMorph.prototype.init = function (definition, isProto) {
|
|||
CustomCommandBlockMorph.prototype.initializeVariables = function (oldVars) {
|
||||
var myself = this;
|
||||
this.variables = new VariableFrame();
|
||||
this.definition.variableNames.forEach(function (name) {
|
||||
this.definition.value.variableNames.forEach(function (name) {
|
||||
var v = oldVars ? oldVars[name] : null;
|
||||
myself.variables.addVar(
|
||||
name,
|
||||
|
@ -470,7 +470,7 @@ CustomCommandBlockMorph.prototype.initializeVariables = function (oldVars) {
|
|||
};
|
||||
|
||||
CustomCommandBlockMorph.prototype.refresh = function (silently) {
|
||||
var def = this.definition,
|
||||
var def = this.definition.value,
|
||||
newSpec = this.isPrototype ?
|
||||
def.spec : def.blockSpec(),
|
||||
oldInputs;
|
||||
|
@ -547,7 +547,9 @@ CustomCommandBlockMorph.prototype.refreshDefaults = function () {
|
|||
|
||||
inputs.forEach(function (inp) {
|
||||
if (inp instanceof InputSlotMorph || inp instanceof BooleanSlotMorph) {
|
||||
inp.setContents(myself.definition.defaultValueOfInputIdx(idx));
|
||||
inp.setContents(
|
||||
myself.definition.value.defaultValueOfInputIdx(idx)
|
||||
);
|
||||
}
|
||||
idx += 1;
|
||||
});
|
||||
|
@ -576,7 +578,7 @@ CustomCommandBlockMorph.prototype.refreshPrototype = function () {
|
|||
if (part.fragment.type) { // marked as input, take label as is
|
||||
frags.push(part.fragment);
|
||||
} else { // not an input, devide into several non-input fragments
|
||||
words = myself.definition.parseSpec(
|
||||
words = myself.definition.value.parseSpec(
|
||||
part.fragment.labelString
|
||||
);
|
||||
words.forEach(function (word) {
|
||||
|
@ -597,7 +599,7 @@ CustomCommandBlockMorph.prototype.refreshPrototype = function () {
|
|||
if (this instanceof CustomCommandBlockMorph
|
||||
&& ((hat.type === 'reporter') || (hat.type === 'predicate'))) {
|
||||
myself = new CustomReporterBlockMorph(
|
||||
this.definition,
|
||||
this.definition.value,
|
||||
hat.type === 'predicate',
|
||||
true
|
||||
);
|
||||
|
@ -605,7 +607,7 @@ CustomCommandBlockMorph.prototype.refreshPrototype = function () {
|
|||
} else if (this instanceof CustomReporterBlockMorph) {
|
||||
if (hat.type === 'command') {
|
||||
myself = new CustomCommandBlockMorph(
|
||||
this.definition,
|
||||
this.definition.value,
|
||||
true
|
||||
);
|
||||
hat.silentReplaceInput(this, myself);
|
||||
|
@ -723,7 +725,7 @@ CustomCommandBlockMorph.prototype.parseSpec = function (spec) {
|
|||
if (!this.isPrototype) {
|
||||
return CustomCommandBlockMorph.uber.parseSpec.call(this, spec);
|
||||
}
|
||||
return this.definition.parseSpec.call(this, spec);
|
||||
return this.definition.value.parseSpec.call(this, spec);
|
||||
};
|
||||
|
||||
CustomCommandBlockMorph.prototype.mouseClickLeft = function () {
|
||||
|
@ -737,7 +739,7 @@ CustomCommandBlockMorph.prototype.edit = function () {
|
|||
var myself = this, editor, block, hat, rcvr;
|
||||
|
||||
if (this.isPrototype) {
|
||||
block = this.definition.blockInstance();
|
||||
block = this.definition.value.blockInstance();
|
||||
block.addShadow();
|
||||
hat = this.parentThatIsA(PrototypeHatBlockMorph);
|
||||
new BlockDialogMorph(
|
||||
|
@ -765,7 +767,7 @@ CustomCommandBlockMorph.prototype.edit = function () {
|
|||
/* // under construction, commented out for now
|
||||
if (rcvr && contains(
|
||||
Object.keys(rcvr.inheritedBlocks()),
|
||||
this.definition.blockSpec()
|
||||
this.definition.value.blockSpec()
|
||||
)
|
||||
) {
|
||||
this.duplicateBlockDefinition();
|
||||
|
@ -774,7 +776,7 @@ CustomCommandBlockMorph.prototype.edit = function () {
|
|||
*/
|
||||
|
||||
Morph.prototype.trackChanges = false;
|
||||
editor = new BlockEditorMorph(this.definition, rcvr);
|
||||
editor = new BlockEditorMorph(this.definition.value, rcvr);
|
||||
editor.popUp();
|
||||
Morph.prototype.trackChanges = true;
|
||||
editor.changed();
|
||||
|
@ -822,7 +824,7 @@ CustomCommandBlockMorph.prototype.attachTargets = function () {
|
|||
CustomCommandBlockMorph.prototype.isInUse = function () {
|
||||
// answer true if an instance of my definition is found
|
||||
// in any of my receiver's scripts or block definitions
|
||||
var def = this.definition,
|
||||
var def = this.definition.value,
|
||||
ide = this.receiver().parentThatIsA(IDE_Morph);
|
||||
if (def.isGlobal && ide) {
|
||||
return ide.sprites.asArray().concat([ide.stage]).some(
|
||||
|
@ -939,7 +941,7 @@ CustomCommandBlockMorph.prototype.userMenu = function () {
|
|||
};
|
||||
|
||||
CustomCommandBlockMorph.prototype.exportBlockDefinition = function () {
|
||||
var xml = new SnapSerializer().serialize(this.definition),
|
||||
var xml = new SnapSerializer().serialize(this.definition.value),
|
||||
ide = this.parentThatIsA(IDE_Morph);
|
||||
|
||||
ide.saveXMLAs(xml, this.spec);
|
||||
|
@ -947,9 +949,9 @@ CustomCommandBlockMorph.prototype.exportBlockDefinition = function () {
|
|||
|
||||
CustomCommandBlockMorph.prototype.duplicateBlockDefinition = function () {
|
||||
var rcvr = this.receiver(),
|
||||
dup = this.definition.copyAndBindTo(rcvr),
|
||||
dup = this.definition.value.copyAndBindTo(rcvr),
|
||||
ide = this.parentThatIsA(IDE_Morph);
|
||||
if (this.definition.isGlobal) {
|
||||
if (this.definition.value.isGlobal) {
|
||||
ide.stage.globalBlocks.push(dup);
|
||||
} else {
|
||||
rcvr.customBlocks.push(dup);
|
||||
|
@ -964,21 +966,21 @@ CustomCommandBlockMorph.prototype.deleteBlockDefinition = function () {
|
|||
if (this.isPrototype) {
|
||||
return null; // under construction...
|
||||
}
|
||||
block = myself.definition.blockInstance();
|
||||
block = myself.definition.value.blockInstance();
|
||||
block.addShadow();
|
||||
new DialogBoxMorph(
|
||||
this,
|
||||
function () {
|
||||
rcvr = myself.receiver();
|
||||
rcvr.deleteAllBlockInstances(myself.definition);
|
||||
if (myself.definition.isGlobal) {
|
||||
rcvr.deleteAllBlockInstances(myself.definition.value);
|
||||
if (myself.definition.value.isGlobal) {
|
||||
stage = rcvr.parentThatIsA(StageMorph);
|
||||
idx = stage.globalBlocks.indexOf(myself.definition);
|
||||
idx = stage.globalBlocks.indexOf(myself.definition.value);
|
||||
if (idx !== -1) {
|
||||
stage.globalBlocks.splice(idx, 1);
|
||||
}
|
||||
} else {
|
||||
idx = rcvr.customBlocks.indexOf(myself.definition);
|
||||
idx = rcvr.customBlocks.indexOf(myself.definition.value);
|
||||
if (idx !== -1) {
|
||||
rcvr.customBlocks.splice(idx, 1);
|
||||
}
|
||||
|
@ -1001,6 +1003,9 @@ CustomCommandBlockMorph.prototype.deleteBlockDefinition = function () {
|
|||
// CustomCommandBlockMorph relabelling
|
||||
|
||||
CustomCommandBlockMorph.prototype.relabel = function (alternatives) {
|
||||
// +++ this needs tweaking for block inheritance
|
||||
// +++ and also so embeded blocks do not get lost
|
||||
// +++ -Jens
|
||||
var menu = new MenuMorph(this),
|
||||
oldInputs = this.inputs().map(
|
||||
function (each) {return each.fullCopy(); }
|
||||
|
@ -1014,7 +1019,7 @@ CustomCommandBlockMorph.prototype.relabel = function (alternatives) {
|
|||
menu.addItem(
|
||||
block,
|
||||
function () {
|
||||
myself.definition = def;
|
||||
myself.definition.value = def; // +++ needs tweaking for inheritance
|
||||
myself.refresh();
|
||||
}
|
||||
);
|
||||
|
@ -1031,8 +1036,8 @@ CustomCommandBlockMorph.prototype.alternatives = function () {
|
|||
allDefs = rcvr.customBlocks.concat(stage.globalBlocks),
|
||||
myself = this;
|
||||
return allDefs.filter(function (each) {
|
||||
return each !== myself.definition &&
|
||||
each.type === myself.definition.type;
|
||||
return each !== myself.definition.value &&
|
||||
each.type === myself.definition.value.type;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1055,7 +1060,7 @@ CustomReporterBlockMorph.prototype.init = function (
|
|||
isPredicate,
|
||||
isProto
|
||||
) {
|
||||
this.definition = definition; // mandatory
|
||||
this.definition = new Variable(definition); // mandatory
|
||||
this.isPrototype = isProto || false; // optional
|
||||
CustomReporterBlockMorph.uber.init.call(this, isPredicate, true); // sil.
|
||||
this.category = definition.category;
|
||||
|
@ -1073,7 +1078,7 @@ CustomReporterBlockMorph.prototype.initializeVariables =
|
|||
CustomReporterBlockMorph.prototype.refresh = function () {
|
||||
CustomCommandBlockMorph.prototype.refresh.call(this, true);
|
||||
if (!this.isPrototype) {
|
||||
this.isPredicate = (this.definition.type === 'predicate');
|
||||
this.isPredicate = (this.definition.value.type === 'predicate');
|
||||
}
|
||||
if (this.parent instanceof SyntaxElementMorph) {
|
||||
this.parent.cachedInputs = null;
|
||||
|
@ -1945,11 +1950,13 @@ BlockEditorMorph.prototype.close = function () {
|
|||
block = detect(
|
||||
this.body.contents.allChildren(),
|
||||
function (morph) {
|
||||
return morph.definition && !morph.definition.isGlobal;
|
||||
return morph.definition &&
|
||||
morph.definition.value && // exclude the prototype
|
||||
!morph.definition.value.isGlobal;
|
||||
}
|
||||
);
|
||||
if (block) {
|
||||
block = block.definition.blockInstance();
|
||||
block = block.definition.value.blockInstance();
|
||||
block.addShadow();
|
||||
new DialogBoxMorph().inform(
|
||||
'Local Block(s) in Global Definition',
|
||||
|
|
4
gui.js
4
gui.js
|
@ -74,7 +74,7 @@ isRetinaSupported, SliderMorph, Animation, BooleanSlotMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.gui = '2017-February-01';
|
||||
modules.gui = '2017-February-16';
|
||||
|
||||
// Declarations
|
||||
|
||||
|
@ -6972,7 +6972,7 @@ SpriteIconMorph.prototype.copyStack = function (block) {
|
|||
// delete all custom blocks pointing to local definitions
|
||||
// under construction...
|
||||
dup.allChildren().forEach(function (morph) {
|
||||
if (morph.definition && !morph.definition.isGlobal) {
|
||||
if (morph.definition && !morph.definition.value.isGlobal) {
|
||||
morph.deleteBlock();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3372,3 +3372,7 @@ Fixes:
|
|||
------
|
||||
* Lists: remove experimental methods for object-use
|
||||
* Objects, BYOB: disable (comment out) experimental block inheritance for now
|
||||
|
||||
170216
|
||||
------
|
||||
* turn “definition” property of custom block instances into a double-pointer (Variable) structure, in preparation for OOP (method inheritance)
|
||||
|
|
26
objects.js
26
objects.js
|
@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
|
|||
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
|
||||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph*/
|
||||
|
||||
modules.objects = '2017-February-14';
|
||||
modules.objects = '2017-February-16';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -1408,7 +1408,7 @@ SpriteMorph.prototype.fullCopy = function (forClone) {
|
|||
cb = def.copyAndBindTo(c);
|
||||
c.customBlocks.push(cb);
|
||||
c.allBlockInstances(def).forEach(function (block) {
|
||||
block.definition = cb;
|
||||
block.definition.value = cb; // +++ might have to be tweaked, -Jens
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -4637,7 +4637,7 @@ SpriteMorph.prototype.allBlockInstances = function (definition) {
|
|||
stage.globalBlocks.forEach(function (def) {
|
||||
if (def.body) {
|
||||
def.body.expression.allChildren().forEach(function (c) {
|
||||
if (c.definition && (c.definition === definition)) {
|
||||
if (c.definition && (c.definition.value === definition)) {
|
||||
inDefinitions.push(c);
|
||||
}
|
||||
});
|
||||
|
@ -4652,14 +4652,14 @@ SpriteMorph.prototype.allLocalBlockInstances = function (definition) {
|
|||
var inScripts, inDefinitions, inBlockEditors, inPalette, result;
|
||||
|
||||
inScripts = this.scripts.allChildren().filter(function (c) {
|
||||
return c.definition && (c.definition === definition);
|
||||
return c.definition && (c.definition.value === definition);
|
||||
});
|
||||
|
||||
inDefinitions = [];
|
||||
this.customBlocks.forEach(function (def) {
|
||||
if (def.body) {
|
||||
def.body.expression.allChildren().forEach(function (c) {
|
||||
if (c.definition && (c.definition === definition)) {
|
||||
if (c.definition && (c.definition.value === definition)) {
|
||||
inDefinitions.push(c);
|
||||
}
|
||||
});
|
||||
|
@ -4687,7 +4687,8 @@ SpriteMorph.prototype.allEditorBlockInstances = function (definition) {
|
|||
morph.body.contents.allChildren().forEach(function (block) {
|
||||
if (!block.isPrototype
|
||||
&& !(block instanceof PrototypeHatBlockMorph)
|
||||
&& (block.definition === definition)) {
|
||||
&& block.definition
|
||||
&& (block.definition.value === definition)) {
|
||||
inBlockEditors.push(block);
|
||||
}
|
||||
});
|
||||
|
@ -4703,7 +4704,8 @@ SpriteMorph.prototype.paletteBlockInstance = function (definition) {
|
|||
return detect(
|
||||
ide.palette.contents.children,
|
||||
function (block) {
|
||||
return block.definition === definition;
|
||||
return block.definition &&
|
||||
(block.definition.value === definition);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -4718,7 +4720,7 @@ SpriteMorph.prototype.usesBlockInstance = function (
|
|||
inScripts = detect(
|
||||
this.scripts.allChildren(),
|
||||
function (c) {
|
||||
return c.definition && (c.definition === definition);
|
||||
return c.definition && (c.definition.value === definition);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -4732,7 +4734,9 @@ SpriteMorph.prototype.usesBlockInstance = function (
|
|||
if (skipBlocks && contains(skipBlocks, def)) {return; }
|
||||
if (def.body) {
|
||||
def.body.expression.allChildren().forEach(function (c) {
|
||||
if (c.definition && (c.definition === definition)) {
|
||||
if (c.definition &&
|
||||
(c.definition.value === definition)
|
||||
) {
|
||||
inDefinitions.push(c);
|
||||
}
|
||||
});
|
||||
|
@ -4746,7 +4750,7 @@ SpriteMorph.prototype.usesBlockInstance = function (
|
|||
this.customBlocks.forEach(function (def) {
|
||||
if (def.body) {
|
||||
def.body.expression.allChildren().forEach(function (c) {
|
||||
if (c.definition && (c.definition === definition)) {
|
||||
if (c.definition && (c.definition.value === definition)) {
|
||||
inDefinitions.push(c);
|
||||
}
|
||||
});
|
||||
|
@ -4782,7 +4786,7 @@ SpriteMorph.prototype.replaceDoubleDefinitionsFor = function (definition) {
|
|||
ide;
|
||||
doubles.forEach(function (double) {
|
||||
myself.allBlockInstances(double).forEach(function (block) {
|
||||
block.definition = definition;
|
||||
block.definition.value = definition; // might have to be tweaked +++
|
||||
block.refresh();
|
||||
});
|
||||
});
|
||||
|
|
14
store.js
14
store.js
|
@ -61,7 +61,7 @@ normalizeCanvas, contains*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.store = '2017-January-30';
|
||||
modules.store = '2017-February-16';
|
||||
|
||||
|
||||
// XML_Serializer ///////////////////////////////////////////////////////
|
||||
|
@ -1827,23 +1827,23 @@ ReporterBlockMorph.prototype.toScriptXML = function (
|
|||
};
|
||||
|
||||
CustomCommandBlockMorph.prototype.toBlockXML = function (serializer) {
|
||||
var scope = this.definition.isGlobal ? undefined
|
||||
: this.definition.receiver.name;
|
||||
var scope = this.definition.value.isGlobal ? undefined
|
||||
: this.definition.value.receiver.name;
|
||||
return serializer.format(
|
||||
'<custom-block s="@"%>%%%%</custom-block>',
|
||||
this.blockSpec,
|
||||
this.definition.isGlobal ?
|
||||
this.definition.value.isGlobal ?
|
||||
'' : serializer.format(' scope="@"', scope),
|
||||
serializer.store(this.inputs()),
|
||||
this.definition.variableNames.length ?
|
||||
this.definition.value.variableNames.length ?
|
||||
'<variables>' +
|
||||
this.variables.toXML(serializer) +
|
||||
'</variables>'
|
||||
: '',
|
||||
this.comment ? this.comment.toXML(serializer) : '',
|
||||
scope && !this.definition.receiver[serializer.idProperty] ?
|
||||
scope && !this.definition.value.receiver[serializer.idProperty] ?
|
||||
'<receiver>' +
|
||||
serializer.store(this.definition.receiver) +
|
||||
serializer.store(this.definition.value.receiver) +
|
||||
'</receiver>'
|
||||
: ''
|
||||
);
|
||||
|
|
15
threads.js
15
threads.js
|
@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
|
|||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
||||
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
||||
|
||||
modules.threads = '2017-February-09';
|
||||
modules.threads = '2017-February-16';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -1269,8 +1269,8 @@ Process.prototype.runContinuation = function (aContext, args) {
|
|||
|
||||
Process.prototype.evaluateCustomBlock = function () {
|
||||
var caller = this.context.parentContext,
|
||||
context = this.context.expression.definition.body,
|
||||
declarations = this.context.expression.definition.declarations,
|
||||
context = this.context.expression.definition.value.body,
|
||||
declarations = this.context.expression.definition.value.declarations,
|
||||
args = new List(this.context.inputs),
|
||||
parms = args.asArray(),
|
||||
runnable,
|
||||
|
@ -1290,7 +1290,7 @@ Process.prototype.evaluateCustomBlock = function () {
|
|||
// only splice in block vars if any are defined, because block vars
|
||||
// can cause race conditions in global block definitions that
|
||||
// access sprite-local variables at the same time.
|
||||
if (this.context.expression.definition.variableNames.length) {
|
||||
if (this.context.expression.definition.value.variableNames.length) {
|
||||
this.context.expression.variables.parentFrame = outer.receiver ?
|
||||
outer.receiver.variables : null;
|
||||
} else {
|
||||
|
@ -1329,7 +1329,7 @@ Process.prototype.evaluateCustomBlock = function () {
|
|||
}
|
||||
|
||||
// tag return target
|
||||
if (this.context.expression.definition.type !== 'command') {
|
||||
if (this.context.expression.definition.value.type !== 'command') {
|
||||
if (caller) {
|
||||
// tag caller, so "report" can catch it later
|
||||
caller.tag = 'exit';
|
||||
|
@ -1361,7 +1361,8 @@ Process.prototype.evaluateCustomBlock = function () {
|
|||
}
|
||||
// yield commands unless explicitly "warped" or directly recursive
|
||||
if (!this.isAtomic &&
|
||||
this.context.expression.definition.isDirectlyRecursive()) {
|
||||
this.context.expression.definition.value.isDirectlyRecursive()
|
||||
) {
|
||||
this.readyToYield = true;
|
||||
}
|
||||
}
|
||||
|
@ -3660,7 +3661,7 @@ function Variable(value, isTransient) {
|
|||
}
|
||||
|
||||
Variable.prototype.toString = function () {
|
||||
return 'a ' + this.isTransient ? 'transient ' : '' + 'Variable [' +
|
||||
return 'a ' + (this.isTransient ? 'transient ' : '') + 'Variable [' +
|
||||
this.value + ']';
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue