From 1d1a6e949230aff623b8427f042d4a8d1fd166c3 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Tue, 5 Jul 2011 17:01:01 -0400 Subject: [PATCH] continuing to life out types --- js-assembler/runtime-src/baselib_boxes.js | 14 +++--- js-assembler/runtime-src/baselib_paths.js | 2 +- .../runtime-src/baselib_placeholders.js | 49 +++++++++++++++++++ js-assembler/runtime-src/types.js | 36 -------------- 4 files changed, 57 insertions(+), 44 deletions(-) create mode 100644 js-assembler/runtime-src/baselib_placeholders.js diff --git a/js-assembler/runtime-src/baselib_boxes.js b/js-assembler/runtime-src/baselib_boxes.js index b8d48c0..a50b29e 100644 --- a/js-assembler/runtime-src/baselib_boxes.js +++ b/js-assembler/runtime-src/baselib_boxes.js @@ -1,8 +1,8 @@ // Exceptions (function(baselib) { - var exceptions = {}; - baselib.boxes = exceptions; + var exports = {}; + baselib.boxes = exports; ////////////////////////////////////////////////////////////////////// @@ -25,30 +25,30 @@ Box.prototype.toString = function(cache) { cache.put(this, true); - return "#&" + toWrittenString(this.val, cache); + return "#&" + plt.baselib.format.toWrittenString(this.val, cache); }; Box.prototype.toWrittenString = function(cache) { cache.put(this, true); - return "#&" + toWrittenString(this.val, cache); + return "#&" + plt.baselib.format.toWrittenString(this.val, cache); }; Box.prototype.toDisplayedString = function(cache) { cache.put(this, true); - return "#&" + toDisplayedString(this.val, cache); + return "#&" + plt.baselib.format.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)); + parent.appendChild(plt.baselib.format.toDomNode(this.val, cache)); return parent; }; Box.prototype.equals = function(other, aUnionFind) { return ((other instanceof Box) && - equals(this.val, other.val, aUnionFind)); + plt.baselib.equality.equals(this.val, other.val, aUnionFind)); }; diff --git a/js-assembler/runtime-src/baselib_paths.js b/js-assembler/runtime-src/baselib_paths.js index 54dbc35..de850cc 100644 --- a/js-assembler/runtime-src/baselib_paths.js +++ b/js-assembler/runtime-src/baselib_paths.js @@ -9,7 +9,7 @@ }; Path.prototype.toString = function() { - return this.path; + return String(this.path); }; ////////////////////////////////////////////////////////////////////// diff --git a/js-assembler/runtime-src/baselib_placeholders.js b/js-assembler/runtime-src/baselib_placeholders.js new file mode 100644 index 0000000..5096793 --- /dev/null +++ b/js-assembler/runtime-src/baselib_placeholders.js @@ -0,0 +1,49 @@ +// Exceptions + +(function(baselib) { + var exports = {}; + baselib.placeholders = exports; + + + // Placeholders: same thing as boxes. Distinct type just to support make-reader-graph. + + var Placeholder = function(x, mutable) { + this.val = x; + }; + + Placeholder.prototype.ref = function() { + return this.val; + }; + + Placeholder.prototype.set = function(newVal) { + this.val = newVal; + }; + + Placeholder.prototype.toString = function(cache) { + return "#"; + }; + + Placeholder.prototype.toWrittenString = function(cache) { + return "#"; + }; + + Placeholder.prototype.toDisplayedString = function(cache) { + return "#"; + }; + + Placeholder.prototype.toDomNode = function(cache) { + var parent = document.createElement("span"); + parent.appendChild(document.createTextNode('#')); + return parent; + }; + + Placeholder.prototype.equals = function(other, aUnionFind) { + return ((other instanceof Placeholder) && + plt.baselib.equality.equals(this.val, other.val, aUnionFind)); + }; + + + exports.Placeholder = Placeholder; + + +})(this['plt'].baselib); \ No newline at end of file diff --git a/js-assembler/runtime-src/types.js b/js-assembler/runtime-src/types.js index f46fa86..1c751bd 100644 --- a/js-assembler/runtime-src/types.js +++ b/js-assembler/runtime-src/types.js @@ -84,42 +84,6 @@ if (! this['plt']) { this['plt'] = {}; } ////////////////////////////////////////////////////////////////////// - // Placeholders: same thing as boxes. Distinct type just to support make-reader-graph. - - var Placeholder = function(x, mutable) { - this.val = x; - }; - - Placeholder.prototype.ref = function() { - return this.val; - }; - - Placeholder.prototype.set = function(newVal) { - this.val = newVal; - }; - - Placeholder.prototype.toString = function(cache) { - return "#"; - }; - - Placeholder.prototype.toWrittenString = function(cache) { - return "#"; - }; - - Placeholder.prototype.toDisplayedString = function(cache) { - return "#"; - }; - - Placeholder.prototype.toDomNode = function(cache) { - var parent = document.createElement("span"); - parent.appendChild(document.createTextNode('#')); - return parent; - }; - - Placeholder.prototype.equals = function(other, aUnionFind) { - return ((other instanceof Placeholder) && - equals(this.val, other.val, aUnionFind)); - };