| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 * @param {!FrameMirror} frameMirror | 409 * @param {!FrameMirror} frameMirror |
| 410 * @return {!JavaScriptCallFrame} | 410 * @return {!JavaScriptCallFrame} |
| 411 */ | 411 */ |
| 412 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror) | 412 DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror) |
| 413 { | 413 { |
| 414 // Stuff that can not be initialized lazily (i.e. valid while paused with a
valid break_id). | 414 // Stuff that can not be initialized lazily (i.e. valid while paused with a
valid break_id). |
| 415 // The frameMirror and scopeMirror can be accessed only while paused on the
debugger. | 415 // The frameMirror and scopeMirror can be accessed only while paused on the
debugger. |
| 416 var frameDetails = frameMirror.details(); | 416 var frameDetails = frameMirror.details(); |
| 417 | 417 |
| 418 var funcObject = frameDetails.func(); | 418 var funcObject = frameDetails.func(); |
| 419 var scriptObject = frameDetails.script(); |
| 419 var sourcePosition = frameDetails.sourcePosition(); | 420 var sourcePosition = frameDetails.sourcePosition(); |
| 420 var thisObject = frameDetails.receiver(); | 421 var thisObject = frameDetails.receiver(); |
| 421 | 422 |
| 422 var isAtReturn = !!frameDetails.isAtReturn(); | 423 var isAtReturn = !!frameDetails.isAtReturn(); |
| 423 var returnValue = isAtReturn ? frameDetails.returnValue() : undefined; | 424 var returnValue = isAtReturn ? frameDetails.returnValue() : undefined; |
| 424 | 425 |
| 425 var scopeMirrors = frameMirror.allScopes(false); | 426 var scopeMirrors = frameMirror.allScopes(false); |
| 426 /** @type {!Array<number>} */ | 427 /** @type {!Array<number>} */ |
| 427 var scopeTypes = new Array(scopeMirrors.length); | 428 var scopeTypes = new Array(scopeMirrors.length); |
| 428 /** @type {?Array<!Object>} */ | 429 /** @type {?Array<!Object>} */ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 441 scopeObjects[i] = scopeDetails.object(); | 442 scopeObjects[i] = scopeDetails.object(); |
| 442 scopeNames[i] = scopeDetails.name(); | 443 scopeNames[i] = scopeDetails.name(); |
| 443 scopeStartPositions[i] = scopeDetails.startPosition ? scopeDetails.start
Position() : 0; | 444 scopeStartPositions[i] = scopeDetails.startPosition ? scopeDetails.start
Position() : 0; |
| 444 scopeEndPositions[i] = scopeDetails.endPosition ? scopeDetails.endPositi
on() : 0; | 445 scopeEndPositions[i] = scopeDetails.endPosition ? scopeDetails.endPositi
on() : 0; |
| 445 scopeFunctions[i] = scopeDetails.func ? scopeDetails.func() : null; | 446 scopeFunctions[i] = scopeDetails.func ? scopeDetails.func() : null; |
| 446 } | 447 } |
| 447 | 448 |
| 448 // Calculated lazily. | 449 // Calculated lazily. |
| 449 var scopeChain; | 450 var scopeChain; |
| 450 var funcMirror; | 451 var funcMirror; |
| 452 var scriptMirror; |
| 451 var location; | 453 var location; |
| 452 /** @type {!Array<?RawLocation>} */ | 454 /** @type {!Array<?RawLocation>} */ |
| 453 var scopeStartLocations; | 455 var scopeStartLocations; |
| 454 /** @type {!Array<?RawLocation>} */ | 456 /** @type {!Array<?RawLocation>} */ |
| 455 var scopeEndLocations; | 457 var scopeEndLocations; |
| 456 var details; | 458 var details; |
| 457 | 459 |
| 458 /** | 460 /** |
| 459 * @param {!ScriptMirror|undefined} script | 461 * @param {!ScriptMirror|undefined} script |
| 460 * @param {number} pos | 462 * @param {number} pos |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 return scopeChain; | 511 return scopeChain; |
| 510 } | 512 } |
| 511 | 513 |
| 512 /** | 514 /** |
| 513 * @return {!JavaScriptCallFrameDetails} | 515 * @return {!JavaScriptCallFrameDetails} |
| 514 */ | 516 */ |
| 515 function lazyDetails() | 517 function lazyDetails() |
| 516 { | 518 { |
| 517 if (!details) { | 519 if (!details) { |
| 518 var scopeObjects = ensureScopeChain(); | 520 var scopeObjects = ensureScopeChain(); |
| 519 var script = ensureFuncMirror().script(); | 521 var script = ensureScriptMirror(); |
| 520 /** @type {!Array<Scope>} */ | 522 /** @type {!Array<Scope>} */ |
| 521 var scopes = []; | 523 var scopes = []; |
| 522 for (var i = 0; i < scopeObjects.length; ++i) { | 524 for (var i = 0; i < scopeObjects.length; ++i) { |
| 523 var scope = { | 525 var scope = { |
| 524 "type": /** @type {string} */(DebuggerScript._scopeTypeNames
.get(scopeTypes[i])), | 526 "type": /** @type {string} */(DebuggerScript._scopeTypeNames
.get(scopeTypes[i])), |
| 525 "object": scopeObjects[i], | 527 "object": scopeObjects[i], |
| 526 }; | 528 }; |
| 527 if (scopeNames[i]) | 529 if (scopeNames[i]) |
| 528 scope.name = scopeNames[i]; | 530 scope.name = scopeNames[i]; |
| 529 if (scopeStartLocations[i]) | 531 if (scopeStartLocations[i]) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 { | 565 { |
| 564 if (!funcMirror) { | 566 if (!funcMirror) { |
| 565 funcMirror = MakeMirror(funcObject); | 567 funcMirror = MakeMirror(funcObject); |
| 566 if (!funcMirror.isFunction()) | 568 if (!funcMirror.isFunction()) |
| 567 funcMirror = new UnresolvedFunctionMirror(funcObject); | 569 funcMirror = new UnresolvedFunctionMirror(funcObject); |
| 568 } | 570 } |
| 569 return /** @type {!FunctionMirror} */(funcMirror); | 571 return /** @type {!FunctionMirror} */(funcMirror); |
| 570 } | 572 } |
| 571 | 573 |
| 572 /** | 574 /** |
| 575 * @return {!ScriptMirror} |
| 576 */ |
| 577 function ensureScriptMirror() |
| 578 { |
| 579 if (!scriptMirror) { |
| 580 scriptMirror = MakeMirror(scriptObject); |
| 581 } |
| 582 return /** @type {!ScriptMirror} */(scriptMirror); |
| 583 } |
| 584 |
| 585 /** |
| 573 * @return {!{line: number, column: number}} | 586 * @return {!{line: number, column: number}} |
| 574 */ | 587 */ |
| 575 function ensureLocation() | 588 function ensureLocation() |
| 576 { | 589 { |
| 577 if (!location) { | 590 if (!location) { |
| 578 var script = ensureFuncMirror().script(); | 591 var script = ensureScriptMirror(); |
| 579 if (script) | 592 location = script.locationFromPosition(sourcePosition, true); |
| 580 location = script.locationFromPosition(sourcePosition, true); | |
| 581 if (!location) | 593 if (!location) |
| 582 location = { line: 0, column: 0 }; | 594 location = { line: 0, column: 0 }; |
| 583 } | 595 } |
| 584 return location; | 596 return location; |
| 585 } | 597 } |
| 586 | 598 |
| 587 /** | 599 /** |
| 588 * @return {number} | 600 * @return {number} |
| 589 */ | 601 */ |
| 590 function line() | 602 function line() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 609 // Old V8 do not have context() function on these objects | 621 // Old V8 do not have context() function on these objects |
| 610 if (!mirror.context) | 622 if (!mirror.context) |
| 611 return DebuggerScript._executionContextId(mirror.script().value().co
ntext_data); | 623 return DebuggerScript._executionContextId(mirror.script().value().co
ntext_data); |
| 612 var context = mirror.context(); | 624 var context = mirror.context(); |
| 613 if (context) | 625 if (context) |
| 614 return DebuggerScript._executionContextId(context.data()); | 626 return DebuggerScript._executionContextId(context.data()); |
| 615 return 0; | 627 return 0; |
| 616 } | 628 } |
| 617 | 629 |
| 618 /** | 630 /** |
| 619 * @return {number|undefined} | 631 * @return {number} |
| 620 */ | 632 */ |
| 621 function sourceID() | 633 function sourceID() |
| 622 { | 634 { |
| 623 var script = ensureFuncMirror().script(); | 635 var script = ensureScriptMirror(); |
| 624 return script && script.id(); | 636 return script.id(); |
| 625 } | 637 } |
| 626 | 638 |
| 627 /** | 639 /** |
| 628 * @param {string} expression | 640 * @param {string} expression |
| 629 * @return {*} | 641 * @return {*} |
| 630 */ | 642 */ |
| 631 function evaluate(expression) | 643 function evaluate(expression) |
| 632 { | 644 { |
| 633 return frameMirror.evaluate(expression, false).value(); | 645 return frameMirror.evaluate(expression, false).value(); |
| 634 } | 646 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 break; | 715 break; |
| 704 } | 716 } |
| 705 return result; | 717 return result; |
| 706 } | 718 } |
| 707 | 719 |
| 708 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | 720 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. |
| 709 ToggleMirrorCache(false); | 721 ToggleMirrorCache(false); |
| 710 | 722 |
| 711 return DebuggerScript; | 723 return DebuggerScript; |
| 712 })(); | 724 })(); |
| OLD | NEW |