Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/DebuggerScript.js

Issue 1653053002: Devtools: parse variables scopes and sourcemap them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 var sourcePosition = frameDetails.sourcePosition(); 388 var sourcePosition = frameDetails.sourcePosition();
389 var thisObject = frameDetails.receiver(); 389 var thisObject = frameDetails.receiver();
390 390
391 var isAtReturn = !!frameDetails.isAtReturn(); 391 var isAtReturn = !!frameDetails.isAtReturn();
392 var returnValue = isAtReturn ? frameDetails.returnValue() : undefined; 392 var returnValue = isAtReturn ? frameDetails.returnValue() : undefined;
393 393
394 var scopeMirrors = includeScopes ? frameMirror.allScopes(false) : []; 394 var scopeMirrors = includeScopes ? frameMirror.allScopes(false) : [];
395 var scopeTypes = new Array(scopeMirrors.length); 395 var scopeTypes = new Array(scopeMirrors.length);
396 var scopeObjects = new Array(scopeMirrors.length); 396 var scopeObjects = new Array(scopeMirrors.length);
397 var scopeNames = new Array(scopeMirrors.length); 397 var scopeNames = new Array(scopeMirrors.length);
398 var scopeStartPositions = new Array(scopeMirrors.length);
399 var scopeEndPositions = new Array(scopeMirrors.length);
400 var scopeFunctions = new Array(scopeMirrors.length);
398 for (var i = 0; i < scopeMirrors.length; ++i) { 401 for (var i = 0; i < scopeMirrors.length; ++i) {
399 var scopeDetails = scopeMirrors[i].details(); 402 var scopeDetails = scopeMirrors[i].details();
400 scopeTypes[i] = scopeDetails.type(); 403 scopeTypes[i] = scopeDetails.type();
401 scopeObjects[i] = scopeDetails.object(); 404 scopeObjects[i] = scopeDetails.object();
402 scopeNames[i] = scopeDetails.name(); 405 scopeNames[i] = scopeDetails.name();
406 scopeStartPositions[i] = scopeDetails.startPosition();
407 scopeEndPositions[i] = scopeDetails.endPosition();
408 scopeFunctions[i] = scopeDetails.func();
403 } 409 }
404 410
405 // Calculated lazily. 411 // Calculated lazily.
406 var scopeChain; 412 var scopeChain;
407 var funcMirror; 413 var funcMirror;
408 var location; 414 var location;
415 var scopeStartLocations;
416 var scopeEndLocations;
417
418 function createLocation(script, pos)
419 {
420 if (!script)
421 return null;
422
423 location = script.locationFromPosition(pos, true);
424 return {
425 "lineNumber": location.line,
426 "columnNumber": location.column,
427 "scriptId": String(script.id())
428 }
429 }
409 430
410 function lazyScopeChain() 431 function lazyScopeChain()
411 { 432 {
412 if (!scopeChain) { 433 if (!scopeChain) {
413 scopeChain = []; 434 scopeChain = [];
435 scopeStartLocations = [];
436 scopeEndLocations = [];
414 for (var i = 0, j = 0; i < scopeObjects.length; ++i) { 437 for (var i = 0, j = 0; i < scopeObjects.length; ++i) {
415 var scopeObject = DebuggerScript._buildScopeObject(scopeTypes[i] , scopeObjects[i], scopeNames[i]); 438 var scopeObject = DebuggerScript._buildScopeObject(scopeTypes[i] , scopeObjects[i]);
416 if (scopeObject) { 439 if (scopeObject) {
417 scopeTypes[j] = scopeTypes[i]; 440 scopeTypes[j] = scopeTypes[i];
418 scopeNames[j] = scopeNames[i]; 441 scopeNames[j] = scopeNames[i];
419 scopeChain[j] = scopeObject; 442 scopeChain[j] = scopeObject;
443
444 var funcMirror = MakeMirror(scopeFunctions[i]);
445 if (!funcMirror.isFunction())
446 funcMirror = new UnresolvedFunctionMirror(funcObject);
447
448 var script = funcMirror.script();
449 scopeStartLocations[j] = createLocation(script, scopeStartPo sitions[i]);
450 scopeEndLocations[j] = createLocation(script, scopeEndPositi ons[i]);
420 ++j; 451 ++j;
421 } 452 }
422 } 453 }
423 scopeTypes.length = scopeChain.length; 454 scopeTypes.length = scopeChain.length;
424 scopeNames.length = scopeChain.length; 455 scopeNames.length = scopeChain.length;
425 scopeObjects = null; // Free for GC. 456 scopeObjects = null; // Free for GC.
457 scopeFunctions = null;
458 scopeStartPositions = null;
459 scopeEndPositions = null;
426 } 460 }
427 return scopeChain; 461 return scopeChain;
428 } 462 }
429 463
430 function lazyScopeTypes() 464 function lazyScopeTypes()
431 { 465 {
432 if (!scopeChain) 466 if (!scopeChain)
433 lazyScopeChain(); 467 lazyScopeChain();
434 return scopeTypes; 468 return scopeTypes;
435 } 469 }
436 470
437 function lazyScopeNames() 471 function lazyScopeNames()
438 { 472 {
439 if (!scopeChain) 473 if (!scopeChain)
440 lazyScopeChain(); 474 lazyScopeChain();
441 return scopeNames; 475 return scopeNames;
442 } 476 }
443 477
478 function lazyScopeStartLocations()
479 {
480 if (!scopeChain)
481 lazyScopeChain();
482
483 return scopeStartLocations;
484 }
485
486 function lazyScopeEndLocations()
487 {
488 if (!scopeChain)
489 lazyScopeChain();
490
491 return scopeEndLocations;
492 }
493
444 function ensureFuncMirror() 494 function ensureFuncMirror()
445 { 495 {
446 if (!funcMirror) { 496 if (!funcMirror) {
447 funcMirror = MakeMirror(funcObject); 497 funcMirror = MakeMirror(funcObject);
448 if (!funcMirror.isFunction()) 498 if (!funcMirror.isFunction())
449 funcMirror = new UnresolvedFunctionMirror(funcObject); 499 funcMirror = new UnresolvedFunctionMirror(funcObject);
450 } 500 }
451 return funcMirror; 501 return funcMirror;
452 } 502 }
453 503
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 "line": line, 594 "line": line,
545 "column": column, 595 "column": column,
546 "scriptName": scriptName, 596 "scriptName": scriptName,
547 "functionName": functionName, 597 "functionName": functionName,
548 "functionLine": functionLine, 598 "functionLine": functionLine,
549 "functionColumn": functionColumn, 599 "functionColumn": functionColumn,
550 "thisObject": thisObject, 600 "thisObject": thisObject,
551 "scopeChain": lazyScopeChain, 601 "scopeChain": lazyScopeChain,
552 "scopeType": lazyScopeTypes, 602 "scopeType": lazyScopeTypes,
553 "scopeName": lazyScopeNames, 603 "scopeName": lazyScopeNames,
604 "scopeStartLocation": lazyScopeStartLocations,
605 "scopeEndLocation": lazyScopeEndLocations,
554 "evaluate": evaluate, 606 "evaluate": evaluate,
555 "caller": callerFrame, 607 "caller": callerFrame,
556 "restart": restart, 608 "restart": restart,
557 "setVariableValue": setVariableValue, 609 "setVariableValue": setVariableValue,
558 "stepInPositions": stepInPositions, 610 "stepInPositions": stepInPositions,
559 "isAtReturn": isAtReturn, 611 "isAtReturn": isAtReturn,
560 "returnValue": returnValue 612 "returnValue": returnValue
561 }; 613 };
562 } 614 }
563 615
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 "parentPromise": eventData.parentPromise().value(), 654 "parentPromise": eventData.parentPromise().value(),
603 "status": eventData.status() 655 "status": eventData.status()
604 }; 656 };
605 } 657 }
606 658
607 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it. 659 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it.
608 ToggleMirrorCache(false); 660 ToggleMirrorCache(false);
609 661
610 return DebuggerScript; 662 return DebuggerScript;
611 })(); 663 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698