summaryrefslogtreecommitdiffstats
path: root/js/src/frontend/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/frontend/Parser.cpp')
-rw-r--r--js/src/frontend/Parser.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index cd586ad2a7..997b7ce8ee 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -811,11 +811,18 @@ bool GeneralParser<ParseHandler, Unit>::noteDeclaredPrivateName(
AddDeclaredNamePtr p = scope->lookupDeclaredNameForAdd(name);
DeclarationKind declKind = DeclarationKind::PrivateName;
- ClosedOver closedOver = ClosedOver::No;
+
+ // Our strategy for enabling debugger functionality is to mark names as closed
+ // over, even if they don't necessarily need to be, to ensure that they are
+ // included in the environment object. This allows us to easily look them up
+ // by name when needed, even if there is no corresponding property on an
+ // object, as is the case with getter, setters and private methods.
+ ClosedOver closedOver = ClosedOver::Yes;
PrivateNameKind kind;
switch (propType) {
case PropertyType::Field:
kind = PrivateNameKind::Field;
+ closedOver = ClosedOver::No;
break;
case PropertyType::FieldWithAccessor:
// In this case, we create a new private field for the underlying storage,
@@ -831,11 +838,6 @@ bool GeneralParser<ParseHandler, Unit>::noteDeclaredPrivateName(
// DeclarationKind::Synthetic.
declKind = DeclarationKind::PrivateMethod;
}
-
- // Methods must be marked closed-over so that
- // EmitterScope::lookupPrivate() works even if the method is used, but not
- // within any method (from a computed property name, or debugger frame)
- closedOver = ClosedOver::Yes;
kind = PrivateNameKind::Method;
break;
case PropertyType::Getter:
@@ -845,7 +847,7 @@ bool GeneralParser<ParseHandler, Unit>::noteDeclaredPrivateName(
kind = PrivateNameKind::Setter;
break;
default:
- kind = PrivateNameKind::None;
+ MOZ_CRASH("Invalid Property Type for noteDeclarePrivateName");
}
if (p) {
@@ -8004,7 +8006,11 @@ GeneralParser<ParseHandler, Unit>::classDefinition(
// position in order to provide it for the nodes created later.
TokenPos namePos = pos();
- bool isInClass = pc_->sc()->inClass();
+ auto isClass = [](ParseContext::Statement* stmt) {
+ return stmt->kind() == StatementKind::Class;
+ };
+
+ bool isInClass = pc_->sc()->inClass() || pc_->findInnermostStatement(isClass);
// Push a ParseContext::ClassStatement to keep track of the constructor
// funbox.