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

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

Issue 10073032: Issue 2081: Expose function's (closure's) inner context in debugger. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: spelling Created 8 years, 8 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-debugger.js ('k') | src/runtime.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 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 result[i] = MakeMirror(result[i]); 889 result[i] = MakeMirror(result[i]);
890 } 890 }
891 891
892 return result; 892 return result;
893 } else { 893 } else {
894 return []; 894 return [];
895 } 895 }
896 }; 896 };
897 897
898 898
899 FunctionMirror.prototype.scopeCount = function() {
900 return %GetFunctionScopeCount(this.value());
901 };
902
903
904 FunctionMirror.prototype.scope = function(index) {
905 return new ScopeMirror(undefined, this, index);
906 };
907
908
899 FunctionMirror.prototype.toText = function() { 909 FunctionMirror.prototype.toText = function() {
900 return this.source(); 910 return this.source();
901 }; 911 };
902 912
903 913
904 /** 914 /**
905 * Mirror object for unresolved functions. 915 * Mirror object for unresolved functions.
906 * @param {string} value The name for the unresolved function reflected by this 916 * @param {string} value The name for the unresolved function reflected by this
907 * mirror. 917 * mirror.
908 * @constructor 918 * @constructor
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 } 1575 }
1566 }; 1576 };
1567 1577
1568 1578
1569 FrameMirror.prototype.scopeCount = function() { 1579 FrameMirror.prototype.scopeCount = function() {
1570 return this.details_.scopeCount(); 1580 return this.details_.scopeCount();
1571 }; 1581 };
1572 1582
1573 1583
1574 FrameMirror.prototype.scope = function(index) { 1584 FrameMirror.prototype.scope = function(index) {
1575 return new ScopeMirror(this, index); 1585 return new ScopeMirror(this, undefined, index);
1576 }; 1586 };
1577 1587
1578 1588
1579 FrameMirror.prototype.evaluate = function(source, disable_break, 1589 FrameMirror.prototype.evaluate = function(source, disable_break,
1580 opt_context_object) { 1590 opt_context_object) {
1581 var result = %DebugEvaluate(this.break_id_, 1591 var result = %DebugEvaluate(this.break_id_,
1582 this.details_.frameId(), 1592 this.details_.frameId(),
1583 this.details_.inlinedFrameIndex(), 1593 this.details_.inlinedFrameIndex(),
1584 source, 1594 source,
1585 Boolean(disable_break), 1595 Boolean(disable_break),
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 result += '\n'; 1738 result += '\n';
1729 result += this.localsText(); 1739 result += this.localsText();
1730 } 1740 }
1731 return result; 1741 return result;
1732 }; 1742 };
1733 1743
1734 1744
1735 var kScopeDetailsTypeIndex = 0; 1745 var kScopeDetailsTypeIndex = 0;
1736 var kScopeDetailsObjectIndex = 1; 1746 var kScopeDetailsObjectIndex = 1;
1737 1747
1738 function ScopeDetails(frame, index) { 1748 function ScopeDetails(frame, fun, index) {
1739 this.break_id_ = frame.break_id_; 1749 if (frame) {
1740 this.details_ = %GetScopeDetails(frame.break_id_, 1750 this.break_id_ = frame.break_id_;
1741 frame.details_.frameId(), 1751 this.details_ = %GetScopeDetails(frame.break_id_,
1742 frame.details_.inlinedFrameIndex(), 1752 frame.details_.frameId(),
1743 index); 1753 frame.details_.inlinedFrameIndex(),
1754 index);
1755 } else {
1756 this.details_ = %GetFunctionScopeDetails(fun.value(), index);
1757 this.break_id_ = undefined;
1758 }
1744 } 1759 }
1745 1760
1746 1761
1747 ScopeDetails.prototype.type = function() { 1762 ScopeDetails.prototype.type = function() {
1748 %CheckExecutionState(this.break_id_); 1763 if (!IS_UNDEFINED(this.break_id_)) {
1764 %CheckExecutionState(this.break_id_);
1765 }
1749 return this.details_[kScopeDetailsTypeIndex]; 1766 return this.details_[kScopeDetailsTypeIndex];
1750 }; 1767 };
1751 1768
1752 1769
1753 ScopeDetails.prototype.object = function() { 1770 ScopeDetails.prototype.object = function() {
1754 %CheckExecutionState(this.break_id_); 1771 if (!IS_UNDEFINED(this.break_id_)) {
1772 %CheckExecutionState(this.break_id_);
1773 }
1755 return this.details_[kScopeDetailsObjectIndex]; 1774 return this.details_[kScopeDetailsObjectIndex];
1756 }; 1775 };
1757 1776
1758 1777
1759 /** 1778 /**
1760 * Mirror object for scope. 1779 * Mirror object for scope of frame or function. Either frame or function must
1780 * be specified.
1761 * @param {FrameMirror} frame The frame this scope is a part of 1781 * @param {FrameMirror} frame The frame this scope is a part of
1782 * @param {FunctionMirror} function The function this scope is a part of
1762 * @param {number} index The scope index in the frame 1783 * @param {number} index The scope index in the frame
1763 * @constructor 1784 * @constructor
1764 * @extends Mirror 1785 * @extends Mirror
1765 */ 1786 */
1766 function ScopeMirror(frame, index) { 1787 function ScopeMirror(frame, function, index) {
1767 %_CallFunction(this, SCOPE_TYPE, Mirror); 1788 %_CallFunction(this, SCOPE_TYPE, Mirror);
1768 this.frame_index_ = frame.index_; 1789 if (frame) {
1790 this.frame_index_ = frame.index_;
1791 } else {
1792 this.frame_index_ = undefined;
1793 }
1769 this.scope_index_ = index; 1794 this.scope_index_ = index;
1770 this.details_ = new ScopeDetails(frame, index); 1795 this.details_ = new ScopeDetails(frame, function, index);
1771 } 1796 }
1772 inherits(ScopeMirror, Mirror); 1797 inherits(ScopeMirror, Mirror);
1773 1798
1774 1799
1775 ScopeMirror.prototype.frameIndex = function() { 1800 ScopeMirror.prototype.frameIndex = function() {
1776 return this.frame_index_; 1801 return this.frame_index_;
1777 }; 1802 };
1778 1803
1779 1804
1780 ScopeMirror.prototype.scopeIndex = function() { 1805 ScopeMirror.prototype.scopeIndex = function() {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 content.resolved = mirror.resolved(); 2277 content.resolved = mirror.resolved();
2253 if (mirror.resolved()) { 2278 if (mirror.resolved()) {
2254 content.source = mirror.source(); 2279 content.source = mirror.source();
2255 } 2280 }
2256 if (mirror.script()) { 2281 if (mirror.script()) {
2257 content.script = this.serializeReference(mirror.script()); 2282 content.script = this.serializeReference(mirror.script());
2258 content.scriptId = mirror.script().id(); 2283 content.scriptId = mirror.script().id();
2259 2284
2260 serializeLocationFields(mirror.sourceLocation(), content); 2285 serializeLocationFields(mirror.sourceLocation(), content);
2261 } 2286 }
2287
2288 content.scopes = [];
2289 for (var i = 0; i < mirror.scopeCount(); i++) {
2290 var scope = mirror.scope(i);
2291 content.scopes.push({
2292 type: scope.scopeType(),
2293 index: i
2294 });
2295 }
2262 } 2296 }
2263 2297
2264 // Add date specific properties. 2298 // Add date specific properties.
2265 if (mirror.isDate()) { 2299 if (mirror.isDate()) {
2266 // Add date specific properties. 2300 // Add date specific properties.
2267 content.value = mirror.value(); 2301 content.value = mirror.value();
2268 } 2302 }
2269 2303
2270 // Add actual properties - named properties followed by indexed properties. 2304 // Add actual properties - named properties followed by indexed properties.
2271 var propertyNames = mirror.propertyNames(PropertyKind.Named); 2305 var propertyNames = mirror.propertyNames(PropertyKind.Named);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 } 2462 }
2429 if (!NUMBER_IS_FINITE(value)) { 2463 if (!NUMBER_IS_FINITE(value)) {
2430 if (value > 0) { 2464 if (value > 0) {
2431 return 'Infinity'; 2465 return 'Infinity';
2432 } else { 2466 } else {
2433 return '-Infinity'; 2467 return '-Infinity';
2434 } 2468 }
2435 } 2469 }
2436 return value; 2470 return value;
2437 } 2471 }
OLDNEW
« no previous file with comments | « src/debug-debugger.js ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698