| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 return numbers; | 388 return numbers; |
| 389 | 389 |
| 390 for (var i = 0; i < breakpoints.length; i++) { | 390 for (var i = 0; i < breakpoints.length; i++) { |
| 391 var breakpoint = breakpoints[i]; | 391 var breakpoint = breakpoints[i]; |
| 392 var scriptBreakPoint = breakpoint.script_break_point(); | 392 var scriptBreakPoint = breakpoint.script_break_point(); |
| 393 numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.n
umber()); | 393 numbers.push(scriptBreakPoint ? scriptBreakPoint.number() : breakpoint.n
umber()); |
| 394 } | 394 } |
| 395 return numbers; | 395 return numbers; |
| 396 } | 396 } |
| 397 | 397 |
| 398 // NOTE: This function is performance critical, as it can be run on every | |
| 399 // statement that generates an async event (like addEventListener) to support | |
| 400 // asynchronous call stacks. Thus, when possible, initialize the data lazily. | |
| 401 /** | 398 /** |
| 402 * @param {!FrameMirror} frameMirror | 399 * @param {!FrameMirror} frameMirror |
| 403 * @return {!JavaScriptCallFrame} | 400 * @return {!JavaScriptCallFrame} |
| 404 */ | 401 */ |
| 405 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror) | 402 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror) |
| 406 { | 403 { |
| 407 // Stuff that can not be initialized lazily (i.e. valid while paused with a
valid break_id). | 404 // Stuff that can not be initialized lazily (i.e. valid while paused with a
valid break_id). |
| 408 // The frameMirror and scopeMirror can be accessed only while paused on the
debugger. | 405 // The frameMirror and scopeMirror can be accessed only while paused on the
debugger. |
| 409 var frameDetails = frameMirror.details(); | 406 var frameDetails = frameMirror.details(); |
| 410 | 407 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 }; | 656 }; |
| 660 } | 657 } |
| 661 | 658 |
| 662 /** | 659 /** |
| 663 * @param {number} scopeType | 660 * @param {number} scopeType |
| 664 * @param {!Object} scopeObject | 661 * @param {!Object} scopeObject |
| 665 * @return {!Object|undefined} | 662 * @return {!Object|undefined} |
| 666 */ | 663 */ |
| 667 DebuggerScript._buildScopeObject = function(scopeType, scopeObject) | 664 DebuggerScript._buildScopeObject = function(scopeType, scopeObject) |
| 668 { | 665 { |
| 669 var result; | 666 // Almost always Script scope will be empty, so just filter out that noise. |
| 670 switch (scopeType) { | 667 // Also drop empty Block scopes, should we get any. |
| 671 case ScopeType.Local: | 668 if (scopeType === ScopeType.Script || scopeType === ScopeType.Block) { |
| 672 case ScopeType.Closure: | 669 if (Object.getOwnPropertyNames(scopeObject).length === 0) |
| 673 case ScopeType.Catch: | 670 return undefined; |
| 674 case ScopeType.Block: | |
| 675 case ScopeType.Script: | |
| 676 // For transient objects we create a "persistent" copy that contains | |
| 677 // the same properties. | |
| 678 // Reset scope object prototype to null so that the proto properties | |
| 679 // don't appear in the local scope section. | |
| 680 var properties = /** @type {!ObjectMirror} */(MakeMirror(scopeObject, tr
ue /* transient */)).properties(); | |
| 681 // Almost always Script scope will be empty, so just filter out that noi
se. | |
| 682 // Also drop empty Block scopes, should we get any. | |
| 683 if (!properties.length && (scopeType === ScopeType.Script || scopeType =
== ScopeType.Block)) | |
| 684 break; | |
| 685 result = { __proto__: null }; | |
| 686 for (var j = 0; j < properties.length; j++) { | |
| 687 var name = properties[j].name(); | |
| 688 if (name.length === 0 || name.charAt(0) === ".") | |
| 689 continue; // Skip internal variables like ".arguments" and varia
bles with empty name | |
| 690 result[name] = properties[j].value_; | |
| 691 } | |
| 692 break; | |
| 693 case ScopeType.Global: | |
| 694 case ScopeType.With: | |
| 695 result = scopeObject; | |
| 696 break; | |
| 697 } | 671 } |
| 698 return result; | 672 return scopeObject; |
| 699 } | 673 } |
| 700 | 674 |
| 701 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | 675 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. |
| 702 ToggleMirrorCache(false); | 676 ToggleMirrorCache(false); |
| 703 | 677 |
| 704 return DebuggerScript; | 678 return DebuggerScript; |
| 705 })(); | 679 })(); |
| OLD | NEW |