removing dead files
This commit is contained in:
parent
ae415aa09b
commit
2ae1b70c17
|
@ -1,513 +0,0 @@
|
|||
// Helper functions for whalesong.
|
||||
//
|
||||
// Note: this originally came from js-vm, and may have cruft that
|
||||
// doesn't belong in whalesong. I need to clean this up.
|
||||
|
||||
|
||||
|
||||
if (! this['plt']) { this['plt'] = {}; }
|
||||
|
||||
// Helpers library: includes a bunch of helper functions that will be used
|
||||
//
|
||||
//
|
||||
// FIXME: there's a circularity between this module and types, and that circularly
|
||||
// should not be there!
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// File of helper functions for primitives and world.
|
||||
|
||||
|
||||
(function(scope) {
|
||||
var helpers = {};
|
||||
scope.helpers = helpers;
|
||||
|
||||
|
||||
// types refers to plt.types, and will be initialized later.
|
||||
var types = scope['types'];
|
||||
scope.link.ready('types',
|
||||
function() {
|
||||
types = scope['types'];
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// forEachK: CPS( array CPS(array -> void) (error -> void) -> void )
|
||||
// Iterates through an array and applies f to each element using CPS
|
||||
// If an error is thrown, it catches the error and calls f_error on it
|
||||
var forEachK = function(a, f, f_error, k) {
|
||||
var forEachHelp = function(i) {
|
||||
if( i >= a.length ) {
|
||||
if (k) {
|
||||
return k();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return f(a[i], function() { return forEachHelp(i+1); });
|
||||
} catch (e) {
|
||||
f_error(e);
|
||||
}
|
||||
};
|
||||
return forEachHelp(0);
|
||||
};
|
||||
|
||||
|
||||
// reportError: (or exception string) -> void
|
||||
// Reports an error to the user, either at the console
|
||||
// if the console exists, or as alerts otherwise.
|
||||
var reportError = function(e) {
|
||||
var reporter;
|
||||
if (typeof(console) != 'undefined' &&
|
||||
typeof(console.log) != 'undefined') {
|
||||
reporter = (function(x) { console.log(x); });
|
||||
} else {
|
||||
reporter = (function(x) { alert(x); });
|
||||
}
|
||||
if (typeof e == 'string') {
|
||||
reporter(e);
|
||||
} else if ( types.isSchemeError(e) ) {
|
||||
if ( types.isExn(e.val) ) {
|
||||
reporter( types.exnMessage(e.val) );
|
||||
}
|
||||
else {
|
||||
reporter(e.val);
|
||||
}
|
||||
} else if ( types.isInternalError(e) ) {
|
||||
reporter(e.val);
|
||||
} else if (e.message) {
|
||||
reporter(e.message);
|
||||
} else {
|
||||
reporter(e.toString());
|
||||
}
|
||||
// if (plt.Kernel.lastLoc) {
|
||||
// var loc = plt.Kernel.lastLoc;
|
||||
// if (typeof(loc) === 'string') {
|
||||
// reporter("Error was raised around " + loc);
|
||||
// } else if (typeof(loc) !== 'undefined' &&
|
||||
// typeof(loc.line) !== 'undefined') {
|
||||
// reporter("Error was raised around: "
|
||||
// + plt.Kernel.locToString(loc));
|
||||
// }
|
||||
// }
|
||||
};
|
||||
|
||||
|
||||
var raise = function(v) {
|
||||
throw types.schemeError(v);
|
||||
};
|
||||
|
||||
|
||||
|
||||
// var throwCheckError = function(details, pos, args) {
|
||||
// var errorFormatStr;
|
||||
// if (args && args.length > 1) {
|
||||
// var errorFormatStrBuffer = ['~a: expects type <~a> as ~a arguments, given: ~s; other arguments were:'];
|
||||
// for (var i = 0; i < args.length; i++) {
|
||||
// if ( i != pos-1 ) {
|
||||
// errorFormatStrBuffer.push(toWrittenString(args[i]));
|
||||
// }
|
||||
// }
|
||||
// errorFormatStr = errorFormatStrBuffer.join(' ');
|
||||
// }
|
||||
// else {
|
||||
// errorFormatStr = "~a: expects argument of type <~a>, given: ~s";
|
||||
// details.splice(2, 1);
|
||||
// }
|
||||
|
||||
// raise( types.incompleteExn(types.exnFailContract,
|
||||
// helpers.format(errorFormatStr, details),
|
||||
// []) );
|
||||
// };
|
||||
|
||||
|
||||
|
||||
// var check = function(x, f, functionName, typeName, position, args) {
|
||||
// if ( !f(x) ) {
|
||||
// throwCheckError([functionName,
|
||||
// typeName,
|
||||
// helpers.ordinalize(position),
|
||||
// x],
|
||||
// position,
|
||||
// args);
|
||||
// }
|
||||
// };
|
||||
|
||||
var isList = function(x) {
|
||||
var seenPairs = plt.baselib.hash.makeLowLevelEqHash();
|
||||
while (true) {
|
||||
if (seenPairs.containsKey(x)) {
|
||||
return true;
|
||||
} else if (x === types.EMPTY) {
|
||||
return true;
|
||||
} else if (types.isPair(x)) {
|
||||
seenPairs.put(x, true);
|
||||
x = x.rest();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var isListOf = function(x, f) {
|
||||
var seenPairs = plt.baselib.hash.makeLowLevelEqHash();
|
||||
while (true) {
|
||||
if (seenPairs.containsKey(x)) {
|
||||
return true;
|
||||
} else if (x === types.EMPTY) {
|
||||
return true;
|
||||
} else if (types.isPair(x)) {
|
||||
seenPairs.put(x, true);
|
||||
if (f(x.first())) {
|
||||
x = x.rest();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// var checkListOf = function(lst, f, functionName, typeName, position, args) {
|
||||
// if ( !isListOf(lst, f) ) {
|
||||
// helpers.throwCheckError([functionName,
|
||||
// 'list of ' + typeName,
|
||||
// helpers.ordinalize(position),
|
||||
// lst],
|
||||
// position,
|
||||
// args);
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
// // remove: array any -> array
|
||||
// // removes the first instance of v in a
|
||||
// // or returns a copy of a if v does not exist
|
||||
// var remove = function(a, v) {
|
||||
// for (var i = 0; i < a.length; i++) {
|
||||
// if (a[i] === v) {
|
||||
// return a.slice(0, i).concat( a.slice(i+1, a.length) );
|
||||
// }
|
||||
// }
|
||||
// return a.slice(0);
|
||||
// };
|
||||
|
||||
// map: array (any -> any) -> array
|
||||
// applies f to each element of a and returns the result
|
||||
// as a new array
|
||||
var map = function(f, a) {
|
||||
var b = new Array(a.length);
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
b[i] = f(a[i]);
|
||||
}
|
||||
return b;
|
||||
};
|
||||
|
||||
|
||||
var concatMap = function(f, a) {
|
||||
var b = [];
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
b = b.concat( f(a[i]) );
|
||||
}
|
||||
return b;
|
||||
};
|
||||
|
||||
|
||||
var schemeListToArray = function(lst) {
|
||||
var result = [];
|
||||
while ( !lst.isEmpty() ) {
|
||||
result.push(lst.first());
|
||||
lst = lst.rest();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// deepListToArray: any -> any
|
||||
// Converts list structure to array structure.
|
||||
var deepListToArray = function(x) {
|
||||
var thing = x;
|
||||
if (thing === types.EMPTY) {
|
||||
return [];
|
||||
} else if (types.isPair(thing)) {
|
||||
var result = [];
|
||||
while (!thing.isEmpty()) {
|
||||
result.push(deepListToArray(thing.first()));
|
||||
thing = thing.rest();
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var flattenSchemeListToArray = function(x) {
|
||||
if ( !isList(x) ) {
|
||||
return [x];
|
||||
}
|
||||
|
||||
var ret = [];
|
||||
while ( !x.isEmpty() ) {
|
||||
ret = ret.concat( flattenSchemeListToArray(x.first()) );
|
||||
x = x.rest();
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
|
||||
var ordinalize = function(n) {
|
||||
// special case for 11th:
|
||||
if ( n % 100 == 11 ) {
|
||||
return n + 'th';
|
||||
}
|
||||
var res = n;
|
||||
switch( n % 10 ) {
|
||||
case 1: res += 'st'; break;
|
||||
case 2: res += 'nd'; break;
|
||||
case 3: res += 'rd'; break;
|
||||
default: res += 'th'; break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// var wrapJsValue = function(x) {
|
||||
// if (x === undefined) {
|
||||
// return types.jsValue('undefined', x);
|
||||
// }
|
||||
// else if (x === null) {
|
||||
// return types.jsValue('null', x);
|
||||
// }
|
||||
// else if (typeof(x) == 'function') {
|
||||
// return types.jsValue('function', x);
|
||||
// }
|
||||
// else if ( x instanceof Array ) {
|
||||
// return types.jsValue('array', x);
|
||||
// }
|
||||
// else if ( typeof(x) == 'string' ) {
|
||||
// return types.jsValue("'" + x.toString() + "'", x);
|
||||
// }
|
||||
// else {
|
||||
// return types.jsValue(x.toString(), x);
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
var getKeyCodeName = function(e) {
|
||||
var code = e.charCode || e.keyCode;
|
||||
var keyname;
|
||||
switch(code) {
|
||||
case 16: keyname = "shift"; break;
|
||||
case 17: keyname = "control"; break;
|
||||
case 19: keyname = "pause"; break;
|
||||
case 27: keyname = "escape"; break;
|
||||
case 33: keyname = "prior"; break;
|
||||
case 34: keyname = "next"; break;
|
||||
case 35: keyname = "end"; break;
|
||||
case 36: keyname = "home"; break;
|
||||
case 37: keyname = "left"; break;
|
||||
case 38: keyname = "up"; break;
|
||||
case 39: keyname = "right"; break;
|
||||
case 40: keyname = "down"; break;
|
||||
case 42: keyname = "print"; break;
|
||||
case 45: keyname = "insert"; break;
|
||||
case 46: keyname = String.fromCharCode(127); break;
|
||||
case 106: keyname = "*"; break;
|
||||
case 107: keyname = "+"; break;
|
||||
case 109: keyname = "-"; break;
|
||||
case 110: keyname = "."; break;
|
||||
case 111: keyname = "/"; break;
|
||||
case 144: keyname = "numlock"; break;
|
||||
case 145: keyname = "scroll"; break;
|
||||
case 186: keyname = ";"; break;
|
||||
case 187: keyname = "="; break;
|
||||
case 188: keyname = ","; break;
|
||||
case 189: keyname = "-"; break;
|
||||
case 190: keyname = "."; break;
|
||||
case 191: keyname = "/"; break;
|
||||
case 192: keyname = "`"; break;
|
||||
case 219: keyname = "["; break;
|
||||
case 220: keyname = "\\"; break;
|
||||
case 221: keyname = "]"; break;
|
||||
case 222: keyname = "'"; break;
|
||||
default: if (code >= 96 && code <= 105) {
|
||||
keyname = (code - 96).toString();
|
||||
}
|
||||
else if (code >= 112 && code <= 123) {
|
||||
keyname = "f" + (code - 111);
|
||||
}
|
||||
else {
|
||||
keyname = String.fromCharCode(code).toLowerCase();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return keyname;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// maybeCallAfterAttach: dom-node -> void
|
||||
// walk the tree rooted at aNode, and call afterAttach if the element has
|
||||
// such a method.
|
||||
var maybeCallAfterAttach = function(aNode) {
|
||||
var stack = [aNode];
|
||||
while (stack.length !== 0) {
|
||||
var nextNode = stack.pop();
|
||||
if (nextNode.afterAttach) {
|
||||
nextNode.afterAttach(nextNode);
|
||||
}
|
||||
if (nextNode.hasChildNodes && nextNode.hasChildNodes()) {
|
||||
var children = nextNode.childNodes;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
stack.push(children[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// makeLocationDom: location -> dom
|
||||
// Dom type that has special support in the editor through the print hook.
|
||||
// The print hook is expected to look at the printing of dom values with
|
||||
// this particular structure. In the context of WeScheme, the environment
|
||||
// will rewrite these to be clickable links.
|
||||
var makeLocationDom = function(aLocation) {
|
||||
var locationSpan = document.createElement("span");
|
||||
var idSpan = document.createElement("span");
|
||||
var offsetSpan = document.createElement("span");
|
||||
var lineSpan = document.createElement("span");
|
||||
var columnSpan = document.createElement("span");
|
||||
var spanSpan = document.createElement("span");
|
||||
|
||||
locationSpan['className'] = 'location-reference';
|
||||
idSpan['className'] = 'location-id';
|
||||
offsetSpan['className'] = 'location-offset';
|
||||
lineSpan['className'] = 'location-line';
|
||||
columnSpan['className'] = 'location-column';
|
||||
spanSpan['className'] = 'location-span';
|
||||
|
||||
idSpan.appendChild(document.createTextNode(String(aLocation.id)));
|
||||
offsetSpan.appendChild(document.createTextNode(String(aLocation.offset)));
|
||||
lineSpan.appendChild(document.createTextNode(String(aLocation.line)));
|
||||
columnSpan.appendChild(document.createTextNode(String(aLocation.column)));
|
||||
spanSpan.appendChild(document.createTextNode(String(aLocation.span)));
|
||||
|
||||
locationSpan.appendChild(idSpan);
|
||||
locationSpan.appendChild(offsetSpan);
|
||||
locationSpan.appendChild(lineSpan);
|
||||
locationSpan.appendChild(columnSpan);
|
||||
locationSpan.appendChild(spanSpan);
|
||||
|
||||
return locationSpan;
|
||||
};
|
||||
|
||||
|
||||
var isLocationDom = function(thing) {
|
||||
return (thing
|
||||
&&
|
||||
(thing.nodeType === Node.TEXT_NODE ||
|
||||
thing.nodeType === Node.ELEMENT_NODE)
|
||||
&&
|
||||
thing['className'] === 'location-reference');
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Inheritance.
|
||||
var heir = function(parentPrototype) {
|
||||
var f = function() {}
|
||||
f.prototype = parentPrototype;
|
||||
return new f();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// clone: object -> object
|
||||
// Copies an object. The new object should respond like the old
|
||||
// object, including to things like instanceof
|
||||
var clone = function(obj) {
|
||||
var C = function() {}
|
||||
C.prototype = obj;
|
||||
var c = new C();
|
||||
for (property in obj) {
|
||||
if (obj.hasOwnProperty(property)) {
|
||||
c[property] = obj[property];
|
||||
}
|
||||
}
|
||||
return c;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
|
||||
helpers.forEachK = forEachK;
|
||||
helpers.reportError = reportError;
|
||||
helpers.raise = raise;
|
||||
|
||||
// helpers.throwCheckError = throwCheckError;
|
||||
helpers.isList = isList;
|
||||
helpers.isListOf = isListOf;
|
||||
// helpers.check = check;
|
||||
// helpers.checkListOf = checkListOf;
|
||||
|
||||
// helpers.remove = remove;
|
||||
helpers.map = map;
|
||||
helpers.concatMap = concatMap;
|
||||
helpers.schemeListToArray = schemeListToArray;
|
||||
helpers.deepListToArray = deepListToArray;
|
||||
helpers.flattenSchemeListToArray = flattenSchemeListToArray;
|
||||
|
||||
helpers.ordinalize = ordinalize;
|
||||
// helpers.wrapJsValue = wrapJsValue;
|
||||
|
||||
helpers.getKeyCodeName = getKeyCodeName;
|
||||
|
||||
helpers.maybeCallAfterAttach = maybeCallAfterAttach;
|
||||
|
||||
helpers.makeLocationDom = makeLocationDom;
|
||||
helpers.isLocationDom = isLocationDom;
|
||||
|
||||
|
||||
helpers.heir = heir;
|
||||
|
||||
|
||||
|
||||
helpers.clone = clone;
|
||||
|
||||
|
||||
scope.link.announceReady('helpers');
|
||||
})(this['plt']);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
File diff suppressed because it is too large
Load Diff
|
@ -1,573 +0,0 @@
|
|||
// The definitions of the basic types in Whalesong.
|
||||
//
|
||||
// Note: this originally came from js-vm, and as a result,
|
||||
// there's quite a lot of cruft and unused code in this module.
|
||||
// I need to filter and rip out the values that aren't used in Whalesong.
|
||||
|
||||
|
||||
if (! this['plt']) { this['plt'] = {}; }
|
||||
|
||||
// FIXME: there's a circularity between this module and helpers, and that circularly
|
||||
// should not be there!
|
||||
|
||||
|
||||
(function (scope) {
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
var types = {};
|
||||
scope['types'] = types;
|
||||
|
||||
|
||||
|
||||
|
||||
var getEqHashCode = plt.baselib.hashes.getEqHashCode;
|
||||
// makeLowLevelEqHash: -> hashtable
|
||||
// Constructs an eq hashtable that uses Moby's getEqHashCode function.
|
||||
var makeLowLevelEqHash = plt.baselib.hashes.makeLowLevelEqHash;
|
||||
var toWrittenString = plt.baselib.format.toWrittenString;
|
||||
var toDisplayedString = plt.baselib.format.toDisplayedString;
|
||||
var toDomNode = plt.baselib.format.toDomNode;
|
||||
|
||||
|
||||
|
||||
var appendChild = function(parent, child) {
|
||||
parent.appendChild(child);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
var Symbol = plt.baselib.symbols.Symbol;
|
||||
var Empty = plt.baselib.lists.Empty;
|
||||
var Cons = plt.baselib.lists.Cons;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var isNumber = jsnums.isSchemeNumber;
|
||||
|
||||
var isReal = jsnums.isReal;
|
||||
var isRational = jsnums.isRational;
|
||||
var isComplex = isNumber;
|
||||
var isInteger = jsnums.isInteger;
|
||||
|
||||
var isNatural = function(x) {
|
||||
return (jsnums.isExact(x) && isInteger(x)
|
||||
&& jsnums.greaterThanOrEqual(x, 0));
|
||||
};
|
||||
var isNonNegativeReal = function(x) {
|
||||
return isReal(x) && jsnums.greaterThanOrEqual(x, 0);
|
||||
};
|
||||
|
||||
var isString = plt.baselib.strings.isString;
|
||||
|
||||
var equals = plt.baselib.equality.equals;
|
||||
|
||||
// isList: Any -> Boolean
|
||||
// Returns true if x is a list (a chain of pairs terminated by EMPTY).
|
||||
var isList = function(x) {
|
||||
while (x !== Empty.EMPTY) {
|
||||
if (x instanceof Cons){
|
||||
x = x.rest;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
var makeList = function() {
|
||||
var result = Empty.EMPTY;
|
||||
for(var i = arguments.length-1; i >= 0; i--) {
|
||||
result = Cons.makeInstance(arguments[i], result);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
var makeVector = function() {
|
||||
return Vector.makeInstance(arguments.length, arguments);
|
||||
};
|
||||
|
||||
|
||||
var makeVectorImmutable = function() {
|
||||
var v = Vector.makeInstance(arguments.length, arguments);
|
||||
v.mutable = false;
|
||||
return v;
|
||||
};
|
||||
|
||||
|
||||
var makeString = function(s) {
|
||||
if (s instanceof plt.baselib.strings.Str) {
|
||||
return s;
|
||||
}
|
||||
else if (s instanceof Array) {
|
||||
// for (var i = 0; i < s.length; i++) {
|
||||
// if ( typeof s[i] !== 'string' || s[i].length != 1 ) {
|
||||
// return undefined;
|
||||
// }
|
||||
// }
|
||||
return plt.baselib.strings.Str.makeInstance(s);
|
||||
}
|
||||
else if (typeof s === 'string') {
|
||||
return plt.baselib.strings.Str.fromString(s);
|
||||
}
|
||||
else {
|
||||
throw types.internalError('makeString expects and array of 1-character strings or a string;' +
|
||||
' given ' + s.toString(),
|
||||
false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var makeHashEq = function(lst) {
|
||||
var newHash = new plt.baselib.hashes.EqHashTable();
|
||||
while ( !isEmpty(lst) ) {
|
||||
newHash.hash.put(lst.first.first, lst.first.rest);
|
||||
lst = lst.rest;
|
||||
}
|
||||
return newHash;
|
||||
};
|
||||
|
||||
|
||||
var makeHashEqual = function(lst) {
|
||||
var newHash = new plt.baselib.hashes.EqualHashTable();
|
||||
while ( !isEmpty(lst) ) {
|
||||
newHash.hash.put(lst.first.first, lst.first.rest);
|
||||
lst = lst.rest;
|
||||
}
|
||||
return newHash;
|
||||
};
|
||||
|
||||
|
||||
var Color = plt.baselib.structs.makeStructureType(
|
||||
'color', false, 3, 0, false, false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// var JsValue = function(name, val) {
|
||||
// this.name = name;
|
||||
// this.val = val;
|
||||
// };
|
||||
|
||||
// JsValue.prototype.toString = function() {
|
||||
// return '#<js-value:' + typeof(this.val) + ':' + this.name + '>';
|
||||
// };
|
||||
|
||||
// JsValue.prototype.toDomNode = function(cache) {
|
||||
// return toDomNode(this.val, cache);
|
||||
// };
|
||||
|
||||
// JsValue.prototype.equals = function(other, aUnionFind) {
|
||||
// return (this.val === other.val);
|
||||
// };
|
||||
|
||||
// // unbox: jsvalue -> any
|
||||
// // Unwraps the value out of the JsValue box.
|
||||
// JsValue.prototype.unbox = function() {
|
||||
// return this.val;
|
||||
// };
|
||||
|
||||
|
||||
|
||||
// var WrappedSchemeValue = function(val) {
|
||||
// this.val = val;
|
||||
// };
|
||||
|
||||
// WrappedSchemeValue.prototype.toString = function() { return toString(this.val); };
|
||||
// WrappedSchemeValue.prototype.toWrittenString = function(cache) { return toWrittenString(this.val, cache); };
|
||||
// WrappedSchemeValue.prototype.toDisplayedString = function(cache) { return toDisplayedString(this.val, cache); };
|
||||
|
||||
|
||||
// // unbox: jsvalue -> any
|
||||
// // Unwraps the value out of the WrappedSchemeValue box.
|
||||
// WrappedSchemeValue.prototype.unbox = function() {
|
||||
// return this.val;
|
||||
// };
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// var WorldConfig = function(startup, shutdown, startupArgs) {
|
||||
// this.startup = startup;
|
||||
// this.shutdown = shutdown;
|
||||
// this.startupArgs = startupArgs;
|
||||
// };
|
||||
|
||||
// WorldConfig.prototype.toString = function() {
|
||||
// return '#<world-config>';
|
||||
// };
|
||||
|
||||
// WorldConfig.prototype.equals = function(other, aUnionFind) {
|
||||
// return ( equals(this.startup, other.startup, aUnionFind) &&
|
||||
// equals(this.shutdown, other.shutdown, aUnionFind) &&
|
||||
// equals(this.shutdownArg, other.shutdownArg, aUnionFind) &&
|
||||
// equals(this.restartArg, other.restartArg, aUnionFind) );
|
||||
// };
|
||||
|
||||
|
||||
// var Effect = plt.baselib.structs.makeStructureType('effect', false, 0, 0, false, false);
|
||||
// Effect.type.prototype.invokeEffect = function() {
|
||||
// helpers.raise(types.incompleteExn(
|
||||
// types.exnFail,
|
||||
// 'effect type created without using make-effect-type',
|
||||
// []));
|
||||
// };
|
||||
|
||||
|
||||
// var makeEffectType = function(name, superType, initFieldCnt, impl, guard) {
|
||||
// if ( !superType ) {
|
||||
// superType = Effect;
|
||||
// }
|
||||
|
||||
// var newType = plt.baselib.structs.makeStructureType(name, superType, initFieldCnt, 0, false, guard);
|
||||
// var lastFieldIndex = newType.firstField + newType.numberOfFields;
|
||||
|
||||
// newType.type.prototype.invokeEffect = function(aBigBang, k) {
|
||||
// var schemeChangeWorld = new PrimProc('update-world', 1, false, false,
|
||||
// function(worldUpdater) {
|
||||
// //helpers.check(worldUpdater, helpers.procArityContains(1),
|
||||
// // 'update-world', 'procedure (arity 1)', 1);
|
||||
|
||||
// return new INTERNAL_PAUSE(
|
||||
// function(caller, onSuccess, onFail) {
|
||||
// aBigBang.changeWorld(function(w, k2) {
|
||||
// caller(worldUpdater,
|
||||
// [w], k2,
|
||||
// function(e) { throw e; },
|
||||
// 'change-world (effect)');
|
||||
// },
|
||||
// function() { onSuccess(VOID_VALUE, 'restarting (change-world (effect))'); });
|
||||
// });
|
||||
// });
|
||||
|
||||
// var args = this._fields.slice(0, lastFieldIndex);
|
||||
// args.unshift(schemeChangeWorld);
|
||||
// return aBigBang.caller(impl, args, k, function(e) { throw e; }, 'invoking effect ' + name);
|
||||
// }
|
||||
|
||||
// return newType;
|
||||
// };
|
||||
|
||||
|
||||
// var RenderEffect = plt.baselib.structs.makeStructureType('render-effect', false, 0, 0, false, false);
|
||||
// RenderEffect.type.prototype.callImplementation = function(caller, k) {
|
||||
// helpers.raise(types.incompleteExn(
|
||||
// types.exnFail,
|
||||
// 'render effect created without using make-render-effect-type',
|
||||
// []));
|
||||
// };
|
||||
|
||||
// var makeRenderEffectType = function(name, superType, initFieldCnt, impl, guard) {
|
||||
// if ( !superType ) {
|
||||
// superType = RenderEffect;
|
||||
// }
|
||||
|
||||
// var newType = plt.baselib.structs.makeStructureType(name, superType, initFieldCnt, 0, false, guard);
|
||||
// var lastFieldIndex = newType.firstField + newType.numberOfFields;
|
||||
|
||||
// newType.type.prototype.callImplementation = function(caller, k) {
|
||||
// var args = this._fields.slice(0, lastFieldIndex);
|
||||
// caller(impl, args, k);
|
||||
// }
|
||||
|
||||
// return newType;
|
||||
// };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// var makeOptionPrimitive = function(name,
|
||||
// numArgs,
|
||||
// defaultVals,
|
||||
// usesState,
|
||||
// bodyF) {
|
||||
// var makeNthPrimitive = function(n) {
|
||||
// return new PrimProc(name,
|
||||
// numArgs + n,
|
||||
// false,
|
||||
// usesState,
|
||||
// function() {
|
||||
// var expectedNumArgs = numArgs + n + (usesState ? 1 : 0);
|
||||
// assert.equal(arguments.length,
|
||||
// expectedNumArgs);
|
||||
// var args = [arguments];
|
||||
// for (var i = 0; i < arguments.length; i++) {
|
||||
// args.push(arguments[i]);
|
||||
// }
|
||||
// var startDefaults = i - numArgs - (usesState ? 1 : 0);
|
||||
// return bodyF.apply(
|
||||
// bodyF,
|
||||
// args.concat(defaultVals.slice(startDefaults)));
|
||||
// });
|
||||
// };
|
||||
|
||||
// var cases = [];
|
||||
// for (var i = 0; i <= defaultVals.length; i++) {
|
||||
// cases.push(makeNthPrimitive(i));
|
||||
// }
|
||||
// return new CasePrimitive(name, cases);
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// INTERNAL_CALL
|
||||
// used for interaction between the Primitives and the interpreter (callPrimitiveProcedure).
|
||||
// Don't confuse this with CallControl.
|
||||
// var INTERNAL_CALL = function(operator, operands, k) {
|
||||
// this.operator = operator;
|
||||
// this.operands = operands;
|
||||
// this.k = k;
|
||||
// };
|
||||
|
||||
// // INTERNAL_PAUSE
|
||||
// // used for interaction between the Primitive functions and the
|
||||
// // interpreter.
|
||||
// // Halts the interpreter, but passing onPause the functions necessary
|
||||
// // to restart computation.
|
||||
// var INTERNAL_PAUSE = function(onPause) {
|
||||
// this.onPause = onPause;
|
||||
// };
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// // ContinuationPromptTag: symbol | false -> ContinuationPromptTag
|
||||
// var ContinuationPromptTag = function(sym) {
|
||||
// this.sym = sym;
|
||||
// };
|
||||
|
||||
// var defaultContinuationPromptTag = new ContinuationPromptTag();
|
||||
|
||||
// var defaultContinuationPromptTagHandler = new PrimProc(
|
||||
// 'default-continuation-prompt-tag-handler',
|
||||
// 1,
|
||||
// false,
|
||||
// true,
|
||||
// function(aState, thunk) {
|
||||
// aState.pushControl(
|
||||
// new control.ApplicationControl(
|
||||
// new control.ConstantControl(thunk),
|
||||
// []));
|
||||
// });
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Exports
|
||||
|
||||
|
||||
|
||||
types.symbol = Symbol.makeInstance;
|
||||
types.rational = jsnums.makeRational;
|
||||
types.floatpoint = jsnums.makeFloat;
|
||||
types.complex = jsnums.makeComplex;
|
||||
types.bignum = jsnums.makeBignum;
|
||||
types.list = makeList;
|
||||
types.vector = makeVector;
|
||||
types.vectorImmutable = makeVectorImmutable;
|
||||
types.regexp = function(p) { return new plt.baselib.regexps.RegularExpression(p) ; }
|
||||
types.byteRegexp = function(p) { return new plt.baselib.regexps.ByteRegularExpression(p) ; }
|
||||
types.character = plt.baselib.chars.Char.makeInstance;
|
||||
types['string'] = makeString;
|
||||
types.placeholder = function(x) { return new plt.baselib.placeholders.Placeholder(x); };
|
||||
types.box = function(x) { return new plt.baselib.boxes.Box(x, true); };
|
||||
types.boxImmutable = function(x) { return new plt.baselib.boxes.Box(x, false); };
|
||||
types.path = function(x) { return new plt.baselib.paths.Path(x); };
|
||||
types.bytes = function(x, mutable) { return new plt.baselib.bytes.Bytes(x, mutable); };
|
||||
types.bytesImmutable = function(x) { return new plt.baselib.bytes.Bytes(x, false); };
|
||||
types.keyword = function(k) { return new plt.baselib.keywords.Keyword(k); };
|
||||
types.pair = function(x, y) { return plt.baselib.lists.Cons.makeInstance(x, y); };
|
||||
types.hash = makeHashEqual;
|
||||
types.hashEq = makeHashEq;
|
||||
// types.jsValue = function(name, val) { return new JsValue(name, val); };
|
||||
// types.wrappedSchemeValue = function(val) { return new WrappedSchemeValue(val); };
|
||||
|
||||
|
||||
types.color = Color.constructor;
|
||||
types.colorRed = function(x) { return Color.accessor(x, 0); };
|
||||
types.colorGreen = function(x) { return Color.accessor(x, 1); };
|
||||
types.colorBlue = function(x) { return Color.accessor(x, 2); };
|
||||
|
||||
|
||||
|
||||
types.FALSE = false;
|
||||
types.TRUE = true;
|
||||
types.EMPTY = Empty.EMPTY;
|
||||
|
||||
types.equals = equals;
|
||||
types.isNumber = isNumber;
|
||||
|
||||
types.isReal = jsnums.isReal;
|
||||
types.isRational = jsnums.isRational;
|
||||
types.isComplex = isNumber;
|
||||
types.isInteger = jsnums.isInteger;
|
||||
types.isNatural = isNatural;
|
||||
types.isNonNegativeReal = isNonNegativeReal;
|
||||
|
||||
|
||||
types.isSymbol = function(x) { return x instanceof Symbol; };
|
||||
types.isChar = function(x) { return x instanceof plt.baselib.chars.Char; };
|
||||
types.isString = isString;
|
||||
types.isPair = function(x) { return x instanceof Cons; };
|
||||
types.isList = isList;
|
||||
types.isEmpty = function(x) { return x === Empty.EMPTY; };
|
||||
types.isVector = function(x) { return x instanceof Vector; };
|
||||
types.isBox = function(x) { return x instanceof plt.baselib.boxes.Box; };
|
||||
types.isPlaceholder = function(x) { return x instanceof plt.baselib.placeholders.Placeholder; };
|
||||
types.isHash = function(x) { return (x instanceof plt.baselib.hashes.EqHashTable ||
|
||||
x instanceof plt.baselib.hashes.EqualHashTable); };
|
||||
types.isByteString = function(x) { return x instanceof plt.baselib.bytes.Bytes; };
|
||||
types.isStruct = function(x) { return x instanceof Struct; };
|
||||
types.isColor = Color.predicate;
|
||||
|
||||
// types.isFunction = function(x) {
|
||||
// return (x instanceof PrimProc);
|
||||
// };
|
||||
|
||||
|
||||
// types.isJsValue = function(x) { return x instanceof JsValue; };
|
||||
// types.isWrappedSchemeValue = function(x) { return x instanceof WrappedSchemeValue; };
|
||||
|
||||
types.cons = Cons.makeInstance;
|
||||
|
||||
types.VOID = plt.baselib.constants.VOID_VALUE;
|
||||
types.EOF = plt.baselib.constants.EOF_VALUE;
|
||||
|
||||
// types.ContinuationPromptTag = ContinuationPromptTag;
|
||||
// types.defaultContinuationPromptTag = defaultContinuationPromptTag;
|
||||
// types.defaultContinuationPromptTagHandler = defaultContinuationPromptTagHandler;
|
||||
// types.makeOptionPrimitive = makeOptionPrimitive;
|
||||
|
||||
// types.internalCall = function(op, args, k) { return new INTERNAL_CALL(op, args, k); };
|
||||
// types.isInternalCall = function(x) { return (x instanceof INTERNAL_CALL); };
|
||||
// types.internalPause = function(onPause) { return new INTERNAL_PAUSE(onPause) };
|
||||
// types.isInternalPause = function(x) { return (x instanceof INTERNAL_PAUSE); };
|
||||
|
||||
|
||||
types.continuationMarkSet = function(dict) { return new plt.baselib.contmarks.ContinuationMarkSet(dict); };
|
||||
types.isContinuationMarkSet = function(x) { return x instanceof plt.baselib.contmarks.ContinuationMarkSet; };
|
||||
// types.isContinuationPromptTag = function(x) { return x instanceof ContinuationPromptTag; };
|
||||
|
||||
|
||||
types.Box = plt.baselib.boxes.Box;
|
||||
types.Placeholder = plt.baselib.placeholders.Placeholder;
|
||||
|
||||
|
||||
|
||||
types.isStructType = function(x) { return x instanceof plt.baselib.structs.StructType; };
|
||||
|
||||
// types.StructProc = StructProc;
|
||||
// types.StructConstructorProc = StructConstructorProc;
|
||||
// types.StructPredicateProc = StructPredicateProc;
|
||||
// types.StructAccessorProc = StructAccessorProc;
|
||||
// types.StructMutatorProc = StructMutatorProc;
|
||||
|
||||
|
||||
|
||||
|
||||
types.makeLowLevelEqHash = makeLowLevelEqHash;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// World-specific exports
|
||||
|
||||
// // 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,
|
||||
// function(args, name, k) {
|
||||
// //helpers.check(args[0], helpers.procArityContains(1), name, 'procedure (arity 1)', 1);
|
||||
// //helpers.check(args[1], types.isJsValue, name, 'js-object', 2);
|
||||
// return k(args);
|
||||
// });
|
||||
// types.BigBangInfo = BigBangInfo;
|
||||
// types.makeBigBangInfo = BigBangInfo.constructor;
|
||||
// types.isBigBangInfo = BigBangInfo.predicate;
|
||||
// types.bbInfoChangeWorld = function(info) { return BigBangInfo.accessor(info, 0); };
|
||||
// types.bbInfoToplevelNode = function(info) { return BigBangInfo.accessor(info, 1); };
|
||||
|
||||
|
||||
|
||||
// World config information for user-defined configurations
|
||||
// types.worldConfig = function(startup, shutdown, pause, restart) { return new WorldConfig(startup, shutdown, pause, restart); };
|
||||
// types.isWorldConfig = function(x) { return x instanceof WorldConfig; };
|
||||
|
||||
|
||||
// exporting information to create effect types
|
||||
// types.makeEffectType = makeEffectType;
|
||||
// types.isEffectType = function(x) {
|
||||
// return ((x instanceof plt.baselib.structs.StructType)&& x.type.prototype.invokeEffect) ? true : false;
|
||||
// };
|
||||
|
||||
// types.isEffect = Effect.predicate;
|
||||
|
||||
|
||||
// exporting functions to create render effect types
|
||||
// types.makeRenderEffectType = makeRenderEffectType;
|
||||
// types.isRenderEffectType = function(x) {
|
||||
// return (x instanceof plt.baselib.structs.StructType && x.type.prototype.callImplementation) ? true : false;
|
||||
// };
|
||||
|
||||
// types.isRenderEffect = RenderEffect.predicate;
|
||||
|
||||
|
||||
|
||||
|
||||
scope.link.announceReady('types');
|
||||
})(this['plt']);
|
||||
|
Loading…
Reference in New Issue
Block a user