--- e081749eef4040050988375205004d666a6b018c/js/src/frontend/Stencil.cpp
+++ a87db3b698e19b65bc001936fc7a8b80239a25dd/js/src/frontend/Stencil.cpp
@@ -754,16 +754,39 @@ void ScopeContext::cacheEnclosingScope(c
case ScopeKind::WasmFunction:
MOZ_CRASH("No direct eval inside wasm functions");
}
}
MOZ_CRASH("Malformed scope chain");
}
+// Given an input scope, possibly refine this to a more precise scope.
+// This is used during eval in the debugger to provide the appropriate scope and
+// ThisBinding kind and environment, which is key to making private field eval
+// work correctly.
+//
+// The trick here is that an eval may have a non-syntatic scope but nevertheless
+// have an 'interesting' environment which can be traversed to find the
+// appropriate scope the the eval to function as desired. See the diagram below.
+//
+// Eval Scope Eval Env Frame Env Frame Scope
+// ============ ============= ========= =============
+//
+// NonSyntactic
+// |
+// v
+// null DebugEnvProxy LexicalScope
+// | |
+// v v
+// DebugEnvProxy --> CallObj --> FunctionScope
+// | | |
+// v v v
+// ... ... ...
+//
InputScope ScopeContext::determineEffectiveScope(InputScope& scope,
JSObject* environment) {
MOZ_ASSERT(effectiveScopeHops == 0);
// If the scope-chain is non-syntactic, we may still determine a more precise
// effective-scope to use instead.
if (environment && scope.hasOnChain(ScopeKind::NonSyntactic)) {
JSObject* env = environment;
while (env) {
Files
/js/src/frontend/Stencil.cpp
Changesets
Diffs
/js/src/frontend/Stencil.cpp