| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // Get script ID. | 317 // Get script ID. |
| 318 var script = func.script(); | 318 var script = func.script(); |
| 319 var sourceID = script && script.id(); | 319 var sourceID = script && script.id(); |
| 320 | 320 |
| 321 // Get location. | 321 // Get location. |
| 322 var location = frameMirror.sourceLocation(); | 322 var location = frameMirror.sourceLocation(); |
| 323 | 323 |
| 324 // Get this object. | 324 // Get this object. |
| 325 var thisObject = frameMirror.details_.receiver(); | 325 var thisObject = frameMirror.details_.receiver(); |
| 326 | 326 |
| 327 // Get scope chain array in format: [<scope type>, <scope object>, <scope ty
pe>, <scope object>,...] | |
| 328 var scopeChain = []; | 327 var scopeChain = []; |
| 329 var scopeType = []; | 328 var scopeType = []; |
| 330 for (var i = 0; i < frameMirror.scopeCount(); i++) { | 329 for (var i = 0; i < frameMirror.scopeCount(); i++) { |
| 331 var scopeMirror = frameMirror.scope(i); | 330 var scopeMirror = frameMirror.scope(i); |
| 332 scopeType.push(scopeMirror.scopeType()); | 331 scopeType.push(scopeMirror.scopeType()); |
| 333 scopeChain.push(DebuggerScript._buildScopeObject(scopeMirror)); | 332 scopeChain.push(DebuggerScript._buildScopeObject(scopeMirror)); |
| 334 } | 333 } |
| 335 | 334 |
| 335 // Updates the existing array. |
| 336 function rereadScopes() { |
| 337 for (var i = 0; i < frameMirror.scopeCount(); i++) { |
| 338 var scopeMirror = frameMirror.scope(i); |
| 339 scopeChain[i] = DebuggerScript._buildScopeObject(scopeMirror); |
| 340 } |
| 341 } |
| 342 |
| 336 function evaluate(expression) | 343 function evaluate(expression) |
| 337 { | 344 { |
| 338 return frameMirror.evaluate(expression, false).value(); | 345 return frameMirror.evaluate(expression, false).value(); |
| 339 } | 346 } |
| 340 | 347 |
| 341 function restart() | 348 function restart() |
| 342 { | 349 { |
| 343 return Debug.LiveEdit.RestartFrame(frameMirror); | 350 return Debug.LiveEdit.RestartFrame(frameMirror); |
| 344 } | 351 } |
| 345 | 352 |
| 346 function setVariableValue(scopeNumber, variableName, newValue) | 353 function setVariableValue(scopeNumber, variableName, newValue) |
| 347 { | 354 { |
| 348 return DebuggerScript._setScopeVariableValue(frameMirror, scopeNumber, v
ariableName, newValue); | 355 return DebuggerScript._setScopeVariableValue(frameMirror, scopeNumber, v
ariableName, newValue); |
| 349 } | 356 } |
| 350 | 357 |
| 351 return { | 358 return { |
| 352 "sourceID": sourceID, | 359 "sourceID": sourceID, |
| 353 "line": location ? location.line : 0, | 360 "line": location ? location.line : 0, |
| 354 "column": location ? location.column : 0, | 361 "column": location ? location.column : 0, |
| 355 "functionName": functionName, | 362 "functionName": functionName, |
| 356 "thisObject": thisObject, | 363 "thisObject": thisObject, |
| 357 "scopeChain": scopeChain, | 364 "scopeChain": scopeChain, |
| 358 "scopeType": scopeType, | 365 "scopeType": scopeType, |
| 359 "evaluate": evaluate, | 366 "evaluate": evaluate, |
| 360 "caller": callerFrame, | 367 "caller": callerFrame, |
| 361 "restart": restart, | 368 "restart": restart, |
| 362 "setVariableValue": setVariableValue | 369 "setVariableValue": setVariableValue, |
| 370 "rereadScopes": rereadScopes |
| 363 }; | 371 }; |
| 364 } | 372 } |
| 365 | 373 |
| 366 DebuggerScript._buildScopeObject = function(scopeMirror) { | 374 DebuggerScript._buildScopeObject = function(scopeMirror) { |
| 367 var scopeObject; | 375 var scopeObject; |
| 368 switch (scopeMirror.scopeType()) { | 376 switch (scopeMirror.scopeType()) { |
| 369 case ScopeType.Local: | 377 case ScopeType.Local: |
| 370 case ScopeType.Closure: | 378 case ScopeType.Closure: |
| 371 case ScopeType.Catch: | 379 case ScopeType.Catch: |
| 372 // For transient objects we create a "persistent" copy that contains | 380 // For transient objects we create a "persistent" copy that contains |
| (...skipping 17 matching lines...) Expand all Loading... |
| 390 break; | 398 break; |
| 391 case ScopeType.Block: | 399 case ScopeType.Block: |
| 392 // Unsupported yet. Mustn't be reachable. | 400 // Unsupported yet. Mustn't be reachable. |
| 393 break; | 401 break; |
| 394 } | 402 } |
| 395 return scopeObject; | 403 return scopeObject; |
| 396 } | 404 } |
| 397 | 405 |
| 398 return DebuggerScript; | 406 return DebuggerScript; |
| 399 })(); | 407 })(); |
| OLD | NEW |