lifting out more types
This commit is contained in:
parent
1bb1b70192
commit
bc8546bae0
|
@ -22,85 +22,49 @@
|
||||||
|
|
||||||
(provide/contract [get-runtime (-> string?)])
|
(provide/contract [get-runtime (-> string?)])
|
||||||
|
|
||||||
;; jquery is special: we need to make sure it's resilient against
|
|
||||||
;; multiple invokation and inclusion.
|
|
||||||
(define-runtime-path jquery-protect-header.js "runtime-src/jquery-protect-header.js")
|
|
||||||
(define-runtime-path jquery.js "runtime-src/jquery.js")
|
|
||||||
(define-runtime-path jquery-protect-footer.js "runtime-src/jquery-protect-footer.js")
|
|
||||||
|
|
||||||
|
(define-runtime-path base-path "runtime-src")
|
||||||
(define-runtime-path baselib.js "runtime-src/baselib.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_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_symbol.js "runtime-src/baselib_symbol.js")
|
|
||||||
(define-runtime-path baselib_structs.js "runtime-src/baselib_structs.js")
|
|
||||||
(define-runtime-path baselib_arity.js "runtime-src/baselib_arity.js")
|
|
||||||
(define-runtime-path baselib_inspectors.js "runtime-src/baselib_inspectors.js")
|
|
||||||
(define-runtime-path baselib_exceptions.js "runtime-src/baselib_exceptions.js")
|
|
||||||
(define-runtime-path baselib_format.js "runtime-src/baselib_format.js")
|
|
||||||
(define-runtime-path baselib_chars.js "runtime-src/baselib_chars.js")
|
|
||||||
(define-runtime-path baselib_strings.js "runtime-src/baselib_strings.js")
|
|
||||||
(define-runtime-path baselib_bytes.js "runtime-src/baselib_bytes.js")
|
|
||||||
(define-runtime-path baselib_readergraph.js "runtime-src/baselib_readergraph.js")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define-runtime-path jshashtable.js "runtime-src/jshashtable-2.1_src.js")
|
|
||||||
(define-runtime-path jsnums.js "runtime-src/js-numbers.js")
|
|
||||||
(define-runtime-path link.js "runtime-src/link.js")
|
|
||||||
|
|
||||||
;; from js-vm
|
|
||||||
;; Deprecated:
|
|
||||||
;; (define-runtime-path helpers.js "runtime-src/helpers.js")
|
|
||||||
|
|
||||||
|
|
||||||
;; from js-vm
|
|
||||||
(define-runtime-path types.js "runtime-src/types.js")
|
|
||||||
;; These primitives were coded for the js-vm project, and we'll gradually
|
|
||||||
;; absorb them in.
|
|
||||||
;(define-runtime-path js-vm-primitives.js "runtime-src/js-vm-primitives.js")
|
|
||||||
|
|
||||||
(define-runtime-path runtime.js "runtime-src/runtime.js")
|
|
||||||
|
|
||||||
|
|
||||||
;; The order matters here. link needs to come near the top, because
|
;; The order matters here. link needs to come near the top, because
|
||||||
;; the other modules below have some circular dependencies that are resolved
|
;; the other modules below have some circular dependencies that are resolved
|
||||||
;; by link.
|
;; by link.
|
||||||
(define files (list jquery-protect-header.js
|
(define files '(
|
||||||
jquery.js
|
;; jquery is special: we need to make sure it's resilient against
|
||||||
jquery-protect-footer.js
|
;; multiple invokation and inclusion.
|
||||||
|
jquery-protect-header.js
|
||||||
jshashtable.js
|
jquery.js
|
||||||
jsnums.js
|
jquery-protect-footer.js
|
||||||
|
|
||||||
baselib.js
|
jshashtable-2.1_src.js
|
||||||
|
js-numbers.js
|
||||||
baselib_unionfind.js
|
|
||||||
baselib_equality.js
|
baselib.js
|
||||||
baselib_format.js
|
|
||||||
|
baselib_unionfind.js
|
||||||
baselib_lists.js
|
baselib_equality.js
|
||||||
baselib_vectors.js
|
baselib_format.js
|
||||||
baselib_chars.js
|
|
||||||
baselib_symbol.js
|
baselib_lists.js
|
||||||
baselib_strings.js
|
baselib_vectors.js
|
||||||
baselib_bytes.js
|
baselib_chars.js
|
||||||
baselib_hash.js
|
baselib_symbol.js
|
||||||
|
baselib_strings.js
|
||||||
baselib_structs.js
|
baselib_bytes.js
|
||||||
baselib_arity.js
|
baselib_hash.js
|
||||||
baselib_inspectors.js
|
baselib_regexps.js
|
||||||
baselib_exceptions.js
|
baselib_paths.js
|
||||||
baselib_readergraph.js
|
baselib_boxes.js
|
||||||
|
|
||||||
link.js
|
baselib_structs.js
|
||||||
; helpers.js
|
baselib_arity.js
|
||||||
types.js
|
baselib_inspectors.js
|
||||||
; js-vm-primitives.js
|
baselib_exceptions.js
|
||||||
runtime.js))
|
baselib_readergraph.js
|
||||||
|
|
||||||
|
link.js
|
||||||
|
types.js
|
||||||
|
runtime.js))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,8 +75,10 @@
|
||||||
|
|
||||||
|
|
||||||
(define text (apply string-append
|
(define text (apply string-append
|
||||||
(map path->string files)))
|
(map (lambda (n)
|
||||||
|
(path->string
|
||||||
|
(build-path base-path (symbol->string n))))
|
||||||
|
files)))
|
||||||
|
|
||||||
(define (get-runtime)
|
(define (get-runtime)
|
||||||
text)
|
text)
|
59
js-assembler/runtime-src/baselib_boxes.js
Normal file
59
js-assembler/runtime-src/baselib_boxes.js
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
// Exceptions
|
||||||
|
|
||||||
|
(function(baselib) {
|
||||||
|
var exceptions = {};
|
||||||
|
baselib.boxes = exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Boxes
|
||||||
|
|
||||||
|
var Box = function(x, mutable) {
|
||||||
|
this.val = x;
|
||||||
|
this.mutable = mutable;
|
||||||
|
};
|
||||||
|
|
||||||
|
Box.prototype.ref = function() {
|
||||||
|
return this.val;
|
||||||
|
};
|
||||||
|
|
||||||
|
Box.prototype.set = function(newVal) {
|
||||||
|
if (this.mutable) {
|
||||||
|
this.val = newVal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Box.prototype.toString = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
return "#&" + toWrittenString(this.val, cache);
|
||||||
|
};
|
||||||
|
|
||||||
|
Box.prototype.toWrittenString = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
return "#&" + toWrittenString(this.val, cache);
|
||||||
|
};
|
||||||
|
|
||||||
|
Box.prototype.toDisplayedString = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
return "#&" + toDisplayedString(this.val, cache);
|
||||||
|
};
|
||||||
|
|
||||||
|
Box.prototype.toDomNode = function(cache) {
|
||||||
|
cache.put(this, true);
|
||||||
|
var parent = document.createElement("span");
|
||||||
|
parent.appendChild(document.createTextNode('#&'));
|
||||||
|
parent.appendChild(toDomNode(this.val, cache));
|
||||||
|
return parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
Box.prototype.equals = function(other, aUnionFind) {
|
||||||
|
return ((other instanceof Box) &&
|
||||||
|
equals(this.val, other.val, aUnionFind));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.Box = Box;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})(this['plt'].baselib);
|
19
js-assembler/runtime-src/baselib_paths.js
Normal file
19
js-assembler/runtime-src/baselib_paths.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
(function(baselib) {
|
||||||
|
var exports = {};
|
||||||
|
baselib.paths = exports;
|
||||||
|
|
||||||
|
// Paths
|
||||||
|
|
||||||
|
var Path = function(p) {
|
||||||
|
this.path = p;
|
||||||
|
};
|
||||||
|
|
||||||
|
Path.prototype.toString = function() {
|
||||||
|
return this.path;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
exports.Path = Path;
|
||||||
|
|
||||||
|
})(this['plt'].baselib);
|
22
js-assembler/runtime-src/baselib_regexps.js
Normal file
22
js-assembler/runtime-src/baselib_regexps.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
(function(baselib) {
|
||||||
|
var exports = {};
|
||||||
|
baselib.regexps = exports;
|
||||||
|
|
||||||
|
|
||||||
|
// Regular expressions.
|
||||||
|
|
||||||
|
var RegularExpression = function(pattern) {
|
||||||
|
this.pattern = pattern;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var ByteRegularExpression = function(pattern) {
|
||||||
|
this.pattern = pattern;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
exports.RegularExpression = RegularExpression;
|
||||||
|
exports.ByteRegularExpression = ByteRegularExpression;
|
||||||
|
|
||||||
|
})(this['plt'].baselib);
|
|
@ -69,31 +69,6 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Regular expressions.
|
|
||||||
|
|
||||||
var RegularExpression = function(pattern) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
var ByteRegularExpression = function(pattern) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Paths
|
|
||||||
|
|
||||||
var Path = function(p) {
|
|
||||||
this.path = p;
|
|
||||||
};
|
|
||||||
|
|
||||||
Path.prototype.toString = function() {
|
|
||||||
return this.path;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,51 +76,11 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Boxes
|
|
||||||
|
|
||||||
var Box = function(x, mutable) {
|
|
||||||
this.val = x;
|
|
||||||
this.mutable = mutable;
|
|
||||||
};
|
|
||||||
|
|
||||||
Box.prototype.ref = function() {
|
|
||||||
return this.val;
|
|
||||||
};
|
|
||||||
|
|
||||||
Box.prototype.set = function(newVal) {
|
|
||||||
if (this.mutable) {
|
|
||||||
this.val = newVal;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Box.prototype.toString = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
return "#&" + toWrittenString(this.val, cache);
|
|
||||||
};
|
|
||||||
|
|
||||||
Box.prototype.toWrittenString = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
return "#&" + toWrittenString(this.val, cache);
|
|
||||||
};
|
|
||||||
|
|
||||||
Box.prototype.toDisplayedString = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
return "#&" + toDisplayedString(this.val, cache);
|
|
||||||
};
|
|
||||||
|
|
||||||
Box.prototype.toDomNode = function(cache) {
|
|
||||||
cache.put(this, true);
|
|
||||||
var parent = document.createElement("span");
|
|
||||||
parent.appendChild(document.createTextNode('#&'));
|
|
||||||
parent.appendChild(toDomNode(this.val, cache));
|
|
||||||
return parent;
|
|
||||||
};
|
|
||||||
|
|
||||||
Box.prototype.equals = function(other, aUnionFind) {
|
|
||||||
return ((other instanceof Box) &&
|
|
||||||
equals(this.val, other.val, aUnionFind));
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -765,14 +700,14 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
types.list = makeList;
|
types.list = makeList;
|
||||||
types.vector = makeVector;
|
types.vector = makeVector;
|
||||||
types.vectorImmutable = makeVectorImmutable;
|
types.vectorImmutable = makeVectorImmutable;
|
||||||
types.regexp = function(p) { return new RegularExpression(p) ; }
|
types.regexp = function(p) { return new plt.baselib.regexps.RegularExpression(p) ; }
|
||||||
types.byteRegexp = function(p) { return new ByteRegularExpression(p) ; }
|
types.byteRegexp = function(p) { return new plt.baselib.regexps.ByteRegularExpression(p) ; }
|
||||||
types.character = plt.baselib.chars.Char.makeInstance;
|
types.character = plt.baselib.chars.Char.makeInstance;
|
||||||
types['string'] = makeString;
|
types['string'] = makeString;
|
||||||
types.box = function(x) { return new Box(x, true); };
|
types.box = function(x) { return new plt.baselib.boxes.Box(x, true); };
|
||||||
types.placeholder = function(x) { return new Placeholder(x); };
|
types.placeholder = function(x) { return new Placeholder(x); };
|
||||||
types.boxImmutable = function(x) { return new Box(x, false); };
|
types.boxImmutable = function(x) { return new plt.baselib.boxes.Box(x, false); };
|
||||||
types.path = function(x) { return new Path(x); };
|
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.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); };
|
||||||
|
@ -812,7 +747,7 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
types.isList = isList;
|
types.isList = isList;
|
||||||
types.isEmpty = function(x) { return x === Empty.EMPTY; };
|
types.isEmpty = function(x) { return x === Empty.EMPTY; };
|
||||||
types.isVector = function(x) { return x instanceof Vector; };
|
types.isVector = function(x) { return x instanceof Vector; };
|
||||||
types.isBox = function(x) { return x instanceof Box; };
|
types.isBox = function(x) { return x instanceof plt.baselib.boxes.Box; };
|
||||||
types.isPlaceholder = function(x) { return x instanceof Placeholder; };
|
types.isPlaceholder = function(x) { return x instanceof Placeholder; };
|
||||||
types.isHash = function(x) { return (x instanceof plt.baselib.hash.EqHashTable ||
|
types.isHash = function(x) { return (x instanceof plt.baselib.hash.EqHashTable ||
|
||||||
x instanceof plt.baselib.hash.EqualHashTable); };
|
x instanceof plt.baselib.hash.EqualHashTable); };
|
||||||
|
@ -851,7 +786,7 @@ if (! this['plt']) { this['plt'] = {}; }
|
||||||
// types.isContinuationPromptTag = function(x) { return x instanceof ContinuationPromptTag; };
|
// types.isContinuationPromptTag = function(x) { return x instanceof ContinuationPromptTag; };
|
||||||
|
|
||||||
|
|
||||||
types.Box = Box;
|
types.Box = plt.baselib.boxes.Box;
|
||||||
types.Placeholder = Placeholder;
|
types.Placeholder = Placeholder;
|
||||||
types.ThreadCell = ThreadCell;
|
types.ThreadCell = ThreadCell;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user