contining to factor out functionality
This commit is contained in:
parent
190b805b6c
commit
7a0c6381db
|
@ -37,6 +37,8 @@
|
||||||
(define-runtime-path baselib.js "runtime-src/baselib.js")
|
(define-runtime-path baselib.js "runtime-src/baselib.js")
|
||||||
(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_equality.js "runtime-src/baselib_equality.js")
|
(define-runtime-path baselib_equality.js "runtime-src/baselib_equality.js")
|
||||||
|
(define-runtime-path baselib_lists.js "runtime-src/baselib_lists.js")
|
||||||
|
(define-runtime-path baselib_vectors.js "runtime-src/baselib_vectors.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_symbol.js "runtime-src/baselib_symbol.js")
|
(define-runtime-path baselib_symbol.js "runtime-src/baselib_symbol.js")
|
||||||
(define-runtime-path baselib_structs.js "runtime-src/baselib_structs.js")
|
(define-runtime-path baselib_structs.js "runtime-src/baselib_structs.js")
|
||||||
|
@ -79,16 +81,20 @@
|
||||||
baselib.js
|
baselib.js
|
||||||
baselib_unionfind.js
|
baselib_unionfind.js
|
||||||
baselib_equality.js
|
baselib_equality.js
|
||||||
baselib_hash.js
|
|
||||||
baselib_format.js
|
baselib_format.js
|
||||||
|
|
||||||
|
baselib_lists.js
|
||||||
|
baselib_vectors.js
|
||||||
|
baselib_chars.js
|
||||||
baselib_symbol.js
|
baselib_symbol.js
|
||||||
|
baselib_strings.js
|
||||||
|
baselib_bytes.js
|
||||||
|
baselib_hash.js
|
||||||
|
|
||||||
baselib_structs.js
|
baselib_structs.js
|
||||||
baselib_arity.js
|
baselib_arity.js
|
||||||
baselib_inspectors.js
|
baselib_inspectors.js
|
||||||
baselib_exceptions.js
|
baselib_exceptions.js
|
||||||
baselib_chars.js
|
|
||||||
baselib_strings.js
|
|
||||||
baselib_bytes.js
|
|
||||||
baselib_readergraph.js
|
baselib_readergraph.js
|
||||||
|
|
||||||
link.js
|
link.js
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
} else if (isArityAtLeast(arity)) {
|
} else if (isArityAtLeast(arity)) {
|
||||||
return n >= arityAtLeastValue(arity);
|
return n >= arityAtLeastValue(arity);
|
||||||
} else {
|
} else {
|
||||||
while (arity !== plt.types.EMPTY) {
|
while (arity !== plt.baselib.lists.EMPTY) {
|
||||||
if (typeof(arity.first) === 'number') {
|
if (typeof(arity.first) === 'number') {
|
||||||
if (arity.first === n) { return true; }
|
if (arity.first === n) { return true; }
|
||||||
} else if (isArityAtLeast(arity)) {
|
} else if (isArityAtLeast(arity)) {
|
||||||
|
|
159
js-assembler/runtime-src/baselib_lists.js
Normal file
159
js-assembler/runtime-src/baselib_lists.js
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
// list structures (pairs, empty)
|
||||||
|
(function(baselib) {
|
||||||
|
var exports = {};
|
||||||
|
baselib.lists = exports;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Empty = function() {
|
||||||
|
};
|
||||||
|
Empty.EMPTY = new Empty();
|
||||||
|
|
||||||
|
|
||||||
|
Empty.prototype.equals = function(other, aUnionFind) {
|
||||||
|
return other instanceof Empty;
|
||||||
|
};
|
||||||
|
|
||||||
|
Empty.prototype.reverse = function() {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
Empty.prototype.toWrittenString = function(cache) { return "empty"; };
|
||||||
|
Empty.prototype.toDisplayedString = function(cache) { return "empty"; };
|
||||||
|
Empty.prototype.toString = function(cache) { return "()"; };
|
||||||
|
|
||||||
|
|
||||||
|
// Empty.append: (listof X) -> (listof X)
|
||||||
|
Empty.prototype.append = function(b){
|
||||||
|
return b;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Cons Pairs
|
||||||
|
|
||||||
|
var Cons = function(f, r) {
|
||||||
|
this.first = f;
|
||||||
|
this.rest = r;
|
||||||
|
};
|
||||||
|
|
||||||
|
Cons.prototype.reverse = function() {
|
||||||
|
var lst = this;
|
||||||
|
var ret = Empty.EMPTY;
|
||||||
|
while (!isEmpty(lst)){
|
||||||
|
ret = Cons.makeInstance(lst.first, ret);
|
||||||
|
lst = lst.rest;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
Cons.makeInstance = function(f, r) {
|
||||||
|
return new Cons(f, r);
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: can we reduce the recursion on this?
|
||||||
|
Cons.prototype.equals = function(other, aUnionFind) {
|
||||||
|
if (! (other instanceof Cons)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (plt.baselib.equality.equals(this.first, other.first, aUnionFind) &&
|
||||||
|
plt.baselib.equality.equals(this.rest, other.rest, aUnionFind));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Cons.append: (listof X) -> (listof X)
|
||||||
|
Cons.prototype.append = function(b){
|
||||||
|
if (b === Empty.EMPTY)
|
||||||
|
return this;
|
||||||
|
var ret = b;
|
||||||
|
var lst = this.reverse();
|
||||||
|
while ( !isEmpty(lst) ) {
|
||||||
|
ret = Cons.makeInstance(lst.first, ret);
|
||||||
|
lst = lst.rest;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Cons.prototype.toWrittenString = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
var texts = [];
|
||||||
|
var p = this;
|
||||||
|
while ( p instanceof Cons ) {
|
||||||
|
texts.push(plt.baselib.format.toWrittenString(p.first, cache));
|
||||||
|
p = p.rest;
|
||||||
|
if (typeof(p) === 'object' && cache.containsKey(p)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( p !== Empty.EMPTY ) {
|
||||||
|
texts.push('.');
|
||||||
|
texts.push(plt.baselib.format.toWrittenString(p, cache));
|
||||||
|
}
|
||||||
|
return "(" + texts.join(" ") + ")";
|
||||||
|
};
|
||||||
|
|
||||||
|
Cons.prototype.toString = Cons.prototype.toWrittenString;
|
||||||
|
|
||||||
|
Cons.prototype.toDisplayedString = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
var texts = [];
|
||||||
|
var p = this;
|
||||||
|
while ( p instanceof Cons ) {
|
||||||
|
texts.push(plt.baselib.format.toDisplayedString(p.first, cache));
|
||||||
|
p = p.rest;
|
||||||
|
if (typeof(p) === 'object' && cache.containsKey(p)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( p !== Empty.EMPTY ) {
|
||||||
|
texts.push('.');
|
||||||
|
texts.push(plt.baselib.format.toDisplayedString(p, cache));
|
||||||
|
}
|
||||||
|
return "(" + texts.join(" ") + ")";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Cons.prototype.toDomNode = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
var node = document.createElement("span");
|
||||||
|
node.appendChild(document.createTextNode("("));
|
||||||
|
var p = this;
|
||||||
|
while ( p instanceof Cons ) {
|
||||||
|
appendChild(node, plt.baselib.format.toDomNode(p.first, cache));
|
||||||
|
p = p.rest;
|
||||||
|
if ( p !== Empty.EMPTY ) {
|
||||||
|
appendChild(node, document.createTextNode(" "));
|
||||||
|
}
|
||||||
|
if (typeof(p) === 'object' && cache.containsKey(p)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( p !== Empty.EMPTY ) {
|
||||||
|
appendChild(node, document.createTextNode("."));
|
||||||
|
appendChild(node, document.createTextNode(" "));
|
||||||
|
appendChild(node, plt.baselib.format.toDomNode(p, cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
node.appendChild(document.createTextNode(")"));
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.EMPTY = Empty.EMPTY;
|
||||||
|
exports.Empty = Empty;
|
||||||
|
exports.Cons = Cons;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})(this['plt'].baselib);
|
99
js-assembler/runtime-src/baselib_vectors.js
Normal file
99
js-assembler/runtime-src/baselib_vectors.js
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
// vectors
|
||||||
|
(function(baselib) {
|
||||||
|
var exports = {};
|
||||||
|
baselib.vectors = exports;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Vector = function(n, initialElements) {
|
||||||
|
this.elts = new Array(n);
|
||||||
|
if (initialElements) {
|
||||||
|
for (var i = 0; i < n; i++) {
|
||||||
|
this.elts[i] = initialElements[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < n; i++) {
|
||||||
|
this.elts[i] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.mutable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector.makeInstance = function(n, elts) {
|
||||||
|
return new Vector(n, elts);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector.prototype.length = function() {
|
||||||
|
return this.elts.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector.prototype.ref = function(k) {
|
||||||
|
return this.elts[k];
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector.prototype.set = function(k, v) {
|
||||||
|
this.elts[k] = v;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector.prototype.equals = function(other, aUnionFind) {
|
||||||
|
if (other != null && other != undefined && other instanceof Vector) {
|
||||||
|
if (other.length() != this.length()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for (var i = 0; i < this.length(); i++) {
|
||||||
|
if (! plt.baselib.equality.equals(this.elts[i], other.elts[i], aUnionFind)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector.prototype.toList = function() {
|
||||||
|
var ret = plt.baselib.lists.EMPTY;
|
||||||
|
for (var i = this.length() - 1; i >= 0; i--) {
|
||||||
|
ret = plt.baselib.lists.Cons.makeInstance(this.elts[i], ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector.prototype.toWrittenString = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
var texts = [];
|
||||||
|
for (var i = 0; i < this.length(); i++) {
|
||||||
|
texts.push(plt.baselib.format.toWrittenString(this.ref(i), cache));
|
||||||
|
}
|
||||||
|
return "#(" + texts.join(" ") + ")";
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector.prototype.toDisplayedString = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
var texts = [];
|
||||||
|
for (var i = 0; i < this.length(); i++) {
|
||||||
|
texts.push(plt.baselib.format.toDisplayedString(this.ref(i), cache));
|
||||||
|
}
|
||||||
|
return "#(" + texts.join(" ") + ")";
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector.prototype.toDomNode = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
var node = document.createElement("span");
|
||||||
|
node.appendChild(document.createTextNode("#("));
|
||||||
|
for (var i = 0; i < this.length(); i++) {
|
||||||
|
appendChild(node,
|
||||||
|
plt.baselib.format.toDomNode(this.ref(i), cache));
|
||||||
|
if (i !== this.length()-1) {
|
||||||
|
appendChild(node, document.createTextNode(" "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node.appendChild(document.createTextNode(")"));
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.Vector = Vector;
|
||||||
|
|
||||||
|
})(this['plt'].baselib);
|
|
@ -39,6 +39,8 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
|
|
||||||
|
|
||||||
var Symbol = plt.baselib.Symbol;
|
var Symbol = plt.baselib.Symbol;
|
||||||
|
var Empty = plt.baselib.lists.Empty;
|
||||||
|
var Cons = plt.baselib.lists.Cons;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -238,150 +240,6 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Empty = function() {
|
|
||||||
};
|
|
||||||
Empty.EMPTY = new Empty();
|
|
||||||
|
|
||||||
|
|
||||||
Empty.prototype.equals = function(other, aUnionFind) {
|
|
||||||
return other instanceof Empty;
|
|
||||||
};
|
|
||||||
|
|
||||||
Empty.prototype.reverse = function() {
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
Empty.prototype.toWrittenString = function(cache) { return "empty"; };
|
|
||||||
Empty.prototype.toDisplayedString = function(cache) { return "empty"; };
|
|
||||||
Empty.prototype.toString = function(cache) { return "()"; };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Empty.append: (listof X) -> (listof X)
|
|
||||||
Empty.prototype.append = function(b){
|
|
||||||
return b;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Cons Pairs
|
|
||||||
|
|
||||||
var Cons = function(f, r) {
|
|
||||||
this.first = f;
|
|
||||||
this.rest = r;
|
|
||||||
};
|
|
||||||
|
|
||||||
Cons.prototype.reverse = function() {
|
|
||||||
var lst = this;
|
|
||||||
var ret = Empty.EMPTY;
|
|
||||||
while (!isEmpty(lst)){
|
|
||||||
ret = Cons.makeInstance(lst.first, ret);
|
|
||||||
lst = lst.rest;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Cons.makeInstance = function(f, r) {
|
|
||||||
return new Cons(f, r);
|
|
||||||
};
|
|
||||||
|
|
||||||
// FIXME: can we reduce the recursion on this?
|
|
||||||
Cons.prototype.equals = function(other, aUnionFind) {
|
|
||||||
if (! (other instanceof Cons)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (equals(this.first, other.first, aUnionFind) &&
|
|
||||||
equals(this.rest, other.rest, aUnionFind));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Cons.append: (listof X) -> (listof X)
|
|
||||||
Cons.prototype.append = function(b){
|
|
||||||
if (b === Empty.EMPTY)
|
|
||||||
return this;
|
|
||||||
var ret = b;
|
|
||||||
var lst = this.reverse();
|
|
||||||
while ( !isEmpty(lst) ) {
|
|
||||||
ret = Cons.makeInstance(lst.first, ret);
|
|
||||||
lst = lst.rest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Cons.prototype.toWrittenString = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
var texts = [];
|
|
||||||
var p = this;
|
|
||||||
while ( p instanceof Cons ) {
|
|
||||||
texts.push(toWrittenString(p.first, cache));
|
|
||||||
p = p.rest;
|
|
||||||
if (typeof(p) === 'object' && cache.containsKey(p)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( p !== Empty.EMPTY ) {
|
|
||||||
texts.push('.');
|
|
||||||
texts.push(toWrittenString(p, cache));
|
|
||||||
}
|
|
||||||
return "(" + texts.join(" ") + ")";
|
|
||||||
};
|
|
||||||
|
|
||||||
Cons.prototype.toString = Cons.prototype.toWrittenString;
|
|
||||||
|
|
||||||
Cons.prototype.toDisplayedString = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
var texts = [];
|
|
||||||
var p = this;
|
|
||||||
while ( p instanceof Cons ) {
|
|
||||||
texts.push(toDisplayedString(p.first, cache));
|
|
||||||
p = p.rest;
|
|
||||||
if (typeof(p) === 'object' && cache.containsKey(p)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( p !== Empty.EMPTY ) {
|
|
||||||
texts.push('.');
|
|
||||||
texts.push(toDisplayedString(p, cache));
|
|
||||||
}
|
|
||||||
return "(" + texts.join(" ") + ")";
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Cons.prototype.toDomNode = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
var node = document.createElement("span");
|
|
||||||
node.appendChild(document.createTextNode("("));
|
|
||||||
var p = this;
|
|
||||||
while ( p instanceof Cons ) {
|
|
||||||
appendChild(node, toDomNode(p.first, cache));
|
|
||||||
p = p.rest;
|
|
||||||
if ( p !== Empty.EMPTY ) {
|
|
||||||
appendChild(node, document.createTextNode(" "));
|
|
||||||
}
|
|
||||||
if (typeof(p) === 'object' && cache.containsKey(p)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( p !== Empty.EMPTY ) {
|
|
||||||
appendChild(node, document.createTextNode("."));
|
|
||||||
appendChild(node, document.createTextNode(" "));
|
|
||||||
appendChild(node, toDomNode(p, cache));
|
|
||||||
}
|
|
||||||
|
|
||||||
node.appendChild(document.createTextNode(")"));
|
|
||||||
return node;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// isList: Any -> Boolean
|
// isList: Any -> Boolean
|
||||||
// Returns true if x is a list (a chain of pairs terminated by EMPTY).
|
// Returns true if x is a list (a chain of pairs terminated by EMPTY).
|
||||||
var isList = function(x) {
|
var isList = function(x) {
|
||||||
|
@ -400,89 +258,6 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Vector = function(n, initialElements) {
|
|
||||||
this.elts = new Array(n);
|
|
||||||
if (initialElements) {
|
|
||||||
for (var i = 0; i < n; i++) {
|
|
||||||
this.elts[i] = initialElements[i];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var i = 0; i < n; i++) {
|
|
||||||
this.elts[i] = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.mutable = true;
|
|
||||||
};
|
|
||||||
Vector.makeInstance = function(n, elts) {
|
|
||||||
return new Vector(n, elts);
|
|
||||||
}
|
|
||||||
Vector.prototype.length = function() {
|
|
||||||
return this.elts.length;
|
|
||||||
};
|
|
||||||
Vector.prototype.ref = function(k) {
|
|
||||||
return this.elts[k];
|
|
||||||
};
|
|
||||||
Vector.prototype.set = function(k, v) {
|
|
||||||
this.elts[k] = v;
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector.prototype.equals = function(other, aUnionFind) {
|
|
||||||
if (other != null && other != undefined && other instanceof Vector) {
|
|
||||||
if (other.length() != this.length()) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for (var i = 0; i < this.length(); i++) {
|
|
||||||
if (! equals(this.elts[i], other.elts[i], aUnionFind)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector.prototype.toList = function() {
|
|
||||||
var ret = Empty.EMPTY;
|
|
||||||
for (var i = this.length() - 1; i >= 0; i--) {
|
|
||||||
ret = Cons.makeInstance(this.elts[i], ret);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector.prototype.toWrittenString = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
var texts = [];
|
|
||||||
for (var i = 0; i < this.length(); i++) {
|
|
||||||
texts.push(toWrittenString(this.ref(i), cache));
|
|
||||||
}
|
|
||||||
return "#(" + texts.join(" ") + ")";
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector.prototype.toDisplayedString = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
var texts = [];
|
|
||||||
for (var i = 0; i < this.length(); i++) {
|
|
||||||
texts.push(toDisplayedString(this.ref(i), cache));
|
|
||||||
}
|
|
||||||
return "#(" + texts.join(" ") + ")";
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector.prototype.toDomNode = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
var node = document.createElement("span");
|
|
||||||
node.appendChild(document.createTextNode("#("));
|
|
||||||
for (var i = 0; i < this.length(); i++) {
|
|
||||||
appendChild(node,
|
|
||||||
toDomNode(this.ref(i), cache));
|
|
||||||
if (i !== this.length()-1) {
|
|
||||||
appendChild(node, document.createTextNode(" "));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node.appendChild(document.createTextNode(")"));
|
|
||||||
return node;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -1003,7 +778,7 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
types.bytes = function(x, mutable) { return new plt.baselib.bytes.Bytes(x, mutable); };
|
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.bytesImmutable = function(x) { return new plt.baselib.bytes.Bytes(x, false); };
|
||||||
types.keyword = function(k) { return new Keyword(k); };
|
types.keyword = function(k) { return new Keyword(k); };
|
||||||
types.pair = function(x, y) { return Cons.makeInstance(x, y); };
|
types.pair = function(x, y) { return plt.baselib.lists.Cons.makeInstance(x, y); };
|
||||||
types.hash = makeHashEqual;
|
types.hash = makeHashEqual;
|
||||||
types.hashEq = makeHashEq;
|
types.hashEq = makeHashEq;
|
||||||
// types.jsValue = function(name, val) { return new JsValue(name, val); };
|
// types.jsValue = function(name, val) { return new JsValue(name, val); };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user