Index: src/mirror-delay.js |
=================================================================== |
--- src/mirror-delay.js (revision 1106) |
+++ src/mirror-delay.js (working copy) |
@@ -58,6 +58,11 @@ |
if (mirror.value() === value) { |
return mirror; |
} |
+ // Special check for NaN as NaN == NaN is false. |
+ if (mirror.isNumber() && isNaN(mirror.value()) && |
+ typeof value == 'number' && isNaN(value)) { |
+ return mirror; |
+ } |
} |
if (IS_UNDEFINED(value)) { |
@@ -342,6 +347,14 @@ |
} |
+/** |
+ * Allocate a handle id for this object. |
+ */ |
+Mirror.prototype.allocateHandle_ = function() { |
+ this.handle_ = next_handle_++; |
+} |
+ |
+ |
Mirror.prototype.toText = function() { |
// Simpel to text which is used when on specialization in subclass. |
return "#<" + builtins.GetInstanceName(this.constructor.name) + ">"; |
@@ -357,8 +370,8 @@ |
*/ |
function ValueMirror(type, value) { |
Mirror.call(this, type); |
- this.handle_ = next_handle_++; |
this.value_ = value; |
+ this.allocateHandle_(); |
} |
inherits(ValueMirror, Mirror); |
@@ -1516,6 +1529,7 @@ |
function ScriptMirror(script) { |
Mirror.call(this, SCRIPT_TYPE); |
this.script_ = script; |
+ this.allocateHandle_(); |
} |
inherits(ScriptMirror, Mirror); |
@@ -1656,9 +1670,10 @@ |
JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference, |
details) { |
- // If serializing a reference to a value just return the reference and add the |
- // mirror to the referenced mirrors. |
- if (reference && mirror.isValue()) { |
+ // If serializing a reference to a mirror just return the reference and add |
+ // the mirror to the referenced mirrors. |
+ if (reference && |
+ (mirror.isValue() || mirror.isScript())) { |
this.add_(mirror); |
return '{"ref":' + mirror.handle() + '}'; |
} |
@@ -1785,7 +1800,7 @@ |
content.push(MakeJSONPair_('source', StringToJSON_(mirror.source()))); |
} |
if (mirror.script()) { |
- content.push(MakeJSONPair_('script', this.serializeValue(mirror.script()))); |
+ content.push(MakeJSONPair_('script', this.serializeReference(mirror.script()))); |
} |
} |