continuing to move and disable

This commit is contained in:
Danny Yoo 2011-07-03 19:12:37 -04:00
parent 8ccaf4ac54
commit b597932d4c
6 changed files with 365 additions and 244 deletions

View File

@ -38,6 +38,7 @@
(define-runtime-path baselib_unionfind.js "runtime-src/baselib_unionfind.js") (define-runtime-path baselib_unionfind.js "runtime-src/baselib_unionfind.js")
(define-runtime-path baselib_hash.js "runtime-src/baselib_hash.js") (define-runtime-path baselib_hash.js "runtime-src/baselib_hash.js")
(define-runtime-path baselib_structs.js "runtime-src/baselib_structs.js") (define-runtime-path baselib_structs.js "runtime-src/baselib_structs.js")
(define-runtime-path baselib_arity.js "runtime-src/baselib_arity.js")
(define-runtime-path jshashtable.js "runtime-src/jshashtable-2.1_src.js") (define-runtime-path jshashtable.js "runtime-src/jshashtable-2.1_src.js")
@ -61,16 +62,15 @@
(define files (list jquery-protect-header.js (define files (list jquery-protect-header.js
jquery.js jquery.js
jquery-protect-footer.js jquery-protect-footer.js
jshashtable.js jshashtable.js
jsnums.js jsnums.js
baselib.js baselib.js
baselib_unionfind.js baselib_unionfind.js
baselib_hash.js baselib_hash.js
baselib_structs.js baselib_structs.js
baselib_arity.js
link.js link.js

View File

@ -0,0 +1,40 @@
// Arity structure
(function(baselib) {
var exports = {};
baselib.arity = exports;
// An arity is either a primitive number, an ArityAtLeast instance,
// or a list of either primitive numbers or ArityAtLeast instances.
var ArityAtLeast = function(n) {
this.value = n;
};
// isArityMatching: arity natural -> boolean
// Produces true if n satisfies the arity.
var isArityMatching = function(arity, n) {
if (typeof(arity) === 'number') {
return arity === n;
} else if (arity instanceof ArityAtLeast) {
return n >= arity.value;
} else {
while (arity !== plt.types.EMPTY) {
if (typeof(arity.first) === 'number') {
if (arity.first === n) { return true; }
} else if (arity instanceof ArityAtLeast) {
if (n >= arity.first.value) { return true; }
}
arity = arity.rest;
}
return false;
}
}
exports.ArityAtLeast = ArityAtLeast;
exports.isArityMatching = isArityMatching;
})(this['plt'].baselib);

View File

@ -0,0 +1,133 @@
// Exceptions
(function(baselib) {
var exceptions = {};
baselib.exceptions = exceptions;
// Error type exports
var InternalError = function(val, contMarks) {
this.val = val;
this.contMarks = (contMarks ? contMarks : false);
}
var SchemeError = function(val) {
this.val = val;
}
var IncompleteExn = function(constructor, msg, otherArgs) {
this.constructor = constructor;
this.msg = msg;
this.otherArgs = otherArgs;
};
var Exn = plt.baselib.structs.makeStructureType(
'exn',
false,
2,
0,
false,
function(args, name, k) {
// helpers.check(args[0], isString, name, 'string', 1);
// helpers.check(args[1], types.isContinuationMarkSet,
// name, 'continuation mark set', 2);
return k(args);
});
// (define-struct (exn:break exn) (continuation))
var ExnBreak = plt.baselib.structs.makeStructureType(
'exn:break', Exn, 1, 0, false,
function(args, name, k) {
// helpers.check(args[2], function(x) { return x instanceof ContinuationClosureValue; },
// name, 'continuation', 3);
return k(args);
});
var ExnFail =
plt.baselib.structs.makeStructureType('exn:fail',
Exn, 0, 0, false, false);
var ExnFailContract =
plt.baselib.structs.makeStructureType('exn:fail:contract',
ExnFail, 0, 0, false, false);
var ExnFailContractArity =
plt.baselib.structs.makeStructureType('exn:fail:contract:arity',
ExnFailContract, 0, 0, false, false);
var ExnFailContractVariable =
plt.baselib.structs.makeStructureType('exn:fail:contract:variable',
ExnFailContract, 1, 0, false, false);
var ExnFailContractDivisionByZero =
plt.baselib.structs.makeStructureType('exn:fail:contract:divide-by-zero',
ExnFailContract, 0, 0, false, false);
//////////////////////////////////////////////////////////////////////
// Exports
exceptions.InternalError = InternalError;
exceptions.internalError = function(v, contMarks) { return new InternalError(v, contMarks); };
exceptions.isInternalError = function(x) { return x instanceof InternalError; };
exceptions.SchemeError = SchemeError;
exceptions.schemeError = function(v) { return new SchemeError(v); };
exceptions.isSchemeError = function(v) { return v instanceof SchemeError; };
exceptions.IncompleteExn = IncompleteExn;
exceptions.incompleteExn = function(constructor, msg, args) { return new IncompleteExn(constructor, msg, args); };
exceptions.isIncompleteExn = function(x) { return x instanceof IncompleteExn; };
exceptions.Exn = Exn;
exceptions.exn = Exn.constructor;
exceptions.isExn = Exn.predicate;
exceptions.exnMessage = function(exn) { return Exn.accessor(exn, 0); };
exceptions.exnContMarks = function(exn) { return Exn.accessor(exn, 1); };
exceptions.exnSetContMarks = function(exn, v) { Exn.mutator(exn, 1, v); };
exceptions.ExnBreak = ExnBreak;
exceptions.exnBreak = ExnBreak.constructor;
exceptions.isExnBreak = ExnBreak.predicate;
exceptions.exnBreakContinuation =
function(exn) { return ExnBreak.accessor(exn, 0); };
exceptions.ExnFail = ExnFail;
exceptions.exnFail = ExnFail.constructor;
exceptions.isExnFail = ExnFail.predicate;
exceptions.ExnFailContract = ExnFailContract;
exceptions.exnFailContract = ExnFailContract.constructor;
exceptions.isExnFailContract = ExnFailContract.predicate;
exceptions.ExnFailContractArity = ExnFailContractArity;
exceptions.exnFailContractArity = ExnFailContractArity.constructor;
exceptions.isExnFailContractArity = ExnFailContractArity.predicate;
exceptions.ExnFailContractVariable = ExnFailContractVariable;
exceptions.exnFailContractVariable = ExnFailContractVariable.constructor;
exceptions.isExnFailContractVariable = ExnFailContractVariable.predicate;
exceptions.exnFailContractVariableId =
function(exn) { return ExnFailContractVariable.accessor(exn, 0); };
exceptions.ExnFailContractDivisionByZero = ExnFailContractDivisionByZero;
exceptions.exnFailContractDivisionByZero = ExnFailContractDivisionByZero.constructor;
exceptions.isExnFailContractDivisionByZero = ExnFailContractDivisionByZero.predicate;
})(this['plt'].baselib);

View File

@ -9,8 +9,16 @@
var StructType = function(name, type, numberOfArgs, numberOfFields, firstField, var StructType = function(name, // string
applyGuard, constructor, predicate, accessor, mutator) { type, // StructType
numberOfArgs, // number
numberOfFields, // number
firstField,
applyGuard,
constructor,
predicate,
accessor,
mutator) {
this.name = name; this.name = name;
this.type = type; this.type = type;
this.numberOfArgs = numberOfArgs; this.numberOfArgs = numberOfArgs;
@ -38,10 +46,17 @@
// guard-function: array string (array -> value)
// makeStructureType: string StructType number number boolean
// guard-function -> StructType
//
// Creates a new structure type. // Creates a new structure type.
var makeStructureType = function(theName, var makeStructureType = function(theName,
parentType, parentType,
initFieldCnt, initFieldCnt,

View File

@ -96,7 +96,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
'currentErrorHandler': function(MACHINE, exn) { 'currentErrorHandler': function(MACHINE, exn) {
MACHINE.params.currentErrorDisplayer( MACHINE.params.currentErrorDisplayer(
MACHINE, MACHINE,
exn); toDomNode(exn));
}, },
'currentNamespace': {}, 'currentNamespace': {},
@ -542,33 +542,6 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
// An arity is either a primitive number, an ArityAtLeast instance,
// or a list of either primitive numbers or ArityAtLeast instances.
var ArityAtLeast = function(n) {
this.value = n;
};
// isArityMatching: arity natural -> boolean
// Produces true if n satisfies the arity.
var isArityMatching = function(arity, n) {
if (typeof(arity) === 'number') {
return arity === n;
} else if (arity instanceof ArityAtLeast) {
return n >= arity.value;
} else {
while (arity !== NULL) {
if (typeof(arity.first) === 'number') {
if (arity.first === n) { return true; }
} else if (arity instanceof ArityAtLeast) {
if (n >= arity.first.value) { return true; }
}
arity = arity.rest;
}
return false;
}
}
@ -696,7 +669,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'format', 'format',
new ArityAtLeast(1), new plt.baselib.arity.ArityAtLeast(1),
function(MACHINE) { function(MACHINE) {
var args = [], i, formatString; var args = [], i, formatString;
testArgument(MACHINE, testArgument(MACHINE,
@ -716,7 +689,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'printf', 'printf',
new ArityAtLeast(1), new plt.baselib.arity.ArityAtLeast(1),
function(MACHINE) { function(MACHINE) {
var args = [], i, formatString; var args = [], i, formatString;
testArgument(MACHINE, testArgument(MACHINE,
@ -738,7 +711,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'fprintf', 'fprintf',
new ArityAtLeast(2), new plt.baselib.arity.ArityAtLeast(2),
function(MACHINE) { function(MACHINE) {
var args = [], i, formatString; var args = [], i, formatString;
testArgument(MACHINE, testArgument(MACHINE,
@ -799,7 +772,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'=', '=',
new ArityAtLeast(2), new plt.baselib.arity.ArityAtLeast(2),
function(MACHINE) { function(MACHINE) {
var firstArg = MACHINE.env[MACHINE.env.length-1]; var firstArg = MACHINE.env[MACHINE.env.length-1];
testArgument(MACHINE, 'number', isNumber, firstArg, 0, '='); testArgument(MACHINE, 'number', isNumber, firstArg, 0, '=');
@ -853,7 +826,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'<', '<',
new ArityAtLeast(2), new plt.baselib.arity.ArityAtLeast(2),
function(MACHINE) { function(MACHINE) {
var firstArg = MACHINE.env[MACHINE.env.length-1]; var firstArg = MACHINE.env[MACHINE.env.length-1];
testArgument(MACHINE, testArgument(MACHINE,
@ -876,7 +849,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'>', '>',
new ArityAtLeast(2), new plt.baselib.arity.ArityAtLeast(2),
function(MACHINE) { function(MACHINE) {
var firstArg = MACHINE.env[MACHINE.env.length-1]; var firstArg = MACHINE.env[MACHINE.env.length-1];
testArgument(MACHINE, testArgument(MACHINE,
@ -898,7 +871,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'<=', '<=',
new ArityAtLeast(2), new plt.baselib.arity.ArityAtLeast(2),
function(MACHINE) { function(MACHINE) {
var firstArg = MACHINE.env[MACHINE.env.length-1]; var firstArg = MACHINE.env[MACHINE.env.length-1];
testArgument(MACHINE, testArgument(MACHINE,
@ -921,7 +894,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'>=', '>=',
new ArityAtLeast(2), new plt.baselib.arity.ArityAtLeast(2),
function(MACHINE) { function(MACHINE) {
var firstArg = MACHINE.env[MACHINE.env.length-1]; var firstArg = MACHINE.env[MACHINE.env.length-1];
testArgument(MACHINE, testArgument(MACHINE,
@ -944,7 +917,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'+', '+',
new ArityAtLeast(0), new plt.baselib.arity.ArityAtLeast(0),
function(MACHINE) { function(MACHINE) {
var result = 0; var result = 0;
var i = 0; var i = 0;
@ -963,7 +936,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'*', '*',
new ArityAtLeast(0), new plt.baselib.arity.ArityAtLeast(0),
function(MACHINE) { function(MACHINE) {
var result = 1; var result = 1;
var i = 0; var i = 0;
@ -981,7 +954,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'-', '-',
new ArityAtLeast(1), new plt.baselib.arity.ArityAtLeast(1),
function(MACHINE) { function(MACHINE) {
if (MACHINE.argcount === 1) { if (MACHINE.argcount === 1) {
testArgument(MACHINE, testArgument(MACHINE,
@ -1007,7 +980,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'/', '/',
new ArityAtLeast(1), new plt.baselib.arity.ArityAtLeast(1),
function(MACHINE) { function(MACHINE) {
testArgument(MACHINE, testArgument(MACHINE,
'number', 'number',
@ -1080,7 +1053,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'list', 'list',
new ArityAtLeast(0), new plt.baselib.arity.ArityAtLeast(0),
function(MACHINE) { function(MACHINE) {
var result = NULL; var result = NULL;
for (var i = 0; i < MACHINE.argcount; i++) { for (var i = 0; i < MACHINE.argcount; i++) {
@ -1180,7 +1153,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'vector', 'vector',
new ArityAtLeast(0), new plt.baselib.arity.ArityAtLeast(0),
function(MACHINE) { function(MACHINE) {
var i; var i;
var result = []; var result = [];
@ -1322,7 +1295,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'string-append', 'string-append',
new ArityAtLeast(0), new plt.baselib.arity.ArityAtLeast(0),
function(MACHINE) { function(MACHINE) {
var buffer = []; var buffer = [];
var i; var i;
@ -1369,7 +1342,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'void', 'void',
new ArityAtLeast(0), new plt.baselib.arity.ArityAtLeast(0),
function(MACHINE) { function(MACHINE) {
return VOID; return VOID;
}); });
@ -1624,7 +1597,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'gcd', 'gcd',
new ArityAtLeast(1), new plt.baselib.arity.ArityAtLeast(1),
function(MACHINE) { function(MACHINE) {
var args = [], i, x; var args = [], i, x;
for (i = 0; i < MACHINE.argcount; i++) { for (i = 0; i < MACHINE.argcount; i++) {
@ -1643,7 +1616,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'lcm', 'lcm',
new ArityAtLeast(1), new plt.baselib.arity.ArityAtLeast(1),
function(MACHINE) { function(MACHINE) {
var args = [], i, x; var args = [], i, x;
for (i = 0; i < MACHINE.argcount; i++) { for (i = 0; i < MACHINE.argcount; i++) {
@ -2060,7 +2033,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
installPrimitiveProcedure( installPrimitiveProcedure(
'format', 'format',
new ArityAtLeast(1), new plt.baselib.arity.ArityAtLeast(1),
function(MACHINE) { function(MACHINE) {
var args = [], i, formatString; var args = [], i, formatString;
testArgument(MACHINE, testArgument(MACHINE,
@ -2104,8 +2077,9 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
inspector, // FIXME: currently ignored inspector, // FIXME: currently ignored
procSpec, // FIXME: currently ignored procSpec, // FIXME: currently ignored
immutables, // FIXME: currently ignored immutables, // FIXME: currently ignored
guard, guard, // FIXME: currently ignored
constructorName) { constructorName // FIXME, currently ignored
) {
// FIXME: we need to return those five values back. // FIXME: we need to return those five values back.
finalizeClosureCall(MACHINE, finalizeClosureCall(MACHINE,
@ -2542,8 +2516,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
exports['toWrittenString'] = toWrittenString; exports['toWrittenString'] = toWrittenString;
exports['toDisplayedString'] = toDisplayedString; exports['toDisplayedString'] = toDisplayedString;
exports['ArityAtLeast'] = ArityAtLeast; exports['ArityAtLeast'] = plt.baselib.arity.ArityAtLeast;
exports['isArityMatching'] = isArityMatching; exports['isArityMatching'] = plt.baselib.arity.isArityMatching;
exports['heir'] = heir; exports['heir'] = heir;
exports['makeClassPredicate'] = makeClassPredicate; exports['makeClassPredicate'] = makeClassPredicate;

View File

@ -963,134 +963,134 @@ String.prototype.toDisplayedString = function(cache) {
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
var JsValue = function(name, val) { // var JsValue = function(name, val) {
this.name = name; // this.name = name;
this.val = val; // this.val = val;
}; // };
JsValue.prototype.toString = function() { // JsValue.prototype.toString = function() {
return '#<js-value:' + typeof(this.val) + ':' + this.name + '>'; // return '#<js-value:' + typeof(this.val) + ':' + this.name + '>';
}; // };
JsValue.prototype.toDomNode = function(cache) { // JsValue.prototype.toDomNode = function(cache) {
return toDomNode(this.val, cache); // return toDomNode(this.val, cache);
}; // };
JsValue.prototype.equals = function(other, aUnionFind) { // JsValue.prototype.equals = function(other, aUnionFind) {
return (this.val === other.val); // return (this.val === other.val);
}; // };
// unbox: jsvalue -> any // // unbox: jsvalue -> any
// Unwraps the value out of the JsValue box. // // Unwraps the value out of the JsValue box.
JsValue.prototype.unbox = function() { // JsValue.prototype.unbox = function() {
return this.val; // return this.val;
}; // };
var WrappedSchemeValue = function(val) { // var WrappedSchemeValue = function(val) {
this.val = val; // this.val = val;
}; // };
WrappedSchemeValue.prototype.toString = function() { return toString(this.val); }; // WrappedSchemeValue.prototype.toString = function() { return toString(this.val); };
WrappedSchemeValue.prototype.toWrittenString = function(cache) { return toWrittenString(this.val, cache); }; // WrappedSchemeValue.prototype.toWrittenString = function(cache) { return toWrittenString(this.val, cache); };
WrappedSchemeValue.prototype.toDisplayedString = function(cache) { return toDisplayedString(this.val, cache); }; // WrappedSchemeValue.prototype.toDisplayedString = function(cache) { return toDisplayedString(this.val, cache); };
// unbox: jsvalue -> any // // unbox: jsvalue -> any
// Unwraps the value out of the WrappedSchemeValue box. // // Unwraps the value out of the WrappedSchemeValue box.
WrappedSchemeValue.prototype.unbox = function() { // WrappedSchemeValue.prototype.unbox = function() {
return this.val; // return this.val;
}; // };
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
var WorldConfig = function(startup, shutdown, startupArgs) { // var WorldConfig = function(startup, shutdown, startupArgs) {
this.startup = startup; // this.startup = startup;
this.shutdown = shutdown; // this.shutdown = shutdown;
this.startupArgs = startupArgs; // this.startupArgs = startupArgs;
}; // };
WorldConfig.prototype.toString = function() { // WorldConfig.prototype.toString = function() {
return '#<world-config>'; // return '#<world-config>';
}; // };
WorldConfig.prototype.equals = function(other, aUnionFind) { // WorldConfig.prototype.equals = function(other, aUnionFind) {
return ( equals(this.startup, other.startup, aUnionFind) && // return ( equals(this.startup, other.startup, aUnionFind) &&
equals(this.shutdown, other.shutdown, aUnionFind) && // equals(this.shutdown, other.shutdown, aUnionFind) &&
equals(this.shutdownArg, other.shutdownArg, aUnionFind) && // equals(this.shutdownArg, other.shutdownArg, aUnionFind) &&
equals(this.restartArg, other.restartArg, aUnionFind) ); // equals(this.restartArg, other.restartArg, aUnionFind) );
}; // };
var Effect = plt.baselib.structs.makeStructureType('effect', false, 0, 0, false, false); // var Effect = plt.baselib.structs.makeStructureType('effect', false, 0, 0, false, false);
Effect.type.prototype.invokeEffect = function() { // Effect.type.prototype.invokeEffect = function() {
helpers.raise(types.incompleteExn( // helpers.raise(types.incompleteExn(
types.exnFail, // types.exnFail,
'effect type created without using make-effect-type', // 'effect type created without using make-effect-type',
[])); // []));
}; // };
var makeEffectType = function(name, superType, initFieldCnt, impl, guard) { // var makeEffectType = function(name, superType, initFieldCnt, impl, guard) {
if ( !superType ) { // if ( !superType ) {
superType = Effect; // superType = Effect;
} // }
var newType = plt.baselib.structs.makeStructureType(name, superType, initFieldCnt, 0, false, guard); // var newType = plt.baselib.structs.makeStructureType(name, superType, initFieldCnt, 0, false, guard);
var lastFieldIndex = newType.firstField + newType.numberOfFields; // var lastFieldIndex = newType.firstField + newType.numberOfFields;
newType.type.prototype.invokeEffect = function(aBigBang, k) { // newType.type.prototype.invokeEffect = function(aBigBang, k) {
var schemeChangeWorld = new PrimProc('update-world', 1, false, false, // var schemeChangeWorld = new PrimProc('update-world', 1, false, false,
function(worldUpdater) { // function(worldUpdater) {
//helpers.check(worldUpdater, helpers.procArityContains(1), // //helpers.check(worldUpdater, helpers.procArityContains(1),
// 'update-world', 'procedure (arity 1)', 1); // // 'update-world', 'procedure (arity 1)', 1);
return new INTERNAL_PAUSE( // return new INTERNAL_PAUSE(
function(caller, onSuccess, onFail) { // function(caller, onSuccess, onFail) {
aBigBang.changeWorld(function(w, k2) { // aBigBang.changeWorld(function(w, k2) {
caller(worldUpdater, // caller(worldUpdater,
[w], k2, // [w], k2,
function(e) { throw e; }, // function(e) { throw e; },
'change-world (effect)'); // 'change-world (effect)');
}, // },
function() { onSuccess(VOID_VALUE, 'restarting (change-world (effect))'); }); // function() { onSuccess(VOID_VALUE, 'restarting (change-world (effect))'); });
}); // });
}); // });
var args = this._fields.slice(0, lastFieldIndex); // var args = this._fields.slice(0, lastFieldIndex);
args.unshift(schemeChangeWorld); // args.unshift(schemeChangeWorld);
return aBigBang.caller(impl, args, k, function(e) { throw e; }, 'invoking effect ' + name); // return aBigBang.caller(impl, args, k, function(e) { throw e; }, 'invoking effect ' + name);
} // }
return newType; // return newType;
}; // };
var RenderEffect = plt.baselib.structs.makeStructureType('render-effect', false, 0, 0, false, false); // var RenderEffect = plt.baselib.structs.makeStructureType('render-effect', false, 0, 0, false, false);
RenderEffect.type.prototype.callImplementation = function(caller, k) { // RenderEffect.type.prototype.callImplementation = function(caller, k) {
helpers.raise(types.incompleteExn( // helpers.raise(types.incompleteExn(
types.exnFail, // types.exnFail,
'render effect created without using make-render-effect-type', // 'render effect created without using make-render-effect-type',
[])); // []));
}; // };
var makeRenderEffectType = function(name, superType, initFieldCnt, impl, guard) { // var makeRenderEffectType = function(name, superType, initFieldCnt, impl, guard) {
if ( !superType ) { // if ( !superType ) {
superType = RenderEffect; // superType = RenderEffect;
} // }
var newType = plt.baselib.structs.makeStructureType(name, superType, initFieldCnt, 0, false, guard); // var newType = plt.baselib.structs.makeStructureType(name, superType, initFieldCnt, 0, false, guard);
var lastFieldIndex = newType.firstField + newType.numberOfFields; // var lastFieldIndex = newType.firstField + newType.numberOfFields;
newType.type.prototype.callImplementation = function(caller, k) { // newType.type.prototype.callImplementation = function(caller, k) {
var args = this._fields.slice(0, lastFieldIndex); // var args = this._fields.slice(0, lastFieldIndex);
caller(impl, args, k); // caller(impl, args, k);
} // }
return newType; // return newType;
}; // };
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -1239,20 +1239,6 @@ String.prototype.toDisplayedString = function(cache) {
var ContinuationClosureValue = function(vstack, cstack) {
this.name = types.EMPTY;
this.vstack = vstack.slice(0);
this.cstack = cstack.slice(0);
};
ContinuationClosureValue.prototype.toString = function() {
if (this.name !== Empty.EMPTY) {
return helpers.format("#<continuation:~a>", [this.name]);
} else {
return "#<continuation>";
}
};
@ -1315,33 +1301,6 @@ String.prototype.toDisplayedString = function(cache) {
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
var PrimProc = function(name, numParams, isRest, usesState, impl) {
this.name = name;
this.numParams = numParams;
this.isRest = isRest;
this.usesState = usesState;
this.impl = impl;
};
PrimProc.prototype.toString = function() {
return ("#<procedure:" + this.name + ">");
};
PrimProc.prototype.toWrittenString = function(cache) {
return ("#<procedure:" + this.name + ">");
};
PrimProc.prototype.toDisplayedString = function(cache) {
return ("#<procedure:" + this.name + ">");
};
PrimProc.prototype.toDomNode = function(cache) {
var div = document.createElement("span");
div.appendChild(document.createTextNode("#<procedure:"+ this.name +">"));
return div;
};
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -1414,24 +1373,24 @@ String.prototype.toDisplayedString = function(cache) {
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// ContinuationPromptTag: symbol | false -> ContinuationPromptTag // // ContinuationPromptTag: symbol | false -> ContinuationPromptTag
var ContinuationPromptTag = function(sym) { // var ContinuationPromptTag = function(sym) {
this.sym = sym; // this.sym = sym;
}; // };
var defaultContinuationPromptTag = new ContinuationPromptTag(); // var defaultContinuationPromptTag = new ContinuationPromptTag();
var defaultContinuationPromptTagHandler = new PrimProc( // var defaultContinuationPromptTagHandler = new PrimProc(
'default-continuation-prompt-tag-handler', // 'default-continuation-prompt-tag-handler',
1, // 1,
false, // false,
true, // true,
function(aState, thunk) { // function(aState, thunk) {
aState.pushControl( // aState.pushControl(
new control.ApplicationControl( // new control.ApplicationControl(
new control.ConstantControl(thunk), // new control.ConstantControl(thunk),
[])); // []));
}); // });
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -1653,10 +1612,12 @@ String.prototype.toDisplayedString = function(cache) {
types.isStruct = function(x) { return x instanceof Struct; }; types.isStruct = function(x) { return x instanceof Struct; };
types.isArityAtLeast = ArityAtLeast.predicate; types.isArityAtLeast = ArityAtLeast.predicate;
types.isColor = Color.predicate; types.isColor = Color.predicate;
types.isFunction = function(x) {
return (x instanceof PrimProc || // types.isFunction = function(x) {
x instanceof ContinuationClosureValue); // return (x instanceof PrimProc);
}; // };
types.isJsValue = function(x) { return x instanceof JsValue; }; types.isJsValue = function(x) { return x instanceof JsValue; };
types.isWrappedSchemeValue = function(x) { return x instanceof WrappedSchemeValue; }; types.isWrappedSchemeValue = function(x) { return x instanceof WrappedSchemeValue; };
@ -1666,11 +1627,9 @@ String.prototype.toDisplayedString = function(cache) {
types.VOID = VOID_VALUE; types.VOID = VOID_VALUE;
types.EOF = EOF_VALUE; types.EOF = EOF_VALUE;
types.ContinuationPromptTag = ContinuationPromptTag; // types.ContinuationPromptTag = ContinuationPromptTag;
types.defaultContinuationPromptTag = defaultContinuationPromptTag; // types.defaultContinuationPromptTag = defaultContinuationPromptTag;
types.defaultContinuationPromptTagHandler = defaultContinuationPromptTagHandler; // types.defaultContinuationPromptTagHandler = defaultContinuationPromptTagHandler;
types.ContinuationClosureValue = ContinuationClosureValue;
types.PrimProc = PrimProc;
// types.makeOptionPrimitive = makeOptionPrimitive; // types.makeOptionPrimitive = makeOptionPrimitive;
types.internalCall = function(op, args, k) { return new INTERNAL_CALL(op, args, k); }; types.internalCall = function(op, args, k) { return new INTERNAL_CALL(op, args, k); };
@ -1682,7 +1641,7 @@ String.prototype.toDisplayedString = function(cache) {
types.isContMarkRecordControl = function(x) { return x instanceof ContMarkRecordControl; }; types.isContMarkRecordControl = function(x) { return x instanceof ContMarkRecordControl; };
types.continuationMarkSet = function(dict) { return new ContinuationMarkSet(dict); }; types.continuationMarkSet = function(dict) { return new ContinuationMarkSet(dict); };
types.isContinuationMarkSet = function(x) { return x instanceof ContinuationMarkSet; }; types.isContinuationMarkSet = function(x) { return x instanceof ContinuationMarkSet; };
types.isContinuationPromptTag = function(x) { return x instanceof ContinuationPromptTag; }; // types.isContinuationPromptTag = function(x) { return x instanceof ContinuationPromptTag; };
types.Box = Box; types.Box = Box;
@ -1708,42 +1667,42 @@ String.prototype.toDisplayedString = function(cache) {
/////////////////////////////////////// ///////////////////////////////////////
// World-specific exports // World-specific exports
// big bang info to be passed into a make-world-config startup argument // // big bang info to be passed into a make-world-config startup argument
var BigBangInfo = plt.baselib.structs.makeStructureType('bb-info', false, 2, 0, false, // var BigBangInfo = plt.baselib.structs.makeStructureType('bb-info', false, 2, 0, false,
function(args, name, k) { // function(args, name, k) {
//helpers.check(args[0], helpers.procArityContains(1), name, 'procedure (arity 1)', 1); // //helpers.check(args[0], helpers.procArityContains(1), name, 'procedure (arity 1)', 1);
//helpers.check(args[1], types.isJsValue, name, 'js-object', 2); // //helpers.check(args[1], types.isJsValue, name, 'js-object', 2);
return k(args); // return k(args);
}); // });
types.BigBangInfo = BigBangInfo; // types.BigBangInfo = BigBangInfo;
types.makeBigBangInfo = BigBangInfo.constructor; // types.makeBigBangInfo = BigBangInfo.constructor;
types.isBigBangInfo = BigBangInfo.predicate; // types.isBigBangInfo = BigBangInfo.predicate;
types.bbInfoChangeWorld = function(info) { return BigBangInfo.accessor(info, 0); }; // types.bbInfoChangeWorld = function(info) { return BigBangInfo.accessor(info, 0); };
types.bbInfoToplevelNode = function(info) { return BigBangInfo.accessor(info, 1); }; // types.bbInfoToplevelNode = function(info) { return BigBangInfo.accessor(info, 1); };
// World config information for user-defined configurations // World config information for user-defined configurations
types.worldConfig = function(startup, shutdown, pause, restart) { return new WorldConfig(startup, shutdown, pause, restart); }; // types.worldConfig = function(startup, shutdown, pause, restart) { return new WorldConfig(startup, shutdown, pause, restart); };
types.isWorldConfig = function(x) { return x instanceof WorldConfig; }; // types.isWorldConfig = function(x) { return x instanceof WorldConfig; };
// exporting information to create effect types // exporting information to create effect types
types.makeEffectType = makeEffectType; // types.makeEffectType = makeEffectType;
types.isEffectType = function(x) { // types.isEffectType = function(x) {
return ((x instanceof plt.baselib.structs.StructType)&& x.type.prototype.invokeEffect) ? true : false; // return ((x instanceof plt.baselib.structs.StructType)&& x.type.prototype.invokeEffect) ? true : false;
}; // };
types.isEffect = Effect.predicate; // types.isEffect = Effect.predicate;
// exporting functions to create render effect types // exporting functions to create render effect types
types.makeRenderEffectType = makeRenderEffectType; // types.makeRenderEffectType = makeRenderEffectType;
types.isRenderEffectType = function(x) { // types.isRenderEffectType = function(x) {
return (x instanceof plt.baselib.structs.StructType && x.type.prototype.callImplementation) ? true : false; // return (x instanceof plt.baselib.structs.StructType && x.type.prototype.callImplementation) ? true : false;
}; // };
types.isRenderEffect = RenderEffect.predicate; // types.isRenderEffect = RenderEffect.predicate;