kopia lustrzana https://github.com/backface/turtlestitch
block-assembly support refactorings, experimental
rodzic
e6e54c8964
commit
d095d9d961
|
@ -68,6 +68,9 @@
|
|||
* Chinese, thanks, Simon!
|
||||
* Brazilian Portuguese, thank you, Cassiano D'Andrea!
|
||||
|
||||
### 2021-12-01
|
||||
* blocks, threads: block-assembly support refactorings, experimental
|
||||
|
||||
### 2021-11-30
|
||||
* blocks, threads: block-assembly support, experimental
|
||||
* gui: fixed #2920
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
<script src="src/morphic.js?version=2021-07-09"></script>
|
||||
<script src="src/symbols.js?version=2021-03-03"></script>
|
||||
<script src="src/widgets.js?version=2021-17-09"></script>
|
||||
<script src="src/blocks.js?version=2021-11-29"></script>
|
||||
<script src="src/threads.js?version=2021-11-29"></script>
|
||||
<script src="src/blocks.js?version=2021-12-01"></script>
|
||||
<script src="src/threads.js?version=2021-12-01"></script>
|
||||
<script src="src/objects.js?version=2021-11-26"></script>
|
||||
<script src="src/scenes.js?version=2021-11-24"></script>
|
||||
<script src="src/gui.js?version=2021-11-30"></script>
|
||||
|
|
|
@ -160,7 +160,7 @@ CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2021-November-30';
|
||||
modules.blocks = '2021-December-01';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -3736,7 +3736,30 @@ BlockMorph.prototype.copyWithInputs = function (inputs) {
|
|||
}
|
||||
}
|
||||
});
|
||||
return cpy;
|
||||
return cpy.reify();
|
||||
};
|
||||
|
||||
BlockMorph.prototype.reify = function () {
|
||||
// private - assumes that I've already been deep copied
|
||||
var context = new Context();
|
||||
context.expression = this;
|
||||
context.emptySlots = this.markEmptySlots();
|
||||
return context;
|
||||
};
|
||||
|
||||
BlockMorph.prototype.markEmptySlots = function () {
|
||||
// private - mark all empty slots with an identifier
|
||||
// and return the count
|
||||
var count = 0;
|
||||
this.allEmptySlots().forEach(slot => {
|
||||
count += 1;
|
||||
if (slot instanceof MultiArgMorph) {
|
||||
slot.bindingID = Symbol.for('arguments');
|
||||
} else {
|
||||
slot.bindingID = count;
|
||||
}
|
||||
});
|
||||
return count;
|
||||
};
|
||||
|
||||
// BlockMorph code mapping
|
||||
|
@ -5467,9 +5490,9 @@ CommandBlockMorph.prototype.components = function () {
|
|||
expr.fixBlockColor(null, true);
|
||||
inputs = expr.inputs();
|
||||
if (!inputs.length) {
|
||||
return expr;
|
||||
return expr.reify();
|
||||
}
|
||||
parts = new List([expr]);
|
||||
parts = new List([expr.reify()]);
|
||||
inputs.forEach(inp => {
|
||||
var val;
|
||||
if (inp instanceof BlockMorph) {
|
||||
|
@ -5481,6 +5504,7 @@ CommandBlockMorph.prototype.components = function () {
|
|||
}
|
||||
expr.revertToDefaultInput(inp, true); // empty
|
||||
});
|
||||
parts.at(1).updateEmptySlots();
|
||||
return parts;
|
||||
});
|
||||
return seq.length() === 1 ? seq.at(1) : seq;
|
||||
|
@ -5491,7 +5515,7 @@ CommandBlockMorph.prototype.copyWithNext = function (next) {
|
|||
bottom = exp.bottomBlock(),
|
||||
top = next.fullCopy().topBlock();
|
||||
bottom.nextBlock(top);
|
||||
return exp;
|
||||
return exp.reify();
|
||||
};
|
||||
|
||||
// CommandBlockMorph drawing:
|
||||
|
@ -6266,9 +6290,9 @@ ReporterBlockMorph.prototype.components = function () {
|
|||
expr.fixBlockColor(null, true);
|
||||
if (!inputs.length ||
|
||||
inputs.every(slot => slot.isEmptySlot && slot.isEmptySlot())) {
|
||||
return expr;
|
||||
return expr.reify();
|
||||
}
|
||||
parts = new List([expr]);
|
||||
parts = new List([expr.reify()]);
|
||||
inputs.forEach(inp => {
|
||||
var val;
|
||||
if (inp instanceof BlockMorph) {
|
||||
|
@ -6280,6 +6304,7 @@ ReporterBlockMorph.prototype.components = function () {
|
|||
}
|
||||
expr.revertToDefaultInput(inp, true); // empty
|
||||
});
|
||||
parts.at(1).updateEmptySlots();
|
||||
return parts;
|
||||
};
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ SnapExtensions, AlignmentMorph, TextMorph, Cloud, HatBlockMorph*/
|
|||
|
||||
/*jshint esversion: 6*/
|
||||
|
||||
modules.threads = '2021-November-30';
|
||||
modules.threads = '2021-December-01';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -7023,6 +7023,18 @@ Context.prototype.components = function () {
|
|||
return parts;
|
||||
};
|
||||
|
||||
Context.prototype.copyWithInputs = function (inputs) {
|
||||
return this.expression.copyWithInputs(inputs);
|
||||
};
|
||||
|
||||
Context.prototype.copyWithNext = function (next) {
|
||||
return this.expression.copyWithNext(next.expression);
|
||||
};
|
||||
|
||||
Context.prototype.updateEmptySlots = function () {
|
||||
this.emptySlots = this.expression.markEmptySlots();
|
||||
};
|
||||
|
||||
// Variable /////////////////////////////////////////////////////////////////
|
||||
|
||||
function Variable(value, isTransient, isHidden) {
|
||||
|
|
Ładowanie…
Reference in New Issue