| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 DebuggerScript.getFunctionScopes = function(fun) | 71 DebuggerScript.getFunctionScopes = function(fun) |
| 72 { | 72 { |
| 73 var mirror = MakeMirror(fun); | 73 var mirror = MakeMirror(fun); |
| 74 var count = mirror.scopeCount(); | 74 var count = mirror.scopeCount(); |
| 75 if (count == 0) | 75 if (count == 0) |
| 76 return null; | 76 return null; |
| 77 var result = []; | 77 var result = []; |
| 78 for (var i = 0; i < count; i++) { | 78 for (var i = 0; i < count; i++) { |
| 79 var scopeDetails = mirror.scope(i).details(); | 79 var scopeDetails = mirror.scope(i).details(); |
| 80 result[i] = { | 80 var scopeObject = DebuggerScript._buildScopeObject(scopeDetails.type(),
scopeDetails.object()); |
| 81 if (!scopeObject) |
| 82 continue; |
| 83 result.push({ |
| 81 type: scopeDetails.type(), | 84 type: scopeDetails.type(), |
| 82 object: DebuggerScript._buildScopeObject(scopeDetails.type(), scopeD
etails.object()) | 85 object: scopeObject |
| 83 }; | 86 }); |
| 84 } | 87 } |
| 85 return result; | 88 return result; |
| 86 } | 89 } |
| 87 | 90 |
| 88 DebuggerScript.getCollectionEntries = function(object) | 91 DebuggerScript.getCollectionEntries = function(object) |
| 89 { | 92 { |
| 90 var mirror = MakeMirror(object, true /* transient */); | 93 var mirror = MakeMirror(object, true /* transient */); |
| 91 if (mirror.isMap()) | 94 if (mirror.isMap()) |
| 92 return mirror.entries(); | 95 return mirror.entries(); |
| 93 if (mirror.isSet()) { | 96 if (mirror.isSet()) { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 378 |
| 376 // Calculated lazily. | 379 // Calculated lazily. |
| 377 var scopeChain; | 380 var scopeChain; |
| 378 var funcMirror; | 381 var funcMirror; |
| 379 var location; | 382 var location; |
| 380 | 383 |
| 381 function lazyScopeChain() | 384 function lazyScopeChain() |
| 382 { | 385 { |
| 383 if (!scopeChain) { | 386 if (!scopeChain) { |
| 384 scopeChain = []; | 387 scopeChain = []; |
| 385 for (var i = 0; i < scopeObjects.length; ++i) | 388 for (var i = 0, j = 0; i < scopeObjects.length; ++i) { |
| 386 scopeChain.push(DebuggerScript._buildScopeObject(scopeTypes[i],
scopeObjects[i])); | 389 var scopeObject = DebuggerScript._buildScopeObject(scopeTypes[i]
, scopeObjects[i]); |
| 390 if (scopeObject) { |
| 391 scopeTypes[j] = scopeTypes[i]; |
| 392 scopeChain[j] = scopeObject; |
| 393 ++j; |
| 394 } |
| 395 } |
| 396 scopeTypes.length = scopeChain.length; |
| 387 scopeObjects = null; // Free for GC. | 397 scopeObjects = null; // Free for GC. |
| 388 } | 398 } |
| 389 return scopeChain; | 399 return scopeChain; |
| 390 } | 400 } |
| 391 | 401 |
| 402 function lazyScopeTypes() |
| 403 { |
| 404 if (!scopeChain) |
| 405 lazyScopeChain(); |
| 406 return scopeTypes; |
| 407 } |
| 408 |
| 392 function ensureFuncMirror() | 409 function ensureFuncMirror() |
| 393 { | 410 { |
| 394 if (!funcMirror) { | 411 if (!funcMirror) { |
| 395 funcMirror = MakeMirror(funcObject); | 412 funcMirror = MakeMirror(funcObject); |
| 396 if (!funcMirror.isFunction()) | 413 if (!funcMirror.isFunction()) |
| 397 funcMirror = new UnresolvedFunctionMirror(funcObject); | 414 funcMirror = new UnresolvedFunctionMirror(funcObject); |
| 398 } | 415 } |
| 399 return funcMirror; | 416 return funcMirror; |
| 400 } | 417 } |
| 401 | 418 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 } | 500 } |
| 484 | 501 |
| 485 return { | 502 return { |
| 486 "sourceID": sourceID, | 503 "sourceID": sourceID, |
| 487 "line": line, | 504 "line": line, |
| 488 "column": column, | 505 "column": column, |
| 489 "scriptName": scriptName, | 506 "scriptName": scriptName, |
| 490 "functionName": functionName, | 507 "functionName": functionName, |
| 491 "thisObject": thisObject, | 508 "thisObject": thisObject, |
| 492 "scopeChain": lazyScopeChain, | 509 "scopeChain": lazyScopeChain, |
| 493 "scopeType": scopeTypes, | 510 "scopeType": lazyScopeTypes, |
| 494 "evaluate": evaluate, | 511 "evaluate": evaluate, |
| 495 "caller": callerFrame, | 512 "caller": callerFrame, |
| 496 "restart": restart, | 513 "restart": restart, |
| 497 "setVariableValue": setVariableValue, | 514 "setVariableValue": setVariableValue, |
| 498 "stepInPositions": stepInPositions, | 515 "stepInPositions": stepInPositions, |
| 499 "isAtReturn": isAtReturn, | 516 "isAtReturn": isAtReturn, |
| 500 "returnValue": returnValue | 517 "returnValue": returnValue |
| 501 }; | 518 }; |
| 502 } | 519 } |
| 503 | 520 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 "parentPromise": eventData.parentPromise().value(), | 556 "parentPromise": eventData.parentPromise().value(), |
| 540 "status": eventData.status() | 557 "status": eventData.status() |
| 541 }; | 558 }; |
| 542 } | 559 } |
| 543 | 560 |
| 544 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | 561 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. |
| 545 ToggleMirrorCache(false); | 562 ToggleMirrorCache(false); |
| 546 | 563 |
| 547 return DebuggerScript; | 564 return DebuggerScript; |
| 548 })(); | 565 })(); |
| OLD | NEW |