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

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

Issue 10171003: Issue 2081: Expose function's (closure's) inner context in debugger. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: trailing whitespace Created 8 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-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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 result[i] = MakeMirror(result[i]); 906 result[i] = MakeMirror(result[i]);
907 } 907 }
908 908
909 return result; 909 return result;
910 } else { 910 } else {
911 return []; 911 return [];
912 } 912 }
913 }; 913 };
914 914
915 915
916 FunctionMirror.prototype.scopeCount = function() {
917 if (this.resolved()) {
918 return %GetFunctionScopeCount(this.value());
919 } else {
920 return 0;
921 }
922 };
923
924
925 FunctionMirror.prototype.scope = function(index) {
926 if (this.resolved()) {
927 return new ScopeMirror(void 0, this, index);
928 }
929 };
930
931
916 FunctionMirror.prototype.toText = function() { 932 FunctionMirror.prototype.toText = function() {
917 return this.source(); 933 return this.source();
918 }; 934 };
919 935
920 936
921 /** 937 /**
922 * Mirror object for unresolved functions. 938 * Mirror object for unresolved functions.
923 * @param {string} value The name for the unresolved function reflected by this 939 * @param {string} value The name for the unresolved function reflected by this
924 * mirror. 940 * mirror.
925 * @constructor 941 * @constructor
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 } 1598 }
1583 }; 1599 };
1584 1600
1585 1601
1586 FrameMirror.prototype.scopeCount = function() { 1602 FrameMirror.prototype.scopeCount = function() {
1587 return this.details_.scopeCount(); 1603 return this.details_.scopeCount();
1588 }; 1604 };
1589 1605
1590 1606
1591 FrameMirror.prototype.scope = function(index) { 1607 FrameMirror.prototype.scope = function(index) {
1592 return new ScopeMirror(this, index); 1608 return new ScopeMirror(this, void 0, index);
1593 }; 1609 };
1594 1610
1595 1611
1596 FrameMirror.prototype.evaluate = function(source, disable_break, 1612 FrameMirror.prototype.evaluate = function(source, disable_break,
1597 opt_context_object) { 1613 opt_context_object) {
1598 var result = %DebugEvaluate(this.break_id_, 1614 var result = %DebugEvaluate(this.break_id_,
1599 this.details_.frameId(), 1615 this.details_.frameId(),
1600 this.details_.inlinedFrameIndex(), 1616 this.details_.inlinedFrameIndex(),
1601 source, 1617 source,
1602 Boolean(disable_break), 1618 Boolean(disable_break),
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 result += '\n'; 1761 result += '\n';
1746 result += this.localsText(); 1762 result += this.localsText();
1747 } 1763 }
1748 return result; 1764 return result;
1749 }; 1765 };
1750 1766
1751 1767
1752 var kScopeDetailsTypeIndex = 0; 1768 var kScopeDetailsTypeIndex = 0;
1753 var kScopeDetailsObjectIndex = 1; 1769 var kScopeDetailsObjectIndex = 1;
1754 1770
1755 function ScopeDetails(frame, index) { 1771 function ScopeDetails(frame, fun, index) {
1756 this.break_id_ = frame.break_id_; 1772 if (frame) {
1757 this.details_ = %GetScopeDetails(frame.break_id_, 1773 this.break_id_ = frame.break_id_;
1758 frame.details_.frameId(), 1774 this.details_ = %GetScopeDetails(frame.break_id_,
1759 frame.details_.inlinedFrameIndex(), 1775 frame.details_.frameId(),
1760 index); 1776 frame.details_.inlinedFrameIndex(),
1777 index);
1778 } else {
1779 this.details_ = %GetFunctionScopeDetails(fun.value(), index);
1780 this.break_id_ = undefined;
1781 }
1761 } 1782 }
1762 1783
1763 1784
1764 ScopeDetails.prototype.type = function() { 1785 ScopeDetails.prototype.type = function() {
1765 %CheckExecutionState(this.break_id_); 1786 if (!IS_UNDEFINED(this.break_id_)) {
1787 %CheckExecutionState(this.break_id_);
1788 }
1766 return this.details_[kScopeDetailsTypeIndex]; 1789 return this.details_[kScopeDetailsTypeIndex];
1767 }; 1790 };
1768 1791
1769 1792
1770 ScopeDetails.prototype.object = function() { 1793 ScopeDetails.prototype.object = function() {
1771 %CheckExecutionState(this.break_id_); 1794 if (!IS_UNDEFINED(this.break_id_)) {
1795 %CheckExecutionState(this.break_id_);
1796 }
1772 return this.details_[kScopeDetailsObjectIndex]; 1797 return this.details_[kScopeDetailsObjectIndex];
1773 }; 1798 };
1774 1799
1775 1800
1776 /** 1801 /**
1777 * Mirror object for scope. 1802 * Mirror object for scope of frame or function. Either frame or function must
1803 * be specified.
1778 * @param {FrameMirror} frame The frame this scope is a part of 1804 * @param {FrameMirror} frame The frame this scope is a part of
1805 * @param {FunctionMirror} function The function this scope is a part of
1779 * @param {number} index The scope index in the frame 1806 * @param {number} index The scope index in the frame
1780 * @constructor 1807 * @constructor
1781 * @extends Mirror 1808 * @extends Mirror
1782 */ 1809 */
1783 function ScopeMirror(frame, index) { 1810 function ScopeMirror(frame, function, index) {
1784 %_CallFunction(this, SCOPE_TYPE, Mirror); 1811 %_CallFunction(this, SCOPE_TYPE, Mirror);
1785 this.frame_index_ = frame.index_; 1812 if (frame) {
1813 this.frame_index_ = frame.index_;
1814 } else {
1815 this.frame_index_ = undefined;
1816 }
1786 this.scope_index_ = index; 1817 this.scope_index_ = index;
1787 this.details_ = new ScopeDetails(frame, index); 1818 this.details_ = new ScopeDetails(frame, function, index);
1788 } 1819 }
1789 inherits(ScopeMirror, Mirror); 1820 inherits(ScopeMirror, Mirror);
1790 1821
1791 1822
1792 ScopeMirror.prototype.frameIndex = function() { 1823 ScopeMirror.prototype.frameIndex = function() {
1793 return this.frame_index_; 1824 return this.frame_index_;
1794 }; 1825 };
1795 1826
1796 1827
1797 ScopeMirror.prototype.scopeIndex = function() { 1828 ScopeMirror.prototype.scopeIndex = function() {
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 content.resolved = mirror.resolved(); 2305 content.resolved = mirror.resolved();
2275 if (mirror.resolved()) { 2306 if (mirror.resolved()) {
2276 content.source = mirror.source(); 2307 content.source = mirror.source();
2277 } 2308 }
2278 if (mirror.script()) { 2309 if (mirror.script()) {
2279 content.script = this.serializeReference(mirror.script()); 2310 content.script = this.serializeReference(mirror.script());
2280 content.scriptId = mirror.script().id(); 2311 content.scriptId = mirror.script().id();
2281 2312
2282 serializeLocationFields(mirror.sourceLocation(), content); 2313 serializeLocationFields(mirror.sourceLocation(), content);
2283 } 2314 }
2315
2316 content.scopes = [];
2317 for (var i = 0; i < mirror.scopeCount(); i++) {
2318 var scope = mirror.scope(i);
2319 content.scopes.push({
2320 type: scope.scopeType(),
2321 index: i
2322 });
2323 }
2284 } 2324 }
2285 2325
2286 // Add date specific properties. 2326 // Add date specific properties.
2287 if (mirror.isDate()) { 2327 if (mirror.isDate()) {
2288 // Add date specific properties. 2328 // Add date specific properties.
2289 content.value = mirror.value(); 2329 content.value = mirror.value();
2290 } 2330 }
2291 2331
2292 // Add actual properties - named properties followed by indexed properties. 2332 // Add actual properties - named properties followed by indexed properties.
2293 var propertyNames = mirror.propertyNames(PropertyKind.Named); 2333 var propertyNames = mirror.propertyNames(PropertyKind.Named);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 } 2490 }
2451 if (!NUMBER_IS_FINITE(value)) { 2491 if (!NUMBER_IS_FINITE(value)) {
2452 if (value > 0) { 2492 if (value > 0) {
2453 return 'Infinity'; 2493 return 'Infinity';
2454 } else { 2494 } else {
2455 return '-Infinity'; 2495 return '-Infinity';
2456 } 2496 }
2457 } 2497 }
2458 return value; 2498 return value;
2459 } 2499 }
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