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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 scope.name = scopeNames[i]; | 383 scope.name = scopeNames[i]; |
384 if (scopeStartLocations[i]) | 384 if (scopeStartLocations[i]) |
385 scope.startLocation = /** @type {!RawLocation} */(scopeStart
Locations[i]); | 385 scope.startLocation = /** @type {!RawLocation} */(scopeStart
Locations[i]); |
386 if (scopeEndLocations[i]) | 386 if (scopeEndLocations[i]) |
387 scope.endLocation = /** @type {!RawLocation} */(scopeEndLoca
tions[i]); | 387 scope.endLocation = /** @type {!RawLocation} */(scopeEndLoca
tions[i]); |
388 scopes.push(scope); | 388 scopes.push(scope); |
389 } | 389 } |
390 details = { | 390 details = { |
391 "functionName": ensureFuncMirror().debugName(), | 391 "functionName": ensureFuncMirror().debugName(), |
392 "location": { | 392 "location": { |
393 "lineNumber": line(), | 393 "lineNumber": ensureLocation().line, |
394 "columnNumber": column(), | 394 "columnNumber": ensureLocation().column, |
395 "scriptId": String(script.id()) | 395 "scriptId": String(script.id()) |
396 }, | 396 }, |
397 "this": thisObject, | 397 "this": thisObject, |
398 "scopeChain": scopes | 398 "scopeChain": scopes |
399 }; | 399 }; |
400 var functionLocation = ensureFuncMirror().sourceLocation(); | 400 var functionLocation = ensureFuncMirror().sourceLocation(); |
401 if (functionLocation) { | 401 if (functionLocation) { |
402 details.functionLocation = { | 402 details.functionLocation = { |
403 "lineNumber": functionLocation.line, | 403 "lineNumber": functionLocation.line, |
404 "columnNumber": functionLocation.column, | 404 "columnNumber": functionLocation.column, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 location = script.locationFromPosition(sourcePosition, true); | 445 location = script.locationFromPosition(sourcePosition, true); |
446 if (!location) | 446 if (!location) |
447 location = { line: 0, column: 0 }; | 447 location = { line: 0, column: 0 }; |
448 } | 448 } |
449 return location; | 449 return location; |
450 } | 450 } |
451 | 451 |
452 /** | 452 /** |
453 * @return {number} | 453 * @return {number} |
454 */ | 454 */ |
455 function line() | |
456 { | |
457 return ensureLocation().line; | |
458 } | |
459 | |
460 /** | |
461 * @return {number} | |
462 */ | |
463 function column() | |
464 { | |
465 return ensureLocation().column; | |
466 } | |
467 | |
468 /** | |
469 * @return {number} | |
470 */ | |
471 function contextId() | 455 function contextId() |
472 { | 456 { |
473 var mirror = ensureFuncMirror(); | 457 var mirror = ensureFuncMirror(); |
474 var context = mirror.context(); | 458 var context = mirror.context(); |
475 if (context && context.data()) | 459 if (context && context.data()) |
476 return Number(context.data()); | 460 return Number(context.data()); |
477 return 0; | 461 return 0; |
478 } | 462 } |
479 | 463 |
480 /** | 464 /** |
481 * @return {number} | |
482 */ | |
483 function sourceID() | |
484 { | |
485 var script = ensureScriptMirror(); | |
486 return script.id(); | |
487 } | |
488 | |
489 /** | |
490 * @param {string} expression | 465 * @param {string} expression |
491 * @return {*} | 466 * @return {*} |
492 */ | 467 */ |
493 function evaluate(expression) | 468 function evaluate(expression) |
494 { | 469 { |
495 return frameMirror.evaluate(expression).value(); | 470 return frameMirror.evaluate(expression).value(); |
496 } | 471 } |
497 | 472 |
498 /** @return {undefined} */ | 473 /** @return {undefined} */ |
499 function restart() | 474 function restart() |
500 { | 475 { |
501 return frameMirror.restart(); | 476 return frameMirror.restart(); |
502 } | 477 } |
503 | 478 |
504 /** | 479 /** |
505 * @param {number} scopeNumber | 480 * @param {number} scopeNumber |
506 * @param {string} variableName | 481 * @param {string} variableName |
507 * @param {*} newValue | 482 * @param {*} newValue |
508 */ | 483 */ |
509 function setVariableValue(scopeNumber, variableName, newValue) | 484 function setVariableValue(scopeNumber, variableName, newValue) |
510 { | 485 { |
511 var scopeMirror = frameMirror.scope(scopeNumber); | 486 var scopeMirror = frameMirror.scope(scopeNumber); |
512 if (!scopeMirror) | 487 if (!scopeMirror) |
513 throw new Error("Incorrect scope index"); | 488 throw new Error("Incorrect scope index"); |
514 scopeMirror.setVariableValue(variableName, newValue); | 489 scopeMirror.setVariableValue(variableName, newValue); |
515 } | 490 } |
516 | 491 |
517 return { | 492 return { |
518 "sourceID": sourceID, | |
519 "line": line, | |
520 "column": column, | |
521 "contextId": contextId, | 493 "contextId": contextId, |
522 "thisObject": thisObject, | 494 "thisObject": thisObject, |
523 "evaluate": evaluate, | 495 "evaluate": evaluate, |
524 "restart": restart, | 496 "restart": restart, |
525 "setVariableValue": setVariableValue, | 497 "setVariableValue": setVariableValue, |
526 "isAtReturn": isAtReturn, | 498 "isAtReturn": isAtReturn, |
527 "details": lazyDetails | 499 "details": lazyDetails |
528 }; | 500 }; |
529 } | 501 } |
530 | 502 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 break; | 543 break; |
572 } | 544 } |
573 return result; | 545 return result; |
574 } | 546 } |
575 | 547 |
576 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. | 548 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr
ors in the cache we disable it. |
577 ToggleMirrorCache(false); | 549 ToggleMirrorCache(false); |
578 | 550 |
579 return DebuggerScript; | 551 return DebuggerScript; |
580 })(); | 552 })(); |
OLD | NEW |