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

Side by Side Diff: src/mirror-delay.js

Issue 115401: Introduce compact version of debugger response (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/debug-delay.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 1745
1746 return content; 1746 return content;
1747 } 1747 }
1748 1748
1749 1749
1750 JSONProtocolSerializer.prototype.includeSource_ = function() { 1750 JSONProtocolSerializer.prototype.includeSource_ = function() {
1751 return this.options_ && this.options_.includeSource; 1751 return this.options_ && this.options_.includeSource;
1752 } 1752 }
1753 1753
1754 1754
1755 JSONProtocolSerializer.prototype.compactFormat_ = function() {
1756 return this.options_ && this.options_.compactFormat;
1757 }
1758
1759
1755 JSONProtocolSerializer.prototype.add_ = function(mirror) { 1760 JSONProtocolSerializer.prototype.add_ = function(mirror) {
1756 // If this mirror is already in the list just return. 1761 // If this mirror is already in the list just return.
1757 for (var i = 0; i < this.mirrors_.length; i++) { 1762 for (var i = 0; i < this.mirrors_.length; i++) {
1758 if (this.mirrors_[i] === mirror) { 1763 if (this.mirrors_[i] === mirror) {
1759 return; 1764 return;
1760 } 1765 }
1761 } 1766 }
1762 1767
1763 // Add the mirror to the list of mirrors to be serialized. 1768 // Add the mirror to the list of mirrors to be serialized.
1764 this.mirrors_.push(mirror); 1769 this.mirrors_.push(mirror);
1765 } 1770 }
1766 1771
1767 1772
1773 /**
1774 * Formats mirror object to protocol reference object with some data that can
1775 * be used to display the value in debugger.
1776 * @param {Mirror} mirror Mirror to serialize.
1777 * @return {Object} Protocol reference object.
1778 */
1779 JSONProtocolSerializer.prototype.serializeReferenceWithDisplayData_ =
1780 function(mirror) {
1781 var o = {};
1782 o.ref = mirror.handle();
1783 o.type = mirror.type();
1784 switch (mirror.type()) {
1785 case UNDEFINED_TYPE:
1786 case NULL_TYPE:
1787 case BOOLEAN_TYPE:
1788 case NUMBER_TYPE:
1789 o.value = mirror.value();
1790 break;
1791 case STRING_TYPE:
1792 // Limit string length.
1793 o.value = mirror.toText();
1794 break;
1795 case FUNCTION_TYPE:
1796 o.name = mirror.name();
1797 o.inferredName = mirror.inferredName();
1798 if (mirror.script()) {
1799 o.scriptId = mirror.script().id();
1800 }
1801 break;
1802 case ERROR_TYPE:
1803 case REGEXP_TYPE:
1804 o.value = mirror.toText();
1805 break;
1806 case OBJECT_TYPE:
1807 o.className = mirror.className();
1808 break;
1809 }
1810 return o;
1811 };
1812
1768 JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference, 1813 JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference,
1769 details) { 1814 details) {
1770 // If serializing a reference to a mirror just return the reference and add 1815 // If serializing a reference to a mirror just return the reference and add
1771 // the mirror to the referenced mirrors. 1816 // the mirror to the referenced mirrors.
1772 if (reference && 1817 if (reference &&
1773 (mirror.isValue() || mirror.isScript() || mirror.isContext())) { 1818 (mirror.isValue() || mirror.isScript() || mirror.isContext())) {
1774 this.add_(mirror); 1819 if (this.compactFormat_() && mirror.isValue()) {
1775 return {'ref' : mirror.handle()}; 1820 return this.serializeReferenceWithDisplayData_(mirror);
1821 } else {
1822 this.add_(mirror);
1823 return {'ref' : mirror.handle()};
1824 }
1776 } 1825 }
1777 1826
1778 // Collect the JSON property/value pairs. 1827 // Collect the JSON property/value pairs.
1779 var content = {}; 1828 var content = {};
1780 1829
1781 // Add the mirror handle. 1830 // Add the mirror handle.
1782 if (mirror.isValue() || mirror.isScript() || mirror.isContext()) { 1831 if (mirror.isValue() || mirror.isScript() || mirror.isContext()) {
1783 content.handle = mirror.handle(); 1832 content.handle = mirror.handle();
1784 } 1833 }
1785 1834
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 * {"name":"hello","ref":1} 2007 * {"name":"hello","ref":1}
1959 * {"name":"length","attributes":7,"propertyType":3,"ref":2} 2008 * {"name":"length","attributes":7,"propertyType":3,"ref":2}
1960 * 2009 *
1961 * @param {PropertyMirror} propertyMirror The property to serialize. 2010 * @param {PropertyMirror} propertyMirror The property to serialize.
1962 * @returns {Object} Protocol object representing the property. 2011 * @returns {Object} Protocol object representing the property.
1963 */ 2012 */
1964 JSONProtocolSerializer.prototype.serializeProperty_ = function(propertyMirror) { 2013 JSONProtocolSerializer.prototype.serializeProperty_ = function(propertyMirror) {
1965 var result = {}; 2014 var result = {};
1966 2015
1967 result.name = propertyMirror.name(); 2016 result.name = propertyMirror.name();
1968 if (propertyMirror.attributes() != PropertyAttribute.None) { 2017 var propertyValue = propertyMirror.value();
1969 result.attributes = propertyMirror.attributes(); 2018 if (this.compactFormat_() && propertyValue.isValue()) {
2019 result.value = this.serializeReferenceWithDisplayData_(propertyValue);
2020 } else {
2021 if (propertyMirror.attributes() != PropertyAttribute.None) {
2022 result.attributes = propertyMirror.attributes();
2023 }
2024 if (propertyMirror.propertyType() != PropertyType.Normal) {
2025 result.propertyType = propertyMirror.propertyType();
2026 }
2027 result.ref = propertyValue.handle();
1970 } 2028 }
1971 if (propertyMirror.propertyType() != PropertyType.Normal) {
1972 result.propertyType = propertyMirror.propertyType();
1973 }
1974 result.ref = propertyMirror.value().handle();
1975 return result; 2029 return result;
1976 } 2030 }
1977 2031
1978 2032
1979 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { 2033 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) {
1980 content.index = mirror.index(); 2034 content.index = mirror.index();
1981 content.receiver = this.serializeReference(mirror.receiver()); 2035 content.receiver = this.serializeReference(mirror.receiver());
1982 var func = mirror.func(); 2036 var func = mirror.func();
1983 content.func = this.serializeReference(func); 2037 content.func = this.serializeReference(func);
1984 if (func.script()) { 2038 if (func.script()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 } 2090 }
2037 if (!isFinite(value)) { 2091 if (!isFinite(value)) {
2038 if (value > 0) { 2092 if (value > 0) {
2039 return 'Infinity'; 2093 return 'Infinity';
2040 } else { 2094 } else {
2041 return '-Infinity'; 2095 return '-Infinity';
2042 } 2096 }
2043 } 2097 }
2044 return value; 2098 return value;
2045 } 2099 }
OLDNEW
« no previous file with comments | « src/debug-delay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698