more jslinting

This commit is contained in:
Danny Yoo 2011-08-08 00:16:36 -04:00
parent e9b36e1bdd
commit 97e1ed7e38
5 changed files with 120 additions and 108 deletions

View File

@ -1,6 +1,7 @@
// Helper functions for argument checking.
(function(baselib) {
'use strict';
var exports = {};
baselib.check = exports;
@ -258,4 +259,4 @@
})(this['plt'].baselib);
}(this.plt.baselib));

View File

@ -1,25 +1,29 @@
/*jslint vars: true, maxerr: 50, indent: 4 */
// Other miscellaneous constants
(function(baselib) {
(function (baselib) {
'use strict';
var exports = {};
baselib.constants = exports;
var VoidValue = function() {};
VoidValue.prototype.toString = function() {
return "#<void>";
var VoidValue = function () {};
VoidValue.prototype.toString = function () {
return "#<void>";
};
var VOID_VALUE = new VoidValue();
var EofValue = function() {};
EofValue.prototype.toString = function() {
return "#<eof>";
}
var EofValue = function () {};
EofValue.prototype.toString = function () {
return "#<eof>";
};
var EOF_VALUE = new EofValue();
exports.VOID_VALUE = VOID_VALUE;
exports.EOF_VALUE = EOF_VALUE;
})(this['plt'].baselib);
}(this.plt.baselib));

View File

@ -1,12 +1,15 @@
/*jslint browser: true, unparam: true, vars: true, white: true, maxerr: 50, indent: 4 */
// Continuation marks
(function(baselib) {
'use strict';
var exports = {};
baselib.contmarks = exports;
var ContinuationMarkSet = function(dict) {
this.dict = dict;
}
};
ContinuationMarkSet.prototype.toDomNode = function(cache) {
var dom = document.createElement("span");
@ -45,4 +48,4 @@
exports.ContinuationMarkSet = ContinuationMarkSet;
exports.ContinuationPromptTag = ContinuationPromptTag;
})(this['plt'].baselib);
}(this.plt.baselib));

View File

@ -1,19 +1,24 @@
/*jslint vars: true, white: true, maxerr: 50, indent: 4 */
// Equality function
(function(baselib) {
/*global jsnums*/
(function (baselib) {
'use strict';
var exports = {};
baselib.equality = exports;
var eqv = function(x, y) {
var eqv = function (x, y) {
if (x === y) { return true; }
if (plt.baselib.numbers.isNumber(x) && plt.baselib.numbers.isNumber(y)) {
return jsnums.eqv(x, y);
} else if (plt.baselib.chars.isChar(x) && plt.baselib.chars.isChar(y)) {
return x.val === y.val;
} else {
return false;
if (baselib.numbers.isNumber(x) && baselib.numbers.isNumber(y)) {
return jsnums.eqv(x, y);
} else if (baselib.chars.isChar(x) && baselib.chars.isChar(y)) {
return x.val === y.val;
} else {
return false;
}
};
@ -22,42 +27,39 @@
// equals: X Y -> boolean
// 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 (plt.baselib.numbers.isNumber(x) && plt.baselib.numbers.isNumber(y)) {
return plt.baselib.numbers.eqv(x, y);
if (baselib.numbers.isNumber(x) && baselib.numbers.isNumber(y)) {
return baselib.numbers.eqv(x, 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) {
return (y == undefined || y == null);
if (x === undefined || x === null) {
return (y === undefined || y === null);
}
if ( typeof(x) == 'object' &&
typeof(y) == 'object' &&
x.equals &&
y.equals) {
if (typeof (x) === 'object' && typeof (y) === 'object' &&
x.equals && y.equals) {
if (typeof (aUnionFind) === 'undefined') {
aUnionFind = new baselib.UnionFind();
}
if (typeof (aUnionFind) === 'undefined') {
aUnionFind = new plt.baselib.UnionFind();
}
if (aUnionFind.find(x) === aUnionFind.find(y)) {
return true;
}
else {
aUnionFind.merge(x, y);
return x.equals(y, aUnionFind);
}
if (aUnionFind.find(x) === aUnionFind.find(y)) {
return true;
}
else {
aUnionFind.merge(x, y);
return x.equals(y, aUnionFind);
}
}
return false;
};
exports.eqv = eqv;
exports.equals = equals;
})(this['plt'].baselib);
}(this.plt.baselib));

View File

@ -1,6 +1,9 @@
/*jslint browser: true, undef: false, unparam: true, sub: true, vars: true, white: true, plusplus: true, maxerr: 50, indent: 4 */
// Exceptions
(function(baselib) {
'use strict';
var exceptions = {};
baselib.exceptions = exceptions;
@ -8,53 +11,53 @@
// Error type exports
var InternalError = function(val, contMarks) {
this.val = val;
this.contMarks = (contMarks ? contMarks : false);
}
this.val = val;
this.contMarks = contMarks || false;
};
var SchemeError = function(val) {
this.val = val;
}
this.val = val;
};
var IncompleteExn = function(constructor, msg, otherArgs) {
this.constructor = constructor;
this.msg = msg;
this.otherArgs = otherArgs;
this.constructor = constructor;
this.msg = msg;
this.otherArgs = otherArgs;
};
// (define-struct exn (message continuation-mark-set))
var Exn = plt.baselib.structs.makeStructureType(
var Exn = baselib.structs.makeStructureType(
'exn', false, 2, 0, false, false);
// (define-struct (exn:break exn) (continuation))
var ExnBreak = plt.baselib.structs.makeStructureType(
var ExnBreak = baselib.structs.makeStructureType(
'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);
var ExnFailContract = plt.baselib.structs.makeStructureType(
var ExnFailContract = baselib.structs.makeStructureType(
'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);
var ExnFailContractVariable = plt.baselib.structs.makeStructureType(
var ExnFailContractVariable = baselib.structs.makeStructureType(
'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);
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);
}
if (typeof(window['console']) !== 'undefined' &&
typeof(console['log']) === 'function') {
console.log(MACHINE);
if (e['stack']) { console.log(e['stack']); }
else { console.log(e); }
}
throw e;
if (typeof(window.console) !== 'undefined' &&
typeof(window.console['log']) === 'function') {
window.console.log(MACHINE);
if (e['stack']) { window.console.log(e['stack']); }
else { window.console.log(e); }
}
throw e;
};
@ -86,10 +89,10 @@
var raiseUnboundToplevelError = function(MACHINE, name) {
raise(MACHINE,
new Error(
plt.baselib.format.format(
"Not bound: ~a",
[name])));
new Error(
baselib.format.format(
"Not bound: ~a",
[name])));
};
@ -99,70 +102,69 @@
argumentOffset,
actualValue) {
if (argumentOffset !== undefined) {
raise(MACHINE,
raise(MACHINE,
new Error(
plt.baselib.format.format(
"~a: expected ~a as argument ~e but received ~e",
[callerName,
expectedTypeName,
(argumentOffset + 1),
actualValue])));
baselib.format.format(
"~a: expected ~a as argument ~e but received ~e",
[callerName,
expectedTypeName,
(argumentOffset + 1),
actualValue])));
} else {
raise(MACHINE,
raise(MACHINE,
new Error(
plt.baselib.format.format(
"~a: expected ~a but received ~e",
[callerName,
expectedTypeName,
actualValue])));
baselib.format.format(
"~a: expected ~a but received ~e",
[callerName,
expectedTypeName,
actualValue])));
}
};
var raiseContextExpectedValuesError = function(MACHINE, expected) {
raise(MACHINE,
new Error(plt.baselib.format.format(
"expected ~e values, received ~e values"
[expected,
MACHINE.argcount])));
raise(MACHINE,
new Error(baselib.format.format(
"expected ~e values, received ~e values",
[expected, MACHINE.argcount])));
};
var raiseArityMismatchError = function(MACHINE, proc, expected, received) {
raise(MACHINE,
new Error(plt.baselib.format.format(
"~a: expected ~e value(s), received ~e value(s)",
[proc.displayName,
expected ,
received])))
raise(MACHINE,
new Error(baselib.format.format(
"~a: expected ~e value(s), received ~e value(s)",
[proc.displayName,
expected,
received])));
};
var raiseOperatorApplicationError = function(MACHINE, operator) {
raise(MACHINE,
new Error(
plt.baselib.format.format(
"not a procedure: ~e",
[operator])));
raise(MACHINE,
new Error(
baselib.format.format(
"not a procedure: ~e",
[operator])));
};
var raiseOperatorIsNotClosure = function(MACHINE, operator) {
raise(MACHINE,
new Error(
plt.baselib.format.format(
"not a closure: ~e",
[operator])));
baselib.format.format(
"not a closure: ~e",
[operator])));
};
var raiseOperatorIsNotPrimitiveProcedure = function(MACHINE, operator) {
raise(MACHINE,
new Error(
plt.baselib.format.format(
"not a primitive procedure: ~e",
[operator])));
baselib.format.format(
"not a primitive procedure: ~e",
[operator])));
};
var raiseUnimplementedPrimitiveError = function(MACHINE, name) {
raise(MACHINE,
new Error("unimplemented kernel procedure: " + name))
raise(MACHINE,
new Error("unimplemented kernel procedure: " + name));
};
@ -245,4 +247,4 @@
exceptions.raiseUnimplementedPrimitiveError = raiseUnimplementedPrimitiveError;
})(this['plt'].baselib);
}(this.plt.baselib));