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

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

Issue 660095: Merge revision 3813 to 3930 from bleeding_edge to partial snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: '' Created 10 years, 10 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/mips/codegen-mips.cc ('k') | src/number-info.h » ('j') | 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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 function StringMirror(value) { 539 function StringMirror(value) {
540 ValueMirror.call(this, STRING_TYPE, value); 540 ValueMirror.call(this, STRING_TYPE, value);
541 } 541 }
542 inherits(StringMirror, ValueMirror); 542 inherits(StringMirror, ValueMirror);
543 543
544 544
545 StringMirror.prototype.length = function() { 545 StringMirror.prototype.length = function() {
546 return this.value_.length; 546 return this.value_.length;
547 }; 547 };
548 548
549 StringMirror.prototype.getTruncatedValue = function(maxLength) {
550 if (maxLength != -1 && this.length() > maxLength) {
551 return this.value_.substring(0, maxLength) +
552 '... (length: ' + this.length() + ')';
553 }
554 return this.value_;
555 }
549 556
550 StringMirror.prototype.toText = function() { 557 StringMirror.prototype.toText = function() {
551 if (this.length() > kMaxProtocolStringLength) { 558 return this.getTruncatedValue(kMaxProtocolStringLength);
552 return this.value_.substring(0, kMaxProtocolStringLength) +
553 '... (length: ' + this.length() + ')';
554 } else {
555 return this.value_;
556 }
557 } 559 }
558 560
559 561
560 /** 562 /**
561 * Mirror object for objects. 563 * Mirror object for objects.
562 * @param {object} value The object reflected by this mirror 564 * @param {object} value The object reflected by this mirror
563 * @param {boolean} transient indicate whether this object is transient with a 565 * @param {boolean} transient indicate whether this object is transient with a
564 * transient handle 566 * transient handle
565 * @constructor 567 * @constructor
566 * @extends ValueMirror 568 * @extends ValueMirror
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 } 1721 }
1720 inherits(ScriptMirror, Mirror); 1722 inherits(ScriptMirror, Mirror);
1721 1723
1722 1724
1723 ScriptMirror.prototype.value = function() { 1725 ScriptMirror.prototype.value = function() {
1724 return this.script_; 1726 return this.script_;
1725 }; 1727 };
1726 1728
1727 1729
1728 ScriptMirror.prototype.name = function() { 1730 ScriptMirror.prototype.name = function() {
1729 return this.script_.name; 1731 // If we have name, we trust it more than sourceURL from comments
1732 return this.script_.name || this.sourceUrlFromComment_();
1730 }; 1733 };
1731 1734
1732 1735
1733 ScriptMirror.prototype.id = function() { 1736 ScriptMirror.prototype.id = function() {
1734 return this.script_.id; 1737 return this.script_.id;
1735 }; 1738 };
1736 1739
1737 1740
1738 ScriptMirror.prototype.source = function() { 1741 ScriptMirror.prototype.source = function() {
1739 return this.script_.source; 1742 return this.script_.source;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 result += this.lineOffset() + this.lineCount() - 1; 1818 result += this.lineOffset() + this.lineCount() - 1;
1816 } else { 1819 } else {
1817 result += this.lineCount(); 1820 result += this.lineCount();
1818 } 1821 }
1819 result += ')'; 1822 result += ')';
1820 return result; 1823 return result;
1821 } 1824 }
1822 1825
1823 1826
1824 /** 1827 /**
1828 * Returns a suggested script URL from comments in script code (if found),
1829 * undefined otherwise. Used primarily by debuggers for identifying eval()'ed
1830 * scripts. See
1831 * http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt
1832 * for details.
1833 *
1834 * @return {?string} value for //@ sourceURL comment
1835 */
1836 ScriptMirror.prototype.sourceUrlFromComment_ = function() {
1837 if (!('sourceUrl_' in this) && this.source()) {
1838 // TODO(608): the spaces in a regexp below had to be escaped as \040
1839 // because this file is being processed by js2c whose handling of spaces
1840 // in regexps is broken.
1841 // We're not using \s here to prevent \n from matching.
1842 var sourceUrlPattern = /\/\/@[\040\t]sourceURL=[\040\t]*(\S+)[\040\t]*$/m;
1843 var match = sourceUrlPattern.exec(this.source());
1844 this.sourceUrl_ = match ? match[1] : undefined;
1845 }
1846 return this.sourceUrl_;
1847 };
1848
1849
1850 /**
1825 * Mirror object for context. 1851 * Mirror object for context.
1826 * @param {Object} data The context data 1852 * @param {Object} data The context data
1827 * @constructor 1853 * @constructor
1828 * @extends Mirror 1854 * @extends Mirror
1829 */ 1855 */
1830 function ContextMirror(data) { 1856 function ContextMirror(data) {
1831 Mirror.call(this, CONTEXT_TYPE); 1857 Mirror.call(this, CONTEXT_TYPE);
1832 this.data_ = data; 1858 this.data_ = data;
1833 this.allocateHandle_(); 1859 this.allocateHandle_();
1834 } 1860 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 JSONProtocolSerializer.prototype.includeSource_ = function() { 1943 JSONProtocolSerializer.prototype.includeSource_ = function() {
1918 return this.options_ && this.options_.includeSource; 1944 return this.options_ && this.options_.includeSource;
1919 } 1945 }
1920 1946
1921 1947
1922 JSONProtocolSerializer.prototype.inlineRefs_ = function() { 1948 JSONProtocolSerializer.prototype.inlineRefs_ = function() {
1923 return this.options_ && this.options_.inlineRefs; 1949 return this.options_ && this.options_.inlineRefs;
1924 } 1950 }
1925 1951
1926 1952
1953 JSONProtocolSerializer.prototype.maxStringLength_ = function() {
1954 if (IS_UNDEFINED(this.options_) ||
1955 IS_UNDEFINED(this.options_.maxStringLength)) {
1956 return kMaxProtocolStringLength;
1957 }
1958 return this.options_.maxStringLength;
1959 }
1960
1961
1927 JSONProtocolSerializer.prototype.add_ = function(mirror) { 1962 JSONProtocolSerializer.prototype.add_ = function(mirror) {
1928 // If this mirror is already in the list just return. 1963 // If this mirror is already in the list just return.
1929 for (var i = 0; i < this.mirrors_.length; i++) { 1964 for (var i = 0; i < this.mirrors_.length; i++) {
1930 if (this.mirrors_[i] === mirror) { 1965 if (this.mirrors_[i] === mirror) {
1931 return; 1966 return;
1932 } 1967 }
1933 } 1968 }
1934 1969
1935 // Add the mirror to the list of mirrors to be serialized. 1970 // Add the mirror to the list of mirrors to be serialized.
1936 this.mirrors_.push(mirror); 1971 this.mirrors_.push(mirror);
(...skipping 12 matching lines...) Expand all
1949 o.ref = mirror.handle(); 1984 o.ref = mirror.handle();
1950 o.type = mirror.type(); 1985 o.type = mirror.type();
1951 switch (mirror.type()) { 1986 switch (mirror.type()) {
1952 case UNDEFINED_TYPE: 1987 case UNDEFINED_TYPE:
1953 case NULL_TYPE: 1988 case NULL_TYPE:
1954 case BOOLEAN_TYPE: 1989 case BOOLEAN_TYPE:
1955 case NUMBER_TYPE: 1990 case NUMBER_TYPE:
1956 o.value = mirror.value(); 1991 o.value = mirror.value();
1957 break; 1992 break;
1958 case STRING_TYPE: 1993 case STRING_TYPE:
1959 // Limit string length. 1994 o.value = mirror.getTruncatedValue(this.maxStringLength_());
1960 o.value = mirror.toText();
1961 break; 1995 break;
1962 case FUNCTION_TYPE: 1996 case FUNCTION_TYPE:
1963 o.name = mirror.name(); 1997 o.name = mirror.name();
1964 o.inferredName = mirror.inferredName(); 1998 o.inferredName = mirror.inferredName();
1965 if (mirror.script()) { 1999 if (mirror.script()) {
1966 o.scriptId = mirror.script().id(); 2000 o.scriptId = mirror.script().id();
1967 } 2001 }
1968 break; 2002 break;
1969 case ERROR_TYPE: 2003 case ERROR_TYPE:
1970 case REGEXP_TYPE: 2004 case REGEXP_TYPE:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 content.value = mirror.value(); 2048 content.value = mirror.value();
2015 break; 2049 break;
2016 2050
2017 case NUMBER_TYPE: 2051 case NUMBER_TYPE:
2018 // Number values are simply represented by their value. 2052 // Number values are simply represented by their value.
2019 content.value = NumberToJSON_(mirror.value()); 2053 content.value = NumberToJSON_(mirror.value());
2020 break; 2054 break;
2021 2055
2022 case STRING_TYPE: 2056 case STRING_TYPE:
2023 // String values might have their value cropped to keep down size. 2057 // String values might have their value cropped to keep down size.
2024 if (mirror.length() > kMaxProtocolStringLength) { 2058 if (this.maxStringLength_() != -1 &&
2025 var str = mirror.value().substring(0, kMaxProtocolStringLength); 2059 mirror.length() > this.maxStringLength_()) {
2060 var str = mirror.getTruncatedValue(this.maxStringLength_());
2026 content.value = str; 2061 content.value = str;
2027 content.fromIndex = 0; 2062 content.fromIndex = 0;
2028 content.toIndex = kMaxProtocolStringLength; 2063 content.toIndex = this.maxStringLength_();
2029 } else { 2064 } else {
2030 content.value = mirror.value(); 2065 content.value = mirror.value();
2031 } 2066 }
2032 content.length = mirror.length(); 2067 content.length = mirror.length();
2033 break; 2068 break;
2034 2069
2035 case OBJECT_TYPE: 2070 case OBJECT_TYPE:
2036 case FUNCTION_TYPE: 2071 case FUNCTION_TYPE:
2037 case ERROR_TYPE: 2072 case ERROR_TYPE:
2038 case REGEXP_TYPE: 2073 case REGEXP_TYPE:
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 } 2353 }
2319 if (!isFinite(value)) { 2354 if (!isFinite(value)) {
2320 if (value > 0) { 2355 if (value > 0) {
2321 return 'Infinity'; 2356 return 'Infinity';
2322 } else { 2357 } else {
2323 return '-Infinity'; 2358 return '-Infinity';
2324 } 2359 }
2325 } 2360 }
2326 return value; 2361 return value;
2327 } 2362 }
OLDNEW
« no previous file with comments | « src/mips/codegen-mips.cc ('k') | src/number-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698