| 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 {!Script} script |
| 143 * @return {number} |
| 144 */ |
| 145 DebuggerScript._executionContextId = function(script) |
| 146 { |
| 147 var context_data = script.context_data; |
| 148 if (!context_data) |
| 149 return 0; |
| 150 var firstComma = context_data.indexOf(","); |
| 151 if (firstComma === -1) |
| 152 return 0; |
| 153 var secondComma = context_data.indexOf(",", firstComma + 1); |
| 154 if (secondComma === -1) |
| 155 return 0; |
| 156 |
| 157 return parseInt(context_data.substring(firstComma + 1, secondComma), 10) ||
0; |
| 158 } |
| 159 |
| 160 /** |
| 142 * @param {string} contextGroupId | 161 * @param {string} contextGroupId |
| 143 * @return {!Array<!FormattedScript>} | 162 * @return {!Array<!FormattedScript>} |
| 144 */ | 163 */ |
| 145 DebuggerScript.getScripts = function(contextGroupId) | 164 DebuggerScript.getScripts = function(contextGroupId) |
| 146 { | 165 { |
| 147 var result = []; | 166 var result = []; |
| 148 var scripts = Debug.scripts(); | 167 var scripts = Debug.scripts(); |
| 149 var contextDataPrefix = null; | 168 var contextDataPrefix = null; |
| 150 if (contextGroupId) | 169 if (contextGroupId) |
| 151 contextDataPrefix = contextGroupId + ","; | 170 contextDataPrefix = contextGroupId + ","; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 177 // V8 will not count last line if script source ends with \n. | 196 // V8 will not count last line if script source ends with \n. |
| 178 if (script.source[script.source.length - 1] === '\n') { | 197 if (script.source[script.source.length - 1] === '\n') { |
| 179 endLine += 1; | 198 endLine += 1; |
| 180 endColumn = 0; | 199 endColumn = 0; |
| 181 } else { | 200 } else { |
| 182 if (lineCount === 1) | 201 if (lineCount === 1) |
| 183 endColumn = script.source.length + script.column_offset; | 202 endColumn = script.source.length + script.column_offset; |
| 184 else | 203 else |
| 185 endColumn = script.source.length - (lineEnds[lineCount - 2] + 1); | 204 endColumn = script.source.length - (lineEnds[lineCount - 2] + 1); |
| 186 } | 205 } |
| 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 { | 206 return { |
| 207 id: script.id, | 207 id: script.id, |
| 208 name: script.nameOrSourceURL(), | 208 name: script.nameOrSourceURL(), |
| 209 sourceURL: script.source_url, | 209 sourceURL: script.source_url, |
| 210 sourceMappingURL: script.source_mapping_url, | 210 sourceMappingURL: script.source_mapping_url, |
| 211 source: script.source, | 211 source: script.source, |
| 212 startLine: script.line_offset, | 212 startLine: script.line_offset, |
| 213 startColumn: script.column_offset, | 213 startColumn: script.column_offset, |
| 214 endLine: endLine, | 214 endLine: endLine, |
| 215 endColumn: endColumn, | 215 endColumn: endColumn, |
| 216 executionContextId: executionContextId(), | 216 executionContextId: DebuggerScript._executionContextId(script), |
| 217 isContentScript: !!script.context_data && script.context_data.endsWith("
,injected"), | 217 isContentScript: !!script.context_data && script.context_data.endsWith("
,injected"), |
| 218 isInternalScript: script.is_debugger_script | 218 isInternalScript: script.is_debugger_script |
| 219 }; | 219 }; |
| 220 } | 220 } |
| 221 | 221 |
| 222 /** | 222 /** |
| 223 * @param {!ExecutionState} execState | 223 * @param {!ExecutionState} execState |
| 224 * @param {!BreakpointInfo} info | 224 * @param {!BreakpointInfo} info |
| 225 * @return {string|undefined} | 225 * @return {string|undefined} |
| 226 */ | 226 */ |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 /** | 616 /** |
| 617 * @return {number} | 617 * @return {number} |
| 618 */ | 618 */ |
| 619 function column() | 619 function column() |
| 620 { | 620 { |
| 621 return ensureLocation().column; | 621 return ensureLocation().column; |
| 622 } | 622 } |
| 623 | 623 |
| 624 /** | 624 /** |
| 625 * @return {number} |
| 626 */ |
| 627 function contextId() |
| 628 { |
| 629 var script = ensureFuncMirror().script(); |
| 630 return script ? DebuggerScript._executionContextId(script.value()) : 0; |
| 631 } |
| 632 |
| 633 /** |
| 625 * @return {number|undefined} | 634 * @return {number|undefined} |
| 626 */ | 635 */ |
| 627 function sourceID() | 636 function sourceID() |
| 628 { | 637 { |
| 629 var script = ensureFuncMirror().script(); | 638 var script = ensureFuncMirror().script(); |
| 630 return script && script.id(); | 639 return script && script.id(); |
| 631 } | 640 } |
| 632 | 641 |
| 633 /** | 642 /** |
| 634 * @param {string} expression | 643 * @param {string} expression |
| (...skipping 20 matching lines...) Expand all Loading... |
| 655 var scopeMirror = frameMirror.scope(scopeNumber); | 664 var scopeMirror = frameMirror.scope(scopeNumber); |
| 656 if (!scopeMirror) | 665 if (!scopeMirror) |
| 657 throw new Error("Incorrect scope index"); | 666 throw new Error("Incorrect scope index"); |
| 658 scopeMirror.setVariableValue(variableName, newValue); | 667 scopeMirror.setVariableValue(variableName, newValue); |
| 659 } | 668 } |
| 660 | 669 |
| 661 return { | 670 return { |
| 662 "sourceID": sourceID, | 671 "sourceID": sourceID, |
| 663 "line": line, | 672 "line": line, |
| 664 "column": column, | 673 "column": column, |
| 674 "contextId": contextId, |
| 665 "thisObject": thisObject, | 675 "thisObject": thisObject, |
| 666 "evaluate": evaluate, | 676 "evaluate": evaluate, |
| 667 "caller": callerFrame, | 677 "caller": callerFrame, |
| 668 "restart": restart, | 678 "restart": restart, |
| 669 "setVariableValue": setVariableValue, | 679 "setVariableValue": setVariableValue, |
| 670 "isAtReturn": isAtReturn, | 680 "isAtReturn": isAtReturn, |
| 671 "details": lazyDetails | 681 "details": lazyDetails |
| 672 }; | 682 }; |
| 673 } | 683 } |
| 674 | 684 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 break; | 719 break; |
| 710 } | 720 } |
| 711 return result; | 721 return result; |
| 712 } | 722 } |
| 713 | 723 |
| 714 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | 724 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. |
| 715 ToggleMirrorCache(false); | 725 ToggleMirrorCache(false); |
| 716 | 726 |
| 717 return DebuggerScript; | 727 return DebuggerScript; |
| 718 })(); | 728 })(); |
| OLD | NEW |