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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 var sourcePosition = frameDetails.sourcePosition(); | 394 var sourcePosition = frameDetails.sourcePosition(); |
395 var thisObject = frameDetails.receiver(); | 395 var thisObject = frameDetails.receiver(); |
396 | 396 |
397 var isAtReturn = !!frameDetails.isAtReturn(); | 397 var isAtReturn = !!frameDetails.isAtReturn(); |
398 var returnValue = isAtReturn ? frameDetails.returnValue() : undefined; | 398 var returnValue = isAtReturn ? frameDetails.returnValue() : undefined; |
399 | 399 |
400 var scopeMirrors = (scopeDetailsLevel === DebuggerScript.ScopeInfoDetails.No Scopes ? [] : frameMirror.allScopes(scopeDetailsLevel === DebuggerScript.ScopeIn foDetails.FastAsyncScopes)); | 400 var scopeMirrors = (scopeDetailsLevel === DebuggerScript.ScopeInfoDetails.No Scopes ? [] : frameMirror.allScopes(scopeDetailsLevel === DebuggerScript.ScopeIn foDetails.FastAsyncScopes)); |
401 var scopeTypes = new Array(scopeMirrors.length); | 401 var scopeTypes = new Array(scopeMirrors.length); |
402 var scopeObjects = new Array(scopeMirrors.length); | 402 var scopeObjects = new Array(scopeMirrors.length); |
403 var scopeNames = new Array(scopeMirrors.length); | 403 var scopeNames = new Array(scopeMirrors.length); |
404 var scopeStartPositions = new Array(scopeMirrors.length); | |
405 var scopeEndPositions = new Array(scopeMirrors.length); | |
406 var scopeFunctions = new Array(scopeMirrors.length); | |
404 for (var i = 0; i < scopeMirrors.length; ++i) { | 407 for (var i = 0; i < scopeMirrors.length; ++i) { |
405 var scopeDetails = scopeMirrors[i].details(); | 408 var scopeDetails = scopeMirrors[i].details(); |
406 scopeTypes[i] = scopeDetails.type(); | 409 scopeTypes[i] = scopeDetails.type(); |
407 scopeObjects[i] = scopeDetails.object(); | 410 scopeObjects[i] = scopeDetails.object(); |
408 scopeNames[i] = scopeDetails.name(); | 411 scopeNames[i] = scopeDetails.name(); |
412 scopeStartPositions[i] = scopeDetails.startPosition(); | |
413 scopeEndPositions[i] = scopeDetails.endPosition(); | |
414 scopeFunctions[i] = scopeDetails.func(); | |
409 } | 415 } |
410 | 416 |
411 // Calculated lazily. | 417 // Calculated lazily. |
412 var scopeChain; | 418 var scopeChain; |
413 var funcMirror; | 419 var funcMirror; |
414 var location; | 420 var location; |
421 var scopeStartLocations; | |
422 var scopeEndLocations; | |
423 | |
424 function createLocation(script, pos) | |
425 { | |
426 if (!script) | |
427 return null; | |
428 | |
429 location = script.locationFromPosition(pos, true); | |
430 return { | |
431 "lineNumber": location.line, | |
432 "columnNumber": location.column, | |
433 "scriptId": String(script.id()) | |
434 } | |
435 } | |
415 | 436 |
416 function lazyScopeChain() | 437 function lazyScopeChain() |
417 { | 438 { |
418 if (!scopeChain) { | 439 if (!scopeChain) { |
419 scopeChain = []; | 440 scopeChain = []; |
441 scopeStartLocations = []; | |
442 scopeEndLocations = []; | |
420 for (var i = 0, j = 0; i < scopeObjects.length; ++i) { | 443 for (var i = 0, j = 0; i < scopeObjects.length; ++i) { |
421 var scopeObject = DebuggerScript._buildScopeObject(scopeTypes[i] , scopeObjects[i], scopeNames[i]); | 444 var scopeObject = DebuggerScript._buildScopeObject(scopeTypes[i] , scopeObjects[i]); |
422 if (scopeObject) { | 445 if (scopeObject) { |
423 scopeTypes[j] = scopeTypes[i]; | 446 scopeTypes[j] = scopeTypes[i]; |
424 scopeNames[j] = scopeNames[i]; | 447 scopeNames[j] = scopeNames[i]; |
425 scopeChain[j] = scopeObject; | 448 scopeChain[j] = scopeObject; |
449 | |
450 var funcMirror = MakeMirror(scopeFunctions[i]); | |
451 if (!funcMirror.isFunction()) | |
452 funcMirror = new UnresolvedFunctionMirror(funcObject); | |
453 | |
454 var script = funcMirror.script(); | |
455 scopeStartLocations[j] = createLocation(script, scopeStartPo sitions[i]); | |
456 scopeEndLocations[j] = createLocation(script, scopeEndPositi ons[i]); | |
426 ++j; | 457 ++j; |
427 } | 458 } |
428 } | 459 } |
429 scopeTypes.length = scopeChain.length; | 460 scopeTypes.length = scopeChain.length; |
430 scopeNames.length = scopeChain.length; | 461 scopeNames.length = scopeChain.length; |
431 scopeObjects = null; // Free for GC. | 462 scopeObjects = null; // Free for GC. |
463 scopeFunctions = null; | |
464 scopeStartPositions = null; | |
465 scopeEndPositions = null; | |
466 | |
dgozman
2016/02/22 17:24:56
nit: extra blank line
sergeyv
2016/02/22 21:42:54
Done.
| |
432 } | 467 } |
433 return scopeChain; | 468 return scopeChain; |
434 } | 469 } |
435 | 470 |
436 function lazyScopeTypes() | 471 function lazyScopeTypes() |
437 { | 472 { |
438 if (!scopeChain) | 473 if (!scopeChain) |
439 lazyScopeChain(); | 474 lazyScopeChain(); |
440 return scopeTypes; | 475 return scopeTypes; |
441 } | 476 } |
442 | 477 |
443 function lazyScopeNames() | 478 function lazyScopeNames() |
444 { | 479 { |
445 if (!scopeChain) | 480 if (!scopeChain) |
446 lazyScopeChain(); | 481 lazyScopeChain(); |
447 return scopeNames; | 482 return scopeNames; |
448 } | 483 } |
449 | 484 |
485 function lazyScopeStartLocations() | |
486 { | |
487 if (!scopeChain) | |
488 lazyScopeChain(); | |
489 | |
490 return scopeStartLocations; | |
491 } | |
492 | |
493 function lazyScopeEndLocations() | |
494 { | |
495 if (!scopeChain) | |
496 lazyScopeChain(); | |
497 | |
498 return scopeEndLocations; | |
499 } | |
500 | |
450 function ensureFuncMirror() | 501 function ensureFuncMirror() |
451 { | 502 { |
452 if (!funcMirror) { | 503 if (!funcMirror) { |
453 funcMirror = MakeMirror(funcObject); | 504 funcMirror = MakeMirror(funcObject); |
454 if (!funcMirror.isFunction()) | 505 if (!funcMirror.isFunction()) |
455 funcMirror = new UnresolvedFunctionMirror(funcObject); | 506 funcMirror = new UnresolvedFunctionMirror(funcObject); |
456 } | 507 } |
457 return funcMirror; | 508 return funcMirror; |
458 } | 509 } |
459 | 510 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 "line": line, | 601 "line": line, |
551 "column": column, | 602 "column": column, |
552 "scriptName": scriptName, | 603 "scriptName": scriptName, |
553 "functionName": functionName, | 604 "functionName": functionName, |
554 "functionLine": functionLine, | 605 "functionLine": functionLine, |
555 "functionColumn": functionColumn, | 606 "functionColumn": functionColumn, |
556 "thisObject": thisObject, | 607 "thisObject": thisObject, |
557 "scopeChain": lazyScopeChain, | 608 "scopeChain": lazyScopeChain, |
558 "scopeType": lazyScopeTypes, | 609 "scopeType": lazyScopeTypes, |
559 "scopeName": lazyScopeNames, | 610 "scopeName": lazyScopeNames, |
611 "scopeStartLocation": lazyScopeStartLocations, | |
612 "scopeEndLocation": lazyScopeEndLocations, | |
560 "evaluate": evaluate, | 613 "evaluate": evaluate, |
561 "caller": callerFrame, | 614 "caller": callerFrame, |
562 "restart": restart, | 615 "restart": restart, |
563 "setVariableValue": setVariableValue, | 616 "setVariableValue": setVariableValue, |
564 "stepInPositions": stepInPositions, | 617 "stepInPositions": stepInPositions, |
565 "isAtReturn": isAtReturn, | 618 "isAtReturn": isAtReturn, |
566 "returnValue": returnValue | 619 "returnValue": returnValue |
567 }; | 620 }; |
568 } | 621 } |
569 | 622 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 "parentPromise": eventData.parentPromise().value(), | 661 "parentPromise": eventData.parentPromise().value(), |
609 "status": eventData.status() | 662 "status": eventData.status() |
610 }; | 663 }; |
611 } | 664 } |
612 | 665 |
613 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it. | 666 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it. |
614 ToggleMirrorCache(false); | 667 ToggleMirrorCache(false); |
615 | 668 |
616 return DebuggerScript; | 669 return DebuggerScript; |
617 })(); | 670 })(); |
OLD | NEW |