kopia lustrzana https://github.com/backface/turtlestitch
tweaked block assembly support, experimental
rodzic
0e04a9ca9a
commit
78b6df548d
|
@ -444,7 +444,9 @@ SyntaxElementMorph.prototype.labelParts = {
|
|||
'tab' : ['tab'],
|
||||
'cr' : ['cr'],
|
||||
'csv' : ['csv'],
|
||||
'json' : ['json']
|
||||
'json' : ['json'],
|
||||
'~' : null,
|
||||
'blocks' : ['blocks']
|
||||
/*
|
||||
'csv records' : ['csv records'],
|
||||
'csv fields' : ['csv fields']
|
||||
|
@ -3760,6 +3762,10 @@ BlockMorph.prototype.markEmptySlots = function () {
|
|||
// private - mark all empty slots with an identifier
|
||||
// and return the count
|
||||
var count = 0;
|
||||
|
||||
this.allInputs().forEach(input =>
|
||||
delete input.bindingID
|
||||
);
|
||||
this.allEmptySlots().forEach(slot => {
|
||||
count += 1;
|
||||
if (slot instanceof MultiArgMorph) {
|
||||
|
|
|
@ -4283,11 +4283,25 @@ Process.prototype.reportJoin = function (a, b) {
|
|||
|
||||
Process.prototype.reportJoinWords = function (aList) {
|
||||
if (aList instanceof List) {
|
||||
if (this.isAST(aList)) {
|
||||
return this.assemble(aList);
|
||||
}
|
||||
return aList.asText();
|
||||
}
|
||||
return (aList || '').toString();
|
||||
};
|
||||
|
||||
Process.prototype.isAST = function (aList) {
|
||||
var first = aList.at(1);
|
||||
if (first instanceof Context) {
|
||||
return true;
|
||||
}
|
||||
if (first instanceof List) {
|
||||
return first.at(1) instanceof Context;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// Process string ops - hyper-monadic/dyadic
|
||||
|
||||
Process.prototype.reportLetter = function (idx, string) {
|
||||
|
@ -4360,6 +4374,10 @@ Process.prototype.reportUnicodeAsLetter = function (num) {
|
|||
};
|
||||
|
||||
Process.prototype.reportTextSplit = function (string, delimiter) {
|
||||
if (this.inputOption(delimiter) === 'blocks') {
|
||||
this.assertType(string, ['command', 'reporter', 'predicate']);
|
||||
return string.components();
|
||||
}
|
||||
return this.hyperDyadic(
|
||||
(str, delim) => this.reportBasicTextSplit(str, delim),
|
||||
string,
|
||||
|
@ -4530,6 +4548,24 @@ Process.prototype.parseJSON = function (string) {
|
|||
return listify(JSON.parse(string));
|
||||
};
|
||||
|
||||
// Process script components - EXPERIMENTAL
|
||||
|
||||
Process.prototype.assemble = function (blocks) {
|
||||
var first;
|
||||
if (!(blocks instanceof List)) {
|
||||
return blocks;
|
||||
}
|
||||
first = blocks.at(1);
|
||||
if (first instanceof Context) {
|
||||
return first.copyWithInputs(
|
||||
blocks.cdr().map(each => this.assemble(each))
|
||||
);
|
||||
}
|
||||
return blocks.map(each => this.assemble(each)).itemsArray().reduce(
|
||||
(a, b) => a.copyWithNext(b)
|
||||
);
|
||||
};
|
||||
|
||||
// Process debugging
|
||||
|
||||
Process.prototype.alert = function (data) {
|
||||
|
|
Ładowanie…
Reference in New Issue