Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: src/debug-delay.js

Issue 18092: Added handles to the mirror objects. When a mirror for an object is created... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug.cc ('k') | src/mirror-delay.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug-delay.js
===================================================================
--- src/debug-delay.js (revision 1079)
+++ src/debug-delay.js (working copy)
@@ -994,22 +994,25 @@
if (this.body) {
json += ',"body":';
// Encode the body part.
- if (this.body.toJSONProtocol) {
- json += this.body.toJSONProtocol(true);
+ var serializer = MakeMirrorSerializer(true);
+ if (this.body instanceof Mirror) {
+ json += serializer.serializeValue(this.body);
} else if (this.body instanceof Array) {
json += '[';
for (var i = 0; i < this.body.length; i++) {
if (i != 0) json += ',';
- if (this.body[i].toJSONProtocol) {
- json += this.body[i].toJSONProtocol(true)
+ if (this.body[i] instanceof Mirror) {
+ json += serializer.serializeValue(this.body[i]);
} else {
- json += SimpleObjectToJSON_(this.body[i]);
+ json += SimpleObjectToJSON_(this.body[i], serializer);
}
}
json += ']';
} else {
- json += SimpleObjectToJSON_(this.body);
+ json += SimpleObjectToJSON_(this.body, serializer);
}
+ json += ',"refs":';
+ json += serializer.serializeReferencedObjects();
}
if (this.message) {
json += ',"message":' + StringToJSON_(this.message) ;
@@ -1568,9 +1571,11 @@
* a general implementation but sufficient for the debugger. Note that circular
* structures will cause infinite recursion.
* @param {Object} object The object to format as JSON
+ * @param {MirrorSerializer} mirror_serializer The serializer to use if any
+ * mirror objects are encountered.
* @return {string} JSON formatted object value
*/
-function SimpleObjectToJSON_(object) {
+function SimpleObjectToJSON_(object, mirror_serializer) {
var content = [];
for (var key in object) {
// Only consider string keys.
@@ -1584,9 +1589,9 @@
if (typeof property_value.toJSONProtocol == 'function') {
property_value_json = property_value.toJSONProtocol(true)
} else if (IS_ARRAY(property_value)){
- property_value_json = SimpleArrayToJSON_(property_value);
+ property_value_json = SimpleArrayToJSON_(property_value, mirror_serializer);
} else {
- property_value_json = SimpleObjectToJSON_(property_value);
+ property_value_json = SimpleObjectToJSON_(property_value, mirror_serializer);
}
break;
@@ -1620,10 +1625,12 @@
/**
* Convert an array to its JSON representation. This is a VERY simple
* implementation just to support what is needed for the debugger.
- * @param {Array} arrya The array to format as JSON
+ * @param {Array} array The array to format as JSON
+ * @param {MirrorSerializer} mirror_serializer The serializer to use if any
+ * mirror objects are encountered.
* @return {string} JSON formatted array value
*/
-function SimpleArrayToJSON_(array) {
+function SimpleArrayToJSON_(array, mirror_serializer) {
// Make JSON array representation.
var json = '[';
for (var i = 0; i < array.length; i++) {
@@ -1631,8 +1638,8 @@
json += ',';
}
var elem = array[i];
- if (elem.toJSONProtocol) {
- json += elem.toJSONProtocol(true)
+ if (elem instanceof Mirror) {
+ json += mirror_serializer.serializeValue(elem);
} else if (IS_OBJECT(elem)) {
json += SimpleObjectToJSON_(elem);
} else if (IS_BOOLEAN(elem)) {
« no previous file with comments | « src/debug.cc ('k') | src/mirror-delay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698