| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (mirror.isSet() || mirror.isIterator()) { | 132 if (mirror.isSet() || mirror.isIterator()) { |
| 133 var result = []; | 133 var result = []; |
| 134 var values = mirror.isSet() ? /** @type {!SetMirror} */(mirror).values()
: /** @type {!IteratorMirror} */(mirror).preview(); | 134 var values = mirror.isSet() ? /** @type {!SetMirror} */(mirror).values()
: /** @type {!IteratorMirror} */(mirror).preview(); |
| 135 for (var i = 0; i < values.length; ++i) | 135 for (var i = 0; i < values.length; ++i) |
| 136 result.push({ value: values[i] }); | 136 result.push({ value: values[i] }); |
| 137 return result; | 137 return result; |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * @param {string|undefined} contextData |
| 143 * @return {number} |
| 144 */ |
| 145 DebuggerScript._executionContextId = function(contextData) |
| 146 { |
| 147 if (!contextData) |
| 148 return 0; |
| 149 var firstComma = contextData.indexOf(","); |
| 150 if (firstComma === -1) |
| 151 return 0; |
| 152 var secondComma = contextData.indexOf(",", firstComma + 1); |
| 153 if (secondComma === -1) |
| 154 return 0; |
| 155 |
| 156 return parseInt(contextData.substring(firstComma + 1, secondComma), 10) || 0
; |
| 157 } |
| 158 |
| 159 /** |
| 142 * @param {string} contextGroupId | 160 * @param {string} contextGroupId |
| 143 * @return {!Array<!FormattedScript>} | 161 * @return {!Array<!FormattedScript>} |
| 144 */ | 162 */ |
| 145 DebuggerScript.getScripts = function(contextGroupId) | 163 DebuggerScript.getScripts = function(contextGroupId) |
| 146 { | 164 { |
| 147 var result = []; | 165 var result = []; |
| 148 var scripts = Debug.scripts(); | 166 var scripts = Debug.scripts(); |
| 149 var contextDataPrefix = null; | 167 var contextDataPrefix = null; |
| 150 if (contextGroupId) | 168 if (contextGroupId) |
| 151 contextDataPrefix = contextGroupId + ","; | 169 contextDataPrefix = contextGroupId + ","; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 177 // V8 will not count last line if script source ends with \n. | 195 // V8 will not count last line if script source ends with \n. |
| 178 if (script.source[script.source.length - 1] === '\n') { | 196 if (script.source[script.source.length - 1] === '\n') { |
| 179 endLine += 1; | 197 endLine += 1; |
| 180 endColumn = 0; | 198 endColumn = 0; |
| 181 } else { | 199 } else { |
| 182 if (lineCount === 1) | 200 if (lineCount === 1) |
| 183 endColumn = script.source.length + script.column_offset; | 201 endColumn = script.source.length + script.column_offset; |
| 184 else | 202 else |
| 185 endColumn = script.source.length - (lineEnds[lineCount - 2] + 1); | 203 endColumn = script.source.length - (lineEnds[lineCount - 2] + 1); |
| 186 } | 204 } |
| 187 | |
| 188 /** | |
| 189 * @return {number} | |
| 190 */ | |
| 191 function executionContextId() | |
| 192 { | |
| 193 var context_data = script.context_data; | |
| 194 if (!context_data) | |
| 195 return 0; | |
| 196 var firstComma = context_data.indexOf(","); | |
| 197 if (firstComma === -1) | |
| 198 return 0; | |
| 199 var secondComma = context_data.indexOf(",", firstComma + 1); | |
| 200 if (secondComma === -1) | |
| 201 return 0; | |
| 202 | |
| 203 return parseInt(context_data.substring(firstComma + 1, secondComma), 10)
|| 0; | |
| 204 } | |
| 205 | |
| 206 return { | 205 return { |
| 207 id: script.id, | 206 id: script.id, |
| 208 name: script.nameOrSourceURL(), | 207 name: script.nameOrSourceURL(), |
| 209 sourceURL: script.source_url, | 208 sourceURL: script.source_url, |
| 210 sourceMappingURL: script.source_mapping_url, | 209 sourceMappingURL: script.source_mapping_url, |
| 211 source: script.source, | 210 source: script.source, |
| 212 startLine: script.line_offset, | 211 startLine: script.line_offset, |
| 213 startColumn: script.column_offset, | 212 startColumn: script.column_offset, |
| 214 endLine: endLine, | 213 endLine: endLine, |
| 215 endColumn: endColumn, | 214 endColumn: endColumn, |
| 216 executionContextId: executionContextId(), | 215 executionContextId: DebuggerScript._executionContextId(script.context_da
ta), |
| 217 isContentScript: !!script.context_data && script.context_data.endsWith("
,nondefault"), | 216 isContentScript: !!script.context_data && script.context_data.endsWith("
,nondefault"), |
| 218 isInternalScript: script.is_debugger_script | 217 isInternalScript: script.is_debugger_script |
| 219 }; | 218 }; |
| 220 } | 219 } |
| 221 | 220 |
| 222 /** | 221 /** |
| 223 * @param {!ExecutionState} execState | 222 * @param {!ExecutionState} execState |
| 224 * @param {!BreakpointInfo} info | 223 * @param {!BreakpointInfo} info |
| 225 * @return {string|undefined} | 224 * @return {string|undefined} |
| 226 */ | 225 */ |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 587 |
| 589 /** | 588 /** |
| 590 * @return {number} | 589 * @return {number} |
| 591 */ | 590 */ |
| 592 function column() | 591 function column() |
| 593 { | 592 { |
| 594 return ensureLocation().column; | 593 return ensureLocation().column; |
| 595 } | 594 } |
| 596 | 595 |
| 597 /** | 596 /** |
| 597 * @return {number} |
| 598 */ |
| 599 function contextId() |
| 600 { |
| 601 var context = ensureFuncMirror().context(); |
| 602 if (context) |
| 603 return DebuggerScript._executionContextId(context.data()); |
| 604 return 0; |
| 605 } |
| 606 |
| 607 /** |
| 598 * @return {number|undefined} | 608 * @return {number|undefined} |
| 599 */ | 609 */ |
| 600 function sourceID() | 610 function sourceID() |
| 601 { | 611 { |
| 602 var script = ensureFuncMirror().script(); | 612 var script = ensureFuncMirror().script(); |
| 603 return script && script.id(); | 613 return script && script.id(); |
| 604 } | 614 } |
| 605 | 615 |
| 606 /** | 616 /** |
| 607 * @param {string} expression | 617 * @param {string} expression |
| (...skipping 20 matching lines...) Expand all Loading... |
| 628 var scopeMirror = frameMirror.scope(scopeNumber); | 638 var scopeMirror = frameMirror.scope(scopeNumber); |
| 629 if (!scopeMirror) | 639 if (!scopeMirror) |
| 630 throw new Error("Incorrect scope index"); | 640 throw new Error("Incorrect scope index"); |
| 631 scopeMirror.setVariableValue(variableName, newValue); | 641 scopeMirror.setVariableValue(variableName, newValue); |
| 632 } | 642 } |
| 633 | 643 |
| 634 return { | 644 return { |
| 635 "sourceID": sourceID, | 645 "sourceID": sourceID, |
| 636 "line": line, | 646 "line": line, |
| 637 "column": column, | 647 "column": column, |
| 648 "contextId": contextId, |
| 638 "thisObject": thisObject, | 649 "thisObject": thisObject, |
| 639 "evaluate": evaluate, | 650 "evaluate": evaluate, |
| 640 "restart": restart, | 651 "restart": restart, |
| 641 "setVariableValue": setVariableValue, | 652 "setVariableValue": setVariableValue, |
| 642 "isAtReturn": isAtReturn, | 653 "isAtReturn": isAtReturn, |
| 643 "details": lazyDetails | 654 "details": lazyDetails |
| 644 }; | 655 }; |
| 645 } | 656 } |
| 646 | 657 |
| 647 /** | 658 /** |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 break; | 692 break; |
| 682 } | 693 } |
| 683 return result; | 694 return result; |
| 684 } | 695 } |
| 685 | 696 |
| 686 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | 697 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. |
| 687 ToggleMirrorCache(false); | 698 ToggleMirrorCache(false); |
| 688 | 699 |
| 689 return DebuggerScript; | 700 return DebuggerScript; |
| 690 })(); | 701 })(); |
| OLD | NEW |