jslinted the readergraph library

This commit is contained in:
Danny Yoo 2011-08-07 22:08:18 -04:00
parent a3a74e7bba
commit d23d17a0a0
2 changed files with 44 additions and 39 deletions

View File

@ -1,54 +1,56 @@
// Arity structure
(function(baselib) {
(function (baselib) {
'use strict';
var exports = {};
baselib.readergraph = exports;
var readerGraph = function(x, objectHash, n) {
if (typeof(x) === 'object' && objectHash.containsKey(x)) {
return objectHash.get(x);
var readerGraph = function (x, objectHash, n) {
var i;
if (typeof (x) === 'object' && objectHash.containsKey(x)) {
return objectHash.get(x);
}
if (plt.baselib.lists.isPair(x)) {
var consPair = plt.baselib.lists.makePair(x.first, x.rest);
objectHash.put(x, consPair);
consPair.first = readerGraph(x.first, objectHash, n+1);
consPair.rest = readerGraph(x.rest, objectHash, n+1);
return consPair;
if (baselib.lists.isPair(x)) {
var consPair = baselib.lists.makePair(x.first, x.rest);
objectHash.put(x, consPair);
consPair.first = readerGraph(x.first, objectHash, n + 1);
consPair.rest = readerGraph(x.rest, objectHash, n + 1);
return consPair;
}
if (plt.baselib.vectors.isVector(x)) {
var len = x.length();
var aVector = plt.baselib.vectors.makeVector(len, x.elts);
objectHash.put(x, aVector);
for (var i = 0; i < len; i++) {
aVector.elts[i] = readerGraph(aVector.elts[i], objectHash, n+1);
}
return aVector;
if (baselib.vectors.isVector(x)) {
var len = x.length();
var aVector = baselib.vectors.makeVector(len, x.elts);
objectHash.put(x, aVector);
for (i = 0; i < len; i++) {
aVector.elts[i] = readerGraph(aVector.elts[i], objectHash, n + 1);
}
return aVector;
}
if (plt.baselib.boxes.isBox(x)) {
var aBox = plt.baselib.boxes.makeBox(x.ref());
objectHash.put(x, aBox);
aBox.val = readerGraph(x.ref(), objectHash, n+1);
return aBox;
if (baselib.boxes.isBox(x)) {
var aBox = baselib.boxes.makeBox(x.ref());
objectHash.put(x, aBox);
aBox.val = readerGraph(x.ref(), objectHash, n + 1);
return aBox;
}
if (plt.baselib.hashes.isHash(x)) {
throw new Error("make-reader-graph of hash not implemented yet");
if (baselib.hashes.isHash(x)) {
throw new Error("make-reader-graph of hash not implemented yet");
}
if (plt.baselib.structs.isStruct(x)) {
var aStruct = baselib.clone(x);
objectHash.put(x, aStruct);
for(var i = 0 ;i < x._fields.length; i++) {
x._fields[i] = readerGraph(x._fields[i], objectHash, n+1);
}
return aStruct;
if (baselib.structs.isStruct(x)) {
var aStruct = baselib.clone(x);
objectHash.put(x, aStruct);
for (i = 0; i < x._fields.length; i++) {
x._fields[i] = readerGraph(x._fields[i], objectHash, n + 1);
}
return aStruct;
}
if (plt.baselib.placeholders.isPlaceholder(x)) {
return readerGraph(x.ref(), objectHash, n+1);
if (baselib.placeholders.isPlaceholder(x)) {
return readerGraph(x.ref(), objectHash, n + 1);
}
return x;
@ -56,4 +58,4 @@
exports.readerGraph = readerGraph;
})(this['plt'].baselib);
}(this.plt.baselib));

View File

@ -1,16 +1,19 @@
(function(baselib) {
/*jslint vars: true, maxerr: 50, indent: 4 */
(function (baselib) {
'use strict';
var exports = {};
baselib.regexps = exports;
// Regular expressions.
var RegularExpression = function(pattern) {
var RegularExpression = function (pattern) {
this.pattern = pattern;
};
var ByteRegularExpression = function(pattern) {
var ByteRegularExpression = function (pattern) {
this.pattern = pattern;
};
@ -19,4 +22,4 @@
exports.RegularExpression = RegularExpression;
exports.ByteRegularExpression = ByteRegularExpression;
})(this['plt'].baselib);
}(this.plt.baselib));