enable “JS function” block to create custom control structures and HOFs

pull/3/merge
jmoenig 2014-07-28 14:41:15 +02:00
rodzic d559312b07
commit c0b91b5fa2
2 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -2233,3 +2233,8 @@ ______
------ ------
* Objects, Threads: new “JavaScript function” primitive. Go figure… * Objects, Threads: new “JavaScript function” primitive. Go figure…
* GUI: updated Credits * GUI: updated Credits
140728
------
* Lists: fixed "Load Failed Type Error Cannot read property 'isLinked' of null"
* Threads: enable “JS function” block to create custom control structures and HOFs

Wyświetl plik

@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.threads = '2014-July-27'; modules.threads = '2014-July-28';
var ThreadManager; var ThreadManager;
var Process; var Process;
@ -743,7 +743,7 @@ Process.prototype.reifyPredicate = function (topBlock, parameterNames) {
Process.prototype.reportJSFunction = function (parmNames, body) { Process.prototype.reportJSFunction = function (parmNames, body) {
return Function.apply( return Function.apply(
Object.create(null), null,
parmNames.asArray().concat([body]) parmNames.asArray().concat([body])
); );
}; };
@ -759,7 +759,10 @@ Process.prototype.evaluate = function (
) { ) {
if (!context) {return null; } if (!context) {return null; }
if (context instanceof Function) { if (context instanceof Function) {
return context.apply(this.homeContext.receiver, args.asArray()); return context.apply(
this.homeContext.receiver,
args.asArray().concat([this])
);
} }
if (context.isContinuation) { if (context.isContinuation) {
return this.runContinuation(context, args); return this.runContinuation(context, args);