more jslinting
This commit is contained in:
parent
e9b36e1bdd
commit
97e1ed7e38
|
@ -1,6 +1,7 @@
|
||||||
// Helper functions for argument checking.
|
// Helper functions for argument checking.
|
||||||
|
|
||||||
(function(baselib) {
|
(function(baselib) {
|
||||||
|
'use strict';
|
||||||
var exports = {};
|
var exports = {};
|
||||||
baselib.check = exports;
|
baselib.check = exports;
|
||||||
|
|
||||||
|
@ -258,4 +259,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})(this['plt'].baselib);
|
}(this.plt.baselib));
|
||||||
|
|
|
@ -1,25 +1,29 @@
|
||||||
|
/*jslint vars: true, maxerr: 50, indent: 4 */
|
||||||
|
|
||||||
|
|
||||||
// Other miscellaneous constants
|
// Other miscellaneous constants
|
||||||
(function(baselib) {
|
(function (baselib) {
|
||||||
|
'use strict';
|
||||||
var exports = {};
|
var exports = {};
|
||||||
baselib.constants = exports;
|
baselib.constants = exports;
|
||||||
|
|
||||||
|
|
||||||
var VoidValue = function() {};
|
var VoidValue = function () {};
|
||||||
VoidValue.prototype.toString = function() {
|
VoidValue.prototype.toString = function () {
|
||||||
return "#<void>";
|
return "#<void>";
|
||||||
};
|
};
|
||||||
|
|
||||||
var VOID_VALUE = new VoidValue();
|
var VOID_VALUE = new VoidValue();
|
||||||
|
|
||||||
|
|
||||||
var EofValue = function() {};
|
var EofValue = function () {};
|
||||||
EofValue.prototype.toString = function() {
|
EofValue.prototype.toString = function () {
|
||||||
return "#<eof>";
|
return "#<eof>";
|
||||||
}
|
};
|
||||||
|
|
||||||
var EOF_VALUE = new EofValue();
|
var EOF_VALUE = new EofValue();
|
||||||
|
|
||||||
|
|
||||||
exports.VOID_VALUE = VOID_VALUE;
|
exports.VOID_VALUE = VOID_VALUE;
|
||||||
exports.EOF_VALUE = EOF_VALUE;
|
exports.EOF_VALUE = EOF_VALUE;
|
||||||
})(this['plt'].baselib);
|
}(this.plt.baselib));
|
|
@ -1,12 +1,15 @@
|
||||||
|
/*jslint browser: true, unparam: true, vars: true, white: true, maxerr: 50, indent: 4 */
|
||||||
|
|
||||||
// Continuation marks
|
// Continuation marks
|
||||||
(function(baselib) {
|
(function(baselib) {
|
||||||
|
'use strict';
|
||||||
var exports = {};
|
var exports = {};
|
||||||
baselib.contmarks = exports;
|
baselib.contmarks = exports;
|
||||||
|
|
||||||
|
|
||||||
var ContinuationMarkSet = function(dict) {
|
var ContinuationMarkSet = function(dict) {
|
||||||
this.dict = dict;
|
this.dict = dict;
|
||||||
}
|
};
|
||||||
|
|
||||||
ContinuationMarkSet.prototype.toDomNode = function(cache) {
|
ContinuationMarkSet.prototype.toDomNode = function(cache) {
|
||||||
var dom = document.createElement("span");
|
var dom = document.createElement("span");
|
||||||
|
@ -45,4 +48,4 @@
|
||||||
exports.ContinuationMarkSet = ContinuationMarkSet;
|
exports.ContinuationMarkSet = ContinuationMarkSet;
|
||||||
exports.ContinuationPromptTag = ContinuationPromptTag;
|
exports.ContinuationPromptTag = ContinuationPromptTag;
|
||||||
|
|
||||||
})(this['plt'].baselib);
|
}(this.plt.baselib));
|
|
@ -1,19 +1,24 @@
|
||||||
|
/*jslint vars: true, white: true, maxerr: 50, indent: 4 */
|
||||||
|
|
||||||
|
|
||||||
// Equality function
|
// Equality function
|
||||||
(function(baselib) {
|
/*global jsnums*/
|
||||||
|
(function (baselib) {
|
||||||
|
'use strict';
|
||||||
var exports = {};
|
var exports = {};
|
||||||
baselib.equality = exports;
|
baselib.equality = exports;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var eqv = function(x, y) {
|
var eqv = function (x, y) {
|
||||||
if (x === y) { return true; }
|
if (x === y) { return true; }
|
||||||
|
|
||||||
if (plt.baselib.numbers.isNumber(x) && plt.baselib.numbers.isNumber(y)) {
|
if (baselib.numbers.isNumber(x) && baselib.numbers.isNumber(y)) {
|
||||||
return jsnums.eqv(x, y);
|
return jsnums.eqv(x, y);
|
||||||
} else if (plt.baselib.chars.isChar(x) && plt.baselib.chars.isChar(y)) {
|
} else if (baselib.chars.isChar(x) && baselib.chars.isChar(y)) {
|
||||||
return x.val === y.val;
|
return x.val === y.val;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,42 +27,39 @@
|
||||||
|
|
||||||
// equals: X Y -> boolean
|
// equals: X Y -> boolean
|
||||||
// Returns true if the objects are equivalent; otherwise, returns false.
|
// Returns true if the objects are equivalent; otherwise, returns false.
|
||||||
var equals = function(x, y, aUnionFind) {
|
var equals = function (x, y, aUnionFind) {
|
||||||
if (x === y) { return true; }
|
if (x === y) { return true; }
|
||||||
|
|
||||||
if (plt.baselib.numbers.isNumber(x) && plt.baselib.numbers.isNumber(y)) {
|
if (baselib.numbers.isNumber(x) && baselib.numbers.isNumber(y)) {
|
||||||
return plt.baselib.numbers.eqv(x, y);
|
return baselib.numbers.eqv(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baselib.strings.isString(x) && baselib.strings.isString(y)) {
|
if (baselib.strings.isString(x) && baselib.strings.isString(y)) {
|
||||||
return x.toString() === y.toString();
|
return x.toString() === y.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x == undefined || x == null) {
|
if (x === undefined || x === null) {
|
||||||
return (y == undefined || y == null);
|
return (y === undefined || y === null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( typeof(x) == 'object' &&
|
if (typeof (x) === 'object' && typeof (y) === 'object' &&
|
||||||
typeof(y) == 'object' &&
|
x.equals && y.equals) {
|
||||||
x.equals &&
|
if (typeof (aUnionFind) === 'undefined') {
|
||||||
y.equals) {
|
aUnionFind = new baselib.UnionFind();
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof (aUnionFind) === 'undefined') {
|
if (aUnionFind.find(x) === aUnionFind.find(y)) {
|
||||||
aUnionFind = new plt.baselib.UnionFind();
|
return true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (aUnionFind.find(x) === aUnionFind.find(y)) {
|
aUnionFind.merge(x, y);
|
||||||
return true;
|
return x.equals(y, aUnionFind);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
aUnionFind.merge(x, y);
|
|
||||||
return x.equals(y, aUnionFind);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.eqv = eqv;
|
||||||
exports.equals = equals;
|
exports.equals = equals;
|
||||||
|
|
||||||
})(this['plt'].baselib);
|
}(this.plt.baselib));
|
|
@ -1,6 +1,9 @@
|
||||||
|
/*jslint browser: true, undef: false, unparam: true, sub: true, vars: true, white: true, plusplus: true, maxerr: 50, indent: 4 */
|
||||||
|
|
||||||
// Exceptions
|
// Exceptions
|
||||||
|
|
||||||
(function(baselib) {
|
(function(baselib) {
|
||||||
|
'use strict';
|
||||||
var exceptions = {};
|
var exceptions = {};
|
||||||
baselib.exceptions = exceptions;
|
baselib.exceptions = exceptions;
|
||||||
|
|
||||||
|
@ -8,53 +11,53 @@
|
||||||
|
|
||||||
// Error type exports
|
// Error type exports
|
||||||
var InternalError = function(val, contMarks) {
|
var InternalError = function(val, contMarks) {
|
||||||
this.val = val;
|
this.val = val;
|
||||||
this.contMarks = (contMarks ? contMarks : false);
|
this.contMarks = contMarks || false;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
var SchemeError = function(val) {
|
var SchemeError = function(val) {
|
||||||
this.val = val;
|
this.val = val;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
var IncompleteExn = function(constructor, msg, otherArgs) {
|
var IncompleteExn = function(constructor, msg, otherArgs) {
|
||||||
this.constructor = constructor;
|
this.constructor = constructor;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
this.otherArgs = otherArgs;
|
this.otherArgs = otherArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// (define-struct exn (message continuation-mark-set))
|
// (define-struct exn (message continuation-mark-set))
|
||||||
var Exn = plt.baselib.structs.makeStructureType(
|
var Exn = baselib.structs.makeStructureType(
|
||||||
'exn', false, 2, 0, false, false);
|
'exn', false, 2, 0, false, false);
|
||||||
|
|
||||||
|
|
||||||
// (define-struct (exn:break exn) (continuation))
|
// (define-struct (exn:break exn) (continuation))
|
||||||
var ExnBreak = plt.baselib.structs.makeStructureType(
|
var ExnBreak = baselib.structs.makeStructureType(
|
||||||
'exn:break', Exn, 1, 0, false, false);
|
'exn:break', Exn, 1, 0, false, false);
|
||||||
|
|
||||||
|
|
||||||
var ExnFail = plt.baselib.structs.makeStructureType(
|
var ExnFail = baselib.structs.makeStructureType(
|
||||||
'exn:fail', Exn, 0, 0, false, false);
|
'exn:fail', Exn, 0, 0, false, false);
|
||||||
|
|
||||||
var ExnFailContract = plt.baselib.structs.makeStructureType(
|
var ExnFailContract = baselib.structs.makeStructureType(
|
||||||
'exn:fail:contract', ExnFail, 0, 0, false, false);
|
'exn:fail:contract', ExnFail, 0, 0, false, false);
|
||||||
|
|
||||||
var ExnFailContractArity = plt.baselib.structs.makeStructureType(
|
var ExnFailContractArity = baselib.structs.makeStructureType(
|
||||||
'exn:fail:contract:arity', ExnFailContract, 0, 0, false, false);
|
'exn:fail:contract:arity', ExnFailContract, 0, 0, false, false);
|
||||||
|
|
||||||
var ExnFailContractVariable = plt.baselib.structs.makeStructureType(
|
var ExnFailContractVariable = baselib.structs.makeStructureType(
|
||||||
'exn:fail:contract:variable', ExnFailContract, 1, 0, false, false);
|
'exn:fail:contract:variable', ExnFailContract, 1, 0, false, false);
|
||||||
|
|
||||||
var ExnFailContractDivisionByZero = plt.baselib.structs.makeStructureType(
|
var ExnFailContractDivisionByZero = baselib.structs.makeStructureType(
|
||||||
'exn:fail:contract:divide-by-zero', ExnFailContract, 0, 0, false, false);
|
'exn:fail:contract:divide-by-zero', ExnFailContract, 0, 0, false, false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var exceptionHandlerKey = new plt.baselib.symbols.Symbol("exnh");
|
var exceptionHandlerKey = new baselib.symbols.Symbol("exnh");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,13 +75,13 @@
|
||||||
e.message = Exn.accessor(e, 0);
|
e.message = Exn.accessor(e, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(window['console']) !== 'undefined' &&
|
if (typeof(window.console) !== 'undefined' &&
|
||||||
typeof(console['log']) === 'function') {
|
typeof(window.console['log']) === 'function') {
|
||||||
console.log(MACHINE);
|
window.console.log(MACHINE);
|
||||||
if (e['stack']) { console.log(e['stack']); }
|
if (e['stack']) { window.console.log(e['stack']); }
|
||||||
else { console.log(e); }
|
else { window.console.log(e); }
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,10 +89,10 @@
|
||||||
|
|
||||||
var raiseUnboundToplevelError = function(MACHINE, name) {
|
var raiseUnboundToplevelError = function(MACHINE, name) {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error(
|
new Error(
|
||||||
plt.baselib.format.format(
|
baselib.format.format(
|
||||||
"Not bound: ~a",
|
"Not bound: ~a",
|
||||||
[name])));
|
[name])));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,70 +102,69 @@
|
||||||
argumentOffset,
|
argumentOffset,
|
||||||
actualValue) {
|
actualValue) {
|
||||||
if (argumentOffset !== undefined) {
|
if (argumentOffset !== undefined) {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error(
|
new Error(
|
||||||
plt.baselib.format.format(
|
baselib.format.format(
|
||||||
"~a: expected ~a as argument ~e but received ~e",
|
"~a: expected ~a as argument ~e but received ~e",
|
||||||
[callerName,
|
[callerName,
|
||||||
expectedTypeName,
|
expectedTypeName,
|
||||||
(argumentOffset + 1),
|
(argumentOffset + 1),
|
||||||
actualValue])));
|
actualValue])));
|
||||||
} else {
|
} else {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error(
|
new Error(
|
||||||
plt.baselib.format.format(
|
baselib.format.format(
|
||||||
"~a: expected ~a but received ~e",
|
"~a: expected ~a but received ~e",
|
||||||
[callerName,
|
[callerName,
|
||||||
expectedTypeName,
|
expectedTypeName,
|
||||||
actualValue])));
|
actualValue])));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var raiseContextExpectedValuesError = function(MACHINE, expected) {
|
var raiseContextExpectedValuesError = function(MACHINE, expected) {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error(plt.baselib.format.format(
|
new Error(baselib.format.format(
|
||||||
"expected ~e values, received ~e values"
|
"expected ~e values, received ~e values",
|
||||||
[expected,
|
[expected, MACHINE.argcount])));
|
||||||
MACHINE.argcount])));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var raiseArityMismatchError = function(MACHINE, proc, expected, received) {
|
var raiseArityMismatchError = function(MACHINE, proc, expected, received) {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error(plt.baselib.format.format(
|
new Error(baselib.format.format(
|
||||||
"~a: expected ~e value(s), received ~e value(s)",
|
"~a: expected ~e value(s), received ~e value(s)",
|
||||||
[proc.displayName,
|
[proc.displayName,
|
||||||
expected ,
|
expected,
|
||||||
received])))
|
received])));
|
||||||
};
|
};
|
||||||
|
|
||||||
var raiseOperatorApplicationError = function(MACHINE, operator) {
|
var raiseOperatorApplicationError = function(MACHINE, operator) {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error(
|
new Error(
|
||||||
plt.baselib.format.format(
|
baselib.format.format(
|
||||||
"not a procedure: ~e",
|
"not a procedure: ~e",
|
||||||
[operator])));
|
[operator])));
|
||||||
};
|
};
|
||||||
|
|
||||||
var raiseOperatorIsNotClosure = function(MACHINE, operator) {
|
var raiseOperatorIsNotClosure = function(MACHINE, operator) {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error(
|
new Error(
|
||||||
plt.baselib.format.format(
|
baselib.format.format(
|
||||||
"not a closure: ~e",
|
"not a closure: ~e",
|
||||||
[operator])));
|
[operator])));
|
||||||
};
|
};
|
||||||
|
|
||||||
var raiseOperatorIsNotPrimitiveProcedure = function(MACHINE, operator) {
|
var raiseOperatorIsNotPrimitiveProcedure = function(MACHINE, operator) {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error(
|
new Error(
|
||||||
plt.baselib.format.format(
|
baselib.format.format(
|
||||||
"not a primitive procedure: ~e",
|
"not a primitive procedure: ~e",
|
||||||
[operator])));
|
[operator])));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var raiseUnimplementedPrimitiveError = function(MACHINE, name) {
|
var raiseUnimplementedPrimitiveError = function(MACHINE, name) {
|
||||||
raise(MACHINE,
|
raise(MACHINE,
|
||||||
new Error("unimplemented kernel procedure: " + name))
|
new Error("unimplemented kernel procedure: " + name));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -245,4 +247,4 @@
|
||||||
exceptions.raiseUnimplementedPrimitiveError = raiseUnimplementedPrimitiveError;
|
exceptions.raiseUnimplementedPrimitiveError = raiseUnimplementedPrimitiveError;
|
||||||
|
|
||||||
|
|
||||||
})(this['plt'].baselib);
|
}(this.plt.baselib));
|
Loading…
Reference in New Issue
Block a user