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

Side by Side Diff: src/inspector/debugger-script.js

Issue 2519773003: [debug] Add Eval scope type to inspector protocol (Closed)
Patch Set: Created 4 years, 1 month 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 24 matching lines...) Expand all
35 35
36 /** @type {!Map<!ScopeType, string>} */ 36 /** @type {!Map<!ScopeType, string>} */
37 DebuggerScript._scopeTypeNames = new Map(); 37 DebuggerScript._scopeTypeNames = new Map();
38 DebuggerScript._scopeTypeNames.set(ScopeType.Global, "global"); 38 DebuggerScript._scopeTypeNames.set(ScopeType.Global, "global");
39 DebuggerScript._scopeTypeNames.set(ScopeType.Local, "local"); 39 DebuggerScript._scopeTypeNames.set(ScopeType.Local, "local");
40 DebuggerScript._scopeTypeNames.set(ScopeType.With, "with"); 40 DebuggerScript._scopeTypeNames.set(ScopeType.With, "with");
41 DebuggerScript._scopeTypeNames.set(ScopeType.Closure, "closure"); 41 DebuggerScript._scopeTypeNames.set(ScopeType.Closure, "closure");
42 DebuggerScript._scopeTypeNames.set(ScopeType.Catch, "catch"); 42 DebuggerScript._scopeTypeNames.set(ScopeType.Catch, "catch");
43 DebuggerScript._scopeTypeNames.set(ScopeType.Block, "block"); 43 DebuggerScript._scopeTypeNames.set(ScopeType.Block, "block");
44 DebuggerScript._scopeTypeNames.set(ScopeType.Script, "script"); 44 DebuggerScript._scopeTypeNames.set(ScopeType.Script, "script");
45 DebuggerScript._scopeTypeNames.set(ScopeType.Eval, "eval");
45 46
46 /** 47 /**
47 * @param {function()} fun 48 * @param {function()} fun
48 * @return {?Array<!Scope>} 49 * @return {?Array<!Scope>}
49 */ 50 */
50 DebuggerScript.getFunctionScopes = function(fun) 51 DebuggerScript.getFunctionScopes = function(fun)
51 { 52 {
52 var mirror = MakeMirror(fun); 53 var mirror = MakeMirror(fun);
53 if (!mirror.isFunction()) 54 if (!mirror.isFunction())
54 return null; 55 return null;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 */ 524 */
524 DebuggerScript._buildScopeObject = function(scopeType, scopeObject) 525 DebuggerScript._buildScopeObject = function(scopeType, scopeObject)
525 { 526 {
526 var result; 527 var result;
527 switch (scopeType) { 528 switch (scopeType) {
528 case ScopeType.Local: 529 case ScopeType.Local:
529 case ScopeType.Closure: 530 case ScopeType.Closure:
530 case ScopeType.Catch: 531 case ScopeType.Catch:
531 case ScopeType.Block: 532 case ScopeType.Block:
532 case ScopeType.Script: 533 case ScopeType.Script:
534 case ScopeType.Eval:
533 // For transient objects we create a "persistent" copy that contains 535 // For transient objects we create a "persistent" copy that contains
534 // the same properties. 536 // the same properties.
535 // Reset scope object prototype to null so that the proto properties 537 // Reset scope object prototype to null so that the proto properties
536 // don't appear in the local scope section. 538 // don't appear in the local scope section.
537 var properties = /** @type {!ObjectMirror} */(MakeMirror(scopeObject, tr ue /* transient */)).properties(); 539 var properties = /** @type {!ObjectMirror} */(MakeMirror(scopeObject, tr ue /* transient */)).properties();
538 // Almost always Script scope will be empty, so just filter out that noi se. 540 // Almost always Script scope will be empty, so just filter out that noi se.
539 // Also drop empty Block scopes, should we get any. 541 // Also drop empty Block scopes, should we get any.
540 if (!properties.length && (scopeType === ScopeType.Script || scopeType = == ScopeType.Block)) 542 if (!properties.length && (scopeType === ScopeType.Script || scopeType = == ScopeType.Block))
kozy 2016/11/21 17:52:09 Dmitry, good catch! Jakob, please filter empty eva
jgruber 2016/11/22 13:55:21 Done.
541 break; 543 break;
542 result = { __proto__: null }; 544 result = { __proto__: null };
543 for (var j = 0; j < properties.length; j++) { 545 for (var j = 0; j < properties.length; j++) {
544 var name = properties[j].name(); 546 var name = properties[j].name();
545 if (name.length === 0 || name.charAt(0) === ".") 547 if (name.length === 0 || name.charAt(0) === ".")
546 continue; // Skip internal variables like ".arguments" and varia bles with empty name 548 continue; // Skip internal variables like ".arguments" and varia bles with empty name
547 result[name] = properties[j].value_; 549 result[name] = properties[j].value_;
548 } 550 }
549 break; 551 break;
550 case ScopeType.Global: 552 case ScopeType.Global:
551 case ScopeType.With: 553 case ScopeType.With:
552 result = scopeObject; 554 result = scopeObject;
553 break; 555 break;
554 } 556 }
555 return result; 557 return result;
556 } 558 }
557 559
558 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it. 560 // We never resolve Mirror by its handle so to avoid memory leaks caused by Mirr ors in the cache we disable it.
559 ToggleMirrorCache(false); 561 ToggleMirrorCache(false);
560 562
561 return DebuggerScript; 563 return DebuggerScript;
562 })(); 564 })();
OLDNEW
« no previous file with comments | « no previous file | src/inspector/debugger_script_externs.js » ('j') | src/inspector/js_protocol-1.2.json » ('J')

Powered by Google App Engine
This is Rietveld 408576698