Reviewers: antonm, Søren Gjesse,
Message:
Debugger: show local scope before with in scope chain for functions created
inside with block. E.g. in the following script
with({x: 1}) { (function(x) { debugger; })(2); } debugger should return
Local
scope object before With one.
Corresponding Chromium issue:
http://code.google.com/p/chromium/issues/detail?id=70065
Description:
Debugger: show local scope before with for functions created inside with
block
Please review this at http://codereview.chromium.org/6804015/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/runtime.cc
M test/mjsunit/debug-scopes.js
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 7514)
+++ src/runtime.cc (working copy)
@@ -9821,6 +9821,9 @@
at_local_ = index < 0;
} else if (context_->is_function_context()) {
at_local_ = true;
+ } else if (context_->closure() != *function_) {
+ // The context_ is a with block from the outer function.
+ at_local_ = true;
}
}
Index: test/mjsunit/debug-scopes.js
===================================================================
--- test/mjsunit/debug-scopes.js (revision 7514)
+++ test/mjsunit/debug-scopes.js (working copy)
@@ -144,6 +144,10 @@
if (!scope.scopeObject().property('.catch-var').isUndefined()) {
scope_size--;
}
+ // Skip property with empty name.
+ if (!scope.scopeObject().property('').isUndefined()) {
+ scope_size--;
+ }
if (count != scope_size) {
print('Names found in scope:');
@@ -607,6 +611,23 @@
EndTest();
+// Closure that may be optimized out.
+BeginTest("Closure 8");
+function closure_8() {
+ (function inner(x) {
+ debugger;
+ })(2);
+}
+
+listener_delegate = function(exec_state) {
+ CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.Global], exec_state);
+ CheckScopeContent({x: 2}, 0, exec_state);
+}
+closure_8();
+EndTest();
+
+
// Test a mixture of scopes.
BeginTest("The full monty");
function the_full_monty(a, b) {
@@ -653,6 +674,56 @@
the_full_monty(1, 2)()
EndTest();
+
+BeginTest("Closure inside With 1");
+function closure_in_with_1() {
+ with({x:1}) {
+ (function inner(x) {
+ debugger;
+ })(2);
+ }
+}
+
+listener_delegate = function(exec_state) {
+ CheckScopeChain([debug.ScopeType.Local,
+ debug.ScopeType.With,
+ debug.ScopeType.Closure,
+ debug.ScopeType.Global], exec_state);
+ CheckScopeContent({x: 2}, 0, exec_state);
+}
+closure_in_with_1();
+EndTest();
+
+
+BeginTest("Closure inside With 2");
+function closure_in_with_2() {
+ with({x:1}) {
+ (function inner(x) {
+ with({z:3}) {
+ debugger;
+ }
+ })(2);
+ }
+}
+
+listener_delegate = function(exec_state) {
+try {
+ CheckScopeChain([debug.ScopeType.With,
+ debug.ScopeType.Local,
+ debug.ScopeType.With,
+ debug.ScopeType.Closure,
+ debug.ScopeType.Global], exec_state);
+ CheckScopeContent({z: 3}, 0, exec_state);
+ CheckScopeContent({x: 2}, 1, exec_state);
+ CheckScopeContent({x: 1}, 2, exec_state);
+} catch (e) {
+ print(e);
+}
+}
+closure_in_with_2();
+EndTest();
+
+
// Test global scope.
BeginTest("Global");
listener_delegate = function(exec_state) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev