diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /js/src/frontend/Parser.cpp | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/frontend/Parser.cpp')
-rw-r--r-- | js/src/frontend/Parser.cpp | 22 |
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. |