| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 return result; | 101 return result; |
| 102 } | 102 } |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * @param {Object} object | 105 * @param {Object} object |
| 106 * @return {?RawLocation} | 106 * @return {?RawLocation} |
| 107 */ | 107 */ |
| 108 DebuggerScript.getGeneratorObjectLocation = function(object) | 108 DebuggerScript.getGeneratorObjectLocation = function(object) |
| 109 { | 109 { |
| 110 var mirror = MakeMirror(object, true /* transient */); | 110 var mirror = MakeMirror(object); |
| 111 if (!mirror.isGenerator()) | 111 if (!mirror.isGenerator()) |
| 112 return null; | 112 return null; |
| 113 var generatorMirror = /** @type {!GeneratorMirror} */(mirror); | 113 var generatorMirror = /** @type {!GeneratorMirror} */(mirror); |
| 114 var funcMirror = generatorMirror.func(); | 114 var funcMirror = generatorMirror.func(); |
| 115 if (!funcMirror.resolved()) | 115 if (!funcMirror.resolved()) |
| 116 return null; | 116 return null; |
| 117 var location = generatorMirror.sourceLocation() || funcMirror.sourceLocation
(); | 117 var location = generatorMirror.sourceLocation() || funcMirror.sourceLocation
(); |
| 118 var script = funcMirror.script(); | 118 var script = funcMirror.script(); |
| 119 if (script && location) { | 119 if (script && location) { |
| 120 return { | 120 return { |
| 121 scriptId: "" + script.id(), | 121 scriptId: "" + script.id(), |
| 122 lineNumber: location.line, | 122 lineNumber: location.line, |
| 123 columnNumber: location.column | 123 columnNumber: location.column |
| 124 }; | 124 }; |
| 125 } | 125 } |
| 126 return null; | 126 return null; |
| 127 } | 127 } |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * @param {Object} object | 130 * @param {Object} object |
| 131 * @return {!Array<!{value: *}>|undefined} | 131 * @return {!Array<!{value: *}>|undefined} |
| 132 */ | 132 */ |
| 133 DebuggerScript.getCollectionEntries = function(object) | 133 DebuggerScript.getCollectionEntries = function(object) |
| 134 { | 134 { |
| 135 var mirror = MakeMirror(object, true /* transient */); | 135 var mirror = MakeMirror(object); |
| 136 if (mirror.isMap()) | 136 if (mirror.isMap()) |
| 137 return /** @type {!MapMirror} */(mirror).entries(); | 137 return /** @type {!MapMirror} */(mirror).entries(); |
| 138 if (mirror.isSet() || mirror.isIterator()) { | 138 if (mirror.isSet() || mirror.isIterator()) { |
| 139 var result = []; | 139 var result = []; |
| 140 var values = mirror.isSet() ? /** @type {!SetMirror} */(mirror).values()
: /** @type {!IteratorMirror} */(mirror).preview(); | 140 var values = mirror.isSet() ? /** @type {!SetMirror} */(mirror).values()
: /** @type {!IteratorMirror} */(mirror).preview(); |
| 141 for (var i = 0; i < values.length; ++i) | 141 for (var i = 0; i < values.length; ++i) |
| 142 result.push({ value: values[i] }); | 142 result.push({ value: values[i] }); |
| 143 return result; | 143 return result; |
| 144 } | 144 } |
| 145 } | 145 } |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 case ScopeType.Closure: | 541 case ScopeType.Closure: |
| 542 case ScopeType.Catch: | 542 case ScopeType.Catch: |
| 543 case ScopeType.Block: | 543 case ScopeType.Block: |
| 544 case ScopeType.Script: | 544 case ScopeType.Script: |
| 545 case ScopeType.Eval: | 545 case ScopeType.Eval: |
| 546 case ScopeType.Module: | 546 case ScopeType.Module: |
| 547 // For transient objects we create a "persistent" copy that contains | 547 // For transient objects we create a "persistent" copy that contains |
| 548 // the same properties. | 548 // the same properties. |
| 549 // Reset scope object prototype to null so that the proto properties | 549 // Reset scope object prototype to null so that the proto properties |
| 550 // don't appear in the local scope section. | 550 // don't appear in the local scope section. |
| 551 var properties = /** @type {!ObjectMirror} */(MakeMirror(scopeObject, tr
ue /* transient */)).properties(); | 551 var properties = /** @type {!ObjectMirror} */(MakeMirror(scopeObject)).p
roperties(); |
| 552 // Almost always Script scope will be empty, so just filter out that noi
se. | 552 // Almost always Script scope will be empty, so just filter out that noi
se. |
| 553 // Also drop empty Block, Eval and Script scopes, should we get any. | 553 // Also drop empty Block, Eval and Script scopes, should we get any. |
| 554 if (!properties.length && (scopeType === ScopeType.Script || | 554 if (!properties.length && (scopeType === ScopeType.Script || |
| 555 scopeType === ScopeType.Block || | 555 scopeType === ScopeType.Block || |
| 556 scopeType === ScopeType.Eval || | 556 scopeType === ScopeType.Eval || |
| 557 scopeType === ScopeType.Module)) { | 557 scopeType === ScopeType.Module)) { |
| 558 break; | 558 break; |
| 559 } | 559 } |
| 560 result = { __proto__: null }; | 560 result = { __proto__: null }; |
| 561 for (var j = 0; j < properties.length; j++) { | 561 for (var j = 0; j < properties.length; j++) { |
| 562 var name = properties[j].name(); | 562 var name = properties[j].name(); |
| 563 if (name.length === 0 || name.charAt(0) === ".") | 563 if (name.length === 0 || name.charAt(0) === ".") |
| 564 continue; // Skip internal variables like ".arguments" and varia
bles with empty name | 564 continue; // Skip internal variables like ".arguments" and varia
bles with empty name |
| 565 result[name] = properties[j].value_; | 565 result[name] = properties[j].value_; |
| 566 } | 566 } |
| 567 break; | 567 break; |
| 568 case ScopeType.Global: | 568 case ScopeType.Global: |
| 569 case ScopeType.With: | 569 case ScopeType.With: |
| 570 result = scopeObject; | 570 result = scopeObject; |
| 571 break; | 571 break; |
| 572 } | 572 } |
| 573 return result; | 573 return result; |
| 574 } | 574 } |
| 575 | 575 |
| 576 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | |
| 577 ToggleMirrorCache(false); | |
| 578 | |
| 579 return DebuggerScript; | 576 return DebuggerScript; |
| 580 })(); | 577 })(); |
| OLD | NEW |