Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp
Warning:line 586, column 22
Dereference of null pointer (loaded from variable 'duplicatedParam')

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Parser.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/js/src/frontend -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/js/src/frontend -resource-dir /usr/lib/llvm-18/lib/clang/18 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D WASM_SUPPORTS_HUGE_MEMORY -D JS_CACHEIR_SPEW -D JS_STRUCTURED_SPEW -D JS_HAS_CTYPES -D FFI_BUILDING -D EXPORT_JS_API -D MOZ_HAS_MOZGLUE -D MOZ_SUPPORT_LEAKCHECKING -I /var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/js/src/frontend -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/js/src -I /var/lib/jenkins/workspace/firefox-scan-build/js/src -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -fdeprecated-macro -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-07-21-021012-413605-1 -x c++ /var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7/*
8 * JS parser.
9 *
10 * This is a recursive-descent parser for the JavaScript language specified by
11 * "The ECMAScript Language Specification" (Standard ECMA-262). It uses
12 * lexical and semantic feedback to disambiguate non-LL(1) structures. It
13 * generates trees of nodes induced by the recursive parsing (not precise
14 * syntax trees, see Parser.h). After tree construction, it rewrites trees to
15 * fold constants and evaluate compile-time expressions.
16 *
17 * This parser attempts no error recovery.
18 */
19
20#include "frontend/Parser.h"
21
22#include "mozilla/ArrayUtils.h"
23#include "mozilla/Assertions.h"
24#include "mozilla/Casting.h"
25#include "mozilla/Range.h"
26#include "mozilla/Sprintf.h"
27#include "mozilla/Try.h" // MOZ_TRY*
28#include "mozilla/Utf8.h"
29#include "mozilla/Variant.h"
30
31#include <memory>
32#include <new>
33#include <type_traits>
34
35#include "jsnum.h"
36#include "jstypes.h"
37
38#include "frontend/FoldConstants.h"
39#include "frontend/FunctionSyntaxKind.h" // FunctionSyntaxKind
40#include "frontend/ModuleSharedContext.h"
41#include "frontend/ParseNode.h"
42#include "frontend/ParseNodeVerify.h"
43#include "frontend/Parser-macros.h" // MOZ_TRY_VAR_OR_RETURN
44#include "frontend/ParserAtom.h" // TaggedParserAtomIndex, ParserAtomsTable, ParserAtom
45#include "frontend/ScriptIndex.h" // ScriptIndex
46#include "frontend/TokenStream.h" // IsKeyword, ReservedWordTokenKind, ReservedWordToCharZ, DeprecatedContent, *TokenStream*, CharBuffer, TokenKindToDesc
47#include "irregexp/RegExpAPI.h"
48#include "js/ColumnNumber.h" // JS::LimitedColumnNumberOneOrigin, JS::ColumnNumberOneOrigin
49#include "js/ErrorReport.h" // JSErrorBase
50#include "js/friend/ErrorMessages.h" // js::GetErrorMessage, JSMSG_*
51#include "js/HashTable.h"
52#include "js/RegExpFlags.h" // JS::RegExpFlags
53#include "js/Stack.h" // JS::NativeStackLimit
54#include "util/StringBuffer.h" // StringBuffer
55#include "vm/BytecodeUtil.h"
56#include "vm/FunctionFlags.h" // js::FunctionFlags
57#include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind
58#include "vm/JSContext.h"
59#include "vm/JSScript.h"
60#include "vm/ModuleBuilder.h" // js::ModuleBuilder
61#include "vm/Scope.h" // GetScopeDataTrailingNames
62#include "wasm/AsmJS.h"
63
64#include "frontend/ParseContext-inl.h"
65#include "frontend/SharedContext-inl.h"
66
67using namespace js;
68
69using mozilla::AssertedCast;
70using mozilla::AsVariant;
71using mozilla::Maybe;
72using mozilla::Nothing;
73using mozilla::PointerRangeSize;
74using mozilla::Some;
75using mozilla::Utf8Unit;
76
77using JS::ReadOnlyCompileOptions;
78using JS::RegExpFlags;
79
80namespace js::frontend {
81
82using DeclaredNamePtr = ParseContext::Scope::DeclaredNamePtr;
83using AddDeclaredNamePtr = ParseContext::Scope::AddDeclaredNamePtr;
84using BindingIter = ParseContext::Scope::BindingIter;
85using UsedNamePtr = UsedNameTracker::UsedNameMap::Ptr;
86
87using ParserBindingNameVector = Vector<ParserBindingName, 6>;
88
89static inline void PropagateTransitiveParseFlags(const FunctionBox* inner,
90 SharedContext* outer) {
91 if (inner->bindingsAccessedDynamically()) {
92 outer->setBindingsAccessedDynamically();
93 }
94 if (inner->hasDirectEval()) {
95 outer->setHasDirectEval();
96 }
97}
98
99static bool StatementKindIsBraced(StatementKind kind) {
100 return kind == StatementKind::Block || kind == StatementKind::Switch ||
101 kind == StatementKind::Try || kind == StatementKind::Catch ||
102 kind == StatementKind::Finally;
103}
104
105template <class ParseHandler, typename Unit>
106inline typename GeneralParser<ParseHandler, Unit>::FinalParser*
107GeneralParser<ParseHandler, Unit>::asFinalParser() {
108 static_assert(
109 std::is_base_of_v<GeneralParser<ParseHandler, Unit>, FinalParser>,
110 "inheritance relationship required by the static_cast<> below");
111
112 return static_cast<FinalParser*>(this);
113}
114
115template <class ParseHandler, typename Unit>
116inline const typename GeneralParser<ParseHandler, Unit>::FinalParser*
117GeneralParser<ParseHandler, Unit>::asFinalParser() const {
118 static_assert(
119 std::is_base_of_v<GeneralParser<ParseHandler, Unit>, FinalParser>,
120 "inheritance relationship required by the static_cast<> below");
121
122 return static_cast<const FinalParser*>(this);
123}
124
125template <class ParseHandler, typename Unit>
126template <typename ConditionT, typename ErrorReportT>
127bool GeneralParser<ParseHandler, Unit>::mustMatchTokenInternal(
128 ConditionT condition, ErrorReportT errorReport) {
129 MOZ_ASSERT(condition(TokenKind::Div) == false)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(condition(TokenKind::Div) == false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(condition(TokenKind::Div) ==
false))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("condition(TokenKind::Div) == false", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 129); AnnotateMozCrashReason("MOZ_ASSERT" "(" "condition(TokenKind::Div) == false"
")"); do { *((volatile int*)__null) = 129; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
130 MOZ_ASSERT(condition(TokenKind::DivAssign) == false)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(condition(TokenKind::DivAssign) == false)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(condition(TokenKind::DivAssign) == false))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("condition(TokenKind::DivAssign) == false"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 130); AnnotateMozCrashReason("MOZ_ASSERT" "(" "condition(TokenKind::DivAssign) == false"
")"); do { *((volatile int*)__null) = 130; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
131 MOZ_ASSERT(condition(TokenKind::RegExp) == false)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(condition(TokenKind::RegExp) == false)>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(condition(TokenKind::RegExp) == false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("condition(TokenKind::RegExp) == false"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 131); AnnotateMozCrashReason("MOZ_ASSERT" "(" "condition(TokenKind::RegExp) == false"
")"); do { *((volatile int*)__null) = 131; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
132
133 TokenKind actual;
134 if (!tokenStream.getToken(&actual, TokenStream::SlashIsInvalid)) {
135 return false;
136 }
137 if (!condition(actual)) {
138 errorReport(actual);
139 return false;
140 }
141 return true;
142}
143
144ParserSharedBase::ParserSharedBase(FrontendContext* fc,
145 CompilationState& compilationState,
146 Kind kind)
147 : fc_(fc),
148 alloc_(compilationState.parserAllocScope.alloc()),
149 compilationState_(compilationState),
150 pc_(nullptr),
151 usedNames_(compilationState.usedNames) {
152 fc_->nameCollectionPool().addActiveCompilation();
153}
154
155ParserSharedBase::~ParserSharedBase() {
156 fc_->nameCollectionPool().removeActiveCompilation();
157}
158
159#if defined(DEBUG1) || defined(JS_JITSPEW1)
160void ParserSharedBase::dumpAtom(TaggedParserAtomIndex index) const {
161 parserAtoms().dump(index);
162}
163#endif
164
165ParserBase::ParserBase(FrontendContext* fc,
166 const ReadOnlyCompileOptions& options,
167 bool foldConstants, CompilationState& compilationState)
168 : ParserSharedBase(fc, compilationState, ParserSharedBase::Kind::Parser),
169 anyChars(fc, options, this),
170 ss(nullptr),
171 foldConstants_(foldConstants),
172#ifdef DEBUG1
173 checkOptionsCalled_(false),
174#endif
175 isUnexpectedEOF_(false),
176 awaitHandling_(AwaitIsName),
177 inParametersOfAsyncFunction_(false) {
178}
179
180bool ParserBase::checkOptions() {
181#ifdef DEBUG1
182 checkOptionsCalled_ = true;
183#endif
184
185 return anyChars.checkOptions();
186}
187
188ParserBase::~ParserBase() { MOZ_ASSERT(checkOptionsCalled_)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(checkOptionsCalled_)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(checkOptionsCalled_))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("checkOptionsCalled_"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 188); AnnotateMozCrashReason("MOZ_ASSERT" "(" "checkOptionsCalled_"
")"); do { *((volatile int*)__null) = 188; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
; }
189
190JSAtom* ParserBase::liftParserAtomToJSAtom(TaggedParserAtomIndex index) {
191 JSContext* cx = fc_->maybeCurrentJSContext();
192 MOZ_ASSERT(cx)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(cx)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(cx))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("cx", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 192); AnnotateMozCrashReason("MOZ_ASSERT" "(" "cx" ")"); do
{ *((volatile int*)__null) = 192; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
193 return parserAtoms().toJSAtom(cx, fc_, index,
194 compilationState_.input.atomCache);
195}
196
197template <class ParseHandler>
198PerHandlerParser<ParseHandler>::PerHandlerParser(
199 FrontendContext* fc, const ReadOnlyCompileOptions& options,
200 bool foldConstants, CompilationState& compilationState,
201 void* internalSyntaxParser)
202 : ParserBase(fc, options, foldConstants, compilationState),
203 handler_(fc, compilationState),
204 internalSyntaxParser_(internalSyntaxParser) {
205 MOZ_ASSERT(compilationState.isInitialStencil() ==do { static_assert( mozilla::detail::AssertionConditionType<
decltype(compilationState.isInitialStencil() == compilationState
.input.isInitialStencil())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(compilationState.isInitialStencil
() == compilationState.input.isInitialStencil()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("compilationState.isInitialStencil() == compilationState.input.isInitialStencil()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 206); AnnotateMozCrashReason("MOZ_ASSERT" "(" "compilationState.isInitialStencil() == compilationState.input.isInitialStencil()"
")"); do { *((volatile int*)__null) = 206; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
206 compilationState.input.isInitialStencil())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(compilationState.isInitialStencil() == compilationState
.input.isInitialStencil())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(compilationState.isInitialStencil
() == compilationState.input.isInitialStencil()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("compilationState.isInitialStencil() == compilationState.input.isInitialStencil()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 206); AnnotateMozCrashReason("MOZ_ASSERT" "(" "compilationState.isInitialStencil() == compilationState.input.isInitialStencil()"
")"); do { *((volatile int*)__null) = 206; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
207}
208
209template <class ParseHandler, typename Unit>
210GeneralParser<ParseHandler, Unit>::GeneralParser(
211 FrontendContext* fc, const ReadOnlyCompileOptions& options,
212 const Unit* units, size_t length, bool foldConstants,
213 CompilationState& compilationState, SyntaxParser* syntaxParser)
214 : Base(fc, options, foldConstants, compilationState, syntaxParser),
215 tokenStream(fc, &compilationState.parserAtoms, options, units, length) {}
216
217template <typename Unit>
218void Parser<SyntaxParseHandler, Unit>::setAwaitHandling(
219 AwaitHandling awaitHandling) {
220 this->awaitHandling_ = awaitHandling;
221}
222
223template <typename Unit>
224void Parser<FullParseHandler, Unit>::setAwaitHandling(
225 AwaitHandling awaitHandling) {
226 this->awaitHandling_ = awaitHandling;
227 if (SyntaxParser* syntaxParser = getSyntaxParser()) {
228 syntaxParser->setAwaitHandling(awaitHandling);
229 }
230}
231
232template <class ParseHandler, typename Unit>
233inline void GeneralParser<ParseHandler, Unit>::setAwaitHandling(
234 AwaitHandling awaitHandling) {
235 asFinalParser()->setAwaitHandling(awaitHandling);
236}
237
238template <typename Unit>
239void Parser<SyntaxParseHandler, Unit>::setInParametersOfAsyncFunction(
240 bool inParameters) {
241 this->inParametersOfAsyncFunction_ = inParameters;
242}
243
244template <typename Unit>
245void Parser<FullParseHandler, Unit>::setInParametersOfAsyncFunction(
246 bool inParameters) {
247 this->inParametersOfAsyncFunction_ = inParameters;
248 if (SyntaxParser* syntaxParser = getSyntaxParser()) {
249 syntaxParser->setInParametersOfAsyncFunction(inParameters);
250 }
251}
252
253template <class ParseHandler, typename Unit>
254inline void GeneralParser<ParseHandler, Unit>::setInParametersOfAsyncFunction(
255 bool inParameters) {
256 asFinalParser()->setInParametersOfAsyncFunction(inParameters);
257}
258
259template <class ParseHandler>
260FunctionBox* PerHandlerParser<ParseHandler>::newFunctionBox(
261 FunctionNodeType funNode, TaggedParserAtomIndex explicitName,
262 FunctionFlags flags, uint32_t toStringStart, Directives inheritedDirectives,
263 GeneratorKind generatorKind, FunctionAsyncKind asyncKind) {
264 MOZ_ASSERT(funNode)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funNode)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(funNode))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("funNode", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 264); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funNode" ")"
); do { *((volatile int*)__null) = 264; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
265
266 ScriptIndex index = ScriptIndex(compilationState_.scriptData.length());
267 if (uint32_t(index) >= TaggedScriptThingIndex::IndexLimit) {
268 ReportAllocationOverflow(fc_);
269 return nullptr;
270 }
271 if (!compilationState_.appendScriptStencilAndData(fc_)) {
272 return nullptr;
273 }
274
275 bool isInitialStencil = compilationState_.isInitialStencil();
276
277 // This source extent will be further filled in during the remainder of parse.
278 SourceExtent extent;
279 extent.toStringStart = toStringStart;
280
281 FunctionBox* funbox = alloc_.new_<FunctionBox>(
282 fc_, extent, compilationState_, inheritedDirectives, generatorKind,
283 asyncKind, isInitialStencil, explicitName, flags, index);
284 if (!funbox) {
285 ReportOutOfMemory(fc_);
286 return nullptr;
287 }
288
289 handler_.setFunctionBox(funNode, funbox);
290
291 return funbox;
292}
293
294template <class ParseHandler>
295FunctionBox* PerHandlerParser<ParseHandler>::newFunctionBox(
296 FunctionNodeType funNode, const ScriptStencil& cachedScriptData,
297 const ScriptStencilExtra& cachedScriptExtra) {
298 MOZ_ASSERT(funNode)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funNode)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(funNode))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("funNode", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 298); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funNode" ")"
); do { *((volatile int*)__null) = 298; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
299
300 ScriptIndex index = ScriptIndex(compilationState_.scriptData.length());
301 if (uint32_t(index) >= TaggedScriptThingIndex::IndexLimit) {
302 ReportAllocationOverflow(fc_);
303 return nullptr;
304 }
305 if (!compilationState_.appendScriptStencilAndData(fc_)) {
306 return nullptr;
307 }
308
309 FunctionBox* funbox = alloc_.new_<FunctionBox>(
310 fc_, cachedScriptExtra.extent, compilationState_,
311 Directives(/* strict = */ false), cachedScriptExtra.generatorKind(),
312 cachedScriptExtra.asyncKind(), compilationState_.isInitialStencil(),
313 cachedScriptData.functionAtom, cachedScriptData.functionFlags, index);
314 if (!funbox) {
315 ReportOutOfMemory(fc_);
316 return nullptr;
317 }
318
319 handler_.setFunctionBox(funNode, funbox);
320 funbox->initFromScriptStencilExtra(cachedScriptExtra);
321
322 return funbox;
323}
324
325bool ParserBase::setSourceMapInfo() {
326 // If support for source pragmas have been fully disabled, we can skip
327 // processing of all of these values.
328 if (!options().sourcePragmas()) {
329 return true;
330 }
331
332 // Not all clients initialize ss. Can't update info to an object that isn't
333 // there.
334 if (!ss) {
335 return true;
336 }
337
338 if (anyChars.hasDisplayURL()) {
339 if (!ss->setDisplayURL(fc_, anyChars.displayURL())) {
340 return false;
341 }
342 }
343
344 if (anyChars.hasSourceMapURL()) {
345 MOZ_ASSERT(!ss->hasSourceMapURL())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!ss->hasSourceMapURL())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!ss->hasSourceMapURL())))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("!ss->hasSourceMapURL()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 345); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!ss->hasSourceMapURL()"
")"); do { *((volatile int*)__null) = 345; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
346 if (!ss->setSourceMapURL(fc_, anyChars.sourceMapURL())) {
347 return false;
348 }
349 }
350
351 /*
352 * Source map URLs passed as a compile option (usually via a HTTP source map
353 * header) override any source map urls passed as comment pragmas.
354 */
355 if (options().sourceMapURL()) {
356 // Warn about the replacement, but use the new one.
357 if (ss->hasSourceMapURL()) {
358 if (!warningNoOffset(JSMSG_ALREADY_HAS_PRAGMA, ss->filename(),
359 "//# sourceMappingURL")) {
360 return false;
361 }
362 }
363
364 if (!ss->setSourceMapURL(fc_, options().sourceMapURL())) {
365 return false;
366 }
367 }
368
369 return true;
370}
371
372/*
373 * Parse a top-level JS script.
374 */
375template <class ParseHandler, typename Unit>
376typename ParseHandler::ListNodeResult
377GeneralParser<ParseHandler, Unit>::parse() {
378 MOZ_ASSERT(checkOptionsCalled_)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(checkOptionsCalled_)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(checkOptionsCalled_))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("checkOptionsCalled_"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 378); AnnotateMozCrashReason("MOZ_ASSERT" "(" "checkOptionsCalled_"
")"); do { *((volatile int*)__null) = 378; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
379
380 SourceExtent extent = SourceExtent::makeGlobalExtent(
381 /* len = */ 0, options().lineno,
382 JS::LimitedColumnNumberOneOrigin::fromUnlimited(
383 JS::ColumnNumberOneOrigin(options().column)));
384 Directives directives(options().forceStrictMode());
385 GlobalSharedContext globalsc(this->fc_, ScopeKind::Global, options(),
386 directives, extent);
387 SourceParseContext globalpc(this, &globalsc, /* newDirectives = */ nullptr);
388 if (!globalpc.init()) {
389 return errorResult();
390 }
391
392 ParseContext::VarScope varScope(this);
393 if (!varScope.init(pc_)) {
394 return errorResult();
395 }
396
397 ListNodeType stmtList;
398 MOZ_TRY_VAR(stmtList, statementList(YieldIsName))do { auto mozTryVarTempResult_ = (statementList(YieldIsName))
; if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))
) { return mozTryVarTempResult_.propagateErr(); } (stmtList) =
mozTryVarTempResult_.unwrap(); } while (0)
;
399
400 TokenKind tt;
401 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
402 return errorResult();
403 }
404 if (tt != TokenKind::Eof) {
405 error(JSMSG_GARBAGE_AFTER_INPUT, "script", TokenKindToDesc(tt));
406 return errorResult();
407 }
408
409 if (!CheckParseTree(this->fc_, alloc_, stmtList)) {
410 return errorResult();
411 }
412
413 if (foldConstants_) {
414 Node node = stmtList;
415 // Don't constant-fold inside "use asm" code, as this could create a parse
416 // tree that doesn't type-check as asm.js.
417 if (!pc_->useAsmOrInsideUseAsm()) {
418 if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) {
419 return errorResult();
420 }
421 }
422 stmtList = handler_.asListNode(node);
423 }
424
425 return stmtList;
426}
427
428/*
429 * Strict mode forbids introducing new definitions for 'eval', 'arguments',
430 * 'let', 'static', 'yield', or for any strict mode reserved word.
431 */
432bool ParserBase::isValidStrictBinding(TaggedParserAtomIndex name) {
433 TokenKind tt = ReservedWordTokenKind(name);
434 if (tt == TokenKind::Limit) {
435 return name != TaggedParserAtomIndex::WellKnown::eval() &&
436 name != TaggedParserAtomIndex::WellKnown::arguments();
437 }
438 return tt != TokenKind::Let && tt != TokenKind::Static &&
439 tt != TokenKind::Yield && !TokenKindIsStrictReservedWord(tt);
440}
441
442/*
443 * Returns true if all parameter names are valid strict mode binding names and
444 * no duplicate parameter names are present.
445 */
446bool ParserBase::hasValidSimpleStrictParameterNames() {
447 MOZ_ASSERT(pc_->isFunctionBox() &&do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isFunctionBox() && pc_->functionBox
()->hasSimpleParameterList())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isFunctionBox() &&
pc_->functionBox()->hasSimpleParameterList()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("pc_->isFunctionBox() && pc_->functionBox()->hasSimpleParameterList()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 448); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isFunctionBox() && pc_->functionBox()->hasSimpleParameterList()"
")"); do { *((volatile int*)__null) = 448; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
448 pc_->functionBox()->hasSimpleParameterList())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isFunctionBox() && pc_->functionBox
()->hasSimpleParameterList())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isFunctionBox() &&
pc_->functionBox()->hasSimpleParameterList()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("pc_->isFunctionBox() && pc_->functionBox()->hasSimpleParameterList()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 448); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isFunctionBox() && pc_->functionBox()->hasSimpleParameterList()"
")"); do { *((volatile int*)__null) = 448; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
449
450 if (pc_->functionBox()->hasDuplicateParameters) {
451 return false;
452 }
453
454 for (auto name : pc_->positionalFormalParameterNames()) {
455 MOZ_ASSERT(name)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(name)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(name))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("name", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 455); AnnotateMozCrashReason("MOZ_ASSERT" "(" "name" ")"); do
{ *((volatile int*)__null) = 455; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
456 if (!isValidStrictBinding(name)) {
457 return false;
458 }
459 }
460 return true;
461}
462
463template <class ParseHandler, typename Unit>
464void GeneralParser<ParseHandler, Unit>::reportMissingClosing(
465 unsigned errorNumber, unsigned noteNumber, uint32_t openedPos) {
466 auto notes = MakeUnique<JSErrorNotes>();
467 if (!notes) {
468 ReportOutOfMemory(this->fc_);
469 return;
470 }
471
472 uint32_t line;
473 JS::LimitedColumnNumberOneOrigin column;
474 tokenStream.computeLineAndColumn(openedPos, &line, &column);
475
476 const size_t MaxWidth = sizeof("4294967295");
477 char columnNumber[MaxWidth];
478 SprintfLiteral(columnNumber, "%" PRIu32"u", column.oneOriginValue());
479 char lineNumber[MaxWidth];
480 SprintfLiteral(lineNumber, "%" PRIu32"u", line);
481
482 if (!notes->addNoteASCII(this->fc_, getFilename().c_str(), 0, line,
483 JS::ColumnNumberOneOrigin(column), GetErrorMessage,
484 nullptr, noteNumber, lineNumber, columnNumber)) {
485 return;
486 }
487
488 errorWithNotes(std::move(notes), errorNumber);
489}
490
491template <class ParseHandler, typename Unit>
492void GeneralParser<ParseHandler, Unit>::reportRedeclarationHelper(
493 TaggedParserAtomIndex& name, DeclarationKind& prevKind, TokenPos& pos,
494 uint32_t& prevPos, const unsigned& errorNumber,
495 const unsigned& noteErrorNumber) {
496 UniqueChars bytes = this->parserAtoms().toPrintableString(name);
497 if (!bytes) {
498 ReportOutOfMemory(this->fc_);
499 return;
500 }
501
502 if (prevPos == DeclaredNameInfo::npos) {
503 errorAt(pos.begin, errorNumber, DeclarationKindString(prevKind),
504 bytes.get());
505 return;
506 }
507
508 auto notes = MakeUnique<JSErrorNotes>();
509 if (!notes) {
510 ReportOutOfMemory(this->fc_);
511 return;
512 }
513
514 uint32_t line;
515 JS::LimitedColumnNumberOneOrigin column;
516 tokenStream.computeLineAndColumn(prevPos, &line, &column);
517
518 const size_t MaxWidth = sizeof("4294967295");
519 char columnNumber[MaxWidth];
520 SprintfLiteral(columnNumber, "%" PRIu32"u", column.oneOriginValue());
521 char lineNumber[MaxWidth];
522 SprintfLiteral(lineNumber, "%" PRIu32"u", line);
523
524 if (!notes->addNoteASCII(this->fc_, getFilename().c_str(), 0, line,
525 JS::ColumnNumberOneOrigin(column), GetErrorMessage,
526 nullptr, noteErrorNumber, lineNumber,
527 columnNumber)) {
528 return;
529 }
530
531 errorWithNotesAt(std::move(notes), pos.begin, errorNumber,
532 DeclarationKindString(prevKind), bytes.get());
533}
534
535template <class ParseHandler, typename Unit>
536void GeneralParser<ParseHandler, Unit>::reportRedeclaration(
537 TaggedParserAtomIndex name, DeclarationKind prevKind, TokenPos pos,
538 uint32_t prevPos) {
539 reportRedeclarationHelper(name, prevKind, pos, prevPos, JSMSG_REDECLARED_VAR,
540 JSMSG_PREV_DECLARATION);
541}
542
543template <class ParseHandler, typename Unit>
544void GeneralParser<ParseHandler, Unit>::reportMismatchedPlacement(
545 TaggedParserAtomIndex name, DeclarationKind prevKind, TokenPos pos,
546 uint32_t prevPos) {
547 reportRedeclarationHelper(name, prevKind, pos, prevPos,
548 JSMSG_MISMATCHED_PLACEMENT, JSMSG_PREV_DECLARATION);
549}
550
551// notePositionalFormalParameter is called for both the arguments of a regular
552// function definition and the arguments specified by the Function
553// constructor.
554//
555// The 'disallowDuplicateParams' bool indicates whether the use of another
556// feature (destructuring or default arguments) disables duplicate arguments.
557// (ECMA-262 requires us to support duplicate parameter names, but, for newer
558// features, we consider the code to have "opted in" to higher standards and
559// forbid duplicates.)
560template <class ParseHandler, typename Unit>
561bool GeneralParser<ParseHandler, Unit>::notePositionalFormalParameter(
562 FunctionNodeType funNode, TaggedParserAtomIndex name, uint32_t beginPos,
563 bool disallowDuplicateParams, bool* duplicatedParam) {
564 if (AddDeclaredNamePtr p =
28
Taking true branch
565 pc_->functionScope().lookupDeclaredNameForAdd(name)) {
566 if (disallowDuplicateParams
28.1
'disallowDuplicateParams' is false
) {
29
Taking false branch
567 error(JSMSG_BAD_DUP_ARGS);
568 return false;
569 }
570
571 // Strict-mode disallows duplicate args. We may not know whether we are
572 // in strict mode or not (since the function body hasn't been parsed).
573 // In such cases, report will queue up the potential error and return
574 // 'true'.
575 if (pc_->sc()->strict()) {
30
Assuming the condition is false
31
Taking false branch
576 UniqueChars bytes = this->parserAtoms().toPrintableString(name);
577 if (!bytes) {
578 ReportOutOfMemory(this->fc_);
579 return false;
580 }
581 if (!strictModeError(JSMSG_DUPLICATE_FORMAL, bytes.get())) {
582 return false;
583 }
584 }
585
586 *duplicatedParam = true;
32
Dereference of null pointer (loaded from variable 'duplicatedParam')
587 } else {
588 DeclarationKind kind = DeclarationKind::PositionalFormalParameter;
589 if (!pc_->functionScope().addDeclaredName(pc_, p, name, kind, beginPos)) {
590 return false;
591 }
592 }
593
594 if (!pc_->positionalFormalParameterNames().append(
595 TrivialTaggedParserAtomIndex::from(name))) {
596 ReportOutOfMemory(this->fc_);
597 return false;
598 }
599
600 NameNodeType paramNode;
601 MOZ_TRY_VAR_OR_RETURN(paramNode, newName(name), false)do { auto parserTryVarTempResult_ = (newName(name)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(paramNode) = parserTryVarTempResult_.unwrap(); } while (0)
;
602
603 handler_.addFunctionFormalParameter(funNode, paramNode);
604 return true;
605}
606
607template <class ParseHandler>
608bool PerHandlerParser<ParseHandler>::noteDestructuredPositionalFormalParameter(
609 FunctionNodeType funNode, Node destruct) {
610 // Append an empty name to the positional formals vector to keep track of
611 // argument slots when making FunctionScope::ParserData.
612 if (!pc_->positionalFormalParameterNames().append(
613 TrivialTaggedParserAtomIndex::null())) {
614 ReportOutOfMemory(fc_);
615 return false;
616 }
617
618 handler_.addFunctionFormalParameter(funNode, destruct);
619 return true;
620}
621
622template <class ParseHandler, typename Unit>
623bool GeneralParser<ParseHandler, Unit>::noteDeclaredName(
624 TaggedParserAtomIndex name, DeclarationKind kind, TokenPos pos,
625 ClosedOver isClosedOver) {
626 // The asm.js validator does all its own symbol-table management so, as an
627 // optimization, avoid doing any work here.
628 if (pc_->useAsmOrInsideUseAsm()) {
629 return true;
630 }
631
632 switch (kind) {
633 case DeclarationKind::Var:
634 case DeclarationKind::BodyLevelFunction: {
635 Maybe<DeclarationKind> redeclaredKind;
636 uint32_t prevPos;
637 if (!pc_->tryDeclareVar(name, this, kind, pos.begin, &redeclaredKind,
638 &prevPos)) {
639 return false;
640 }
641
642 if (redeclaredKind) {
643 reportRedeclaration(name, *redeclaredKind, pos, prevPos);
644 return false;
645 }
646
647 break;
648 }
649
650 case DeclarationKind::ModuleBodyLevelFunction: {
651 MOZ_ASSERT(pc_->atModuleLevel())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->atModuleLevel())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->atModuleLevel()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("pc_->atModuleLevel()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 651); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->atModuleLevel()"
")"); do { *((volatile int*)__null) = 651; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
652
653 AddDeclaredNamePtr p = pc_->varScope().lookupDeclaredNameForAdd(name);
654 if (p) {
655 reportRedeclaration(name, p->value()->kind(), pos, p->value()->pos());
656 return false;
657 }
658
659 if (!pc_->varScope().addDeclaredName(pc_, p, name, kind, pos.begin,
660 isClosedOver)) {
661 return false;
662 }
663
664 // Body-level functions in modules are always closed over.
665 pc_->varScope().lookupDeclaredName(name)->value()->setClosedOver();
666
667 break;
668 }
669
670 case DeclarationKind::FormalParameter: {
671 // It is an early error if any non-positional formal parameter name
672 // (e.g., destructuring formal parameter) is duplicated.
673
674 AddDeclaredNamePtr p =
675 pc_->functionScope().lookupDeclaredNameForAdd(name);
676 if (p) {
677 error(JSMSG_BAD_DUP_ARGS);
678 return false;
679 }
680
681 if (!pc_->functionScope().addDeclaredName(pc_, p, name, kind, pos.begin,
682 isClosedOver)) {
683 return false;
684 }
685
686 break;
687 }
688
689 case DeclarationKind::LexicalFunction:
690 case DeclarationKind::PrivateName:
691 case DeclarationKind::Synthetic:
692 case DeclarationKind::PrivateMethod: {
693 ParseContext::Scope* scope = pc_->innermostScope();
694 AddDeclaredNamePtr p = scope->lookupDeclaredNameForAdd(name);
695 if (p) {
696 reportRedeclaration(name, p->value()->kind(), pos, p->value()->pos());
697 return false;
698 }
699
700 if (!scope->addDeclaredName(pc_, p, name, kind, pos.begin,
701 isClosedOver)) {
702 return false;
703 }
704
705 break;
706 }
707
708 case DeclarationKind::SloppyLexicalFunction: {
709 // Functions in block have complex allowances in sloppy mode for being
710 // labelled that other lexical declarations do not have. Those checks
711 // are done in functionStmt.
712
713 ParseContext::Scope* scope = pc_->innermostScope();
714 if (AddDeclaredNamePtr p = scope->lookupDeclaredNameForAdd(name)) {
715 // It is usually an early error if there is another declaration
716 // with the same name in the same scope.
717 //
718 // Sloppy lexical functions may redeclare other sloppy lexical
719 // functions for web compatibility reasons.
720 if (p->value()->kind() != DeclarationKind::SloppyLexicalFunction) {
721 reportRedeclaration(name, p->value()->kind(), pos, p->value()->pos());
722 return false;
723 }
724 } else {
725 if (!scope->addDeclaredName(pc_, p, name, kind, pos.begin,
726 isClosedOver)) {
727 return false;
728 }
729 }
730
731 break;
732 }
733
734 case DeclarationKind::Let:
735 case DeclarationKind::Const:
736#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
737 case DeclarationKind::Using:
738 case DeclarationKind::AwaitUsing:
739#endif
740 case DeclarationKind::Class:
741 // The BoundNames of LexicalDeclaration and ForDeclaration must not
742 // contain 'let'. (CatchParameter is the only lexical binding form
743 // without this restriction.)
744 if (name == TaggedParserAtomIndex::WellKnown::let()) {
745 errorAt(pos.begin, JSMSG_LEXICAL_DECL_DEFINES_LET);
746 return false;
747 }
748
749 // For body-level lexically declared names in a function, it is an
750 // early error if there is a formal parameter of the same name. This
751 // needs a special check if there is an extra var scope due to
752 // parameter expressions.
753 if (pc_->isFunctionExtraBodyVarScopeInnermost()) {
754 DeclaredNamePtr p = pc_->functionScope().lookupDeclaredName(name);
755 if (p && DeclarationKindIsParameter(p->value()->kind())) {
756 reportRedeclaration(name, p->value()->kind(), pos, p->value()->pos());
757 return false;
758 }
759 }
760
761 [[fallthrough]];
762
763 case DeclarationKind::Import:
764 // Module code is always strict, so 'let' is always a keyword and never a
765 // name.
766 MOZ_ASSERT(name != TaggedParserAtomIndex::WellKnown::let())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(name != TaggedParserAtomIndex::WellKnown::let())>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(name != TaggedParserAtomIndex::WellKnown::let()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("name != TaggedParserAtomIndex::WellKnown::let()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 766); AnnotateMozCrashReason("MOZ_ASSERT" "(" "name != TaggedParserAtomIndex::WellKnown::let()"
")"); do { *((volatile int*)__null) = 766; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
767 [[fallthrough]];
768
769 case DeclarationKind::SimpleCatchParameter:
770 case DeclarationKind::CatchParameter: {
771 ParseContext::Scope* scope = pc_->innermostScope();
772
773 // It is an early error if there is another declaration with the same
774 // name in the same scope.
775 AddDeclaredNamePtr p = scope->lookupDeclaredNameForAdd(name);
776 if (p) {
777 reportRedeclaration(name, p->value()->kind(), pos, p->value()->pos());
778 return false;
779 }
780
781 if (!scope->addDeclaredName(pc_, p, name, kind, pos.begin,
782 isClosedOver)) {
783 return false;
784 }
785
786 break;
787 }
788
789 case DeclarationKind::CoverArrowParameter:
790 // CoverArrowParameter is only used as a placeholder declaration kind.
791 break;
792
793 case DeclarationKind::PositionalFormalParameter:
794 MOZ_CRASH(do { do { } while (false); MOZ_ReportCrash("" "Positional formal parameter names should use "
"notePositionalFormalParameter", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 796); AnnotateMozCrashReason("MOZ_CRASH(" "Positional formal parameter names should use "
"notePositionalFormalParameter" ")"); do { *((volatile int*)
__null) = 796; __attribute__((nomerge)) ::abort(); } while (false
); } while (false)
795 "Positional formal parameter names should use "do { do { } while (false); MOZ_ReportCrash("" "Positional formal parameter names should use "
"notePositionalFormalParameter", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 796); AnnotateMozCrashReason("MOZ_CRASH(" "Positional formal parameter names should use "
"notePositionalFormalParameter" ")"); do { *((volatile int*)
__null) = 796; __attribute__((nomerge)) ::abort(); } while (false
); } while (false)
796 "notePositionalFormalParameter")do { do { } while (false); MOZ_ReportCrash("" "Positional formal parameter names should use "
"notePositionalFormalParameter", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 796); AnnotateMozCrashReason("MOZ_CRASH(" "Positional formal parameter names should use "
"notePositionalFormalParameter" ")"); do { *((volatile int*)
__null) = 796; __attribute__((nomerge)) ::abort(); } while (false
); } while (false)
;
797 break;
798
799 case DeclarationKind::VarForAnnexBLexicalFunction:
800 MOZ_CRASH(do { do { } while (false); MOZ_ReportCrash("" "Synthesized Annex B vars should go through "
"addPossibleAnnexBFunctionBox, and " "propagateAndMarkAnnexBFunctionBoxes"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 803); AnnotateMozCrashReason("MOZ_CRASH(" "Synthesized Annex B vars should go through "
"addPossibleAnnexBFunctionBox, and " "propagateAndMarkAnnexBFunctionBoxes"
")"); do { *((volatile int*)__null) = 803; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
801 "Synthesized Annex B vars should go through "do { do { } while (false); MOZ_ReportCrash("" "Synthesized Annex B vars should go through "
"addPossibleAnnexBFunctionBox, and " "propagateAndMarkAnnexBFunctionBoxes"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 803); AnnotateMozCrashReason("MOZ_CRASH(" "Synthesized Annex B vars should go through "
"addPossibleAnnexBFunctionBox, and " "propagateAndMarkAnnexBFunctionBoxes"
")"); do { *((volatile int*)__null) = 803; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
802 "addPossibleAnnexBFunctionBox, and "do { do { } while (false); MOZ_ReportCrash("" "Synthesized Annex B vars should go through "
"addPossibleAnnexBFunctionBox, and " "propagateAndMarkAnnexBFunctionBoxes"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 803); AnnotateMozCrashReason("MOZ_CRASH(" "Synthesized Annex B vars should go through "
"addPossibleAnnexBFunctionBox, and " "propagateAndMarkAnnexBFunctionBoxes"
")"); do { *((volatile int*)__null) = 803; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
803 "propagateAndMarkAnnexBFunctionBoxes")do { do { } while (false); MOZ_ReportCrash("" "Synthesized Annex B vars should go through "
"addPossibleAnnexBFunctionBox, and " "propagateAndMarkAnnexBFunctionBoxes"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 803); AnnotateMozCrashReason("MOZ_CRASH(" "Synthesized Annex B vars should go through "
"addPossibleAnnexBFunctionBox, and " "propagateAndMarkAnnexBFunctionBoxes"
")"); do { *((volatile int*)__null) = 803; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
804 break;
805 }
806
807 return true;
808}
809
810template <class ParseHandler, typename Unit>
811bool GeneralParser<ParseHandler, Unit>::noteDeclaredPrivateName(
812 Node nameNode, TaggedParserAtomIndex name, PropertyType propType,
813 FieldPlacement placement, TokenPos pos) {
814 ParseContext::Scope* scope = pc_->innermostScope();
815 AddDeclaredNamePtr p = scope->lookupDeclaredNameForAdd(name);
816
817 DeclarationKind declKind = DeclarationKind::PrivateName;
818
819 // Our strategy for enabling debugger functionality is to mark names as closed
820 // over, even if they don't necessarily need to be, to ensure that they are
821 // included in the environment object. This allows us to easily look them up
822 // by name when needed, even if there is no corresponding property on an
823 // object, as is the case with getter, setters and private methods.
824 ClosedOver closedOver = ClosedOver::Yes;
825 PrivateNameKind kind;
826 switch (propType) {
827 case PropertyType::Field:
828 kind = PrivateNameKind::Field;
829 closedOver = ClosedOver::No;
830 break;
831 case PropertyType::FieldWithAccessor:
832 // In this case, we create a new private field for the underlying storage,
833 // and use the current name for the getter and setter.
834 kind = PrivateNameKind::GetterSetter;
835 break;
836 case PropertyType::Method:
837 case PropertyType::GeneratorMethod:
838 case PropertyType::AsyncMethod:
839 case PropertyType::AsyncGeneratorMethod:
840 if (placement == FieldPlacement::Instance) {
841 // Optimized private method. Non-optimized paths still get
842 // DeclarationKind::Synthetic.
843 declKind = DeclarationKind::PrivateMethod;
844 }
845 kind = PrivateNameKind::Method;
846 break;
847 case PropertyType::Getter:
848 kind = PrivateNameKind::Getter;
849 break;
850 case PropertyType::Setter:
851 kind = PrivateNameKind::Setter;
852 break;
853 default:
854 MOZ_CRASH("Invalid Property Type for noteDeclarePrivateName")do { do { } while (false); MOZ_ReportCrash("" "Invalid Property Type for noteDeclarePrivateName"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 854); AnnotateMozCrashReason("MOZ_CRASH(" "Invalid Property Type for noteDeclarePrivateName"
")"); do { *((volatile int*)__null) = 854; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
855 }
856
857 if (p) {
858 PrivateNameKind prevKind = p->value()->privateNameKind();
859 if ((prevKind == PrivateNameKind::Getter &&
860 kind == PrivateNameKind::Setter) ||
861 (prevKind == PrivateNameKind::Setter &&
862 kind == PrivateNameKind::Getter)) {
863 // Private methods demands that
864 //
865 // class A {
866 // static set #x(_) {}
867 // get #x() { }
868 // }
869 //
870 // Report a SyntaxError.
871 if (placement == p->value()->placement()) {
872 p->value()->setPrivateNameKind(PrivateNameKind::GetterSetter);
873 handler_.setPrivateNameKind(nameNode, PrivateNameKind::GetterSetter);
874 return true;
875 }
876 }
877
878 reportMismatchedPlacement(name, p->value()->kind(), pos, p->value()->pos());
879 return false;
880 }
881
882 if (!scope->addDeclaredName(pc_, p, name, declKind, pos.begin, closedOver)) {
883 return false;
884 }
885
886 DeclaredNamePtr declared = scope->lookupDeclaredName(name);
887 declared->value()->setPrivateNameKind(kind);
888 declared->value()->setFieldPlacement(placement);
889 handler_.setPrivateNameKind(nameNode, kind);
890
891 return true;
892}
893
894bool ParserBase::noteUsedNameInternal(TaggedParserAtomIndex name,
895 NameVisibility visibility,
896 mozilla::Maybe<TokenPos> tokenPosition) {
897 // The asm.js validator does all its own symbol-table management so, as an
898 // optimization, avoid doing any work here.
899 if (pc_->useAsmOrInsideUseAsm()) {
900 return true;
901 }
902
903 // Global bindings are properties and not actual bindings; we don't need
904 // to know if they are closed over. So no need to track used name at the
905 // global scope. It is not incorrect to track them, this is an
906 // optimization.
907 //
908 // Exceptions:
909 // (a) Track private name references, as the used names tracker is used to
910 // provide early errors for undeclared private name references
911 // (b) If the script has extra bindings, track all references to detect
912 // references to extra bindings
913 ParseContext::Scope* scope = pc_->innermostScope();
914 if (pc_->sc()->isGlobalContext() && scope == &pc_->varScope() &&
915 visibility == NameVisibility::Public &&
916 !this->compilationState_.input.hasExtraBindings()) {
917 return true;
918 }
919
920 return usedNames_.noteUse(fc_, name, visibility, pc_->scriptId(), scope->id(),
921 tokenPosition);
922}
923
924template <class ParseHandler>
925bool PerHandlerParser<ParseHandler>::
926 propagateFreeNamesAndMarkClosedOverBindings(ParseContext::Scope& scope) {
927 // Now that we have all the declared names in the scope, check which
928 // functions should exhibit Annex B semantics.
929 if (!scope.propagateAndMarkAnnexBFunctionBoxes(pc_, this)) {
930 return false;
931 }
932
933 if (handler_.reuseClosedOverBindings()) {
934 MOZ_ASSERT(pc_->isOutermostOfCurrentCompile())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isOutermostOfCurrentCompile())>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(pc_->isOutermostOfCurrentCompile()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->isOutermostOfCurrentCompile()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 934); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isOutermostOfCurrentCompile()"
")"); do { *((volatile int*)__null) = 934; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
935
936 // Closed over bindings for all scopes are stored in a contiguous array, in
937 // the same order as the order in which scopes are visited, and seprated by
938 // TaggedParserAtomIndex::null().
939 uint32_t slotCount = scope.declaredCount();
940 while (auto parserAtom = handler_.nextLazyClosedOverBinding()) {
941 scope.lookupDeclaredName(parserAtom)->value()->setClosedOver();
942 MOZ_ASSERT(slotCount > 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(slotCount > 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(slotCount > 0))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("slotCount > 0"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 942); AnnotateMozCrashReason("MOZ_ASSERT" "(" "slotCount > 0"
")"); do { *((volatile int*)__null) = 942; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
943 slotCount--;
944 }
945
946 if (pc_->isGeneratorOrAsync()) {
947 scope.setOwnStackSlotCount(slotCount);
948 }
949 return true;
950 }
951
952 constexpr bool isSyntaxParser =
953 std::is_same_v<ParseHandler, SyntaxParseHandler>;
954 uint32_t scriptId = pc_->scriptId();
955 uint32_t scopeId = scope.id();
956
957 uint32_t slotCount = 0;
958 for (BindingIter bi = scope.bindings(pc_); bi; bi++) {
959 bool closedOver = false;
960 if (UsedNamePtr p = usedNames_.lookup(bi.name())) {
961 p->value().noteBoundInScope(scriptId, scopeId, &closedOver);
962 if (closedOver) {
963 bi.setClosedOver();
964
965 if constexpr (isSyntaxParser) {
966 if (!pc_->closedOverBindingsForLazy().append(
967 TrivialTaggedParserAtomIndex::from(bi.name()))) {
968 ReportOutOfMemory(fc_);
969 return false;
970 }
971 }
972 }
973 }
974
975 if constexpr (!isSyntaxParser) {
976 if (!closedOver) {
977 slotCount++;
978 }
979 }
980 }
981 if constexpr (!isSyntaxParser) {
982 if (pc_->isGeneratorOrAsync()) {
983 scope.setOwnStackSlotCount(slotCount);
984 }
985 }
986
987 // Append a nullptr to denote end-of-scope.
988 if constexpr (isSyntaxParser) {
989 if (!pc_->closedOverBindingsForLazy().append(
990 TrivialTaggedParserAtomIndex::null())) {
991 ReportOutOfMemory(fc_);
992 return false;
993 }
994 }
995
996 return true;
997}
998
999template <typename Unit>
1000bool Parser<FullParseHandler, Unit>::checkStatementsEOF() {
1001 // This is designed to be paired with parsing a statement list at the top
1002 // level.
1003 //
1004 // The statementList() call breaks on TokenKind::RightCurly, so make sure
1005 // we've reached EOF here.
1006 TokenKind tt;
1007 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
1008 return false;
1009 }
1010 if (tt != TokenKind::Eof) {
1011 error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
1012 return false;
1013 }
1014 return true;
1015}
1016
1017template <typename ScopeT>
1018typename ScopeT::ParserData* NewEmptyBindingData(FrontendContext* fc,
1019 LifoAlloc& alloc,
1020 uint32_t numBindings) {
1021 using Data = typename ScopeT::ParserData;
1022 size_t allocSize = SizeOfScopeData<Data>(numBindings);
1023 auto* bindings = alloc.newWithSize<Data>(allocSize, numBindings);
1024 if (!bindings) {
1025 ReportOutOfMemory(fc);
1026 }
1027 return bindings;
1028}
1029
1030GlobalScope::ParserData* NewEmptyGlobalScopeData(FrontendContext* fc,
1031 LifoAlloc& alloc,
1032 uint32_t numBindings) {
1033 return NewEmptyBindingData<GlobalScope>(fc, alloc, numBindings);
1034}
1035
1036LexicalScope::ParserData* NewEmptyLexicalScopeData(FrontendContext* fc,
1037 LifoAlloc& alloc,
1038 uint32_t numBindings) {
1039 return NewEmptyBindingData<LexicalScope>(fc, alloc, numBindings);
1040}
1041
1042FunctionScope::ParserData* NewEmptyFunctionScopeData(FrontendContext* fc,
1043 LifoAlloc& alloc,
1044 uint32_t numBindings) {
1045 return NewEmptyBindingData<FunctionScope>(fc, alloc, numBindings);
1046}
1047
1048namespace detail {
1049
1050template <class SlotInfo>
1051static MOZ_ALWAYS_INLINEinline ParserBindingName* InitializeIndexedBindings(
1052 SlotInfo& slotInfo, ParserBindingName* start, ParserBindingName* cursor) {
1053 return cursor;
1054}
1055
1056template <class SlotInfo, typename UnsignedInteger, typename... Step>
1057static MOZ_ALWAYS_INLINEinline ParserBindingName* InitializeIndexedBindings(
1058 SlotInfo& slotInfo, ParserBindingName* start, ParserBindingName* cursor,
1059 UnsignedInteger SlotInfo::*field, const ParserBindingNameVector& bindings,
1060 Step&&... step) {
1061 slotInfo.*field =
1062 AssertedCast<UnsignedInteger>(PointerRangeSize(start, cursor));
1063
1064 ParserBindingName* newCursor =
1065 std::uninitialized_copy(bindings.begin(), bindings.end(), cursor);
1066
1067 return InitializeIndexedBindings(slotInfo, start, newCursor,
1068 std::forward<Step>(step)...);
1069}
1070
1071} // namespace detail
1072
1073// Initialize the trailing name bindings of |data|, then set |data->length| to
1074// the count of bindings added (which must equal |count|).
1075//
1076// First, |firstBindings| are added to the trailing names. Then any
1077// "steps" present are performed first to last. Each step is 1) a pointer to a
1078// member of |data| to be set to the current number of bindings added, and 2) a
1079// vector of |ParserBindingName|s to then copy into |data->trailingNames|.
1080// (Thus each |data| member field indicates where the corresponding vector's
1081// names start.)
1082template <class Data, typename... Step>
1083static MOZ_ALWAYS_INLINEinline void InitializeBindingData(
1084 Data* data, uint32_t count, const ParserBindingNameVector& firstBindings,
1085 Step&&... step) {
1086 MOZ_ASSERT(data->length == 0, "data shouldn't be filled yet")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(data->length == 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(data->length == 0))), 0))
) { do { } while (false); MOZ_ReportAssertionFailure("data->length == 0"
" (" "data shouldn't be filled yet" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1086); AnnotateMozCrashReason("MOZ_ASSERT" "(" "data->length == 0"
") (" "data shouldn't be filled yet" ")"); do { *((volatile int
*)__null) = 1086; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1087
1088 ParserBindingName* start = GetScopeDataTrailingNamesPointer(data);
1089 ParserBindingName* cursor = std::uninitialized_copy(
1090 firstBindings.begin(), firstBindings.end(), start);
1091
1092#ifdef DEBUG1
1093 ParserBindingName* end =
1094#endif
1095 detail::InitializeIndexedBindings(data->slotInfo, start, cursor,
1096 std::forward<Step>(step)...);
1097
1098 MOZ_ASSERT(PointerRangeSize(start, end) == count)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(PointerRangeSize(start, end) == count)>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(PointerRangeSize(start, end) == count))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("PointerRangeSize(start, end) == count"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1098); AnnotateMozCrashReason("MOZ_ASSERT" "(" "PointerRangeSize(start, end) == count"
")"); do { *((volatile int*)__null) = 1098; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1099 data->length = count;
1100}
1101
1102static Maybe<GlobalScope::ParserData*> NewGlobalScopeData(
1103 FrontendContext* fc, ParseContext::Scope& scope, LifoAlloc& alloc,
1104 ParseContext* pc) {
1105 ParserBindingNameVector vars(fc);
1106 ParserBindingNameVector lets(fc);
1107 ParserBindingNameVector consts(fc);
1108
1109 bool allBindingsClosedOver = pc->sc()->allBindingsClosedOver();
1110 for (BindingIter bi = scope.bindings(pc); bi; bi++) {
1111 bool closedOver = allBindingsClosedOver || bi.closedOver();
1112
1113 switch (bi.kind()) {
1114 case BindingKind::Var: {
1115 bool isTopLevelFunction =
1116 bi.declarationKind() == DeclarationKind::BodyLevelFunction;
1117
1118 ParserBindingName binding(bi.name(), closedOver, isTopLevelFunction);
1119 if (!vars.append(binding)) {
1120 return Nothing();
1121 }
1122 break;
1123 }
1124 case BindingKind::Let: {
1125 ParserBindingName binding(bi.name(), closedOver);
1126 if (!lets.append(binding)) {
1127 return Nothing();
1128 }
1129 break;
1130 }
1131 case BindingKind::Const: {
1132 ParserBindingName binding(bi.name(), closedOver);
1133 if (!consts.append(binding)) {
1134 return Nothing();
1135 }
1136 break;
1137 }
1138 default:
1139 MOZ_CRASH("Bad global scope BindingKind")do { do { } while (false); MOZ_ReportCrash("" "Bad global scope BindingKind"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1139); AnnotateMozCrashReason("MOZ_CRASH(" "Bad global scope BindingKind"
")"); do { *((volatile int*)__null) = 1139; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
1140 }
1141 }
1142
1143 GlobalScope::ParserData* bindings = nullptr;
1144 uint32_t numBindings = vars.length() + lets.length() + consts.length();
1145
1146 if (numBindings > 0) {
1147 bindings = NewEmptyBindingData<GlobalScope>(fc, alloc, numBindings);
1148 if (!bindings) {
1149 return Nothing();
1150 }
1151
1152 // The ordering here is important. See comments in GlobalScope.
1153 InitializeBindingData(bindings, numBindings, vars,
1154 &ParserGlobalScopeSlotInfo::letStart, lets,
1155 &ParserGlobalScopeSlotInfo::constStart, consts);
1156 }
1157
1158 return Some(bindings);
1159}
1160
1161Maybe<GlobalScope::ParserData*> ParserBase::newGlobalScopeData(
1162 ParseContext::Scope& scope) {
1163 return NewGlobalScopeData(fc_, scope, stencilAlloc(), pc_);
1164}
1165
1166static Maybe<ModuleScope::ParserData*> NewModuleScopeData(
1167 FrontendContext* fc, ParseContext::Scope& scope, LifoAlloc& alloc,
1168 ParseContext* pc) {
1169 ParserBindingNameVector imports(fc);
1170 ParserBindingNameVector vars(fc);
1171 ParserBindingNameVector lets(fc);
1172 ParserBindingNameVector consts(fc);
1173#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1174 ParserBindingNameVector usings(fc);
1175#endif
1176
1177 bool allBindingsClosedOver =
1178 pc->sc()->allBindingsClosedOver() || scope.tooBigToOptimize();
1179
1180 for (BindingIter bi = scope.bindings(pc); bi; bi++) {
1181 // Imports are indirect bindings and must not be given known slots.
1182 ParserBindingName binding(bi.name(),
1183 (allBindingsClosedOver || bi.closedOver()) &&
1184 bi.kind() != BindingKind::Import);
1185 switch (bi.kind()) {
1186 case BindingKind::Import:
1187 if (!imports.append(binding)) {
1188 return Nothing();
1189 }
1190 break;
1191 case BindingKind::Var:
1192 if (!vars.append(binding)) {
1193 return Nothing();
1194 }
1195 break;
1196 case BindingKind::Let:
1197 if (!lets.append(binding)) {
1198 return Nothing();
1199 }
1200 break;
1201 case BindingKind::Const:
1202 if (!consts.append(binding)) {
1203 return Nothing();
1204 }
1205 break;
1206#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1207 case BindingKind::Using:
1208 if (!usings.append(binding)) {
1209 return Nothing();
1210 }
1211 break;
1212#endif
1213 default:
1214 MOZ_CRASH("Bad module scope BindingKind")do { do { } while (false); MOZ_ReportCrash("" "Bad module scope BindingKind"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1214); AnnotateMozCrashReason("MOZ_CRASH(" "Bad module scope BindingKind"
")"); do { *((volatile int*)__null) = 1214; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
1215 }
1216 }
1217
1218 ModuleScope::ParserData* bindings = nullptr;
1219 uint32_t numBindings = imports.length() + vars.length() + lets.length() +
1220 consts.length()
1221#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1222 + usings.length()
1223#endif
1224 ;
1225
1226 if (numBindings > 0) {
1227 bindings = NewEmptyBindingData<ModuleScope>(fc, alloc, numBindings);
1228 if (!bindings) {
1229 return Nothing();
1230 }
1231
1232 // The ordering here is important. See comments in ModuleScope.
1233 InitializeBindingData(bindings, numBindings, imports,
1234 &ParserModuleScopeSlotInfo::varStart, vars,
1235 &ParserModuleScopeSlotInfo::letStart, lets,
1236 &ParserModuleScopeSlotInfo::constStart, consts
1237#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1238 ,
1239 &ParserModuleScopeSlotInfo::usingStart, usings
1240#endif
1241 );
1242 }
1243
1244 return Some(bindings);
1245}
1246
1247Maybe<ModuleScope::ParserData*> ParserBase::newModuleScopeData(
1248 ParseContext::Scope& scope) {
1249 return NewModuleScopeData(fc_, scope, stencilAlloc(), pc_);
1250}
1251
1252static Maybe<EvalScope::ParserData*> NewEvalScopeData(
1253 FrontendContext* fc, ParseContext::Scope& scope, LifoAlloc& alloc,
1254 ParseContext* pc) {
1255 ParserBindingNameVector vars(fc);
1256
1257 // Treat all bindings as closed over in non-strict eval.
1258 bool allBindingsClosedOver =
1259 !pc->sc()->strict() || pc->sc()->allBindingsClosedOver();
1260 for (BindingIter bi = scope.bindings(pc); bi; bi++) {
1261 // Eval scopes only contain 'var' bindings.
1262 MOZ_ASSERT(bi.kind() == BindingKind::Var)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(bi.kind() == BindingKind::Var)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(bi.kind() == BindingKind::Var
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"bi.kind() == BindingKind::Var", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1262); AnnotateMozCrashReason("MOZ_ASSERT" "(" "bi.kind() == BindingKind::Var"
")"); do { *((volatile int*)__null) = 1262; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1263 bool isTopLevelFunction =
1264 bi.declarationKind() == DeclarationKind::BodyLevelFunction;
1265 bool closedOver = allBindingsClosedOver || bi.closedOver();
1266
1267 ParserBindingName binding(bi.name(), closedOver, isTopLevelFunction);
1268 if (!vars.append(binding)) {
1269 return Nothing();
1270 }
1271 }
1272
1273 EvalScope::ParserData* bindings = nullptr;
1274 uint32_t numBindings = vars.length();
1275
1276 if (numBindings > 0) {
1277 bindings = NewEmptyBindingData<EvalScope>(fc, alloc, numBindings);
1278 if (!bindings) {
1279 return Nothing();
1280 }
1281
1282 InitializeBindingData(bindings, numBindings, vars);
1283 }
1284
1285 return Some(bindings);
1286}
1287
1288Maybe<EvalScope::ParserData*> ParserBase::newEvalScopeData(
1289 ParseContext::Scope& scope) {
1290 return NewEvalScopeData(fc_, scope, stencilAlloc(), pc_);
1291}
1292
1293static Maybe<FunctionScope::ParserData*> NewFunctionScopeData(
1294 FrontendContext* fc, ParseContext::Scope& scope, bool hasParameterExprs,
1295 LifoAlloc& alloc, ParseContext* pc) {
1296 ParserBindingNameVector positionalFormals(fc);
1297 ParserBindingNameVector formals(fc);
1298 ParserBindingNameVector vars(fc);
1299
1300 bool allBindingsClosedOver =
1301 pc->sc()->allBindingsClosedOver() || scope.tooBigToOptimize();
1302 bool argumentBindingsClosedOver =
1303 allBindingsClosedOver || pc->isGeneratorOrAsync();
1304 bool hasDuplicateParams = pc->functionBox()->hasDuplicateParameters;
1305
1306 // Positional parameter names must be added in order of appearance as they are
1307 // referenced using argument slots.
1308 for (size_t i = 0; i < pc->positionalFormalParameterNames().length(); i++) {
1309 TaggedParserAtomIndex name = pc->positionalFormalParameterNames()[i];
1310
1311 ParserBindingName bindName;
1312 if (name) {
1313 DeclaredNamePtr p = scope.lookupDeclaredName(name);
1314
1315 // Do not consider any positional formal parameters closed over if
1316 // there are parameter defaults. It is the binding in the defaults
1317 // scope that is closed over instead.
1318 bool closedOver =
1319 argumentBindingsClosedOver || (p && p->value()->closedOver());
1320
1321 // If the parameter name has duplicates, only the final parameter
1322 // name should be on the environment, as otherwise the environment
1323 // object would have multiple, same-named properties.
1324 if (hasDuplicateParams) {
1325 for (size_t j = pc->positionalFormalParameterNames().length() - 1;
1326 j > i; j--) {
1327 if (TaggedParserAtomIndex(pc->positionalFormalParameterNames()[j]) ==
1328 name) {
1329 closedOver = false;
1330 break;
1331 }
1332 }
1333 }
1334
1335 bindName = ParserBindingName(name, closedOver);
1336 }
1337
1338 if (!positionalFormals.append(bindName)) {
1339 return Nothing();
1340 }
1341 }
1342
1343 for (BindingIter bi = scope.bindings(pc); bi; bi++) {
1344 ParserBindingName binding(bi.name(),
1345 allBindingsClosedOver || bi.closedOver());
1346 switch (bi.kind()) {
1347 case BindingKind::FormalParameter:
1348 // Positional parameter names are already handled above.
1349 if (bi.declarationKind() == DeclarationKind::FormalParameter) {
1350 if (!formals.append(binding)) {
1351 return Nothing();
1352 }
1353 }
1354 break;
1355 case BindingKind::Var:
1356 // The only vars in the function scope when there are parameter
1357 // exprs, which induces a separate var environment, should be the
1358 // special bindings.
1359 MOZ_ASSERT_IF(hasParameterExprs,do { if (hasParameterExprs) { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(FunctionScope::isSpecialName
(bi.name()))>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(FunctionScope::isSpecialName(bi.name
())))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("FunctionScope::isSpecialName(bi.name())", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1360); AnnotateMozCrashReason("MOZ_ASSERT" "(" "FunctionScope::isSpecialName(bi.name())"
")"); do { *((volatile int*)__null) = 1360; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1360 FunctionScope::isSpecialName(bi.name()))do { if (hasParameterExprs) { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(FunctionScope::isSpecialName
(bi.name()))>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(FunctionScope::isSpecialName(bi.name
())))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("FunctionScope::isSpecialName(bi.name())", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1360); AnnotateMozCrashReason("MOZ_ASSERT" "(" "FunctionScope::isSpecialName(bi.name())"
")"); do { *((volatile int*)__null) = 1360; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
1361 if (!vars.append(binding)) {
1362 return Nothing();
1363 }
1364 break;
1365 case BindingKind::Let:
1366 case BindingKind::Const:
1367#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1368 case BindingKind::Using:
1369#endif
1370 break;
1371 default:
1372 MOZ_CRASH("bad function scope BindingKind")do { do { } while (false); MOZ_ReportCrash("" "bad function scope BindingKind"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1372); AnnotateMozCrashReason("MOZ_CRASH(" "bad function scope BindingKind"
")"); do { *((volatile int*)__null) = 1372; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
1373 break;
1374 }
1375 }
1376
1377 FunctionScope::ParserData* bindings = nullptr;
1378 uint32_t numBindings =
1379 positionalFormals.length() + formals.length() + vars.length();
1380
1381 if (numBindings > 0) {
1382 bindings = NewEmptyBindingData<FunctionScope>(fc, alloc, numBindings);
1383 if (!bindings) {
1384 return Nothing();
1385 }
1386
1387 // The ordering here is important. See comments in FunctionScope.
1388 InitializeBindingData(
1389 bindings, numBindings, positionalFormals,
1390 &ParserFunctionScopeSlotInfo::nonPositionalFormalStart, formals,
1391 &ParserFunctionScopeSlotInfo::varStart, vars);
1392 }
1393
1394 return Some(bindings);
1395}
1396
1397// Compute if `NewFunctionScopeData` would return any binding list with any
1398// entry marked as closed-over. This is done without the need to allocate the
1399// binding list. If true, an EnvironmentObject will be needed at runtime.
1400bool FunctionScopeHasClosedOverBindings(ParseContext* pc) {
1401 bool allBindingsClosedOver = pc->sc()->allBindingsClosedOver() ||
1402 pc->functionScope().tooBigToOptimize();
1403
1404 for (BindingIter bi = pc->functionScope().bindings(pc); bi; bi++) {
1405 switch (bi.kind()) {
1406 case BindingKind::FormalParameter:
1407 case BindingKind::Var:
1408 if (allBindingsClosedOver || bi.closedOver()) {
1409 return true;
1410 }
1411 break;
1412
1413 default:
1414 break;
1415 }
1416 }
1417
1418 return false;
1419}
1420
1421Maybe<FunctionScope::ParserData*> ParserBase::newFunctionScopeData(
1422 ParseContext::Scope& scope, bool hasParameterExprs) {
1423 return NewFunctionScopeData(fc_, scope, hasParameterExprs, stencilAlloc(),
1424 pc_);
1425}
1426
1427VarScope::ParserData* NewEmptyVarScopeData(FrontendContext* fc,
1428 LifoAlloc& alloc,
1429 uint32_t numBindings) {
1430 return NewEmptyBindingData<VarScope>(fc, alloc, numBindings);
1431}
1432
1433static Maybe<VarScope::ParserData*> NewVarScopeData(FrontendContext* fc,
1434 ParseContext::Scope& scope,
1435 LifoAlloc& alloc,
1436 ParseContext* pc) {
1437 ParserBindingNameVector vars(fc);
1438
1439 bool allBindingsClosedOver =
1440 pc->sc()->allBindingsClosedOver() || scope.tooBigToOptimize();
1441
1442 for (BindingIter bi = scope.bindings(pc); bi; bi++) {
1443 if (bi.kind() == BindingKind::Var) {
1444 ParserBindingName binding(bi.name(),
1445 allBindingsClosedOver || bi.closedOver());
1446 if (!vars.append(binding)) {
1447 return Nothing();
1448 }
1449 } else {
1450 MOZ_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType<
decltype(bi.kind() == BindingKind::Let || bi.kind() == BindingKind
::Const)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(bi.kind() == BindingKind::Let || bi.kind() == BindingKind
::Const))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("bi.kind() == BindingKind::Let || bi.kind() == BindingKind::Const"
" (" "bad var scope BindingKind" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1452); AnnotateMozCrashReason("MOZ_ASSERT" "(" "bi.kind() == BindingKind::Let || bi.kind() == BindingKind::Const"
") (" "bad var scope BindingKind" ")"); do { *((volatile int
*)__null) = 1452; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
1451 bi.kind() == BindingKind::Let || bi.kind() == BindingKind::Const,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(bi.kind() == BindingKind::Let || bi.kind() == BindingKind
::Const)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(bi.kind() == BindingKind::Let || bi.kind() == BindingKind
::Const))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("bi.kind() == BindingKind::Let || bi.kind() == BindingKind::Const"
" (" "bad var scope BindingKind" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1452); AnnotateMozCrashReason("MOZ_ASSERT" "(" "bi.kind() == BindingKind::Let || bi.kind() == BindingKind::Const"
") (" "bad var scope BindingKind" ")"); do { *((volatile int
*)__null) = 1452; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
1452 "bad var scope BindingKind")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(bi.kind() == BindingKind::Let || bi.kind() == BindingKind
::Const)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(bi.kind() == BindingKind::Let || bi.kind() == BindingKind
::Const))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("bi.kind() == BindingKind::Let || bi.kind() == BindingKind::Const"
" (" "bad var scope BindingKind" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1452); AnnotateMozCrashReason("MOZ_ASSERT" "(" "bi.kind() == BindingKind::Let || bi.kind() == BindingKind::Const"
") (" "bad var scope BindingKind" ")"); do { *((volatile int
*)__null) = 1452; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1453 }
1454 }
1455
1456 VarScope::ParserData* bindings = nullptr;
1457 uint32_t numBindings = vars.length();
1458
1459 if (numBindings > 0) {
1460 bindings = NewEmptyBindingData<VarScope>(fc, alloc, numBindings);
1461 if (!bindings) {
1462 return Nothing();
1463 }
1464
1465 InitializeBindingData(bindings, numBindings, vars);
1466 }
1467
1468 return Some(bindings);
1469}
1470
1471// Compute if `NewVarScopeData` would return any binding list. This is done
1472// without allocate the binding list.
1473static bool VarScopeHasBindings(ParseContext* pc) {
1474 for (BindingIter bi = pc->varScope().bindings(pc); bi; bi++) {
1475 if (bi.kind() == BindingKind::Var) {
1476 return true;
1477 }
1478 }
1479
1480 return false;
1481}
1482
1483Maybe<VarScope::ParserData*> ParserBase::newVarScopeData(
1484 ParseContext::Scope& scope) {
1485 return NewVarScopeData(fc_, scope, stencilAlloc(), pc_);
1486}
1487
1488static Maybe<LexicalScope::ParserData*> NewLexicalScopeData(
1489 FrontendContext* fc, ParseContext::Scope& scope, LifoAlloc& alloc,
1490 ParseContext* pc) {
1491 ParserBindingNameVector lets(fc);
1492 ParserBindingNameVector consts(fc);
1493#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1494 ParserBindingNameVector usings(fc);
1495#endif
1496
1497 bool allBindingsClosedOver =
1498 pc->sc()->allBindingsClosedOver() || scope.tooBigToOptimize();
1499
1500 for (BindingIter bi = scope.bindings(pc); bi; bi++) {
1501 ParserBindingName binding(bi.name(),
1502 allBindingsClosedOver || bi.closedOver());
1503 switch (bi.kind()) {
1504 case BindingKind::Let:
1505 if (!lets.append(binding)) {
1506 return Nothing();
1507 }
1508 break;
1509 case BindingKind::Const:
1510 if (!consts.append(binding)) {
1511 return Nothing();
1512 }
1513 break;
1514#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1515 case BindingKind::Using:
1516 if (!usings.append(binding)) {
1517 return Nothing();
1518 }
1519 break;
1520#endif
1521 case BindingKind::Var:
1522 case BindingKind::FormalParameter:
1523 break;
1524 default:
1525 MOZ_CRASH("Bad lexical scope BindingKind")do { do { } while (false); MOZ_ReportCrash("" "Bad lexical scope BindingKind"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1525); AnnotateMozCrashReason("MOZ_CRASH(" "Bad lexical scope BindingKind"
")"); do { *((volatile int*)__null) = 1525; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
1526 break;
1527 }
1528 }
1529
1530 LexicalScope::ParserData* bindings = nullptr;
1531 uint32_t numBindings = lets.length() + consts.length()
1532#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1533 + usings.length()
1534#endif
1535 ;
1536
1537 if (numBindings > 0) {
1538 bindings = NewEmptyBindingData<LexicalScope>(fc, alloc, numBindings);
1539 if (!bindings) {
1540 return Nothing();
1541 }
1542
1543 // The ordering here is important. See comments in LexicalScope.
1544 InitializeBindingData(bindings, numBindings, lets,
1545 &ParserLexicalScopeSlotInfo::constStart, consts
1546#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
1547 ,
1548 &ParserLexicalScopeSlotInfo::usingStart, usings
1549#endif
1550 );
1551 }
1552
1553 return Some(bindings);
1554}
1555
1556// Compute if `NewLexicalScopeData` would return any binding list with any entry
1557// marked as closed-over. This is done without the need to allocate the binding
1558// list. If true, an EnvironmentObject will be needed at runtime.
1559bool LexicalScopeHasClosedOverBindings(ParseContext* pc,
1560 ParseContext::Scope& scope) {
1561 bool allBindingsClosedOver =
1562 pc->sc()->allBindingsClosedOver() || scope.tooBigToOptimize();
1563
1564 for (BindingIter bi = scope.bindings(pc); bi; bi++) {
1565 switch (bi.kind()) {
1566 case BindingKind::Let:
1567 case BindingKind::Const:
1568 if (allBindingsClosedOver || bi.closedOver()) {
1569 return true;
1570 }
1571 break;
1572
1573 default:
1574 break;
1575 }
1576 }
1577
1578 return false;
1579}
1580
1581Maybe<LexicalScope::ParserData*> ParserBase::newLexicalScopeData(
1582 ParseContext::Scope& scope) {
1583 return NewLexicalScopeData(fc_, scope, stencilAlloc(), pc_);
1584}
1585
1586static Maybe<ClassBodyScope::ParserData*> NewClassBodyScopeData(
1587 FrontendContext* fc, ParseContext::Scope& scope, LifoAlloc& alloc,
1588 ParseContext* pc) {
1589 ParserBindingNameVector privateBrand(fc);
1590 ParserBindingNameVector synthetics(fc);
1591 ParserBindingNameVector privateMethods(fc);
1592
1593 bool allBindingsClosedOver =
1594 pc->sc()->allBindingsClosedOver() || scope.tooBigToOptimize();
1595
1596 for (BindingIter bi = scope.bindings(pc); bi; bi++) {
1597 ParserBindingName binding(bi.name(),
1598 allBindingsClosedOver || bi.closedOver());
1599 switch (bi.kind()) {
1600 case BindingKind::Synthetic:
1601 if (bi.name() ==
1602 TaggedParserAtomIndex::WellKnown::dot_privateBrand_()) {
1603 MOZ_ASSERT(privateBrand.empty())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(privateBrand.empty())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(privateBrand.empty()))), 0))
) { do { } while (false); MOZ_ReportAssertionFailure("privateBrand.empty()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1603); AnnotateMozCrashReason("MOZ_ASSERT" "(" "privateBrand.empty()"
")"); do { *((volatile int*)__null) = 1603; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1604 if (!privateBrand.append(binding)) {
1605 return Nothing();
1606 }
1607 } else {
1608 if (!synthetics.append(binding)) {
1609 return Nothing();
1610 }
1611 }
1612 break;
1613
1614 case BindingKind::PrivateMethod:
1615 if (!privateMethods.append(binding)) {
1616 return Nothing();
1617 }
1618 break;
1619
1620 default:
1621 MOZ_CRASH("bad class body scope BindingKind")do { do { } while (false); MOZ_ReportCrash("" "bad class body scope BindingKind"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1621); AnnotateMozCrashReason("MOZ_CRASH(" "bad class body scope BindingKind"
")"); do { *((volatile int*)__null) = 1621; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
1622 break;
1623 }
1624 }
1625
1626 // We should have zero or one private brands.
1627 MOZ_ASSERT(privateBrand.length() == 0 || privateBrand.length() == 1)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(privateBrand.length() == 0 || privateBrand.length() ==
1)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(privateBrand.length() == 0 || privateBrand.length() ==
1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("privateBrand.length() == 0 || privateBrand.length() == 1", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1627); AnnotateMozCrashReason("MOZ_ASSERT" "(" "privateBrand.length() == 0 || privateBrand.length() == 1"
")"); do { *((volatile int*)__null) = 1627; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1628
1629 ClassBodyScope::ParserData* bindings = nullptr;
1630 uint32_t numBindings =
1631 privateBrand.length() + synthetics.length() + privateMethods.length();
1632
1633 if (numBindings > 0) {
1634 bindings = NewEmptyBindingData<ClassBodyScope>(fc, alloc, numBindings);
1635 if (!bindings) {
1636 return Nothing();
1637 }
1638 // To simplify initialization of the bindings, we concatenate the
1639 // synthetics+privateBrand vector such that the private brand is always the
1640 // first element, as ordering is important. See comments in ClassBodyScope.
1641 ParserBindingNameVector brandAndSynthetics(fc);
1642 if (!brandAndSynthetics.appendAll(privateBrand)) {
1643 return Nothing();
1644 }
1645 if (!brandAndSynthetics.appendAll(synthetics)) {
1646 return Nothing();
1647 }
1648
1649 // The ordering here is important. See comments in ClassBodyScope.
1650 InitializeBindingData(bindings, numBindings, brandAndSynthetics,
1651 &ParserClassBodyScopeSlotInfo::privateMethodStart,
1652 privateMethods);
1653 }
1654
1655 // `EmitterScope::lookupPrivate()` requires `.privateBrand` to be stored in a
1656 // predictable slot: the first slot available in the environment object,
1657 // `ClassBodyLexicalEnvironmentObject::privateBrandSlot()`. We assume that
1658 // if `.privateBrand` is first in the scope, it will be stored there.
1659 MOZ_ASSERT_IF(!privateBrand.empty(),do { if (!privateBrand.empty()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(GetScopeDataTrailingNames
(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex
::WellKnown::dot_privateBrand_()))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1661); AnnotateMozCrashReason("MOZ_ASSERT" "(" "GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_()"
")"); do { *((volatile int*)__null) = 1661; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1660 GetScopeDataTrailingNames(bindings)[0].name() ==do { if (!privateBrand.empty()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(GetScopeDataTrailingNames
(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex
::WellKnown::dot_privateBrand_()))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1661); AnnotateMozCrashReason("MOZ_ASSERT" "(" "GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_()"
")"); do { *((volatile int*)__null) = 1661; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
1661 TaggedParserAtomIndex::WellKnown::dot_privateBrand_())do { if (!privateBrand.empty()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(GetScopeDataTrailingNames
(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex
::WellKnown::dot_privateBrand_()))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1661); AnnotateMozCrashReason("MOZ_ASSERT" "(" "GetScopeDataTrailingNames(bindings)[0].name() == TaggedParserAtomIndex::WellKnown::dot_privateBrand_()"
")"); do { *((volatile int*)__null) = 1661; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
1662
1663 return Some(bindings);
1664}
1665
1666Maybe<ClassBodyScope::ParserData*> ParserBase::newClassBodyScopeData(
1667 ParseContext::Scope& scope) {
1668 return NewClassBodyScopeData(fc_, scope, stencilAlloc(), pc_);
1669}
1670
1671template <>
1672SyntaxParseHandler::LexicalScopeNodeResult
1673PerHandlerParser<SyntaxParseHandler>::finishLexicalScope(
1674 ParseContext::Scope& scope, Node body, ScopeKind kind) {
1675 if (!propagateFreeNamesAndMarkClosedOverBindings(scope)) {
1676 return errorResult();
1677 }
1678
1679 return handler_.newLexicalScope(body);
1680}
1681
1682template <>
1683FullParseHandler::LexicalScopeNodeResult
1684PerHandlerParser<FullParseHandler>::finishLexicalScope(
1685 ParseContext::Scope& scope, ParseNode* body, ScopeKind kind) {
1686 if (!propagateFreeNamesAndMarkClosedOverBindings(scope)) {
1687 return errorResult();
1688 }
1689
1690 Maybe<LexicalScope::ParserData*> bindings = newLexicalScopeData(scope);
1691 if (!bindings) {
1692 return errorResult();
1693 }
1694
1695 return handler_.newLexicalScope(*bindings, body, kind);
1696}
1697
1698template <>
1699SyntaxParseHandler::ClassBodyScopeNodeResult
1700PerHandlerParser<SyntaxParseHandler>::finishClassBodyScope(
1701 ParseContext::Scope& scope, ListNodeType body) {
1702 if (!propagateFreeNamesAndMarkClosedOverBindings(scope)) {
1703 return errorResult();
1704 }
1705
1706 return handler_.newClassBodyScope(body);
1707}
1708
1709template <>
1710FullParseHandler::ClassBodyScopeNodeResult
1711PerHandlerParser<FullParseHandler>::finishClassBodyScope(
1712 ParseContext::Scope& scope, ListNode* body) {
1713 if (!propagateFreeNamesAndMarkClosedOverBindings(scope)) {
1714 return errorResult();
1715 }
1716
1717 Maybe<ClassBodyScope::ParserData*> bindings = newClassBodyScopeData(scope);
1718 if (!bindings) {
1719 return errorResult();
1720 }
1721
1722 return handler_.newClassBodyScope(*bindings, body);
1723}
1724
1725template <class ParseHandler>
1726bool PerHandlerParser<ParseHandler>::checkForUndefinedPrivateFields(
1727 EvalSharedContext* evalSc) {
1728 if (!this->compilationState_.isInitialStencil()) {
1729 // We're delazifying -- so we already checked private names during first
1730 // parse.
1731 return true;
1732 }
1733
1734 Vector<UnboundPrivateName, 8> unboundPrivateNames(fc_);
1735 if (!usedNames_.getUnboundPrivateNames(unboundPrivateNames)) {
1736 return false;
1737 }
1738
1739 // No unbound names, let's get out of here!
1740 if (unboundPrivateNames.empty()) {
1741 return true;
1742 }
1743
1744 // It is an early error if there's private name references unbound,
1745 // unless it's an eval, in which case we need to check the scope
1746 // chain.
1747 if (!evalSc) {
1748 // The unbound private names are sorted, so just grab the first one.
1749 UnboundPrivateName minimum = unboundPrivateNames[0];
1750 UniqueChars str = this->parserAtoms().toPrintableString(minimum.atom);
1751 if (!str) {
1752 ReportOutOfMemory(this->fc_);
1753 return false;
1754 }
1755
1756 errorAt(minimum.position.begin, JSMSG_MISSING_PRIVATE_DECL, str.get());
1757 return false;
1758 }
1759
1760 // It's important that the unbound private names are sorted, as we
1761 // want our errors to always be issued to the first textually.
1762 for (UnboundPrivateName unboundName : unboundPrivateNames) {
1763 // If the enclosingScope is non-syntactic, then we are in a
1764 // Debugger.Frame.prototype.eval call. In order to find the declared private
1765 // names, we must use the effective scope that was determined when creating
1766 // the scopeContext.
1767 if (!this->compilationState_.scopeContext
1768 .effectiveScopePrivateFieldCacheHas(unboundName.atom)) {
1769 UniqueChars str = this->parserAtoms().toPrintableString(unboundName.atom);
1770 if (!str) {
1771 ReportOutOfMemory(this->fc_);
1772 return false;
1773 }
1774 errorAt(unboundName.position.begin, JSMSG_MISSING_PRIVATE_DECL,
1775 str.get());
1776 return false;
1777 }
1778 }
1779
1780 return true;
1781}
1782
1783template <typename Unit>
1784FullParseHandler::LexicalScopeNodeResult
1785Parser<FullParseHandler, Unit>::evalBody(EvalSharedContext* evalsc) {
1786 SourceParseContext evalpc(this, evalsc, /* newDirectives = */ nullptr);
1787 if (!evalpc.init()) {
1788 return errorResult();
1789 }
1790
1791 ParseContext::VarScope varScope(this);
1792 if (!varScope.init(pc_)) {
1793 return errorResult();
1794 }
1795
1796 LexicalScopeNode* body;
1797 {
1798 // All evals have an implicit non-extensible lexical scope.
1799 ParseContext::Scope lexicalScope(this);
1800 if (!lexicalScope.init(pc_)) {
1801 return errorResult();
1802 }
1803
1804 ListNode* list;
1805 MOZ_TRY_VAR(list, statementList(YieldIsName))do { auto mozTryVarTempResult_ = (statementList(YieldIsName))
; if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))
) { return mozTryVarTempResult_.propagateErr(); } (list) = mozTryVarTempResult_
.unwrap(); } while (0)
;
1806
1807 if (!checkStatementsEOF()) {
1808 return errorResult();
1809 }
1810
1811 // Private names not lexically defined must trigger a syntax error.
1812 if (!checkForUndefinedPrivateFields(evalsc)) {
1813 return errorResult();
1814 }
1815
1816 MOZ_TRY_VAR(body, finishLexicalScope(lexicalScope, list))do { auto mozTryVarTempResult_ = (finishLexicalScope(lexicalScope
, list)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (body
) = mozTryVarTempResult_.unwrap(); } while (0)
;
1817 }
1818
1819#ifdef DEBUG1
1820 if (evalpc.superScopeNeedsHomeObject() &&
1821 !this->compilationState_.input.enclosingScope.isNull()) {
1822 // If superScopeNeedsHomeObject_ is set and we are an entry-point
1823 // ParseContext, then we must be emitting an eval script, and the
1824 // outer function must already be marked as needing a home object
1825 // since it contains an eval.
1826 MOZ_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType<
decltype(this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain"
" (" "Eval must have found an enclosing function box scope that "
"allows super.property" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1829); AnnotateMozCrashReason("MOZ_ASSERT" "(" "this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain"
") (" "Eval must have found an enclosing function box scope that "
"allows super.property" ")"); do { *((volatile int*)__null) =
1829; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false)
1827 this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain"
" (" "Eval must have found an enclosing function box scope that "
"allows super.property" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1829); AnnotateMozCrashReason("MOZ_ASSERT" "(" "this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain"
") (" "Eval must have found an enclosing function box scope that "
"allows super.property" ")"); do { *((volatile int*)__null) =
1829; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false)
1828 "Eval must have found an enclosing function box scope that "do { static_assert( mozilla::detail::AssertionConditionType<
decltype(this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain"
" (" "Eval must have found an enclosing function box scope that "
"allows super.property" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1829); AnnotateMozCrashReason("MOZ_ASSERT" "(" "this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain"
") (" "Eval must have found an enclosing function box scope that "
"allows super.property" ")"); do { *((volatile int*)__null) =
1829; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false)
1829 "allows super.property")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain"
" (" "Eval must have found an enclosing function box scope that "
"allows super.property" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1829); AnnotateMozCrashReason("MOZ_ASSERT" "(" "this->compilationState_.scopeContext.hasFunctionNeedsHomeObjectOnChain"
") (" "Eval must have found an enclosing function box scope that "
"allows super.property" ")"); do { *((volatile int*)__null) =
1829; __attribute__((nomerge)) ::abort(); } while (false); }
} while (false)
;
1830 }
1831#endif
1832
1833 if (!CheckParseTree(this->fc_, alloc_, body)) {
1834 return errorResult();
1835 }
1836
1837 ParseNode* node = body;
1838 // Don't constant-fold inside "use asm" code, as this could create a parse
1839 // tree that doesn't type-check as asm.js.
1840 if (!pc_->useAsmOrInsideUseAsm()) {
1841 if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) {
1842 return errorResult();
1843 }
1844 }
1845 body = handler_.asLexicalScopeNode(node);
1846
1847 if (!this->setSourceMapInfo()) {
1848 return errorResult();
1849 }
1850
1851 if (pc_->sc()->strict()) {
1852 if (!propagateFreeNamesAndMarkClosedOverBindings(varScope)) {
1853 return errorResult();
1854 }
1855 } else {
1856 // For non-strict eval scripts, since all bindings are automatically
1857 // considered closed over, we don't need to call propagateFreeNames-
1858 // AndMarkClosedOverBindings. However, Annex B.3.3 functions still need to
1859 // be marked.
1860 if (!varScope.propagateAndMarkAnnexBFunctionBoxes(pc_, this)) {
1861 return errorResult();
1862 }
1863 }
1864
1865 Maybe<EvalScope::ParserData*> bindings = newEvalScopeData(pc_->varScope());
1866 if (!bindings) {
1867 return errorResult();
1868 }
1869 evalsc->bindings = *bindings;
1870
1871 return body;
1872}
1873
1874template <typename Unit>
1875FullParseHandler::ListNodeResult Parser<FullParseHandler, Unit>::globalBody(
1876 GlobalSharedContext* globalsc) {
1877 SourceParseContext globalpc(this, globalsc, /* newDirectives = */ nullptr);
1878 if (!globalpc.init()) {
1879 return errorResult();
1880 }
1881
1882 ParseContext::VarScope varScope(this);
1883 if (!varScope.init(pc_)) {
1884 return errorResult();
1885 }
1886
1887 ListNode* body;
1888 MOZ_TRY_VAR(body, statementList(YieldIsName))do { auto mozTryVarTempResult_ = (statementList(YieldIsName))
; if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))
) { return mozTryVarTempResult_.propagateErr(); } (body) = mozTryVarTempResult_
.unwrap(); } while (0)
;
1889
1890 if (!checkStatementsEOF()) {
1891 return errorResult();
1892 }
1893
1894 if (!CheckParseTree(this->fc_, alloc_, body)) {
1895 return errorResult();
1896 }
1897
1898 if (!checkForUndefinedPrivateFields()) {
1899 return errorResult();
1900 }
1901
1902 ParseNode* node = body;
1903 // Don't constant-fold inside "use asm" code, as this could create a parse
1904 // tree that doesn't type-check as asm.js.
1905 if (!pc_->useAsmOrInsideUseAsm()) {
1906 if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) {
1907 return errorResult();
1908 }
1909 }
1910 body = &node->as<ListNode>();
1911
1912 if (!this->setSourceMapInfo()) {
1913 return errorResult();
1914 }
1915
1916 // For global scripts, whether bindings are closed over or not doesn't
1917 // matter, so no need to call propagateFreeNamesAndMarkClosedOver-
1918 // Bindings. However, Annex B.3.3 functions still need to be marked.
1919 if (!varScope.propagateAndMarkAnnexBFunctionBoxes(pc_, this)) {
1920 return errorResult();
1921 }
1922
1923 Maybe<GlobalScope::ParserData*> bindings =
1924 newGlobalScopeData(pc_->varScope());
1925 if (!bindings) {
1926 return errorResult();
1927 }
1928 globalsc->bindings = *bindings;
1929
1930 return body;
1931}
1932
1933template <typename Unit>
1934FullParseHandler::ModuleNodeResult Parser<FullParseHandler, Unit>::moduleBody(
1935 ModuleSharedContext* modulesc) {
1936 MOZ_ASSERT(checkOptionsCalled_)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(checkOptionsCalled_)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(checkOptionsCalled_))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("checkOptionsCalled_"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1936); AnnotateMozCrashReason("MOZ_ASSERT" "(" "checkOptionsCalled_"
")"); do { *((volatile int*)__null) = 1936; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1937
1938 this->compilationState_.moduleMetadata =
1939 fc_->getAllocator()->template new_<StencilModuleMetadata>();
1940 if (!this->compilationState_.moduleMetadata) {
1941 return errorResult();
1942 }
1943
1944 SourceParseContext modulepc(this, modulesc, nullptr);
1945 if (!modulepc.init()) {
1946 return errorResult();
1947 }
1948
1949 ParseContext::VarScope varScope(this);
1950 if (!varScope.init(pc_)) {
1951 return errorResult();
1952 }
1953
1954 ModuleNodeType moduleNode;
1955 MOZ_TRY_VAR(moduleNode, handler_.newModule(pos()))do { auto mozTryVarTempResult_ = (handler_.newModule(pos()));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (moduleNode)
= mozTryVarTempResult_.unwrap(); } while (0)
;
1956
1957 AutoAwaitIsKeyword<FullParseHandler, Unit> awaitIsKeyword(
1958 this, AwaitIsModuleKeyword);
1959 ListNode* stmtList;
1960 MOZ_TRY_VAR(stmtList, statementList(YieldIsName))do { auto mozTryVarTempResult_ = (statementList(YieldIsName))
; if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))
) { return mozTryVarTempResult_.propagateErr(); } (stmtList) =
mozTryVarTempResult_.unwrap(); } while (0)
;
1961
1962 MOZ_ASSERT(stmtList->isKind(ParseNodeKind::StatementList))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(stmtList->isKind(ParseNodeKind::StatementList))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(stmtList->isKind(ParseNodeKind::StatementList))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("stmtList->isKind(ParseNodeKind::StatementList)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 1962); AnnotateMozCrashReason("MOZ_ASSERT" "(" "stmtList->isKind(ParseNodeKind::StatementList)"
")"); do { *((volatile int*)__null) = 1962; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1963 moduleNode->setBody(&stmtList->template as<ListNode>());
1964
1965 if (pc_->isAsync()) {
1966 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::dot_generator_())) {
1967 return errorResult();
1968 }
1969
1970 if (!pc_->declareTopLevelDotGeneratorName()) {
1971 return errorResult();
1972 }
1973 }
1974
1975 TokenKind tt;
1976 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
1977 return errorResult();
1978 }
1979 if (tt != TokenKind::Eof) {
1980 error(JSMSG_GARBAGE_AFTER_INPUT, "module", TokenKindToDesc(tt));
1981 return errorResult();
1982 }
1983
1984 // Set the module to async if an await keyword was found at the top level.
1985 if (pc_->isAsync()) {
1986 pc_->sc()->asModuleContext()->builder.noteAsync(
1987 *this->compilationState_.moduleMetadata);
1988 }
1989
1990 // Generate the Import/Export tables and store in CompilationState.
1991 if (!modulesc->builder.buildTables(*this->compilationState_.moduleMetadata)) {
1992 return errorResult();
1993 }
1994
1995 // Check exported local bindings exist and mark them as closed over.
1996 StencilModuleMetadata& moduleMetadata =
1997 *this->compilationState_.moduleMetadata;
1998 for (auto entry : moduleMetadata.localExportEntries) {
1999 DeclaredNamePtr p = modulepc.varScope().lookupDeclaredName(entry.localName);
2000 if (!p) {
2001 UniqueChars str = this->parserAtoms().toPrintableString(entry.localName);
2002 if (!str) {
2003 ReportOutOfMemory(this->fc_);
2004 return errorResult();
2005 }
2006
2007 errorNoOffset(JSMSG_MISSING_EXPORT, str.get());
2008 return errorResult();
2009 }
2010
2011 p->value()->setClosedOver();
2012 }
2013
2014 // Reserve an environment slot for a "*namespace*" psuedo-binding and mark as
2015 // closed-over. We do not know until module linking if this will be used.
2016 if (!noteDeclaredName(
2017 TaggedParserAtomIndex::WellKnown::star_namespace_star_(),
2018 DeclarationKind::Const, pos())) {
2019 return errorResult();
2020 }
2021 modulepc.varScope()
2022 .lookupDeclaredName(
2023 TaggedParserAtomIndex::WellKnown::star_namespace_star_())
2024 ->value()
2025 ->setClosedOver();
2026
2027 if (options().deoptimizeModuleGlobalVars) {
2028 for (BindingIter bi = modulepc.varScope().bindings(pc_); bi; bi++) {
2029 bi.setClosedOver();
2030 }
2031 }
2032
2033 if (!CheckParseTree(this->fc_, alloc_, stmtList)) {
2034 return errorResult();
2035 }
2036
2037 ParseNode* node = stmtList;
2038 // Don't constant-fold inside "use asm" code, as this could create a parse
2039 // tree that doesn't type-check as asm.js.
2040 if (!pc_->useAsmOrInsideUseAsm()) {
2041 if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) {
2042 return errorResult();
2043 }
2044 }
2045 stmtList = &node->as<ListNode>();
2046
2047 if (!this->setSourceMapInfo()) {
2048 return errorResult();
2049 }
2050
2051 // Private names not lexically defined must trigger a syntax error.
2052 if (!checkForUndefinedPrivateFields()) {
2053 return errorResult();
2054 }
2055
2056 if (!propagateFreeNamesAndMarkClosedOverBindings(modulepc.varScope())) {
2057 return errorResult();
2058 }
2059
2060 Maybe<ModuleScope::ParserData*> bindings =
2061 newModuleScopeData(modulepc.varScope());
2062 if (!bindings) {
2063 return errorResult();
2064 }
2065
2066 modulesc->bindings = *bindings;
2067 return moduleNode;
2068}
2069
2070template <typename Unit>
2071SyntaxParseHandler::ModuleNodeResult
2072Parser<SyntaxParseHandler, Unit>::moduleBody(ModuleSharedContext* modulesc) {
2073 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2073); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 2073; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
2074 return errorResult();
2075}
2076
2077template <class ParseHandler>
2078typename ParseHandler::NameNodeResult
2079PerHandlerParser<ParseHandler>::newInternalDotName(TaggedParserAtomIndex name) {
2080 NameNodeType nameNode;
2081 MOZ_TRY_VAR(nameNode, newName(name))do { auto mozTryVarTempResult_ = (newName(name)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (nameNode) = mozTryVarTempResult_.unwrap()
; } while (0)
;
2082 if (!noteUsedName(name)) {
2083 return errorResult();
2084 }
2085 return nameNode;
2086}
2087
2088template <class ParseHandler>
2089typename ParseHandler::NameNodeResult
2090PerHandlerParser<ParseHandler>::newThisName() {
2091 return newInternalDotName(TaggedParserAtomIndex::WellKnown::dot_this_());
2092}
2093
2094template <class ParseHandler>
2095typename ParseHandler::NameNodeResult
2096PerHandlerParser<ParseHandler>::newNewTargetName() {
2097 return newInternalDotName(TaggedParserAtomIndex::WellKnown::dot_newTarget_());
2098}
2099
2100template <class ParseHandler>
2101typename ParseHandler::NameNodeResult
2102PerHandlerParser<ParseHandler>::newDotGeneratorName() {
2103 return newInternalDotName(TaggedParserAtomIndex::WellKnown::dot_generator_());
2104}
2105
2106template <class ParseHandler>
2107bool PerHandlerParser<ParseHandler>::finishFunctionScopes(
2108 bool isStandaloneFunction) {
2109 FunctionBox* funbox = pc_->functionBox();
2110
2111 if (funbox->hasParameterExprs) {
2112 if (!propagateFreeNamesAndMarkClosedOverBindings(pc_->functionScope())) {
2113 return false;
2114 }
2115
2116 // Functions with parameter expressions utilize the FunctionScope for vars
2117 // generated by sloppy-direct-evals, as well as arguments (which are
2118 // lexicals bindings). If the function body has var bindings (or has a
2119 // sloppy-direct-eval that might), then an extra VarScope must be created
2120 // for them.
2121 if (VarScopeHasBindings(pc_) ||
2122 funbox->needsExtraBodyVarEnvironmentRegardlessOfBindings()) {
2123 funbox->setFunctionHasExtraBodyVarScope();
2124 }
2125 }
2126
2127 // See: JSFunction::needsCallObject()
2128 if (FunctionScopeHasClosedOverBindings(pc_) ||
2129 funbox->needsCallObjectRegardlessOfBindings()) {
2130 funbox->setNeedsFunctionEnvironmentObjects();
2131 }
2132
2133 if (funbox->isNamedLambda() && !isStandaloneFunction) {
2134 if (!propagateFreeNamesAndMarkClosedOverBindings(pc_->namedLambdaScope())) {
2135 return false;
2136 }
2137
2138 // See: JSFunction::needsNamedLambdaEnvironment()
2139 if (LexicalScopeHasClosedOverBindings(pc_, pc_->namedLambdaScope())) {
2140 funbox->setNeedsFunctionEnvironmentObjects();
2141 }
2142 }
2143
2144 return true;
2145}
2146
2147template <>
2148bool PerHandlerParser<FullParseHandler>::finishFunction(
2149 bool isStandaloneFunction /* = false */) {
2150 if (!finishFunctionScopes(isStandaloneFunction)) {
2151 return false;
2152 }
2153
2154 FunctionBox* funbox = pc_->functionBox();
2155 ScriptStencil& script = funbox->functionStencil();
2156
2157 if (funbox->isInterpreted()) {
2158 // BCE will need to generate bytecode for this.
2159 funbox->emitBytecode = true;
2160 this->compilationState_.nonLazyFunctionCount++;
2161 }
2162
2163 bool hasParameterExprs = funbox->hasParameterExprs;
2164
2165 if (hasParameterExprs) {
2166 Maybe<VarScope::ParserData*> bindings = newVarScopeData(pc_->varScope());
2167 if (!bindings) {
2168 return false;
2169 }
2170 funbox->setExtraVarScopeBindings(*bindings);
2171
2172 MOZ_ASSERT(bool(*bindings) == VarScopeHasBindings(pc_))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(bool(*bindings) == VarScopeHasBindings(pc_))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(bool(*bindings) == VarScopeHasBindings(pc_)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("bool(*bindings) == VarScopeHasBindings(pc_)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2172); AnnotateMozCrashReason("MOZ_ASSERT" "(" "bool(*bindings) == VarScopeHasBindings(pc_)"
")"); do { *((volatile int*)__null) = 2172; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2173 MOZ_ASSERT_IF(!funbox->needsExtraBodyVarEnvironmentRegardlessOfBindings(),do { if (!funbox->needsExtraBodyVarEnvironmentRegardlessOfBindings
()) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(bool(*bindings) == funbox->functionHasExtraBodyVarScope
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(bool(*bindings) == funbox->functionHasExtraBodyVarScope
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("bool(*bindings) == funbox->functionHasExtraBodyVarScope()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2174); AnnotateMozCrashReason("MOZ_ASSERT" "(" "bool(*bindings) == funbox->functionHasExtraBodyVarScope()"
")"); do { *((volatile int*)__null) = 2174; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
2174 bool(*bindings) == funbox->functionHasExtraBodyVarScope())do { if (!funbox->needsExtraBodyVarEnvironmentRegardlessOfBindings
()) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(bool(*bindings) == funbox->functionHasExtraBodyVarScope
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(bool(*bindings) == funbox->functionHasExtraBodyVarScope
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("bool(*bindings) == funbox->functionHasExtraBodyVarScope()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2174); AnnotateMozCrashReason("MOZ_ASSERT" "(" "bool(*bindings) == funbox->functionHasExtraBodyVarScope()"
")"); do { *((volatile int*)__null) = 2174; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2175 }
2176
2177 {
2178 Maybe<FunctionScope::ParserData*> bindings =
2179 newFunctionScopeData(pc_->functionScope(), hasParameterExprs);
2180 if (!bindings) {
2181 return false;
2182 }
2183 funbox->setFunctionScopeBindings(*bindings);
2184 }
2185
2186 if (funbox->isNamedLambda() && !isStandaloneFunction) {
2187 Maybe<LexicalScope::ParserData*> bindings =
2188 newLexicalScopeData(pc_->namedLambdaScope());
2189 if (!bindings) {
2190 return false;
2191 }
2192 funbox->setNamedLambdaBindings(*bindings);
2193 }
2194
2195 funbox->finishScriptFlags();
2196 funbox->copyFunctionFields(script);
2197
2198 if (this->compilationState_.isInitialStencil()) {
2199 ScriptStencilExtra& scriptExtra = funbox->functionExtraStencil();
2200 funbox->copyFunctionExtraFields(scriptExtra);
2201 funbox->copyScriptExtraFields(scriptExtra);
2202 }
2203
2204 return true;
2205}
2206
2207template <>
2208bool PerHandlerParser<SyntaxParseHandler>::finishFunction(
2209 bool isStandaloneFunction /* = false */) {
2210 // The BaseScript for a lazily parsed function needs to know its set of
2211 // free variables and inner functions so that when it is fully parsed, we
2212 // can skip over any already syntax parsed inner functions and still
2213 // retain correct scope information.
2214
2215 if (!finishFunctionScopes(isStandaloneFunction)) {
2216 return false;
2217 }
2218
2219 FunctionBox* funbox = pc_->functionBox();
2220 ScriptStencil& script = funbox->functionStencil();
2221
2222 funbox->finishScriptFlags();
2223 funbox->copyFunctionFields(script);
2224
2225 ScriptStencilExtra& scriptExtra = funbox->functionExtraStencil();
2226 funbox->copyFunctionExtraFields(scriptExtra);
2227 funbox->copyScriptExtraFields(scriptExtra);
2228
2229 // Elide nullptr sentinels from end of binding list. These are inserted for
2230 // each scope regardless of if any bindings are actually closed over.
2231 {
2232 AtomVector& closedOver = pc_->closedOverBindingsForLazy();
2233 while (!closedOver.empty() && !closedOver.back()) {
2234 closedOver.popBack();
2235 }
2236 }
2237
2238 // Check if we will overflow the `ngcthings` field later.
2239 mozilla::CheckedUint32 ngcthings =
2240 mozilla::CheckedUint32(pc_->innerFunctionIndexesForLazy.length()) +
2241 mozilla::CheckedUint32(pc_->closedOverBindingsForLazy().length());
2242 if (!ngcthings.isValid()) {
2243 ReportAllocationOverflow(fc_);
2244 return false;
2245 }
2246
2247 // If there are no script-things, we can return early without allocating.
2248 if (ngcthings.value() == 0) {
2249 MOZ_ASSERT(!script.hasGCThings())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!script.hasGCThings())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!script.hasGCThings()))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("!script.hasGCThings()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2249); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!script.hasGCThings()"
")"); do { *((volatile int*)__null) = 2249; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2250 return true;
2251 }
2252
2253 TaggedScriptThingIndex* cursor = nullptr;
2254 if (!this->compilationState_.allocateGCThingsUninitialized(
2255 fc_, funbox->index(), ngcthings.value(), &cursor)) {
2256 return false;
2257 }
2258
2259 // Copy inner-function and closed-over-binding info for the stencil. The order
2260 // is important here. We emit functions first, followed by the bindings info.
2261 // The bindings list uses nullptr as delimiter to separates the bindings per
2262 // scope.
2263 //
2264 // See: FullParseHandler::nextLazyInnerFunction(),
2265 // FullParseHandler::nextLazyClosedOverBinding()
2266 for (const ScriptIndex& index : pc_->innerFunctionIndexesForLazy) {
2267 void* raw = &(*cursor++);
2268 new (raw) TaggedScriptThingIndex(index);
2269 }
2270 for (auto binding : pc_->closedOverBindingsForLazy()) {
2271 void* raw = &(*cursor++);
2272 if (binding) {
2273 this->parserAtoms().markUsedByStencil(binding, ParserAtom::Atomize::Yes);
2274 new (raw) TaggedScriptThingIndex(binding);
2275 } else {
2276 new (raw) TaggedScriptThingIndex();
2277 }
2278 }
2279
2280 return true;
2281}
2282
2283static YieldHandling GetYieldHandling(GeneratorKind generatorKind) {
2284 if (generatorKind == GeneratorKind::NotGenerator) {
2285 return YieldIsName;
2286 }
2287 return YieldIsKeyword;
2288}
2289
2290static AwaitHandling GetAwaitHandling(FunctionAsyncKind asyncKind) {
2291 if (asyncKind == FunctionAsyncKind::SyncFunction) {
2292 return AwaitIsName;
2293 }
2294 return AwaitIsKeyword;
2295}
2296
2297static FunctionFlags InitialFunctionFlags(FunctionSyntaxKind kind,
2298 GeneratorKind generatorKind,
2299 FunctionAsyncKind asyncKind,
2300 bool isSelfHosting) {
2301 FunctionFlags flags = {};
2302
2303 switch (kind) {
2304 case FunctionSyntaxKind::Expression:
2305 flags = (generatorKind == GeneratorKind::NotGenerator &&
2306 asyncKind == FunctionAsyncKind::SyncFunction
2307 ? FunctionFlags::INTERPRETED_LAMBDA
2308 : FunctionFlags::INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC);
2309 break;
2310 case FunctionSyntaxKind::Arrow:
2311 flags = FunctionFlags::INTERPRETED_LAMBDA_ARROW;
2312 break;
2313 case FunctionSyntaxKind::Method:
2314 case FunctionSyntaxKind::FieldInitializer:
2315 case FunctionSyntaxKind::StaticClassBlock:
2316 flags = FunctionFlags::INTERPRETED_METHOD;
2317 break;
2318 case FunctionSyntaxKind::ClassConstructor:
2319 case FunctionSyntaxKind::DerivedClassConstructor:
2320 flags = FunctionFlags::INTERPRETED_CLASS_CTOR;
2321 break;
2322 case FunctionSyntaxKind::Getter:
2323 flags = FunctionFlags::INTERPRETED_GETTER;
2324 break;
2325 case FunctionSyntaxKind::Setter:
2326 flags = FunctionFlags::INTERPRETED_SETTER;
2327 break;
2328 default:
2329 MOZ_ASSERT(kind == FunctionSyntaxKind::Statement)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == FunctionSyntaxKind::Statement)>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(kind == FunctionSyntaxKind::Statement))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("kind == FunctionSyntaxKind::Statement"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2329); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == FunctionSyntaxKind::Statement"
")"); do { *((volatile int*)__null) = 2329; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2330 flags = (generatorKind == GeneratorKind::NotGenerator &&
2331 asyncKind == FunctionAsyncKind::SyncFunction
2332 ? FunctionFlags::INTERPRETED_NORMAL
2333 : FunctionFlags::INTERPRETED_GENERATOR_OR_ASYNC);
2334 }
2335
2336 if (isSelfHosting) {
2337 flags.setIsSelfHostedBuiltin();
2338 }
2339
2340 return flags;
2341}
2342
2343template <typename Unit>
2344FullParseHandler::FunctionNodeResult
2345Parser<FullParseHandler, Unit>::standaloneFunction(
2346 const Maybe<uint32_t>& parameterListEnd, FunctionSyntaxKind syntaxKind,
2347 GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
2348 Directives inheritedDirectives, Directives* newDirectives) {
2349 MOZ_ASSERT(checkOptionsCalled_)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(checkOptionsCalled_)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(checkOptionsCalled_))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("checkOptionsCalled_"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2349); AnnotateMozCrashReason("MOZ_ASSERT" "(" "checkOptionsCalled_"
")"); do { *((volatile int*)__null) = 2349; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2350 // Skip prelude.
2351 TokenKind tt;
2352 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
2353 return errorResult();
2354 }
2355 if (asyncKind == FunctionAsyncKind::AsyncFunction) {
2356 MOZ_ASSERT(tt == TokenKind::Async)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(tt == TokenKind::Async)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(tt == TokenKind::Async))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("tt == TokenKind::Async"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2356); AnnotateMozCrashReason("MOZ_ASSERT" "(" "tt == TokenKind::Async"
")"); do { *((volatile int*)__null) = 2356; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2357 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
2358 return errorResult();
2359 }
2360 }
2361 MOZ_ASSERT(tt == TokenKind::Function)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(tt == TokenKind::Function)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(tt == TokenKind::Function)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("tt == TokenKind::Function"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2361); AnnotateMozCrashReason("MOZ_ASSERT" "(" "tt == TokenKind::Function"
")"); do { *((volatile int*)__null) = 2361; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2362
2363 if (!tokenStream.getToken(&tt)) {
2364 return errorResult();
2365 }
2366 if (generatorKind == GeneratorKind::Generator) {
2367 MOZ_ASSERT(tt == TokenKind::Mul)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(tt == TokenKind::Mul)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(tt == TokenKind::Mul))), 0))
) { do { } while (false); MOZ_ReportAssertionFailure("tt == TokenKind::Mul"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2367); AnnotateMozCrashReason("MOZ_ASSERT" "(" "tt == TokenKind::Mul"
")"); do { *((volatile int*)__null) = 2367; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2368 if (!tokenStream.getToken(&tt)) {
2369 return errorResult();
2370 }
2371 }
2372
2373 // Skip function name, if present.
2374 TaggedParserAtomIndex explicitName;
2375 if (TokenKindIsPossibleIdentifierName(tt)) {
2376 explicitName = anyChars.currentName();
2377 } else {
2378 anyChars.ungetToken();
2379 }
2380
2381 FunctionNodeType funNode;
2382 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, pos()))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (funNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
2383
2384 ParamsBodyNodeType argsbody;
2385 MOZ_TRY_VAR(argsbody, handler_.newParamsBody(pos()))do { auto mozTryVarTempResult_ = (handler_.newParamsBody(pos(
))); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (argsbody
) = mozTryVarTempResult_.unwrap(); } while (0)
;
2386 funNode->setBody(argsbody);
2387
2388 bool isSelfHosting = options().selfHostingMode;
2389 FunctionFlags flags =
2390 InitialFunctionFlags(syntaxKind, generatorKind, asyncKind, isSelfHosting);
2391 FunctionBox* funbox =
2392 newFunctionBox(funNode, explicitName, flags, /* toStringStart = */ 0,
2393 inheritedDirectives, generatorKind, asyncKind);
2394 if (!funbox) {
2395 return errorResult();
2396 }
2397
2398 // Function is not syntactically part of another script.
2399 MOZ_ASSERT(funbox->index() == CompilationStencil::TopLevelIndex)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funbox->index() == CompilationStencil::TopLevelIndex
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(funbox->index() == CompilationStencil::TopLevelIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"funbox->index() == CompilationStencil::TopLevelIndex", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2399); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funbox->index() == CompilationStencil::TopLevelIndex"
")"); do { *((volatile int*)__null) = 2399; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2400
2401 funbox->initStandalone(this->compilationState_.scopeContext, syntaxKind);
2402
2403 SourceParseContext funpc(this, funbox, newDirectives);
2404 if (!funpc.init()) {
2405 return errorResult();
2406 }
2407
2408 YieldHandling yieldHandling = GetYieldHandling(generatorKind);
2409 AwaitHandling awaitHandling = GetAwaitHandling(asyncKind);
2410 AutoAwaitIsKeyword<FullParseHandler, Unit> awaitIsKeyword(this,
2411 awaitHandling);
2412 if (!functionFormalParametersAndBody(InAllowed, yieldHandling, &funNode,
2413 syntaxKind, parameterListEnd,
2414 /* isStandaloneFunction = */ true)) {
2415 return errorResult();
2416 }
2417
2418 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
2419 return errorResult();
2420 }
2421 if (tt != TokenKind::Eof) {
2422 error(JSMSG_GARBAGE_AFTER_INPUT, "function body", TokenKindToDesc(tt));
2423 return errorResult();
2424 }
2425
2426 if (!CheckParseTree(this->fc_, alloc_, funNode)) {
2427 return errorResult();
2428 }
2429
2430 ParseNode* node = funNode;
2431 // Don't constant-fold inside "use asm" code, as this could create a parse
2432 // tree that doesn't type-check as asm.js.
2433 if (!pc_->useAsmOrInsideUseAsm()) {
2434 if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) {
2435 return errorResult();
2436 }
2437 }
2438 funNode = &node->as<FunctionNode>();
2439
2440 if (!checkForUndefinedPrivateFields(nullptr)) {
2441 return errorResult();
2442 }
2443
2444 if (!this->setSourceMapInfo()) {
2445 return errorResult();
2446 }
2447
2448 return funNode;
2449}
2450
2451template <class ParseHandler, typename Unit>
2452typename ParseHandler::LexicalScopeNodeResult
2453GeneralParser<ParseHandler, Unit>::functionBody(InHandling inHandling,
2454 YieldHandling yieldHandling,
2455 FunctionSyntaxKind kind,
2456 FunctionBodyType type) {
2457 MOZ_ASSERT(pc_->isFunctionBox())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isFunctionBox())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isFunctionBox()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("pc_->isFunctionBox()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2457); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isFunctionBox()"
")"); do { *((volatile int*)__null) = 2457; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2458
2459#ifdef DEBUG1
2460 uint32_t startYieldOffset = pc_->lastYieldOffset;
2461#endif
2462
2463 Node body;
2464 if (type == StatementListBody) {
2465 bool inheritedStrict = pc_->sc()->strict();
2466 MOZ_TRY_VAR(body, statementList(yieldHandling))do { auto mozTryVarTempResult_ = (statementList(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (body) = mozTryVarTempResult_
.unwrap(); } while (0)
;
2467
2468 // When we transitioned from non-strict to strict mode, we need to
2469 // validate that all parameter names are valid strict mode names.
2470 if (!inheritedStrict && pc_->sc()->strict()) {
2471 MOZ_ASSERT(pc_->sc()->hasExplicitUseStrict(),do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->sc()->hasExplicitUseStrict())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(pc_->sc()->hasExplicitUseStrict()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->sc()->hasExplicitUseStrict()"
" (" "strict mode should only change when a 'use strict' directive "
"is present" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2473); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->sc()->hasExplicitUseStrict()"
") (" "strict mode should only change when a 'use strict' directive "
"is present" ")"); do { *((volatile int*)__null) = 2473; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
2472 "strict mode should only change when a 'use strict' directive "do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->sc()->hasExplicitUseStrict())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(pc_->sc()->hasExplicitUseStrict()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->sc()->hasExplicitUseStrict()"
" (" "strict mode should only change when a 'use strict' directive "
"is present" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2473); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->sc()->hasExplicitUseStrict()"
") (" "strict mode should only change when a 'use strict' directive "
"is present" ")"); do { *((volatile int*)__null) = 2473; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
2473 "is present")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->sc()->hasExplicitUseStrict())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(pc_->sc()->hasExplicitUseStrict()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->sc()->hasExplicitUseStrict()"
" (" "strict mode should only change when a 'use strict' directive "
"is present" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2473); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->sc()->hasExplicitUseStrict()"
") (" "strict mode should only change when a 'use strict' directive "
"is present" ")"); do { *((volatile int*)__null) = 2473; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
;
2474 if (!hasValidSimpleStrictParameterNames()) {
2475 // Request that this function be reparsed as strict to report
2476 // the invalid parameter name at the correct source location.
2477 pc_->newDirectives->setStrict();
2478 return errorResult();
2479 }
2480 }
2481 } else {
2482 MOZ_ASSERT(type == ExpressionBody)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(type == ExpressionBody)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(type == ExpressionBody))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("type == ExpressionBody"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2482); AnnotateMozCrashReason("MOZ_ASSERT" "(" "type == ExpressionBody"
")"); do { *((volatile int*)__null) = 2482; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2483
2484 // Async functions are implemented as generators, and generators are
2485 // assumed to be statement lists, to prepend initial `yield`.
2486 ListNodeType stmtList = null();
2487 if (pc_->isAsync()) {
2488 MOZ_TRY_VAR(stmtList, handler_.newStatementList(pos()))do { auto mozTryVarTempResult_ = (handler_.newStatementList(pos
())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()),
0))) { return mozTryVarTempResult_.propagateErr(); } (stmtList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
2489 }
2490
2491 Node kid;
2492 MOZ_TRY_VAR(kid,do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
2493 assignExpr(inHandling, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
;
2494
2495 MOZ_TRY_VAR(body, handler_.newExpressionBody(kid))do { auto mozTryVarTempResult_ = (handler_.newExpressionBody(
kid)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr())
, 0))) { return mozTryVarTempResult_.propagateErr(); } (body)
= mozTryVarTempResult_.unwrap(); } while (0)
;
2496
2497 if (pc_->isAsync()) {
2498 handler_.addStatementToList(stmtList, body);
2499 body = stmtList;
2500 }
2501 }
2502
2503 MOZ_ASSERT_IF(!pc_->isGenerator() && !pc_->isAsync(),do { if (!pc_->isGenerator() && !pc_->isAsync()
) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(pc_->lastYieldOffset == startYieldOffset)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(pc_->lastYieldOffset == startYieldOffset))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("pc_->lastYieldOffset == startYieldOffset"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2504); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->lastYieldOffset == startYieldOffset"
")"); do { *((volatile int*)__null) = 2504; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
2504 pc_->lastYieldOffset == startYieldOffset)do { if (!pc_->isGenerator() && !pc_->isAsync()
) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(pc_->lastYieldOffset == startYieldOffset)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(pc_->lastYieldOffset == startYieldOffset))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("pc_->lastYieldOffset == startYieldOffset"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2504); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->lastYieldOffset == startYieldOffset"
")"); do { *((volatile int*)__null) = 2504; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2505 MOZ_ASSERT_IF(pc_->isGenerator(), kind != FunctionSyntaxKind::Arrow)do { if (pc_->isGenerator()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(kind != FunctionSyntaxKind
::Arrow)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(kind != FunctionSyntaxKind::Arrow))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("kind != FunctionSyntaxKind::Arrow"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2505); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind != FunctionSyntaxKind::Arrow"
")"); do { *((volatile int*)__null) = 2505; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2506 MOZ_ASSERT_IF(pc_->isGenerator(), type == StatementListBody)do { if (pc_->isGenerator()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(type == StatementListBody
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(type == StatementListBody))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("type == StatementListBody", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2506); AnnotateMozCrashReason("MOZ_ASSERT" "(" "type == StatementListBody"
")"); do { *((volatile int*)__null) = 2506; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2507
2508 if (pc_->needsDotGeneratorName()) {
2509 MOZ_ASSERT_IF(!pc_->isAsync(), type == StatementListBody)do { if (!pc_->isAsync()) { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(type == StatementListBody
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(type == StatementListBody))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("type == StatementListBody", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2509); AnnotateMozCrashReason("MOZ_ASSERT" "(" "type == StatementListBody"
")"); do { *((volatile int*)__null) = 2509; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2510 if (!pc_->declareDotGeneratorName()) {
2511 return errorResult();
2512 }
2513 if (pc_->isGenerator()) {
2514 NameNodeType generator;
2515 MOZ_TRY_VAR(generator, newDotGeneratorName())do { auto mozTryVarTempResult_ = (newDotGeneratorName()); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (generator) = mozTryVarTempResult_
.unwrap(); } while (0)
;
2516 if (!handler_.prependInitialYield(handler_.asListNode(body), generator)) {
2517 return errorResult();
2518 }
2519 }
2520 }
2521
2522 if (pc_->numberOfArgumentsNames > 0 || kind == FunctionSyntaxKind::Arrow) {
2523 MOZ_ASSERT(pc_->isFunctionBox())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isFunctionBox())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isFunctionBox()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("pc_->isFunctionBox()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2523); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isFunctionBox()"
")"); do { *((volatile int*)__null) = 2523; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2524 pc_->sc()->setIneligibleForArgumentsLength();
2525 }
2526
2527 // Declare the 'arguments', 'this', and 'new.target' bindings if necessary
2528 // before finishing up the scope so these special bindings get marked as
2529 // closed over if necessary. Arrow functions don't have these bindings.
2530 if (kind != FunctionSyntaxKind::Arrow) {
2531 bool canSkipLazyClosedOverBindings = handler_.reuseClosedOverBindings();
2532 if (!pc_->declareFunctionArgumentsObject(usedNames_,
2533 canSkipLazyClosedOverBindings)) {
2534 return errorResult();
2535 }
2536 if (!pc_->declareFunctionThis(usedNames_, canSkipLazyClosedOverBindings)) {
2537 return errorResult();
2538 }
2539 if (!pc_->declareNewTarget(usedNames_, canSkipLazyClosedOverBindings)) {
2540 return errorResult();
2541 }
2542 }
2543
2544 return finishLexicalScope(pc_->varScope(), body, ScopeKind::FunctionLexical);
2545}
2546
2547template <class ParseHandler, typename Unit>
2548bool GeneralParser<ParseHandler, Unit>::matchOrInsertSemicolon(
2549 Modifier modifier /* = TokenStream::SlashIsRegExp */) {
2550 TokenKind tt = TokenKind::Eof;
2551 if (!tokenStream.peekTokenSameLine(&tt, modifier)) {
2552 return false;
2553 }
2554 if (tt != TokenKind::Eof && tt != TokenKind::Eol && tt != TokenKind::Semi &&
2555 tt != TokenKind::RightCurly) {
2556 /*
2557 * When current token is `await` and it's outside of async function,
2558 * it's possibly intended to be an await expression.
2559 *
2560 * await f();
2561 * ^
2562 * |
2563 * tried to insert semicolon here
2564 *
2565 * Detect this situation and throw an understandable error. Otherwise
2566 * we'd throw a confusing "unexpected token: (unexpected token)" error.
2567 */
2568 if (!pc_->isAsync() && anyChars.currentToken().type == TokenKind::Await) {
2569 error(JSMSG_AWAIT_OUTSIDE_ASYNC_OR_MODULE);
2570 return false;
2571 }
2572 if (!yieldExpressionsSupported() &&
2573 anyChars.currentToken().type == TokenKind::Yield) {
2574 error(JSMSG_YIELD_OUTSIDE_GENERATOR);
2575 return false;
2576 }
2577
2578#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
2579 if (!this->pc_->isUsingSyntaxAllowed() &&
2580 anyChars.currentToken().type == TokenKind::Using) {
2581 error(JSMSG_USING_OUTSIDE_BLOCK_OR_MODULE);
2582 return false;
2583 }
2584#endif
2585
2586 /* Advance the scanner for proper error location reporting. */
2587 tokenStream.consumeKnownToken(tt, modifier);
2588 error(JSMSG_UNEXPECTED_TOKEN_NO_EXPECT, TokenKindToDesc(tt));
2589 return false;
2590 }
2591 bool matched;
2592 return tokenStream.matchToken(&matched, TokenKind::Semi, modifier);
2593}
2594
2595bool ParserBase::leaveInnerFunction(ParseContext* outerpc) {
2596 MOZ_ASSERT(pc_ != outerpc)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_ != outerpc)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_ != outerpc))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("pc_ != outerpc"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2596); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_ != outerpc"
")"); do { *((volatile int*)__null) = 2596; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2597
2598 MOZ_ASSERT_IF(outerpc->isFunctionBox(),do { if (outerpc->isFunctionBox()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(outerpc->functionBox
()->index() < pc_->functionBox()->index())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(outerpc->functionBox()->index() < pc_->functionBox
()->index()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("outerpc->functionBox()->index() < pc_->functionBox()->index()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2599); AnnotateMozCrashReason("MOZ_ASSERT" "(" "outerpc->functionBox()->index() < pc_->functionBox()->index()"
")"); do { *((volatile int*)__null) = 2599; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
2599 outerpc->functionBox()->index() < pc_->functionBox()->index())do { if (outerpc->isFunctionBox()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(outerpc->functionBox
()->index() < pc_->functionBox()->index())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(outerpc->functionBox()->index() < pc_->functionBox
()->index()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("outerpc->functionBox()->index() < pc_->functionBox()->index()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2599); AnnotateMozCrashReason("MOZ_ASSERT" "(" "outerpc->functionBox()->index() < pc_->functionBox()->index()"
")"); do { *((volatile int*)__null) = 2599; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2600
2601 // If the current function allows super.property but cannot have a home
2602 // object, i.e., it is an arrow function, we need to propagate the flag to
2603 // the outer ParseContext.
2604 if (pc_->superScopeNeedsHomeObject()) {
2605 if (!pc_->isArrowFunction()) {
2606 MOZ_ASSERT(pc_->functionBox()->needsHomeObject())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->functionBox()->needsHomeObject())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(pc_->functionBox()->needsHomeObject()))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("pc_->functionBox()->needsHomeObject()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2606); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->functionBox()->needsHomeObject()"
")"); do { *((volatile int*)__null) = 2606; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2607 } else {
2608 outerpc->setSuperScopeNeedsHomeObject();
2609 }
2610 }
2611
2612 // Lazy functions inner to another lazy function need to be remembered by
2613 // the inner function so that if the outer function is eventually parsed
2614 // we do not need any further parsing or processing of the inner function.
2615 //
2616 // Append the inner function index here unconditionally; the vector is only
2617 // used if the Parser using outerpc is a syntax parsing. See
2618 // GeneralParser<SyntaxParseHandler>::finishFunction.
2619 if (!outerpc->innerFunctionIndexesForLazy.append(
2620 pc_->functionBox()->index())) {
2621 return false;
2622 }
2623
2624 PropagateTransitiveParseFlags(pc_->functionBox(), outerpc->sc());
2625
2626 return true;
2627}
2628
2629TaggedParserAtomIndex ParserBase::prefixAccessorName(
2630 PropertyType propType, TaggedParserAtomIndex propAtom) {
2631 StringBuffer prefixed(fc_);
2632 if (propType == PropertyType::Setter) {
2633 if (!prefixed.append("set ")) {
2634 return TaggedParserAtomIndex::null();
2635 }
2636 } else {
2637 if (!prefixed.append("get ")) {
2638 return TaggedParserAtomIndex::null();
2639 }
2640 }
2641 if (!prefixed.append(this->parserAtoms(), propAtom)) {
2642 return TaggedParserAtomIndex::null();
2643 }
2644 return prefixed.finishParserAtom(this->parserAtoms(), fc_);
2645}
2646
2647template <class ParseHandler, typename Unit>
2648void GeneralParser<ParseHandler, Unit>::setFunctionStartAtPosition(
2649 FunctionBox* funbox, TokenPos pos) const {
2650 uint32_t startLine;
2651 JS::LimitedColumnNumberOneOrigin startColumn;
2652 tokenStream.computeLineAndColumn(pos.begin, &startLine, &startColumn);
2653
2654 // NOTE: `Debugger::CallData::findScripts` relies on sourceStart and
2655 // lineno/column referring to the same location.
2656 funbox->setStart(pos.begin, startLine, startColumn);
2657}
2658
2659template <class ParseHandler, typename Unit>
2660void GeneralParser<ParseHandler, Unit>::setFunctionStartAtCurrentToken(
2661 FunctionBox* funbox) const {
2662 setFunctionStartAtPosition(funbox, anyChars.currentToken().pos);
2663}
2664
2665template <class ParseHandler, typename Unit>
2666bool GeneralParser<ParseHandler, Unit>::functionArguments(
2667 YieldHandling yieldHandling, FunctionSyntaxKind kind,
2668 FunctionNodeType funNode) {
2669 FunctionBox* funbox = pc_->functionBox();
2670
2671 // Modifier for the following tokens.
2672 // TokenStream::SlashIsDiv for the following cases:
2673 // async a => 1
2674 // ^
2675 //
2676 // (a) => 1
2677 // ^
2678 //
2679 // async (a) => 1
2680 // ^
2681 //
2682 // function f(a) {}
2683 // ^
2684 //
2685 // TokenStream::SlashIsRegExp for the following case:
2686 // a => 1
2687 // ^
2688 Modifier firstTokenModifier =
2689 kind != FunctionSyntaxKind::Arrow || funbox->isAsync()
2690 ? TokenStream::SlashIsDiv
2691 : TokenStream::SlashIsRegExp;
2692 TokenKind tt;
2693 if (!tokenStream.getToken(&tt, firstTokenModifier)) {
2694 return false;
2695 }
2696
2697 if (kind == FunctionSyntaxKind::Arrow && TokenKindIsPossibleIdentifier(tt)) {
2698 // Record the start of function source (for FunctionToString).
2699 setFunctionStartAtCurrentToken(funbox);
2700
2701 ParamsBodyNodeType argsbody;
2702 MOZ_TRY_VAR_OR_RETURN(argsbody, handler_.newParamsBody(pos()), false)do { auto parserTryVarTempResult_ = (handler_.newParamsBody(pos
())); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr(
)), 0))) { return (false); } (argsbody) = parserTryVarTempResult_
.unwrap(); } while (0)
;
2703 handler_.setFunctionFormalParametersAndBody(funNode, argsbody);
2704
2705 TaggedParserAtomIndex name = bindingIdentifier(yieldHandling);
2706 if (!name) {
2707 return false;
2708 }
2709
2710 constexpr bool disallowDuplicateParams = true;
2711 bool duplicatedParam = false;
2712 if (!notePositionalFormalParameter(funNode, name, pos().begin,
2713 disallowDuplicateParams,
2714 &duplicatedParam)) {
2715 return false;
2716 }
2717 MOZ_ASSERT(!duplicatedParam)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!duplicatedParam)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!duplicatedParam))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!duplicatedParam"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2717); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!duplicatedParam"
")"); do { *((volatile int*)__null) = 2717; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2718 MOZ_ASSERT(pc_->positionalFormalParameterNames().length() == 1)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->positionalFormalParameterNames().length() ==
1)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(pc_->positionalFormalParameterNames().length() ==
1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("pc_->positionalFormalParameterNames().length() == 1", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2718); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->positionalFormalParameterNames().length() == 1"
")"); do { *((volatile int*)__null) = 2718; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2719
2720 funbox->setLength(1);
2721 funbox->setArgCount(1);
2722 return true;
2723 }
2724
2725 if (tt != TokenKind::LeftParen) {
2726 error(kind == FunctionSyntaxKind::Arrow ? JSMSG_BAD_ARROW_ARGS
2727 : JSMSG_PAREN_BEFORE_FORMAL);
2728 return false;
2729 }
2730
2731 // Record the start of function source (for FunctionToString).
2732 setFunctionStartAtCurrentToken(funbox);
2733
2734 ParamsBodyNodeType argsbody;
2735 MOZ_TRY_VAR_OR_RETURN(argsbody, handler_.newParamsBody(pos()), false)do { auto parserTryVarTempResult_ = (handler_.newParamsBody(pos
())); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr(
)), 0))) { return (false); } (argsbody) = parserTryVarTempResult_
.unwrap(); } while (0)
;
2736 handler_.setFunctionFormalParametersAndBody(funNode, argsbody);
2737
2738 bool matched;
2739 if (!tokenStream.matchToken(&matched, TokenKind::RightParen,
2740 TokenStream::SlashIsRegExp)) {
2741 return false;
2742 }
2743 if (!matched) {
2744 bool hasRest = false;
2745 bool hasDefault = false;
2746 bool duplicatedParam = false;
2747 bool disallowDuplicateParams =
2748 kind == FunctionSyntaxKind::Arrow ||
2749 kind == FunctionSyntaxKind::Method ||
2750 kind == FunctionSyntaxKind::FieldInitializer ||
2751 kind == FunctionSyntaxKind::ClassConstructor;
2752 AtomVector& positionalFormals = pc_->positionalFormalParameterNames();
2753
2754 if (kind == FunctionSyntaxKind::Getter) {
2755 error(JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s");
2756 return false;
2757 }
2758
2759 while (true) {
2760 if (hasRest) {
2761 error(JSMSG_PARAMETER_AFTER_REST);
2762 return false;
2763 }
2764
2765 TokenKind tt;
2766 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
2767 return false;
2768 }
2769
2770 if (tt == TokenKind::TripleDot) {
2771 if (kind == FunctionSyntaxKind::Setter) {
2772 error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
2773 return false;
2774 }
2775
2776 disallowDuplicateParams = true;
2777 if (duplicatedParam) {
2778 // Has duplicated args before the rest parameter.
2779 error(JSMSG_BAD_DUP_ARGS);
2780 return false;
2781 }
2782
2783 hasRest = true;
2784 funbox->setHasRest();
2785
2786 if (!tokenStream.getToken(&tt)) {
2787 return false;
2788 }
2789
2790 if (!TokenKindIsPossibleIdentifier(tt) &&
2791 tt != TokenKind::LeftBracket && tt != TokenKind::LeftCurly) {
2792 error(JSMSG_NO_REST_NAME);
2793 return false;
2794 }
2795 }
2796
2797 switch (tt) {
2798 case TokenKind::LeftBracket:
2799 case TokenKind::LeftCurly: {
2800 disallowDuplicateParams = true;
2801 if (duplicatedParam) {
2802 // Has duplicated args before the destructuring parameter.
2803 error(JSMSG_BAD_DUP_ARGS);
2804 return false;
2805 }
2806
2807 funbox->hasDestructuringArgs = true;
2808
2809 Node destruct;
2810 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (destructuringDeclarationWithoutYieldOrAwait
( DeclarationKind::FormalParameter, yieldHandling, tt)); if (
(__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0))) {
return (false); } (destruct) = parserTryVarTempResult_.unwrap
(); } while (0)
2811 destruct,do { auto parserTryVarTempResult_ = (destructuringDeclarationWithoutYieldOrAwait
( DeclarationKind::FormalParameter, yieldHandling, tt)); if (
(__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0))) {
return (false); } (destruct) = parserTryVarTempResult_.unwrap
(); } while (0)
2812 destructuringDeclarationWithoutYieldOrAwait(do { auto parserTryVarTempResult_ = (destructuringDeclarationWithoutYieldOrAwait
( DeclarationKind::FormalParameter, yieldHandling, tt)); if (
(__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0))) {
return (false); } (destruct) = parserTryVarTempResult_.unwrap
(); } while (0)
2813 DeclarationKind::FormalParameter, yieldHandling, tt),do { auto parserTryVarTempResult_ = (destructuringDeclarationWithoutYieldOrAwait
( DeclarationKind::FormalParameter, yieldHandling, tt)); if (
(__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0))) {
return (false); } (destruct) = parserTryVarTempResult_.unwrap
(); } while (0)
2814 false)do { auto parserTryVarTempResult_ = (destructuringDeclarationWithoutYieldOrAwait
( DeclarationKind::FormalParameter, yieldHandling, tt)); if (
(__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0))) {
return (false); } (destruct) = parserTryVarTempResult_.unwrap
(); } while (0)
;
2815
2816 if (!noteDestructuredPositionalFormalParameter(funNode, destruct)) {
2817 return false;
2818 }
2819
2820 break;
2821 }
2822
2823 default: {
2824 if (!TokenKindIsPossibleIdentifier(tt)) {
2825 error(JSMSG_MISSING_FORMAL);
2826 return false;
2827 }
2828
2829 TaggedParserAtomIndex name = bindingIdentifier(yieldHandling);
2830 if (!name) {
2831 return false;
2832 }
2833
2834 if (!notePositionalFormalParameter(funNode, name, pos().begin,
2835 disallowDuplicateParams,
2836 &duplicatedParam)) {
2837 return false;
2838 }
2839 if (duplicatedParam) {
2840 funbox->hasDuplicateParameters = true;
2841 }
2842
2843 break;
2844 }
2845 }
2846
2847 if (positionalFormals.length() >= ARGNO_LIMIT) {
2848 error(JSMSG_TOO_MANY_FUN_ARGS);
2849 return false;
2850 }
2851
2852 bool matched;
2853 if (!tokenStream.matchToken(&matched, TokenKind::Assign,
2854 TokenStream::SlashIsRegExp)) {
2855 return false;
2856 }
2857 if (matched) {
2858 if (hasRest) {
2859 error(JSMSG_REST_WITH_DEFAULT);
2860 return false;
2861 }
2862 disallowDuplicateParams = true;
2863 if (duplicatedParam) {
2864 error(JSMSG_BAD_DUP_ARGS);
2865 return false;
2866 }
2867
2868 if (!hasDefault) {
2869 hasDefault = true;
2870
2871 // The Function.length property is the number of formals
2872 // before the first default argument.
2873 funbox->setLength(positionalFormals.length() - 1);
2874 }
2875 funbox->hasParameterExprs = true;
2876
2877 Node def_expr;
2878 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (assignExprWithoutYieldOrAwait
(yieldHandling)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (def_expr) = parserTryVarTempResult_
.unwrap(); } while (0)
2879 def_expr, assignExprWithoutYieldOrAwait(yieldHandling), false)do { auto parserTryVarTempResult_ = (assignExprWithoutYieldOrAwait
(yieldHandling)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (def_expr) = parserTryVarTempResult_
.unwrap(); } while (0)
;
2880 if (!handler_.setLastFunctionFormalParameterDefault(funNode,
2881 def_expr)) {
2882 return false;
2883 }
2884 }
2885
2886 // Setter syntax uniquely requires exactly one argument.
2887 if (kind == FunctionSyntaxKind::Setter) {
2888 break;
2889 }
2890
2891 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
2892 TokenStream::SlashIsRegExp)) {
2893 return false;
2894 }
2895 if (!matched) {
2896 break;
2897 }
2898
2899 if (!hasRest) {
2900 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
2901 return false;
2902 }
2903 if (tt == TokenKind::RightParen) {
2904 break;
2905 }
2906 }
2907 }
2908
2909 TokenKind tt;
2910 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
2911 return false;
2912 }
2913 if (tt != TokenKind::RightParen) {
2914 if (kind == FunctionSyntaxKind::Setter) {
2915 error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
2916 return false;
2917 }
2918
2919 error(JSMSG_PAREN_AFTER_FORMAL);
2920 return false;
2921 }
2922
2923 if (!hasDefault) {
2924 funbox->setLength(positionalFormals.length() - hasRest);
2925 }
2926
2927 funbox->setArgCount(positionalFormals.length());
2928 } else if (kind == FunctionSyntaxKind::Setter) {
2929 error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", "");
2930 return false;
2931 }
2932
2933 return true;
2934}
2935
2936template <typename Unit>
2937bool Parser<FullParseHandler, Unit>::skipLazyInnerFunction(
2938 FunctionNode* funNode, uint32_t toStringStart, bool tryAnnexB) {
2939 // When a lazily-parsed function is called, we only fully parse (and emit)
2940 // that function, not any of its nested children. The initial syntax-only
2941 // parse recorded the free variables of nested functions and their extents,
2942 // so we can skip over them after accounting for their free variables.
2943
2944 MOZ_ASSERT(pc_->isOutermostOfCurrentCompile())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isOutermostOfCurrentCompile())>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(pc_->isOutermostOfCurrentCompile()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->isOutermostOfCurrentCompile()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2944); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isOutermostOfCurrentCompile()"
")"); do { *((volatile int*)__null) = 2944; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2945 handler_.nextLazyInnerFunction();
2946 const ScriptStencil& cachedData = handler_.cachedScriptData();
2947 const ScriptStencilExtra& cachedExtra = handler_.cachedScriptExtra();
2948 MOZ_ASSERT(toStringStart == cachedExtra.extent.toStringStart)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(toStringStart == cachedExtra.extent.toStringStart)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(toStringStart == cachedExtra.extent.toStringStart)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("toStringStart == cachedExtra.extent.toStringStart"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2948); AnnotateMozCrashReason("MOZ_ASSERT" "(" "toStringStart == cachedExtra.extent.toStringStart"
")"); do { *((volatile int*)__null) = 2948; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2949
2950 FunctionBox* funbox = newFunctionBox(funNode, cachedData, cachedExtra);
2951 if (!funbox) {
2952 return false;
2953 }
2954
2955 ScriptStencil& script = funbox->functionStencil();
2956 funbox->copyFunctionFields(script);
2957
2958 // If the inner lazy function is class constructor, connect it to the class
2959 // statement/expression we are parsing.
2960 if (funbox->isClassConstructor()) {
2961 auto classStmt =
2962 pc_->template findInnermostStatement<ParseContext::ClassStatement>();
2963 MOZ_ASSERT(!classStmt->constructorBox)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!classStmt->constructorBox)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!classStmt->constructorBox
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"!classStmt->constructorBox", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2963); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!classStmt->constructorBox"
")"); do { *((volatile int*)__null) = 2963; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2964 classStmt->constructorBox = funbox;
2965 }
2966
2967 MOZ_ASSERT_IF(pc_->isFunctionBox(),do { if (pc_->isFunctionBox()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(pc_->functionBox
()->index() < funbox->index())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->functionBox()->index
() < funbox->index()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("pc_->functionBox()->index() < funbox->index()",
"/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2968); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->functionBox()->index() < funbox->index()"
")"); do { *((volatile int*)__null) = 2968; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
2968 pc_->functionBox()->index() < funbox->index())do { if (pc_->isFunctionBox()) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(pc_->functionBox
()->index() < funbox->index())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->functionBox()->index
() < funbox->index()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("pc_->functionBox()->index() < funbox->index()",
"/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2968); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->functionBox()->index() < funbox->index()"
")"); do { *((volatile int*)__null) = 2968; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2969
2970 PropagateTransitiveParseFlags(funbox, pc_->sc());
2971
2972 if (!tokenStream.advance(funbox->extent().sourceEnd)) {
2973 return false;
2974 }
2975
2976 // Append possible Annex B function box only upon successfully parsing.
2977 if (tryAnnexB &&
2978 !pc_->innermostScope()->addPossibleAnnexBFunctionBox(pc_, funbox)) {
2979 return false;
2980 }
2981
2982 return true;
2983}
2984
2985template <typename Unit>
2986bool Parser<SyntaxParseHandler, Unit>::skipLazyInnerFunction(
2987 FunctionNodeType funNode, uint32_t toStringStart, bool tryAnnexB) {
2988 MOZ_CRASH("Cannot skip lazy inner functions when syntax parsing")do { do { } while (false); MOZ_ReportCrash("" "Cannot skip lazy inner functions when syntax parsing"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 2988); AnnotateMozCrashReason("MOZ_CRASH(" "Cannot skip lazy inner functions when syntax parsing"
")"); do { *((volatile int*)__null) = 2988; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
2989}
2990
2991template <class ParseHandler, typename Unit>
2992bool GeneralParser<ParseHandler, Unit>::skipLazyInnerFunction(
2993 FunctionNodeType funNode, uint32_t toStringStart, bool tryAnnexB) {
2994 return asFinalParser()->skipLazyInnerFunction(funNode, toStringStart,
2995 tryAnnexB);
2996}
2997
2998template <class ParseHandler, typename Unit>
2999bool GeneralParser<ParseHandler, Unit>::addExprAndGetNextTemplStrToken(
3000 YieldHandling yieldHandling, ListNodeType nodeList, TokenKind* ttp) {
3001 Node pn;
3002 MOZ_TRY_VAR_OR_RETURN(pn, expr(InAllowed, yieldHandling, TripledotProhibited),do { auto parserTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (pn) = parserTryVarTempResult_
.unwrap(); } while (0)
3003 false)do { auto parserTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (pn) = parserTryVarTempResult_
.unwrap(); } while (0)
;
3004 handler_.addList(nodeList, pn);
3005
3006 TokenKind tt;
3007 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
3008 return false;
3009 }
3010 if (tt != TokenKind::RightCurly) {
3011 error(JSMSG_TEMPLSTR_UNTERM_EXPR);
3012 return false;
3013 }
3014
3015 return tokenStream.getTemplateToken(ttp);
3016}
3017
3018template <class ParseHandler, typename Unit>
3019bool GeneralParser<ParseHandler, Unit>::taggedTemplate(
3020 YieldHandling yieldHandling, ListNodeType tagArgsList, TokenKind tt) {
3021 CallSiteNodeType callSiteObjNode;
3022 MOZ_TRY_VAR_OR_RETURN(callSiteObjNode,do { auto parserTryVarTempResult_ = (handler_.newCallSiteObject
(pos().begin)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (callSiteObjNode) = parserTryVarTempResult_
.unwrap(); } while (0)
3023 handler_.newCallSiteObject(pos().begin), false)do { auto parserTryVarTempResult_ = (handler_.newCallSiteObject
(pos().begin)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (callSiteObjNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
3024 handler_.addList(tagArgsList, callSiteObjNode);
3025
3026 pc_->sc()->setHasCallSiteObj();
3027
3028 while (true) {
3029 if (!appendToCallSiteObj(callSiteObjNode)) {
3030 return false;
3031 }
3032 if (tt != TokenKind::TemplateHead) {
3033 break;
3034 }
3035
3036 if (!addExprAndGetNextTemplStrToken(yieldHandling, tagArgsList, &tt)) {
3037 return false;
3038 }
3039 }
3040 handler_.setEndPosition(tagArgsList, callSiteObjNode);
3041 return true;
3042}
3043
3044template <class ParseHandler, typename Unit>
3045typename ParseHandler::ListNodeResult
3046GeneralParser<ParseHandler, Unit>::templateLiteral(
3047 YieldHandling yieldHandling) {
3048 NameNodeType literal;
3049 MOZ_TRY_VAR(literal, noSubstitutionUntaggedTemplate())do { auto mozTryVarTempResult_ = (noSubstitutionUntaggedTemplate
()); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (literal)
= mozTryVarTempResult_.unwrap(); } while (0)
;
3050
3051 ListNodeType nodeList;
3052 MOZ_TRY_VAR(nodeList,do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::TemplateStringListExpr, literal)); if ((__builtin_expect(!!
(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (nodeList) = mozTryVarTempResult_.unwrap()
; } while (0)
3053 handler_.newList(ParseNodeKind::TemplateStringListExpr, literal))do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::TemplateStringListExpr, literal)); if ((__builtin_expect(!!
(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (nodeList) = mozTryVarTempResult_.unwrap()
; } while (0)
;
3054
3055 TokenKind tt;
3056 do {
3057 if (!addExprAndGetNextTemplStrToken(yieldHandling, nodeList, &tt)) {
3058 return errorResult();
3059 }
3060
3061 MOZ_TRY_VAR(literal, noSubstitutionUntaggedTemplate())do { auto mozTryVarTempResult_ = (noSubstitutionUntaggedTemplate
()); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (literal)
= mozTryVarTempResult_.unwrap(); } while (0)
;
3062
3063 handler_.addList(nodeList, literal);
3064 } while (tt == TokenKind::TemplateHead);
3065 return nodeList;
3066}
3067
3068template <class ParseHandler, typename Unit>
3069typename ParseHandler::FunctionNodeResult
3070GeneralParser<ParseHandler, Unit>::functionDefinition(
3071 FunctionNodeType funNode, uint32_t toStringStart, InHandling inHandling,
3072 YieldHandling yieldHandling, TaggedParserAtomIndex funName,
3073 FunctionSyntaxKind kind, GeneratorKind generatorKind,
3074 FunctionAsyncKind asyncKind, bool tryAnnexB /* = false */) {
3075 MOZ_ASSERT_IF(kind == FunctionSyntaxKind::Statement, funName)do { if (kind == FunctionSyntaxKind::Statement) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(funName
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(funName))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("funName", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3075); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funName" ")"
); do { *((volatile int*)__null) = 3075; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3076
3077 // If we see any inner function, note it on our current context. The bytecode
3078 // emitter may eliminate the function later, but we use a conservative
3079 // definition for consistency between lazy and full parsing.
3080 pc_->sc()->setHasInnerFunctions();
3081
3082 // When fully parsing a lazy script, we do not fully reparse its inner
3083 // functions, which are also lazy. Instead, their free variables and source
3084 // extents are recorded and may be skipped.
3085 if (handler_.reuseLazyInnerFunctions()) {
3086 if (!skipLazyInnerFunction(funNode, toStringStart, tryAnnexB)) {
3087 return errorResult();
3088 }
3089
3090 return funNode;
3091 }
3092
3093 bool isSelfHosting = options().selfHostingMode;
3094 FunctionFlags flags =
3095 InitialFunctionFlags(kind, generatorKind, asyncKind, isSelfHosting);
3096
3097 // Self-hosted functions with special function names require extended slots
3098 // for various purposes.
3099 bool forceExtended =
3100 isSelfHosting && funName &&
3101 this->parserAtoms().isExtendedUnclonedSelfHostedFunctionName(funName);
3102 if (forceExtended) {
3103 flags.setIsExtended();
3104 }
3105
3106 // Speculatively parse using the directives of the parent parsing context.
3107 // If a directive is encountered (e.g., "use strict") that changes how the
3108 // function should have been parsed, we backup and reparse with the new set
3109 // of directives.
3110 Directives directives(pc_);
3111 Directives newDirectives = directives;
3112
3113 Position start(tokenStream);
3114 auto startObj = this->compilationState_.getPosition();
3115
3116 // Parse the inner function. The following is a loop as we may attempt to
3117 // reparse a function due to failed syntax parsing and encountering new
3118 // "use foo" directives.
3119 while (true) {
3120 if (trySyntaxParseInnerFunction(&funNode, funName, flags, toStringStart,
3121 inHandling, yieldHandling, kind,
3122 generatorKind, asyncKind, tryAnnexB,
3123 directives, &newDirectives)) {
3124 break;
3125 }
3126
3127 // Return on error.
3128 if (anyChars.hadError() || directives == newDirectives) {
3129 return errorResult();
3130 }
3131
3132 // Assignment must be monotonic to prevent infinitely attempting to
3133 // reparse.
3134 MOZ_ASSERT_IF(directives.strict(), newDirectives.strict())do { if (directives.strict()) { do { static_assert( mozilla::
detail::AssertionConditionType<decltype(newDirectives.strict
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(newDirectives.strict()))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("newDirectives.strict()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3134); AnnotateMozCrashReason("MOZ_ASSERT" "(" "newDirectives.strict()"
")"); do { *((volatile int*)__null) = 3134; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3135 MOZ_ASSERT_IF(directives.asmJS(), newDirectives.asmJS())do { if (directives.asmJS()) { do { static_assert( mozilla::detail
::AssertionConditionType<decltype(newDirectives.asmJS())>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(newDirectives.asmJS()))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("newDirectives.asmJS()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3135); AnnotateMozCrashReason("MOZ_ASSERT" "(" "newDirectives.asmJS()"
")"); do { *((volatile int*)__null) = 3135; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
3136 directives = newDirectives;
3137
3138 // Rewind to retry parsing with new directives applied.
3139 tokenStream.rewind(start);
3140 this->compilationState_.rewind(startObj);
3141
3142 // functionFormalParametersAndBody may have already set body before failing.
3143 handler_.setFunctionFormalParametersAndBody(funNode, null());
3144 }
3145
3146 return funNode;
3147}
3148
3149template <typename Unit>
3150bool Parser<FullParseHandler, Unit>::advancePastSyntaxParsedFunction(
3151 SyntaxParser* syntaxParser) {
3152 MOZ_ASSERT(getSyntaxParser() == syntaxParser)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(getSyntaxParser() == syntaxParser)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(getSyntaxParser() == syntaxParser
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"getSyntaxParser() == syntaxParser", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3152); AnnotateMozCrashReason("MOZ_ASSERT" "(" "getSyntaxParser() == syntaxParser"
")"); do { *((volatile int*)__null) = 3152; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3153
3154 // Advance this parser over tokens processed by the syntax parser.
3155 Position currentSyntaxPosition(syntaxParser->tokenStream);
3156 if (!tokenStream.fastForward(currentSyntaxPosition, syntaxParser->anyChars)) {
3157 return false;
3158 }
3159
3160 anyChars.adoptState(syntaxParser->anyChars);
3161 tokenStream.adoptState(syntaxParser->tokenStream);
3162 return true;
3163}
3164
3165template <typename Unit>
3166bool Parser<FullParseHandler, Unit>::trySyntaxParseInnerFunction(
3167 FunctionNode** funNode, TaggedParserAtomIndex explicitName,
3168 FunctionFlags flags, uint32_t toStringStart, InHandling inHandling,
3169 YieldHandling yieldHandling, FunctionSyntaxKind kind,
3170 GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB,
3171 Directives inheritedDirectives, Directives* newDirectives) {
3172 // Try a syntax parse for this inner function.
3173 do {
3174 // If we're assuming this function is an IIFE, always perform a full
3175 // parse to avoid the overhead of a lazy syntax-only parse. Although
3176 // the prediction may be incorrect, IIFEs are common enough that it
3177 // pays off for lots of code.
3178 if ((*funNode)->isLikelyIIFE() &&
3179 generatorKind == GeneratorKind::NotGenerator &&
3180 asyncKind == FunctionAsyncKind::SyncFunction) {
3181 break;
3182 }
3183
3184 SyntaxParser* syntaxParser = getSyntaxParser();
3185 if (!syntaxParser) {
3186 break;
3187 }
3188
3189 UsedNameTracker::RewindToken token = usedNames_.getRewindToken();
3190 auto statePosition = this->compilationState_.getPosition();
3191
3192 // Move the syntax parser to the current position in the stream. In the
3193 // common case this seeks forward, but it'll also seek backward *at least*
3194 // when arrow functions appear inside arrow function argument defaults
3195 // (because we rewind to reparse arrow functions once we're certain they're
3196 // arrow functions):
3197 //
3198 // var x = (y = z => 2) => q;
3199 // // ^ we first seek to here to syntax-parse this function
3200 // // ^ then we seek back to here to syntax-parse the outer function
3201 Position currentPosition(tokenStream);
3202 if (!syntaxParser->tokenStream.seekTo(currentPosition, anyChars)) {
3203 return false;
3204 }
3205
3206 // Make a FunctionBox before we enter the syntax parser, because |pn|
3207 // still expects a FunctionBox to be attached to it during BCE, and
3208 // the syntax parser cannot attach one to it.
3209 FunctionBox* funbox =
3210 newFunctionBox(*funNode, explicitName, flags, toStringStart,
3211 inheritedDirectives, generatorKind, asyncKind);
3212 if (!funbox) {
3213 return false;
3214 }
3215 funbox->initWithEnclosingParseContext(pc_, kind);
3216
3217 auto syntaxNodeResult = syntaxParser->innerFunctionForFunctionBox(
3218 SyntaxParseHandler::Node::NodeGeneric, pc_, funbox, inHandling,
3219 yieldHandling, kind, newDirectives);
3220 if (syntaxNodeResult.isErr()) {
3221 if (syntaxParser->hadAbortedSyntaxParse()) {
3222 // Try again with a full parse. UsedNameTracker needs to be
3223 // rewound to just before we tried the syntax parse for
3224 // correctness.
3225 syntaxParser->clearAbortedSyntaxParse();
3226 usedNames_.rewind(token);
3227 this->compilationState_.rewind(statePosition);
3228 MOZ_ASSERT(!fc_->hadErrors())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!fc_->hadErrors())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!fc_->hadErrors()))), 0))
) { do { } while (false); MOZ_ReportAssertionFailure("!fc_->hadErrors()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3228); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!fc_->hadErrors()"
")"); do { *((volatile int*)__null) = 3228; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3229 break;
3230 }
3231 return false;
3232 }
3233
3234 if (!advancePastSyntaxParsedFunction(syntaxParser)) {
3235 return false;
3236 }
3237
3238 // Update the end position of the parse node.
3239 (*funNode)->pn_pos.end = anyChars.currentToken().pos.end;
3240
3241 // Append possible Annex B function box only upon successfully parsing.
3242 if (tryAnnexB) {
3243 if (!pc_->innermostScope()->addPossibleAnnexBFunctionBox(pc_, funbox)) {
3244 return false;
3245 }
3246 }
3247
3248 return true;
3249 } while (false);
3250
3251 // We failed to do a syntax parse above, so do the full parse.
3252 FunctionNodeType innerFunc;
3253 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3254 innerFunc,do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3255 innerFunction(*funNode, pc_, explicitName, flags, toStringStart,do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3256 inHandling, yieldHandling, kind, generatorKind, asyncKind,do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3257 tryAnnexB, inheritedDirectives, newDirectives),do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3258 false)do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
;
3259
3260 *funNode = innerFunc;
3261 return true;
3262}
3263
3264template <typename Unit>
3265bool Parser<SyntaxParseHandler, Unit>::trySyntaxParseInnerFunction(
3266 FunctionNodeType* funNode, TaggedParserAtomIndex explicitName,
3267 FunctionFlags flags, uint32_t toStringStart, InHandling inHandling,
3268 YieldHandling yieldHandling, FunctionSyntaxKind kind,
3269 GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB,
3270 Directives inheritedDirectives, Directives* newDirectives) {
3271 // This is already a syntax parser, so just parse the inner function.
3272 FunctionNodeType innerFunc;
3273 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3274 innerFunc,do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3275 innerFunction(*funNode, pc_, explicitName, flags, toStringStart,do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3276 inHandling, yieldHandling, kind, generatorKind, asyncKind,do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3277 tryAnnexB, inheritedDirectives, newDirectives),do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
3278 false)do { auto parserTryVarTempResult_ = (innerFunction(*funNode, pc_
, explicitName, flags, toStringStart, inHandling, yieldHandling
, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives
, newDirectives)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (innerFunc) = parserTryVarTempResult_
.unwrap(); } while (0)
;
3279
3280 *funNode = innerFunc;
3281 return true;
3282}
3283
3284template <class ParseHandler, typename Unit>
3285inline bool GeneralParser<ParseHandler, Unit>::trySyntaxParseInnerFunction(
3286 FunctionNodeType* funNode, TaggedParserAtomIndex explicitName,
3287 FunctionFlags flags, uint32_t toStringStart, InHandling inHandling,
3288 YieldHandling yieldHandling, FunctionSyntaxKind kind,
3289 GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB,
3290 Directives inheritedDirectives, Directives* newDirectives) {
3291 return asFinalParser()->trySyntaxParseInnerFunction(
3292 funNode, explicitName, flags, toStringStart, inHandling, yieldHandling,
3293 kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives,
3294 newDirectives);
3295}
3296
3297template <class ParseHandler, typename Unit>
3298typename ParseHandler::FunctionNodeResult
3299GeneralParser<ParseHandler, Unit>::innerFunctionForFunctionBox(
3300 FunctionNodeType funNode, ParseContext* outerpc, FunctionBox* funbox,
3301 InHandling inHandling, YieldHandling yieldHandling, FunctionSyntaxKind kind,
3302 Directives* newDirectives) {
3303 // Note that it is possible for outerpc != this->pc_, as we may be
3304 // attempting to syntax parse an inner function from an outer full
3305 // parser. In that case, outerpc is a SourceParseContext from the full parser
3306 // instead of the current top of the stack of the syntax parser.
3307
3308 // Push a new ParseContext.
3309 SourceParseContext funpc(this, funbox, newDirectives);
3310 if (!funpc.init()) {
3311 return errorResult();
3312 }
3313
3314 if (!functionFormalParametersAndBody(inHandling, yieldHandling, &funNode,
3315 kind)) {
3316 return errorResult();
3317 }
3318
3319 if (!leaveInnerFunction(outerpc)) {
3320 return errorResult();
3321 }
3322
3323 return funNode;
3324}
3325
3326template <class ParseHandler, typename Unit>
3327typename ParseHandler::FunctionNodeResult
3328GeneralParser<ParseHandler, Unit>::innerFunction(
3329 FunctionNodeType funNode, ParseContext* outerpc,
3330 TaggedParserAtomIndex explicitName, FunctionFlags flags,
3331 uint32_t toStringStart, InHandling inHandling, YieldHandling yieldHandling,
3332 FunctionSyntaxKind kind, GeneratorKind generatorKind,
3333 FunctionAsyncKind asyncKind, bool tryAnnexB, Directives inheritedDirectives,
3334 Directives* newDirectives) {
3335 // Note that it is possible for outerpc != this->pc_, as we may be
3336 // attempting to syntax parse an inner function from an outer full
3337 // parser. In that case, outerpc is a SourceParseContext from the full parser
3338 // instead of the current top of the stack of the syntax parser.
3339
3340 FunctionBox* funbox =
3341 newFunctionBox(funNode, explicitName, flags, toStringStart,
3342 inheritedDirectives, generatorKind, asyncKind);
3343 if (!funbox) {
3344 return errorResult();
3345 }
3346 funbox->initWithEnclosingParseContext(outerpc, kind);
3347
3348 FunctionNodeType innerFunc;
3349 MOZ_TRY_VAR(innerFunc,do { auto mozTryVarTempResult_ = (innerFunctionForFunctionBox
(funNode, outerpc, funbox, inHandling, yieldHandling, kind, newDirectives
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (innerFunc
) = mozTryVarTempResult_.unwrap(); } while (0)
3350 innerFunctionForFunctionBox(funNode, outerpc, funbox, inHandling,do { auto mozTryVarTempResult_ = (innerFunctionForFunctionBox
(funNode, outerpc, funbox, inHandling, yieldHandling, kind, newDirectives
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (innerFunc
) = mozTryVarTempResult_.unwrap(); } while (0)
3351 yieldHandling, kind, newDirectives))do { auto mozTryVarTempResult_ = (innerFunctionForFunctionBox
(funNode, outerpc, funbox, inHandling, yieldHandling, kind, newDirectives
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (innerFunc
) = mozTryVarTempResult_.unwrap(); } while (0)
;
3352
3353 // Append possible Annex B function box only upon successfully parsing.
3354 if (tryAnnexB) {
3355 if (!pc_->innermostScope()->addPossibleAnnexBFunctionBox(pc_, funbox)) {
3356 return errorResult();
3357 }
3358 }
3359
3360 return innerFunc;
3361}
3362
3363template <class ParseHandler, typename Unit>
3364bool GeneralParser<ParseHandler, Unit>::appendToCallSiteObj(
3365 CallSiteNodeType callSiteObj) {
3366 Node cookedNode;
3367 MOZ_TRY_VAR_OR_RETURN(cookedNode, noSubstitutionTaggedTemplate(), false)do { auto parserTryVarTempResult_ = (noSubstitutionTaggedTemplate
()); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr()
), 0))) { return (false); } (cookedNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
3368
3369 auto atom = tokenStream.getRawTemplateStringAtom();
3370 if (!atom) {
3371 return false;
3372 }
3373 NameNodeType rawNode;
3374 MOZ_TRY_VAR_OR_RETURN(rawNode, handler_.newTemplateStringLiteral(atom, pos()),do { auto parserTryVarTempResult_ = (handler_.newTemplateStringLiteral
(atom, pos())); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (rawNode) = parserTryVarTempResult_
.unwrap(); } while (0)
3375 false)do { auto parserTryVarTempResult_ = (handler_.newTemplateStringLiteral
(atom, pos())); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (rawNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
3376
3377 handler_.addToCallSiteObject(callSiteObj, rawNode, cookedNode);
3378 return true;
3379}
3380
3381template <typename Unit>
3382FullParseHandler::FunctionNodeResult
3383Parser<FullParseHandler, Unit>::standaloneLazyFunction(
3384 CompilationInput& input, uint32_t toStringStart, bool strict,
3385 GeneratorKind generatorKind, FunctionAsyncKind asyncKind) {
3386 MOZ_ASSERT(checkOptionsCalled_)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(checkOptionsCalled_)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(checkOptionsCalled_))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("checkOptionsCalled_"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3386); AnnotateMozCrashReason("MOZ_ASSERT" "(" "checkOptionsCalled_"
")"); do { *((volatile int*)__null) = 3386; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1
Assuming field 'checkOptionsCalled_' is true
2
Taking false branch
3
Loop condition is false. Exiting loop
3387
3388 FunctionSyntaxKind syntaxKind = input.functionSyntaxKind();
3389 FunctionNodeType funNode;
3390 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, pos()))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (funNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
4
Taking false branch
5
Loop condition is false. Exiting loop
3391
3392 TaggedParserAtomIndex displayAtom =
3393 this->getCompilationState().previousParseCache.displayAtom();
3394
3395 Directives directives(strict);
3396 FunctionBox* funbox =
3397 newFunctionBox(funNode, displayAtom, input.functionFlags(), toStringStart,
3398 directives, generatorKind, asyncKind);
3399 if (!funbox
5.1
'funbox' is non-null
) {
6
Taking false branch
3400 return errorResult();
3401 }
3402 const ScriptStencilExtra& funExtra =
3403 this->getCompilationState().previousParseCache.funExtra();
3404 funbox->initFromLazyFunction(
3405 funExtra, this->getCompilationState().scopeContext, syntaxKind);
3406 if (funbox->useMemberInitializers()) {
7
Assuming the condition is false
8
Taking false branch
3407 funbox->setMemberInitializers(funExtra.memberInitializers());
3408 }
3409
3410 Directives newDirectives = directives;
3411 SourceParseContext funpc(this, funbox, &newDirectives);
3412 if (!funpc.init()) {
9
Assuming the condition is false
3413 return errorResult();
3414 }
3415
3416 // Our tokenStream has no current token, so funNode's position is garbage.
3417 // Substitute the position of the first token in our source. If the
3418 // function is a not-async arrow, use TokenStream::SlashIsRegExp to keep
3419 // verifyConsistentModifier from complaining (we will use
3420 // TokenStream::SlashIsRegExp in functionArguments).
3421 Modifier modifier = (input.functionFlags().isArrow() &&
3422 asyncKind == FunctionAsyncKind::SyncFunction)
3423 ? TokenStream::SlashIsRegExp
3424 : TokenStream::SlashIsDiv;
3425 if (!tokenStream.peekTokenPos(&funNode->pn_pos, modifier)) {
10
Taking false branch
3426 return errorResult();
3427 }
3428
3429 YieldHandling yieldHandling = GetYieldHandling(generatorKind);
3430
3431 if (funbox->isSyntheticFunction()) {
11
Assuming the condition is true
12
Taking true branch
3432 // Currently default class constructors are the only synthetic function that
3433 // supports delazification.
3434 MOZ_ASSERT(funbox->isClassConstructor())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funbox->isClassConstructor())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(funbox->isClassConstructor
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("funbox->isClassConstructor()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3434); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funbox->isClassConstructor()"
")"); do { *((volatile int*)__null) = 3434; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
13
Taking false branch
14
Loop condition is false. Exiting loop
3435 MOZ_ASSERT(funbox->extent().toStringStart == funbox->extent().sourceStart)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funbox->extent().toStringStart == funbox->extent
().sourceStart)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(funbox->extent().toStringStart
== funbox->extent().sourceStart))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("funbox->extent().toStringStart == funbox->extent().sourceStart"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3435); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funbox->extent().toStringStart == funbox->extent().sourceStart"
")"); do { *((volatile int*)__null) = 3435; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
15
Assuming field 'toStringStart' is equal to field 'sourceStart'
16
Taking false branch
3436
3437 HasHeritage hasHeritage = funbox->isDerivedClassConstructor()
17
Loop condition is false. Exiting loop
18
Assuming the condition is true
19
'?' condition is true
3438 ? HasHeritage::Yes
3439 : HasHeritage::No;
3440 TokenPos synthesizedBodyPos(funbox->extent().toStringStart,
3441 funbox->extent().toStringEnd);
3442
3443 // Reset pos() to the `class` keyword for predictable results.
3444 tokenStream.consumeKnownToken(TokenKind::Class);
3445
3446 if (!this->synthesizeConstructorBody(synthesizedBodyPos, hasHeritage,
20
Calling 'GeneralParser::synthesizeConstructorBody'
3447 funNode, funbox)) {
3448 return errorResult();
3449 }
3450 } else {
3451 if (!functionFormalParametersAndBody(InAllowed, yieldHandling, &funNode,
3452 syntaxKind)) {
3453 MOZ_ASSERT(directives == newDirectives)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(directives == newDirectives)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(directives == newDirectives)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("directives == newDirectives"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3453); AnnotateMozCrashReason("MOZ_ASSERT" "(" "directives == newDirectives"
")"); do { *((volatile int*)__null) = 3453; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3454 return errorResult();
3455 }
3456 }
3457
3458 if (!CheckParseTree(this->fc_, alloc_, funNode)) {
3459 return errorResult();
3460 }
3461
3462 ParseNode* node = funNode;
3463 // Don't constant-fold inside "use asm" code, as this could create a parse
3464 // tree that doesn't type-check as asm.js.
3465 if (!pc_->useAsmOrInsideUseAsm()) {
3466 if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) {
3467 return errorResult();
3468 }
3469 }
3470 funNode = &node->as<FunctionNode>();
3471
3472 return funNode;
3473}
3474
3475void ParserBase::setFunctionEndFromCurrentToken(FunctionBox* funbox) const {
3476 if (compilationState_.isInitialStencil()) {
3477 MOZ_ASSERT(anyChars.currentToken().type != TokenKind::Eof)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.currentToken().type != TokenKind::Eof)>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.currentToken().type != TokenKind::Eof))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.currentToken().type != TokenKind::Eof"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3477); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.currentToken().type != TokenKind::Eof"
")"); do { *((volatile int*)__null) = 3477; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3478 MOZ_ASSERT(anyChars.currentToken().type < TokenKind::Limit)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.currentToken().type < TokenKind::Limit)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.currentToken().type < TokenKind::Limit))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.currentToken().type < TokenKind::Limit"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3478); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.currentToken().type < TokenKind::Limit"
")"); do { *((volatile int*)__null) = 3478; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3479 funbox->setEnd(anyChars.currentToken().pos.end);
3480 } else {
3481 // If we're delazifying an arrow function with expression body and
3482 // the expression is also a function, we arrive here immediately after
3483 // skipping the function by Parser::skipLazyInnerFunction.
3484 //
3485 // a => b => c
3486 // ^
3487 // |
3488 // we're here
3489 //
3490 // In that case, the current token's type field is either Limit or
3491 // poisoned.
3492 // We shouldn't read the value if it's poisoned.
3493 // See TokenStreamSpecific<Unit, AnyCharsAccess>::advance and
3494 // mfbt/MemoryChecking.h for more details.
3495 //
3496 // Also, in delazification, the FunctionBox should already have the
3497 // correct extent, and we shouldn't overwrite it here.
3498 // See ScriptStencil variant of PerHandlerParser::newFunctionBox.
3499#if !defined(MOZ_ASAN) && !defined(MOZ_MSAN) && !defined(MOZ_VALGRIND)
3500 MOZ_ASSERT(anyChars.currentToken().type != TokenKind::Eof)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.currentToken().type != TokenKind::Eof)>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.currentToken().type != TokenKind::Eof))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.currentToken().type != TokenKind::Eof"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3500); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.currentToken().type != TokenKind::Eof"
")"); do { *((volatile int*)__null) = 3500; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3501#endif
3502 MOZ_ASSERT(funbox->extent().sourceEnd == anyChars.currentToken().pos.end)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funbox->extent().sourceEnd == anyChars.currentToken
().pos.end)>::isValid, "invalid assertion condition"); if (
(__builtin_expect(!!(!(!!(funbox->extent().sourceEnd == anyChars
.currentToken().pos.end))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("funbox->extent().sourceEnd == anyChars.currentToken().pos.end"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3502); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funbox->extent().sourceEnd == anyChars.currentToken().pos.end"
")"); do { *((volatile int*)__null) = 3502; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3503 }
3504}
3505
3506template <class ParseHandler, typename Unit>
3507bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
3508 InHandling inHandling, YieldHandling yieldHandling,
3509 FunctionNodeType* funNode, FunctionSyntaxKind kind,
3510 const Maybe<uint32_t>& parameterListEnd /* = Nothing() */,
3511 bool isStandaloneFunction /* = false */) {
3512 // Given a properly initialized parse context, try to parse an actual
3513 // function without concern for conversion to strict mode, use of lazy
3514 // parsing and such.
3515
3516 FunctionBox* funbox = pc_->functionBox();
3517
3518 if (kind == FunctionSyntaxKind::ClassConstructor ||
3519 kind == FunctionSyntaxKind::DerivedClassConstructor) {
3520 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::dot_initializers_())) {
3521 return false;
3522 }
3523#ifdef ENABLE_DECORATORS
3524 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::
3525 dot_instanceExtraInitializers_())) {
3526 return false;
3527 }
3528#endif
3529 }
3530
3531 // See below for an explanation why arrow function parameters and arrow
3532 // function bodies are parsed with different yield/await settings.
3533 {
3534 AwaitHandling awaitHandling =
3535 kind == FunctionSyntaxKind::StaticClassBlock ? AwaitIsDisallowed
3536 : (funbox->isAsync() ||
3537 (kind == FunctionSyntaxKind::Arrow && awaitIsKeyword()))
3538 ? AwaitIsKeyword
3539 : AwaitIsName;
3540 AutoAwaitIsKeyword<ParseHandler, Unit> awaitIsKeyword(this, awaitHandling);
3541 AutoInParametersOfAsyncFunction<ParseHandler, Unit> inParameters(
3542 this, funbox->isAsync());
3543 if (!functionArguments(yieldHandling, kind, *funNode)) {
3544 return false;
3545 }
3546 }
3547
3548 Maybe<ParseContext::VarScope> varScope;
3549 if (funbox->hasParameterExprs) {
3550 varScope.emplace(this);
3551 if (!varScope->init(pc_)) {
3552 return false;
3553 }
3554 } else {
3555 pc_->functionScope().useAsVarScope(pc_);
3556 }
3557
3558 if (kind == FunctionSyntaxKind::Arrow) {
3559 TokenKind tt;
3560 if (!tokenStream.peekTokenSameLine(&tt)) {
3561 return false;
3562 }
3563
3564 if (tt == TokenKind::Eol) {
3565 error(JSMSG_UNEXPECTED_TOKEN,
3566 "'=>' on the same line after an argument list",
3567 TokenKindToDesc(tt));
3568 return false;
3569 }
3570 if (tt != TokenKind::Arrow) {
3571 error(JSMSG_BAD_ARROW_ARGS);
3572 return false;
3573 }
3574 tokenStream.consumeKnownToken(TokenKind::Arrow);
3575 }
3576
3577 // When parsing something for new Function() we have to make sure to
3578 // only treat a certain part of the source as a parameter list.
3579 if (parameterListEnd.isSome() && parameterListEnd.value() != pos().begin) {
3580 error(JSMSG_UNEXPECTED_PARAMLIST_END);
3581 return false;
3582 }
3583
3584 // Parse the function body.
3585 FunctionBodyType bodyType = StatementListBody;
3586 TokenKind tt;
3587 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
3588 return false;
3589 }
3590 uint32_t openedPos = 0;
3591 if (tt != TokenKind::LeftCurly) {
3592 if (kind != FunctionSyntaxKind::Arrow) {
3593 error(JSMSG_CURLY_BEFORE_BODY);
3594 return false;
3595 }
3596
3597 anyChars.ungetToken();
3598 bodyType = ExpressionBody;
3599 funbox->setHasExprBody();
3600 } else {
3601 openedPos = pos().begin;
3602 }
3603
3604 // Arrow function parameters inherit yieldHandling from the enclosing
3605 // context, but the arrow body doesn't. E.g. in |(a = yield) => yield|,
3606 // |yield| in the parameters is either a name or keyword, depending on
3607 // whether the arrow function is enclosed in a generator function or not.
3608 // Whereas the |yield| in the function body is always parsed as a name.
3609 // The same goes when parsing |await| in arrow functions.
3610 YieldHandling bodyYieldHandling = GetYieldHandling(pc_->generatorKind());
3611 AwaitHandling bodyAwaitHandling = GetAwaitHandling(pc_->asyncKind());
3612 bool inheritedStrict = pc_->sc()->strict();
3613 LexicalScopeNodeType body;
3614 {
3615 AutoAwaitIsKeyword<ParseHandler, Unit> awaitIsKeyword(this,
3616 bodyAwaitHandling);
3617 AutoInParametersOfAsyncFunction<ParseHandler, Unit> inParameters(this,
3618 false);
3619 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (functionBody(inHandling,
bodyYieldHandling, kind, bodyType)); if ((__builtin_expect(!
!(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
body) = parserTryVarTempResult_.unwrap(); } while (0)
3620 body, functionBody(inHandling, bodyYieldHandling, kind, bodyType),do { auto parserTryVarTempResult_ = (functionBody(inHandling,
bodyYieldHandling, kind, bodyType)); if ((__builtin_expect(!
!(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
body) = parserTryVarTempResult_.unwrap(); } while (0)
3621 false)do { auto parserTryVarTempResult_ = (functionBody(inHandling,
bodyYieldHandling, kind, bodyType)); if ((__builtin_expect(!
!(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
body) = parserTryVarTempResult_.unwrap(); } while (0)
;
3622 }
3623
3624 // Revalidate the function name when we transitioned to strict mode.
3625 if ((kind == FunctionSyntaxKind::Statement ||
3626 kind == FunctionSyntaxKind::Expression) &&
3627 funbox->explicitName() && !inheritedStrict && pc_->sc()->strict()) {
3628 MOZ_ASSERT(pc_->sc()->hasExplicitUseStrict(),do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->sc()->hasExplicitUseStrict())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(pc_->sc()->hasExplicitUseStrict()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->sc()->hasExplicitUseStrict()"
" (" "strict mode should only change when a 'use strict' directive "
"is present" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3630); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->sc()->hasExplicitUseStrict()"
") (" "strict mode should only change when a 'use strict' directive "
"is present" ")"); do { *((volatile int*)__null) = 3630; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
3629 "strict mode should only change when a 'use strict' directive "do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->sc()->hasExplicitUseStrict())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(pc_->sc()->hasExplicitUseStrict()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->sc()->hasExplicitUseStrict()"
" (" "strict mode should only change when a 'use strict' directive "
"is present" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3630); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->sc()->hasExplicitUseStrict()"
") (" "strict mode should only change when a 'use strict' directive "
"is present" ")"); do { *((volatile int*)__null) = 3630; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
3630 "is present")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->sc()->hasExplicitUseStrict())>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(pc_->sc()->hasExplicitUseStrict()))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->sc()->hasExplicitUseStrict()"
" (" "strict mode should only change when a 'use strict' directive "
"is present" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3630); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->sc()->hasExplicitUseStrict()"
") (" "strict mode should only change when a 'use strict' directive "
"is present" ")"); do { *((volatile int*)__null) = 3630; __attribute__
((nomerge)) ::abort(); } while (false); } } while (false)
;
3631
3632 auto propertyName = funbox->explicitName();
3633 YieldHandling nameYieldHandling;
3634 if (kind == FunctionSyntaxKind::Expression) {
3635 // Named lambda has binding inside it.
3636 nameYieldHandling = bodyYieldHandling;
3637 } else {
3638 // Otherwise YieldHandling cannot be checked at this point
3639 // because of different context.
3640 // It should already be checked before this point.
3641 nameYieldHandling = YieldIsName;
3642 }
3643
3644 // We already use the correct await-handling at this point, therefore
3645 // we don't need call AutoAwaitIsKeyword here.
3646
3647 uint32_t nameOffset = handler_.getFunctionNameOffset(*funNode, anyChars);
3648 if (!checkBindingIdentifier(propertyName, nameOffset, nameYieldHandling)) {
3649 return false;
3650 }
3651 }
3652
3653 if (bodyType == StatementListBody) {
3654 // Cannot use mustMatchToken here because of internal compiler error on
3655 // gcc 6.4.0, with linux 64 SM hazard build.
3656 TokenKind actual;
3657 if (!tokenStream.getToken(&actual, TokenStream::SlashIsRegExp)) {
3658 return false;
3659 }
3660 if (actual != TokenKind::RightCurly) {
3661 reportMissingClosing(JSMSG_CURLY_AFTER_BODY, JSMSG_CURLY_OPENED,
3662 openedPos);
3663 return false;
3664 }
3665
3666 setFunctionEndFromCurrentToken(funbox);
3667 } else {
3668 MOZ_ASSERT(kind == FunctionSyntaxKind::Arrow)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == FunctionSyntaxKind::Arrow)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(kind == FunctionSyntaxKind::
Arrow))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == FunctionSyntaxKind::Arrow", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3668); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == FunctionSyntaxKind::Arrow"
")"); do { *((volatile int*)__null) = 3668; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3669
3670 if (anyChars.hadError()) {
3671 return false;
3672 }
3673
3674 setFunctionEndFromCurrentToken(funbox);
3675
3676 if (kind == FunctionSyntaxKind::Statement) {
3677 if (!matchOrInsertSemicolon()) {
3678 return false;
3679 }
3680 }
3681 }
3682
3683 if (IsMethodDefinitionKind(kind) && pc_->superScopeNeedsHomeObject()) {
3684 funbox->setNeedsHomeObject();
3685 }
3686
3687 if (!finishFunction(isStandaloneFunction)) {
3688 return false;
3689 }
3690
3691 handler_.setEndPosition(body, pos().begin);
3692 handler_.setEndPosition(*funNode, pos().end);
3693 handler_.setFunctionBody(*funNode, body);
3694
3695 return true;
3696}
3697
3698template <class ParseHandler, typename Unit>
3699typename ParseHandler::FunctionNodeResult
3700GeneralParser<ParseHandler, Unit>::functionStmt(uint32_t toStringStart,
3701 YieldHandling yieldHandling,
3702 DefaultHandling defaultHandling,
3703 FunctionAsyncKind asyncKind) {
3704 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Function))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Function))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Function)))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Function)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3704); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Function)"
")"); do { *((volatile int*)__null) = 3704; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3705
3706 // In sloppy mode, Annex B.3.2 allows labelled function declarations.
3707 // Otherwise it's a parse error.
3708 ParseContext::Statement* declaredInStmt = pc_->innermostStatement();
3709 if (declaredInStmt && declaredInStmt->kind() == StatementKind::Label) {
3710 MOZ_ASSERT(!pc_->sc()->strict(),do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!pc_->sc()->strict())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!pc_->sc()->strict()))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!pc_->sc()->strict()"
" (" "labeled functions shouldn't be parsed in strict mode" ")"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3711); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!pc_->sc()->strict()"
") (" "labeled functions shouldn't be parsed in strict mode"
")"); do { *((volatile int*)__null) = 3711; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
3711 "labeled functions shouldn't be parsed in strict mode")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!pc_->sc()->strict())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!pc_->sc()->strict()))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!pc_->sc()->strict()"
" (" "labeled functions shouldn't be parsed in strict mode" ")"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3711); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!pc_->sc()->strict()"
") (" "labeled functions shouldn't be parsed in strict mode"
")"); do { *((volatile int*)__null) = 3711; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3712
3713 // Find the innermost non-label statement. Report an error if it's
3714 // unbraced: functions can't appear in it. Otherwise the statement
3715 // (or its absence) determines the scope the function's bound in.
3716 while (declaredInStmt && declaredInStmt->kind() == StatementKind::Label) {
3717 declaredInStmt = declaredInStmt->enclosing();
3718 }
3719
3720 if (declaredInStmt && !StatementKindIsBraced(declaredInStmt->kind())) {
3721 error(JSMSG_SLOPPY_FUNCTION_LABEL);
3722 return errorResult();
3723 }
3724 }
3725
3726 TokenKind tt;
3727 if (!tokenStream.getToken(&tt)) {
3728 return errorResult();
3729 }
3730
3731 GeneratorKind generatorKind = GeneratorKind::NotGenerator;
3732 if (tt == TokenKind::Mul) {
3733 generatorKind = GeneratorKind::Generator;
3734 if (!tokenStream.getToken(&tt)) {
3735 return errorResult();
3736 }
3737 }
3738
3739 TaggedParserAtomIndex name;
3740 if (TokenKindIsPossibleIdentifier(tt)) {
3741 name = bindingIdentifier(yieldHandling);
3742 if (!name) {
3743 return errorResult();
3744 }
3745 } else if (defaultHandling == AllowDefaultName) {
3746 name = TaggedParserAtomIndex::WellKnown::default_();
3747 anyChars.ungetToken();
3748 } else {
3749 /* Unnamed function expressions are forbidden in statement context. */
3750 error(JSMSG_UNNAMED_FUNCTION_STMT);
3751 return errorResult();
3752 }
3753
3754 // Note the declared name and check for early errors.
3755 DeclarationKind kind;
3756 if (declaredInStmt) {
3757 MOZ_ASSERT(declaredInStmt->kind() != StatementKind::Label)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(declaredInStmt->kind() != StatementKind::Label)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(declaredInStmt->kind() != StatementKind::Label)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("declaredInStmt->kind() != StatementKind::Label"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3757); AnnotateMozCrashReason("MOZ_ASSERT" "(" "declaredInStmt->kind() != StatementKind::Label"
")"); do { *((volatile int*)__null) = 3757; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3758 MOZ_ASSERT(StatementKindIsBraced(declaredInStmt->kind()))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(StatementKindIsBraced(declaredInStmt->kind()))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(StatementKindIsBraced(declaredInStmt->kind())))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("StatementKindIsBraced(declaredInStmt->kind())"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3758); AnnotateMozCrashReason("MOZ_ASSERT" "(" "StatementKindIsBraced(declaredInStmt->kind())"
")"); do { *((volatile int*)__null) = 3758; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3759
3760 kind =
3761 (!pc_->sc()->strict() && generatorKind == GeneratorKind::NotGenerator &&
3762 asyncKind == FunctionAsyncKind::SyncFunction)
3763 ? DeclarationKind::SloppyLexicalFunction
3764 : DeclarationKind::LexicalFunction;
3765 } else {
3766 kind = pc_->atModuleLevel() ? DeclarationKind::ModuleBodyLevelFunction
3767 : DeclarationKind::BodyLevelFunction;
3768 }
3769
3770 if (!noteDeclaredName(name, kind, pos())) {
3771 return errorResult();
3772 }
3773
3774 FunctionSyntaxKind syntaxKind = FunctionSyntaxKind::Statement;
3775 FunctionNodeType funNode;
3776 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, pos()))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (funNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
3777
3778 // Under sloppy mode, try Annex B.3.3 semantics. If making an additional
3779 // 'var' binding of the same name does not throw an early error, do so.
3780 // This 'var' binding would be assigned the function object when its
3781 // declaration is reached, not at the start of the block.
3782 //
3783 // This semantics is implemented upon Scope exit in
3784 // Scope::propagateAndMarkAnnexBFunctionBoxes.
3785 bool tryAnnexB = kind == DeclarationKind::SloppyLexicalFunction;
3786
3787 YieldHandling newYieldHandling = GetYieldHandling(generatorKind);
3788 return functionDefinition(funNode, toStringStart, InAllowed, newYieldHandling,
3789 name, syntaxKind, generatorKind, asyncKind,
3790 tryAnnexB);
3791}
3792
3793template <class ParseHandler, typename Unit>
3794typename ParseHandler::FunctionNodeResult
3795GeneralParser<ParseHandler, Unit>::functionExpr(uint32_t toStringStart,
3796 InvokedPrediction invoked,
3797 FunctionAsyncKind asyncKind) {
3798 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Function))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Function))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Function)))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Function)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3798); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Function)"
")"); do { *((volatile int*)__null) = 3798; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3799
3800 AutoAwaitIsKeyword<ParseHandler, Unit> awaitIsKeyword(
3801 this, GetAwaitHandling(asyncKind));
3802 GeneratorKind generatorKind = GeneratorKind::NotGenerator;
3803 TokenKind tt;
3804 if (!tokenStream.getToken(&tt)) {
3805 return errorResult();
3806 }
3807
3808 if (tt == TokenKind::Mul) {
3809 generatorKind = GeneratorKind::Generator;
3810 if (!tokenStream.getToken(&tt)) {
3811 return errorResult();
3812 }
3813 }
3814
3815 YieldHandling yieldHandling = GetYieldHandling(generatorKind);
3816
3817 TaggedParserAtomIndex name;
3818 if (TokenKindIsPossibleIdentifier(tt)) {
3819 name = bindingIdentifier(yieldHandling);
3820 if (!name) {
3821 return errorResult();
3822 }
3823 } else {
3824 anyChars.ungetToken();
3825 }
3826
3827 FunctionSyntaxKind syntaxKind = FunctionSyntaxKind::Expression;
3828 FunctionNodeType funNode;
3829 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, pos()))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (funNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
3830
3831 if (invoked) {
3832 funNode = handler_.setLikelyIIFE(funNode);
3833 }
3834
3835 return functionDefinition(funNode, toStringStart, InAllowed, yieldHandling,
3836 name, syntaxKind, generatorKind, asyncKind);
3837}
3838
3839/*
3840 * Return true if this node, known to be an unparenthesized string literal
3841 * that never contain escape sequences, could be the string of a directive in a
3842 * Directive Prologue. Directive strings never contain escape sequences or line
3843 * continuations.
3844 */
3845static inline bool IsUseStrictDirective(const TokenPos& pos,
3846 TaggedParserAtomIndex atom) {
3847 // the length of "use strict", including quotation.
3848 static constexpr size_t useStrictLength = 12;
3849 return atom == TaggedParserAtomIndex::WellKnown::use_strict_() &&
3850 pos.begin + useStrictLength == pos.end;
3851}
3852static inline bool IsUseAsmDirective(const TokenPos& pos,
3853 TaggedParserAtomIndex atom) {
3854 // the length of "use asm", including quotation.
3855 static constexpr size_t useAsmLength = 9;
3856 return atom == TaggedParserAtomIndex::WellKnown::use_asm_() &&
3857 pos.begin + useAsmLength == pos.end;
3858}
3859
3860template <typename Unit>
3861bool Parser<SyntaxParseHandler, Unit>::asmJS(ListNodeType list) {
3862 // While asm.js could technically be validated and compiled during syntax
3863 // parsing, we have no guarantee that some later JS wouldn't abort the
3864 // syntax parse and cause us to re-parse (and re-compile) the asm.js module.
3865 // For simplicity, unconditionally abort the syntax parse when "use asm" is
3866 // encountered so that asm.js is always validated/compiled exactly once
3867 // during a full parse.
3868 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 3868); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 3868; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
3869 return false;
3870}
3871
3872template <typename Unit>
3873bool Parser<FullParseHandler, Unit>::asmJS(ListNodeType list) {
3874 // Disable syntax parsing in anything nested inside the asm.js module.
3875 disableSyntaxParser();
3876
3877 // We should be encountering the "use asm" directive for the first time; if
3878 // the directive is already, we must have failed asm.js validation and we're
3879 // reparsing. In that case, don't try to validate again. A non-null
3880 // newDirectives means we're not in a normal function.
3881 if (!pc_->newDirectives || pc_->newDirectives->asmJS()) {
3882 return true;
3883 }
3884
3885 // If there is no ScriptSource, then we are doing a non-compiling parse and
3886 // so we shouldn't (and can't, without a ScriptSource) compile.
3887 if (ss == nullptr) {
3888 return true;
3889 }
3890
3891 pc_->functionBox()->useAsm = true;
3892
3893 // Attempt to validate and compile this asm.js module. On success, the
3894 // tokenStream has been advanced to the closing }. On failure, the
3895 // tokenStream is in an indeterminate state and we must reparse the
3896 // function from the beginning. Reparsing is triggered by marking that a
3897 // new directive has been encountered and returning 'false'.
3898 bool validated;
3899 if (!CompileAsmJS(this->fc_, this->parserAtoms(), *this, list, &validated)) {
3900 return false;
3901 }
3902 if (!validated) {
3903 pc_->newDirectives->setAsmJS();
3904 return false;
3905 }
3906
3907 return true;
3908}
3909
3910template <class ParseHandler, typename Unit>
3911inline bool GeneralParser<ParseHandler, Unit>::asmJS(ListNodeType list) {
3912 return asFinalParser()->asmJS(list);
3913}
3914
3915/*
3916 * Recognize Directive Prologue members and directives. Assuming |pn| is a
3917 * candidate for membership in a directive prologue, recognize directives and
3918 * set |pc_|'s flags accordingly. If |pn| is indeed part of a prologue, set its
3919 * |prologue| flag.
3920 *
3921 * Note that the following is a strict mode function:
3922 *
3923 * function foo() {
3924 * "blah" // inserted semi colon
3925 * "blurgh"
3926 * "use\x20loose"
3927 * "use strict"
3928 * }
3929 *
3930 * That is, even though "use\x20loose" can never be a directive, now or in the
3931 * future (because of the hex escape), the Directive Prologue extends through it
3932 * to the "use strict" statement, which is indeed a directive.
3933 */
3934template <class ParseHandler, typename Unit>
3935bool GeneralParser<ParseHandler, Unit>::maybeParseDirective(
3936 ListNodeType list, Node possibleDirective, bool* cont) {
3937 TokenPos directivePos;
3938 TaggedParserAtomIndex directive =
3939 handler_.isStringExprStatement(possibleDirective, &directivePos);
3940
3941 *cont = !!directive;
3942 if (!*cont) {
3943 return true;
3944 }
3945
3946 if (IsUseStrictDirective(directivePos, directive)) {
3947 // Functions with non-simple parameter lists (destructuring,
3948 // default or rest parameters) must not contain a "use strict"
3949 // directive.
3950 if (pc_->isFunctionBox()) {
3951 FunctionBox* funbox = pc_->functionBox();
3952 if (!funbox->hasSimpleParameterList()) {
3953 const char* parameterKind = funbox->hasDestructuringArgs
3954 ? "destructuring"
3955 : funbox->hasParameterExprs ? "default"
3956 : "rest";
3957 errorAt(directivePos.begin, JSMSG_STRICT_NON_SIMPLE_PARAMS,
3958 parameterKind);
3959 return false;
3960 }
3961 }
3962
3963 // We're going to be in strict mode. Note that this scope explicitly
3964 // had "use strict";
3965 pc_->sc()->setExplicitUseStrict();
3966 if (!pc_->sc()->strict()) {
3967 // Some strict mode violations can appear before a Use Strict Directive
3968 // is applied. (See the |DeprecatedContent| enum initializers.) These
3969 // violations can manifest in two ways.
3970 //
3971 // First, the violation can appear *before* the Use Strict Directive.
3972 // Numeric literals (and therefore octal literals) can only precede a
3973 // Use Strict Directive if this function's parameter list is not simple,
3974 // but we reported an error for non-simple parameter lists above, so
3975 // octal literals present no issue. But octal escapes and \8 and \9 can
3976 // appear in the directive prologue before a Use Strict Directive:
3977 //
3978 // function f()
3979 // {
3980 // "hell\157 world"; // octal escape
3981 // "\8"; "\9"; // NonOctalDecimalEscape
3982 // "use strict"; // retroactively makes all the above errors
3983 // }
3984 //
3985 // Second, the violation can appear *after* the Use Strict Directive but
3986 // *before* the directive is recognized as terminated. This only
3987 // happens when a directive is terminated by ASI, and the next token
3988 // contains a violation:
3989 //
3990 // function a()
3991 // {
3992 // "use strict" // ASI
3993 // 0755;
3994 // }
3995 // function b()
3996 // {
3997 // "use strict" // ASI
3998 // "hell\157 world";
3999 // }
4000 // function c()
4001 // {
4002 // "use strict" // ASI
4003 // "\8";
4004 // }
4005 //
4006 // We note such violations when tokenizing. Then, if a violation has
4007 // been observed at the time a "use strict" is applied, we report the
4008 // error.
4009 switch (anyChars.sawDeprecatedContent()) {
4010 case DeprecatedContent::None:
4011 break;
4012 case DeprecatedContent::OctalLiteral:
4013 error(JSMSG_DEPRECATED_OCTAL_LITERAL);
4014 return false;
4015 case DeprecatedContent::OctalEscape:
4016 error(JSMSG_DEPRECATED_OCTAL_ESCAPE);
4017 return false;
4018 case DeprecatedContent::EightOrNineEscape:
4019 error(JSMSG_DEPRECATED_EIGHT_OR_NINE_ESCAPE);
4020 return false;
4021 }
4022
4023 pc_->sc()->setStrictScript();
4024 }
4025 } else if (IsUseAsmDirective(directivePos, directive)) {
4026 if (pc_->isFunctionBox()) {
4027 return asmJS(list);
4028 }
4029 return warningAt(directivePos.begin, JSMSG_USE_ASM_DIRECTIVE_FAIL);
4030 }
4031 return true;
4032}
4033
4034template <class ParseHandler, typename Unit>
4035typename ParseHandler::ListNodeResult
4036GeneralParser<ParseHandler, Unit>::statementList(YieldHandling yieldHandling) {
4037 AutoCheckRecursionLimit recursion(this->fc_);
4038 if (!recursion.check(this->fc_)) {
4039 return errorResult();
4040 }
4041
4042 ListNodeType stmtList;
4043 MOZ_TRY_VAR(stmtList, handler_.newStatementList(pos()))do { auto mozTryVarTempResult_ = (handler_.newStatementList(pos
())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()),
0))) { return mozTryVarTempResult_.propagateErr(); } (stmtList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
4044
4045 bool canHaveDirectives = pc_->atBodyLevel();
4046 if (canHaveDirectives) {
4047 // Clear flags for deprecated content that might have been seen in an
4048 // enclosing context.
4049 anyChars.clearSawDeprecatedContent();
4050 }
4051
4052 bool canHaveHashbangComment = pc_->atTopLevel();
4053 if (canHaveHashbangComment) {
4054 tokenStream.consumeOptionalHashbangComment();
4055 }
4056
4057 bool afterReturn = false;
4058 bool warnedAboutStatementsAfterReturn = false;
4059 uint32_t statementBegin = 0;
4060 for (;;) {
4061 TokenKind tt = TokenKind::Eof;
4062 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
4063 if (anyChars.isEOF()) {
4064 isUnexpectedEOF_ = true;
4065 }
4066 return errorResult();
4067 }
4068 if (tt == TokenKind::Eof || tt == TokenKind::RightCurly) {
4069 TokenPos pos;
4070 if (!tokenStream.peekTokenPos(&pos, TokenStream::SlashIsRegExp)) {
4071 return errorResult();
4072 }
4073 handler_.setListEndPosition(stmtList, pos);
4074 break;
4075 }
4076 if (afterReturn) {
4077 if (!tokenStream.peekOffset(&statementBegin,
4078 TokenStream::SlashIsRegExp)) {
4079 return errorResult();
4080 }
4081 }
4082 auto nextResult = statementListItem(yieldHandling, canHaveDirectives);
4083 if (nextResult.isErr()) {
4084 if (anyChars.isEOF()) {
4085 isUnexpectedEOF_ = true;
4086 }
4087 return errorResult();
4088 }
4089 Node next = nextResult.unwrap();
4090 if (!warnedAboutStatementsAfterReturn) {
4091 if (afterReturn) {
4092 if (!handler_.isStatementPermittedAfterReturnStatement(next)) {
4093 if (!warningAt(statementBegin, JSMSG_STMT_AFTER_RETURN)) {
4094 return errorResult();
4095 }
4096
4097 warnedAboutStatementsAfterReturn = true;
4098 }
4099 } else if (handler_.isReturnStatement(next)) {
4100 afterReturn = true;
4101 }
4102 }
4103
4104 if (canHaveDirectives) {
4105 if (!maybeParseDirective(stmtList, next, &canHaveDirectives)) {
4106 return errorResult();
4107 }
4108 }
4109
4110 handler_.addStatementToList(stmtList, next);
4111 }
4112
4113 return stmtList;
4114}
4115
4116template <class ParseHandler, typename Unit>
4117typename ParseHandler::NodeResult GeneralParser<ParseHandler, Unit>::condition(
4118 InHandling inHandling, YieldHandling yieldHandling) {
4119 if (!mustMatchToken(TokenKind::LeftParen, JSMSG_PAREN_BEFORE_COND)) {
4120 return errorResult();
4121 }
4122
4123 Node pn;
4124 MOZ_TRY_VAR(pn, exprInParens(inHandling, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (exprInParens(inHandling, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (pn) = mozTryVarTempResult_.unwrap(); } while (0)
;
4125
4126 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_COND)) {
4127 return errorResult();
4128 }
4129
4130 return pn;
4131}
4132
4133template <class ParseHandler, typename Unit>
4134bool GeneralParser<ParseHandler, Unit>::matchLabel(
4135 YieldHandling yieldHandling, TaggedParserAtomIndex* labelOut) {
4136 MOZ_ASSERT(labelOut != nullptr)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(labelOut != nullptr)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(labelOut != nullptr))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("labelOut != nullptr"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4136); AnnotateMozCrashReason("MOZ_ASSERT" "(" "labelOut != nullptr"
")"); do { *((volatile int*)__null) = 4136; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4137 TokenKind tt = TokenKind::Eof;
4138 if (!tokenStream.peekTokenSameLine(&tt, TokenStream::SlashIsRegExp)) {
4139 return false;
4140 }
4141
4142 if (TokenKindIsPossibleIdentifier(tt)) {
4143 tokenStream.consumeKnownToken(tt, TokenStream::SlashIsRegExp);
4144
4145 *labelOut = labelIdentifier(yieldHandling);
4146 if (!*labelOut) {
4147 return false;
4148 }
4149 } else {
4150 *labelOut = TaggedParserAtomIndex::null();
4151 }
4152 return true;
4153}
4154
4155template <class ParseHandler, typename Unit>
4156GeneralParser<ParseHandler, Unit>::PossibleError::PossibleError(
4157 GeneralParser<ParseHandler, Unit>& parser)
4158 : parser_(parser) {}
4159
4160template <class ParseHandler, typename Unit>
4161typename GeneralParser<ParseHandler, Unit>::PossibleError::Error&
4162GeneralParser<ParseHandler, Unit>::PossibleError::error(ErrorKind kind) {
4163 if (kind == ErrorKind::Expression) {
4164 return exprError_;
4165 }
4166 if (kind == ErrorKind::Destructuring) {
4167 return destructuringError_;
4168 }
4169 MOZ_ASSERT(kind == ErrorKind::DestructuringWarning)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == ErrorKind::DestructuringWarning)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(kind == ErrorKind::DestructuringWarning))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("kind == ErrorKind::DestructuringWarning"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4169); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == ErrorKind::DestructuringWarning"
")"); do { *((volatile int*)__null) = 4169; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4170 return destructuringWarning_;
4171}
4172
4173template <class ParseHandler, typename Unit>
4174void GeneralParser<ParseHandler, Unit>::PossibleError::setResolved(
4175 ErrorKind kind) {
4176 error(kind).state_ = ErrorState::None;
4177}
4178
4179template <class ParseHandler, typename Unit>
4180bool GeneralParser<ParseHandler, Unit>::PossibleError::hasError(
4181 ErrorKind kind) {
4182 return error(kind).state_ == ErrorState::Pending;
4183}
4184
4185template <class ParseHandler, typename Unit>
4186bool GeneralParser<ParseHandler,
4187 Unit>::PossibleError::hasPendingDestructuringError() {
4188 return hasError(ErrorKind::Destructuring);
4189}
4190
4191template <class ParseHandler, typename Unit>
4192void GeneralParser<ParseHandler, Unit>::PossibleError::setPending(
4193 ErrorKind kind, const TokenPos& pos, unsigned errorNumber) {
4194 // Don't overwrite a previously recorded error.
4195 if (hasError(kind)) {
4196 return;
4197 }
4198
4199 // If we report an error later, we'll do it from the position where we set
4200 // the state to pending.
4201 Error& err = error(kind);
4202 err.offset_ = pos.begin;
4203 err.errorNumber_ = errorNumber;
4204 err.state_ = ErrorState::Pending;
4205}
4206
4207template <class ParseHandler, typename Unit>
4208void GeneralParser<ParseHandler, Unit>::PossibleError::
4209 setPendingDestructuringErrorAt(const TokenPos& pos, unsigned errorNumber) {
4210 setPending(ErrorKind::Destructuring, pos, errorNumber);
4211}
4212
4213template <class ParseHandler, typename Unit>
4214void GeneralParser<ParseHandler, Unit>::PossibleError::
4215 setPendingDestructuringWarningAt(const TokenPos& pos,
4216 unsigned errorNumber) {
4217 setPending(ErrorKind::DestructuringWarning, pos, errorNumber);
4218}
4219
4220template <class ParseHandler, typename Unit>
4221void GeneralParser<ParseHandler, Unit>::PossibleError::
4222 setPendingExpressionErrorAt(const TokenPos& pos, unsigned errorNumber) {
4223 setPending(ErrorKind::Expression, pos, errorNumber);
4224}
4225
4226template <class ParseHandler, typename Unit>
4227bool GeneralParser<ParseHandler, Unit>::PossibleError::checkForError(
4228 ErrorKind kind) {
4229 if (!hasError(kind)) {
4230 return true;
4231 }
4232
4233 Error& err = error(kind);
4234 parser_.errorAt(err.offset_, err.errorNumber_);
4235 return false;
4236}
4237
4238template <class ParseHandler, typename Unit>
4239bool GeneralParser<ParseHandler,
4240 Unit>::PossibleError::checkForDestructuringErrorOrWarning() {
4241 // Clear pending expression error, because we're definitely not in an
4242 // expression context.
4243 setResolved(ErrorKind::Expression);
4244
4245 // Report any pending destructuring error.
4246 return checkForError(ErrorKind::Destructuring);
4247}
4248
4249template <class ParseHandler, typename Unit>
4250bool GeneralParser<ParseHandler,
4251 Unit>::PossibleError::checkForExpressionError() {
4252 // Clear pending destructuring error, because we're definitely not
4253 // in a destructuring context.
4254 setResolved(ErrorKind::Destructuring);
4255 setResolved(ErrorKind::DestructuringWarning);
4256
4257 // Report any pending expression error.
4258 return checkForError(ErrorKind::Expression);
4259}
4260
4261template <class ParseHandler, typename Unit>
4262void GeneralParser<ParseHandler, Unit>::PossibleError::transferErrorTo(
4263 ErrorKind kind, PossibleError* other) {
4264 if (hasError(kind) && !other->hasError(kind)) {
4265 Error& err = error(kind);
4266 Error& otherErr = other->error(kind);
4267 otherErr.offset_ = err.offset_;
4268 otherErr.errorNumber_ = err.errorNumber_;
4269 otherErr.state_ = err.state_;
4270 }
4271}
4272
4273template <class ParseHandler, typename Unit>
4274void GeneralParser<ParseHandler, Unit>::PossibleError::transferErrorsTo(
4275 PossibleError* other) {
4276 MOZ_ASSERT(other)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(other)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(other))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("other", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4276); AnnotateMozCrashReason("MOZ_ASSERT" "(" "other" ")")
; do { *((volatile int*)__null) = 4276; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4277 MOZ_ASSERT(this != other)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(this != other)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(this != other))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("this != other",
"/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4277); AnnotateMozCrashReason("MOZ_ASSERT" "(" "this != other"
")"); do { *((volatile int*)__null) = 4277; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4278 MOZ_ASSERT(&parser_ == &other->parser_,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(&parser_ == &other->parser_)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(&parser_ == &other->parser_))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("&parser_ == &other->parser_"
" (" "Can't transfer fields to an instance which belongs to a "
"different parser" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4280); AnnotateMozCrashReason("MOZ_ASSERT" "(" "&parser_ == &other->parser_"
") (" "Can't transfer fields to an instance which belongs to a "
"different parser" ")"); do { *((volatile int*)__null) = 4280
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
4279 "Can't transfer fields to an instance which belongs to a "do { static_assert( mozilla::detail::AssertionConditionType<
decltype(&parser_ == &other->parser_)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(&parser_ == &other->parser_))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("&parser_ == &other->parser_"
" (" "Can't transfer fields to an instance which belongs to a "
"different parser" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4280); AnnotateMozCrashReason("MOZ_ASSERT" "(" "&parser_ == &other->parser_"
") (" "Can't transfer fields to an instance which belongs to a "
"different parser" ")"); do { *((volatile int*)__null) = 4280
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
4280 "different parser")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(&parser_ == &other->parser_)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(&parser_ == &other->parser_))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("&parser_ == &other->parser_"
" (" "Can't transfer fields to an instance which belongs to a "
"different parser" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4280); AnnotateMozCrashReason("MOZ_ASSERT" "(" "&parser_ == &other->parser_"
") (" "Can't transfer fields to an instance which belongs to a "
"different parser" ")"); do { *((volatile int*)__null) = 4280
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
;
4281
4282 transferErrorTo(ErrorKind::Destructuring, other);
4283 transferErrorTo(ErrorKind::Expression, other);
4284}
4285
4286template <class ParseHandler, typename Unit>
4287typename ParseHandler::BinaryNodeResult
4288GeneralParser<ParseHandler, Unit>::bindingInitializer(
4289 Node lhs, DeclarationKind kind, YieldHandling yieldHandling) {
4290 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Assign))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Assign))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Assign)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Assign)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4290); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Assign)"
")"); do { *((volatile int*)__null) = 4290; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4291
4292 if (kind == DeclarationKind::FormalParameter) {
4293 pc_->functionBox()->hasParameterExprs = true;
4294 }
4295
4296 Node rhs;
4297 MOZ_TRY_VAR(rhs, assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (rhs) = mozTryVarTempResult_.unwrap(); } while (0)
;
4298
4299 BinaryNodeType assign;
4300 MOZ_TRY_VAR(assign,do { auto mozTryVarTempResult_ = (handler_.newAssignment(ParseNodeKind
::AssignExpr, lhs, rhs)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (assign) = mozTryVarTempResult_.unwrap(); } while (0)
4301 handler_.newAssignment(ParseNodeKind::AssignExpr, lhs, rhs))do { auto mozTryVarTempResult_ = (handler_.newAssignment(ParseNodeKind
::AssignExpr, lhs, rhs)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (assign) = mozTryVarTempResult_.unwrap(); } while (0)
;
4302
4303 return assign;
4304}
4305
4306template <class ParseHandler, typename Unit>
4307typename ParseHandler::NameNodeResult
4308GeneralParser<ParseHandler, Unit>::bindingIdentifier(
4309 DeclarationKind kind, YieldHandling yieldHandling) {
4310 TaggedParserAtomIndex name = bindingIdentifier(yieldHandling);
4311 if (!name) {
4312 return errorResult();
4313 }
4314
4315 NameNodeType binding;
4316 MOZ_TRY_VAR(binding, newName(name))do { auto mozTryVarTempResult_ = (newName(name)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (binding) = mozTryVarTempResult_.unwrap();
} while (0)
;
4317 if (!noteDeclaredName(name, kind, pos())) {
4318 return errorResult();
4319 }
4320
4321 return binding;
4322}
4323
4324template <class ParseHandler, typename Unit>
4325typename ParseHandler::NodeResult
4326GeneralParser<ParseHandler, Unit>::bindingIdentifierOrPattern(
4327 DeclarationKind kind, YieldHandling yieldHandling, TokenKind tt) {
4328 if (tt == TokenKind::LeftBracket) {
4329 return arrayBindingPattern(kind, yieldHandling);
4330 }
4331
4332 if (tt == TokenKind::LeftCurly) {
4333 return objectBindingPattern(kind, yieldHandling);
4334 }
4335
4336 if (!TokenKindIsPossibleIdentifierName(tt)) {
4337 error(JSMSG_NO_VARIABLE_NAME);
4338 return errorResult();
4339 }
4340
4341 return bindingIdentifier(kind, yieldHandling);
4342}
4343
4344template <class ParseHandler, typename Unit>
4345typename ParseHandler::ListNodeResult
4346GeneralParser<ParseHandler, Unit>::objectBindingPattern(
4347 DeclarationKind kind, YieldHandling yieldHandling) {
4348 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftCurly))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftCurly))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftCurly))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4348); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
")"); do { *((volatile int*)__null) = 4348; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4349
4350 AutoCheckRecursionLimit recursion(this->fc_);
4351 if (!recursion.check(this->fc_)) {
4352 return errorResult();
4353 }
4354
4355 uint32_t begin = pos().begin;
4356 ListNodeType literal;
4357 MOZ_TRY_VAR(literal, handler_.newObjectLiteral(begin))do { auto mozTryVarTempResult_ = (handler_.newObjectLiteral(begin
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (literal)
= mozTryVarTempResult_.unwrap(); } while (0)
;
4358
4359 Maybe<DeclarationKind> declKind = Some(kind);
4360 TaggedParserAtomIndex propAtom;
4361 for (;;) {
4362 TokenKind tt;
4363 if (!tokenStream.peekToken(&tt)) {
4364 return errorResult();
4365 }
4366 if (tt == TokenKind::RightCurly) {
4367 break;
4368 }
4369
4370 if (tt == TokenKind::TripleDot) {
4371 tokenStream.consumeKnownToken(TokenKind::TripleDot);
4372 uint32_t begin = pos().begin;
4373
4374 TokenKind tt;
4375 if (!tokenStream.getToken(&tt)) {
4376 return errorResult();
4377 }
4378
4379 if (!TokenKindIsPossibleIdentifierName(tt)) {
4380 error(JSMSG_NO_VARIABLE_NAME);
4381 return errorResult();
4382 }
4383
4384 NameNodeType inner;
4385 MOZ_TRY_VAR(inner, bindingIdentifier(kind, yieldHandling))do { auto mozTryVarTempResult_ = (bindingIdentifier(kind, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (inner) =
mozTryVarTempResult_.unwrap(); } while (0)
;
4386
4387 if (!handler_.addSpreadProperty(literal, begin, inner)) {
4388 return errorResult();
4389 }
4390 } else {
4391 TokenPos namePos = anyChars.nextToken().pos;
4392
4393 PropertyType propType;
4394 Node propName;
4395 MOZ_TRY_VAR(propName, propertyOrMethodName(do { auto mozTryVarTempResult_ = (propertyOrMethodName( yieldHandling
, PropertyNameInPattern, declKind, literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
4396 yieldHandling, PropertyNameInPattern, declKind,do { auto mozTryVarTempResult_ = (propertyOrMethodName( yieldHandling
, PropertyNameInPattern, declKind, literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
4397 literal, &propType, &propAtom))do { auto mozTryVarTempResult_ = (propertyOrMethodName( yieldHandling
, PropertyNameInPattern, declKind, literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
4398
4399 if (propType == PropertyType::Normal) {
4400 // Handle e.g., |var {p: x} = o| and |var {p: x=0} = o|.
4401
4402 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
4403 return errorResult();
4404 }
4405
4406 Node binding;
4407 MOZ_TRY_VAR(binding,do { auto mozTryVarTempResult_ = (bindingIdentifierOrPattern(
kind, yieldHandling, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (binding) = mozTryVarTempResult_.unwrap(); } while (0)
4408 bindingIdentifierOrPattern(kind, yieldHandling, tt))do { auto mozTryVarTempResult_ = (bindingIdentifierOrPattern(
kind, yieldHandling, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (binding) = mozTryVarTempResult_.unwrap(); } while (0)
;
4409
4410 bool hasInitializer;
4411 if (!tokenStream.matchToken(&hasInitializer, TokenKind::Assign,
4412 TokenStream::SlashIsRegExp)) {
4413 return errorResult();
4414 }
4415
4416 Node bindingExpr;
4417 if (hasInitializer) {
4418 MOZ_TRY_VAR(bindingExpr,do { auto mozTryVarTempResult_ = (bindingInitializer(binding,
kind, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (bindingExpr) = mozTryVarTempResult_.unwrap(); } while (0)
4419 bindingInitializer(binding, kind, yieldHandling))do { auto mozTryVarTempResult_ = (bindingInitializer(binding,
kind, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (bindingExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
4420 } else {
4421 bindingExpr = binding;
4422 }
4423
4424 if (!handler_.addPropertyDefinition(literal, propName, bindingExpr)) {
4425 return errorResult();
4426 }
4427 } else if (propType == PropertyType::Shorthand) {
4428 // Handle e.g., |var {x, y} = o| as destructuring shorthand
4429 // for |var {x: x, y: y} = o|.
4430 MOZ_ASSERT(TokenKindIsPossibleIdentifierName(tt))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsPossibleIdentifierName(tt))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(TokenKindIsPossibleIdentifierName(tt)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("TokenKindIsPossibleIdentifierName(tt)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4430); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsPossibleIdentifierName(tt)"
")"); do { *((volatile int*)__null) = 4430; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4431
4432 NameNodeType binding;
4433 MOZ_TRY_VAR(binding, bindingIdentifier(kind, yieldHandling))do { auto mozTryVarTempResult_ = (bindingIdentifier(kind, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (binding)
= mozTryVarTempResult_.unwrap(); } while (0)
;
4434
4435 if (!handler_.addShorthand(literal, handler_.asNameNode(propName),
4436 binding)) {
4437 return errorResult();
4438 }
4439 } else if (propType == PropertyType::CoverInitializedName) {
4440 // Handle e.g., |var {x=1, y=2} = o| as destructuring
4441 // shorthand with default values.
4442 MOZ_ASSERT(TokenKindIsPossibleIdentifierName(tt))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsPossibleIdentifierName(tt))>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(TokenKindIsPossibleIdentifierName(tt)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("TokenKindIsPossibleIdentifierName(tt)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4442); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsPossibleIdentifierName(tt)"
")"); do { *((volatile int*)__null) = 4442; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4443
4444 NameNodeType binding;
4445 MOZ_TRY_VAR(binding, bindingIdentifier(kind, yieldHandling))do { auto mozTryVarTempResult_ = (bindingIdentifier(kind, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (binding)
= mozTryVarTempResult_.unwrap(); } while (0)
;
4446
4447 tokenStream.consumeKnownToken(TokenKind::Assign);
4448
4449 BinaryNodeType bindingExpr;
4450 MOZ_TRY_VAR(bindingExpr,do { auto mozTryVarTempResult_ = (bindingInitializer(binding,
kind, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (bindingExpr) = mozTryVarTempResult_.unwrap(); } while (0)
4451 bindingInitializer(binding, kind, yieldHandling))do { auto mozTryVarTempResult_ = (bindingInitializer(binding,
kind, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (bindingExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
4452
4453 if (!handler_.addPropertyDefinition(literal, propName, bindingExpr)) {
4454 return errorResult();
4455 }
4456 } else {
4457 errorAt(namePos.begin, JSMSG_NO_VARIABLE_NAME);
4458 return errorResult();
4459 }
4460 }
4461
4462 bool matched;
4463 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
4464 TokenStream::SlashIsInvalid)) {
4465 return errorResult();
4466 }
4467 if (!matched) {
4468 break;
4469 }
4470 if (tt == TokenKind::TripleDot) {
4471 error(JSMSG_REST_WITH_COMMA);
4472 return errorResult();
4473 }
4474 }
4475
4476 if (!mustMatchToken(TokenKind::RightCurly, [this, begin](TokenKind actual) {
4477 this->reportMissingClosing(JSMSG_CURLY_AFTER_LIST, JSMSG_CURLY_OPENED,
4478 begin);
4479 })) {
4480 return errorResult();
4481 }
4482
4483 handler_.setEndPosition(literal, pos().end);
4484 return literal;
4485}
4486
4487template <class ParseHandler, typename Unit>
4488typename ParseHandler::ListNodeResult
4489GeneralParser<ParseHandler, Unit>::arrayBindingPattern(
4490 DeclarationKind kind, YieldHandling yieldHandling) {
4491 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftBracket))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftBracket))
>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftBracket))
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftBracket)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4491); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftBracket)"
")"); do { *((volatile int*)__null) = 4491; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4492
4493 AutoCheckRecursionLimit recursion(this->fc_);
4494 if (!recursion.check(this->fc_)) {
4495 return errorResult();
4496 }
4497
4498 uint32_t begin = pos().begin;
4499 ListNodeType literal;
4500 MOZ_TRY_VAR(literal, handler_.newArrayLiteral(begin))do { auto mozTryVarTempResult_ = (handler_.newArrayLiteral(begin
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (literal)
= mozTryVarTempResult_.unwrap(); } while (0)
;
4501
4502 uint32_t index = 0;
4503 for (;; index++) {
4504 if (index >= NativeObject::MAX_DENSE_ELEMENTS_COUNT) {
4505 error(JSMSG_ARRAY_INIT_TOO_BIG);
4506 return errorResult();
4507 }
4508
4509 TokenKind tt;
4510 if (!tokenStream.getToken(&tt)) {
4511 return errorResult();
4512 }
4513
4514 if (tt == TokenKind::RightBracket) {
4515 anyChars.ungetToken();
4516 break;
4517 }
4518
4519 if (tt == TokenKind::Comma) {
4520 if (!handler_.addElision(literal, pos())) {
4521 return errorResult();
4522 }
4523 } else if (tt == TokenKind::TripleDot) {
4524 uint32_t begin = pos().begin;
4525
4526 TokenKind tt;
4527 if (!tokenStream.getToken(&tt)) {
4528 return errorResult();
4529 }
4530
4531 Node inner;
4532 MOZ_TRY_VAR(inner, bindingIdentifierOrPattern(kind, yieldHandling, tt))do { auto mozTryVarTempResult_ = (bindingIdentifierOrPattern(
kind, yieldHandling, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (inner) = mozTryVarTempResult_.unwrap(); } while (0)
;
4533
4534 if (!handler_.addSpreadElement(literal, begin, inner)) {
4535 return errorResult();
4536 }
4537 } else {
4538 Node binding;
4539 MOZ_TRY_VAR(binding, bindingIdentifierOrPattern(kind, yieldHandling, tt))do { auto mozTryVarTempResult_ = (bindingIdentifierOrPattern(
kind, yieldHandling, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (binding) = mozTryVarTempResult_.unwrap(); } while (0)
;
4540
4541 bool hasInitializer;
4542 if (!tokenStream.matchToken(&hasInitializer, TokenKind::Assign,
4543 TokenStream::SlashIsRegExp)) {
4544 return errorResult();
4545 }
4546
4547 Node element;
4548 if (hasInitializer) {
4549 MOZ_TRY_VAR(element, bindingInitializer(binding, kind, yieldHandling))do { auto mozTryVarTempResult_ = (bindingInitializer(binding,
kind, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (element) = mozTryVarTempResult_.unwrap(); } while (0)
;
4550 } else {
4551 element = binding;
4552 }
4553
4554 handler_.addArrayElement(literal, element);
4555 }
4556
4557 if (tt != TokenKind::Comma) {
4558 // If we didn't already match TokenKind::Comma in above case.
4559 bool matched;
4560 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
4561 TokenStream::SlashIsRegExp)) {
4562 return errorResult();
4563 }
4564 if (!matched) {
4565 break;
4566 }
4567
4568 if (tt == TokenKind::TripleDot) {
4569 error(JSMSG_REST_WITH_COMMA);
4570 return errorResult();
4571 }
4572 }
4573 }
4574
4575 if (!mustMatchToken(TokenKind::RightBracket, [this, begin](TokenKind actual) {
4576 this->reportMissingClosing(JSMSG_BRACKET_AFTER_LIST,
4577 JSMSG_BRACKET_OPENED, begin);
4578 })) {
4579 return errorResult();
4580 }
4581
4582 handler_.setEndPosition(literal, pos().end);
4583 return literal;
4584}
4585
4586template <class ParseHandler, typename Unit>
4587typename ParseHandler::NodeResult
4588GeneralParser<ParseHandler, Unit>::destructuringDeclaration(
4589 DeclarationKind kind, YieldHandling yieldHandling, TokenKind tt) {
4590 MOZ_ASSERT(anyChars.isCurrentTokenType(tt))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(tt))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
tt)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(tt)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4590); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(tt)"
")"); do { *((volatile int*)__null) = 4590; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4591 MOZ_ASSERT(tt == TokenKind::LeftBracket || tt == TokenKind::LeftCurly)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(tt == TokenKind::LeftBracket || tt == TokenKind::LeftCurly
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(tt == TokenKind::LeftBracket || tt == TokenKind::LeftCurly
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"tt == TokenKind::LeftBracket || tt == TokenKind::LeftCurly",
"/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4591); AnnotateMozCrashReason("MOZ_ASSERT" "(" "tt == TokenKind::LeftBracket || tt == TokenKind::LeftCurly"
")"); do { *((volatile int*)__null) = 4591; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4592
4593 if (tt == TokenKind::LeftBracket) {
4594 return arrayBindingPattern(kind, yieldHandling);
4595 }
4596 return objectBindingPattern(kind, yieldHandling);
4597}
4598
4599template <class ParseHandler, typename Unit>
4600typename ParseHandler::NodeResult
4601GeneralParser<ParseHandler, Unit>::destructuringDeclarationWithoutYieldOrAwait(
4602 DeclarationKind kind, YieldHandling yieldHandling, TokenKind tt) {
4603 uint32_t startYieldOffset = pc_->lastYieldOffset;
4604 uint32_t startAwaitOffset = pc_->lastAwaitOffset;
4605
4606 Node res;
4607 MOZ_TRY_VAR(res, destructuringDeclaration(kind, yieldHandling, tt))do { auto mozTryVarTempResult_ = (destructuringDeclaration(kind
, yieldHandling, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (res) = mozTryVarTempResult_.unwrap(); } while (0)
;
4608
4609 if (pc_->lastYieldOffset != startYieldOffset) {
4610 errorAt(pc_->lastYieldOffset, JSMSG_YIELD_IN_PARAMETER);
4611 return errorResult();
4612 }
4613 if (pc_->lastAwaitOffset != startAwaitOffset) {
4614 errorAt(pc_->lastAwaitOffset, JSMSG_AWAIT_IN_PARAMETER);
4615 return errorResult();
4616 }
4617 return res;
4618}
4619
4620template <class ParseHandler, typename Unit>
4621typename ParseHandler::LexicalScopeNodeResult
4622GeneralParser<ParseHandler, Unit>::blockStatement(YieldHandling yieldHandling,
4623 unsigned errorNumber) {
4624 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftCurly))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftCurly))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftCurly))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4624); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
")"); do { *((volatile int*)__null) = 4624; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4625 uint32_t openedPos = pos().begin;
4626
4627 ParseContext::Statement stmt(pc_, StatementKind::Block);
4628 ParseContext::Scope scope(this);
4629 if (!scope.init(pc_)) {
4630 return errorResult();
4631 }
4632
4633 ListNodeType list;
4634 MOZ_TRY_VAR(list, statementList(yieldHandling))do { auto mozTryVarTempResult_ = (statementList(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (list) = mozTryVarTempResult_
.unwrap(); } while (0)
;
4635
4636 if (!mustMatchToken(TokenKind::RightCurly, [this, errorNumber,
4637 openedPos](TokenKind actual) {
4638 this->reportMissingClosing(errorNumber, JSMSG_CURLY_OPENED, openedPos);
4639 })) {
4640 return errorResult();
4641 }
4642
4643 return finishLexicalScope(scope, list);
4644}
4645
4646template <class ParseHandler, typename Unit>
4647typename ParseHandler::NodeResult
4648GeneralParser<ParseHandler, Unit>::expressionAfterForInOrOf(
4649 ParseNodeKind forHeadKind, YieldHandling yieldHandling) {
4650 MOZ_ASSERT(forHeadKind == ParseNodeKind::ForIn ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(forHeadKind == ParseNodeKind::ForIn || forHeadKind ==
ParseNodeKind::ForOf)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(forHeadKind == ParseNodeKind
::ForIn || forHeadKind == ParseNodeKind::ForOf))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("forHeadKind == ParseNodeKind::ForIn || forHeadKind == ParseNodeKind::ForOf"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4651); AnnotateMozCrashReason("MOZ_ASSERT" "(" "forHeadKind == ParseNodeKind::ForIn || forHeadKind == ParseNodeKind::ForOf"
")"); do { *((volatile int*)__null) = 4651; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4651 forHeadKind == ParseNodeKind::ForOf)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(forHeadKind == ParseNodeKind::ForIn || forHeadKind ==
ParseNodeKind::ForOf)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(forHeadKind == ParseNodeKind
::ForIn || forHeadKind == ParseNodeKind::ForOf))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("forHeadKind == ParseNodeKind::ForIn || forHeadKind == ParseNodeKind::ForOf"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4651); AnnotateMozCrashReason("MOZ_ASSERT" "(" "forHeadKind == ParseNodeKind::ForIn || forHeadKind == ParseNodeKind::ForOf"
")"); do { *((volatile int*)__null) = 4651; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4652 if (forHeadKind == ParseNodeKind::ForOf) {
4653 return assignExpr(InAllowed, yieldHandling, TripledotProhibited);
4654 }
4655
4656 return expr(InAllowed, yieldHandling, TripledotProhibited);
4657}
4658
4659template <class ParseHandler, typename Unit>
4660typename ParseHandler::NodeResult
4661GeneralParser<ParseHandler, Unit>::declarationPattern(
4662 DeclarationKind declKind, TokenKind tt, bool initialDeclaration,
4663 YieldHandling yieldHandling, ParseNodeKind* forHeadKind,
4664 Node* forInOrOfExpression) {
4665 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftBracket) ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftBracket) ||
anyChars.isCurrentTokenType(TokenKind::LeftCurly))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::LeftBracket) || anyChars
.isCurrentTokenType(TokenKind::LeftCurly)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftBracket) || anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4666); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftBracket) || anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
")"); do { *((volatile int*)__null) = 4666; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4666 anyChars.isCurrentTokenType(TokenKind::LeftCurly))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftBracket) ||
anyChars.isCurrentTokenType(TokenKind::LeftCurly))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::LeftBracket) || anyChars
.isCurrentTokenType(TokenKind::LeftCurly)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftBracket) || anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4666); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftBracket) || anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
")"); do { *((volatile int*)__null) = 4666; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4667
4668 Node pattern;
4669 MOZ_TRY_VAR(pattern, destructuringDeclaration(declKind, yieldHandling, tt))do { auto mozTryVarTempResult_ = (destructuringDeclaration(declKind
, yieldHandling, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (pattern) = mozTryVarTempResult_.unwrap(); } while (0)
;
4670
4671 if (initialDeclaration && forHeadKind) {
4672 bool isForIn, isForOf;
4673 if (!matchInOrOf(&isForIn, &isForOf)) {
4674 return errorResult();
4675 }
4676
4677 if (isForIn) {
4678 *forHeadKind = ParseNodeKind::ForIn;
4679 } else if (isForOf) {
4680 *forHeadKind = ParseNodeKind::ForOf;
4681 } else {
4682 *forHeadKind = ParseNodeKind::ForHead;
4683 }
4684
4685 if (*forHeadKind != ParseNodeKind::ForHead) {
4686 MOZ_TRY_VAR(*forInOrOfExpression,do { auto mozTryVarTempResult_ = (expressionAfterForInOrOf(*forHeadKind
, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (*forInOrOfExpression) = mozTryVarTempResult_.unwrap(); } while
(0)
4687 expressionAfterForInOrOf(*forHeadKind, yieldHandling))do { auto mozTryVarTempResult_ = (expressionAfterForInOrOf(*forHeadKind
, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (*forInOrOfExpression) = mozTryVarTempResult_.unwrap(); } while
(0)
;
4688
4689 return pattern;
4690 }
4691 }
4692
4693 if (!mustMatchToken(TokenKind::Assign, JSMSG_BAD_DESTRUCT_DECL)) {
4694 return errorResult();
4695 }
4696
4697 Node init;
4698 MOZ_TRY_VAR(init, assignExpr(forHeadKind ? InProhibited : InAllowed,do { auto mozTryVarTempResult_ = (assignExpr(forHeadKind ? InProhibited
: InAllowed, yieldHandling, TripledotProhibited)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (init) = mozTryVarTempResult_.unwrap(); } while
(0)
4699 yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(forHeadKind ? InProhibited
: InAllowed, yieldHandling, TripledotProhibited)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (init) = mozTryVarTempResult_.unwrap(); } while
(0)
;
4700
4701 return handler_.newAssignment(ParseNodeKind::AssignExpr, pattern, init);
4702}
4703
4704template <class ParseHandler, typename Unit>
4705typename ParseHandler::AssignmentNodeResult
4706GeneralParser<ParseHandler, Unit>::initializerInNameDeclaration(
4707 NameNodeType binding, DeclarationKind declKind, bool initialDeclaration,
4708 YieldHandling yieldHandling, ParseNodeKind* forHeadKind,
4709 Node* forInOrOfExpression) {
4710 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Assign))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Assign))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Assign)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Assign)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4710); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Assign)"
")"); do { *((volatile int*)__null) = 4710; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4711
4712 uint32_t initializerOffset;
4713 if (!tokenStream.peekOffset(&initializerOffset, TokenStream::SlashIsRegExp)) {
4714 return errorResult();
4715 }
4716
4717 Node initializer;
4718 MOZ_TRY_VAR(initializer, assignExpr(forHeadKind ? InProhibited : InAllowed,do { auto mozTryVarTempResult_ = (assignExpr(forHeadKind ? InProhibited
: InAllowed, yieldHandling, TripledotProhibited)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializer) = mozTryVarTempResult_.unwrap
(); } while (0)
4719 yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(forHeadKind ? InProhibited
: InAllowed, yieldHandling, TripledotProhibited)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializer) = mozTryVarTempResult_.unwrap
(); } while (0)
;
4720
4721 if (forHeadKind && initialDeclaration) {
4722 bool isForIn, isForOf;
4723 if (!matchInOrOf(&isForIn, &isForOf)) {
4724 return errorResult();
4725 }
4726
4727 // An initialized declaration can't appear in a for-of:
4728 //
4729 // for (var/let/const x = ... of ...); // BAD
4730 if (isForOf) {
4731 errorAt(initializerOffset, JSMSG_OF_AFTER_FOR_LOOP_DECL);
4732 return errorResult();
4733 }
4734
4735 if (isForIn) {
4736 // Lexical declarations in for-in loops can't be initialized:
4737 //
4738 // for (let/const x = ... in ...); // BAD
4739 if (DeclarationKindIsLexical(declKind)) {
4740 errorAt(initializerOffset, JSMSG_IN_AFTER_LEXICAL_FOR_DECL);
4741 return errorResult();
4742 }
4743
4744 // This leaves only initialized for-in |var| declarations. ES6
4745 // forbids these; later ES un-forbids in non-strict mode code.
4746 *forHeadKind = ParseNodeKind::ForIn;
4747 if (!strictModeErrorAt(initializerOffset,
4748 JSMSG_INVALID_FOR_IN_DECL_WITH_INIT)) {
4749 return errorResult();
4750 }
4751
4752 MOZ_TRY_VAR(do { auto mozTryVarTempResult_ = (expressionAfterForInOrOf(ParseNodeKind
::ForIn, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (*forInOrOfExpression) = mozTryVarTempResult_.unwrap(); } while
(0)
4753 *forInOrOfExpression,do { auto mozTryVarTempResult_ = (expressionAfterForInOrOf(ParseNodeKind
::ForIn, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (*forInOrOfExpression) = mozTryVarTempResult_.unwrap(); } while
(0)
4754 expressionAfterForInOrOf(ParseNodeKind::ForIn, yieldHandling))do { auto mozTryVarTempResult_ = (expressionAfterForInOrOf(ParseNodeKind
::ForIn, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (*forInOrOfExpression) = mozTryVarTempResult_.unwrap(); } while
(0)
;
4755 } else {
4756 *forHeadKind = ParseNodeKind::ForHead;
4757 }
4758 }
4759
4760 return handler_.finishInitializerAssignment(binding, initializer);
4761}
4762
4763template <class ParseHandler, typename Unit>
4764typename ParseHandler::NodeResult
4765GeneralParser<ParseHandler, Unit>::declarationName(DeclarationKind declKind,
4766 TokenKind tt,
4767 bool initialDeclaration,
4768 YieldHandling yieldHandling,
4769 ParseNodeKind* forHeadKind,
4770 Node* forInOrOfExpression) {
4771 // Anything other than possible identifier is an error.
4772 if (!TokenKindIsPossibleIdentifier(tt)) {
4773 error(JSMSG_NO_VARIABLE_NAME);
4774 return errorResult();
4775 }
4776
4777 TaggedParserAtomIndex name = bindingIdentifier(yieldHandling);
4778 if (!name) {
4779 return errorResult();
4780 }
4781
4782 NameNodeType binding;
4783 MOZ_TRY_VAR(binding, newName(name))do { auto mozTryVarTempResult_ = (newName(name)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (binding) = mozTryVarTempResult_.unwrap();
} while (0)
;
4784
4785 TokenPos namePos = pos();
4786
4787 // The '=' context after a variable name in a declaration is an opportunity
4788 // for ASI, and thus for the next token to start an ExpressionStatement:
4789 //
4790 // var foo // VariableDeclaration
4791 // /bar/g; // ExpressionStatement
4792 //
4793 // Therefore get the token here with SlashIsRegExp.
4794 bool matched;
4795 if (!tokenStream.matchToken(&matched, TokenKind::Assign,
4796 TokenStream::SlashIsRegExp)) {
4797 return errorResult();
4798 }
4799
4800 Node declaration;
4801 if (matched) {
4802 MOZ_TRY_VAR(declaration,do { auto mozTryVarTempResult_ = (initializerInNameDeclaration
(binding, declKind, initialDeclaration, yieldHandling, forHeadKind
, forInOrOfExpression)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (declaration) = mozTryVarTempResult_.unwrap(); } while (0)
4803 initializerInNameDeclaration(binding, declKind,do { auto mozTryVarTempResult_ = (initializerInNameDeclaration
(binding, declKind, initialDeclaration, yieldHandling, forHeadKind
, forInOrOfExpression)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (declaration) = mozTryVarTempResult_.unwrap(); } while (0)
4804 initialDeclaration, yieldHandling,do { auto mozTryVarTempResult_ = (initializerInNameDeclaration
(binding, declKind, initialDeclaration, yieldHandling, forHeadKind
, forInOrOfExpression)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (declaration) = mozTryVarTempResult_.unwrap(); } while (0)
4805 forHeadKind, forInOrOfExpression))do { auto mozTryVarTempResult_ = (initializerInNameDeclaration
(binding, declKind, initialDeclaration, yieldHandling, forHeadKind
, forInOrOfExpression)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (declaration) = mozTryVarTempResult_.unwrap(); } while (0)
;
4806 } else {
4807 declaration = binding;
4808
4809 if (initialDeclaration && forHeadKind) {
4810 bool isForIn, isForOf;
4811 if (!matchInOrOf(&isForIn, &isForOf)) {
4812 return errorResult();
4813 }
4814
4815 if (isForIn) {
4816 *forHeadKind = ParseNodeKind::ForIn;
4817#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
4818 if (declKind == DeclarationKind::Using ||
4819 declKind == DeclarationKind::AwaitUsing) {
4820 errorAt(namePos.begin, JSMSG_NO_IN_WITH_USING);
4821 return errorResult();
4822 }
4823#endif
4824 } else if (isForOf) {
4825 *forHeadKind = ParseNodeKind::ForOf;
4826 } else {
4827 *forHeadKind = ParseNodeKind::ForHead;
4828 }
4829 }
4830
4831 if (forHeadKind && *forHeadKind != ParseNodeKind::ForHead) {
4832 MOZ_TRY_VAR(*forInOrOfExpression,do { auto mozTryVarTempResult_ = (expressionAfterForInOrOf(*forHeadKind
, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (*forInOrOfExpression) = mozTryVarTempResult_.unwrap(); } while
(0)
4833 expressionAfterForInOrOf(*forHeadKind, yieldHandling))do { auto mozTryVarTempResult_ = (expressionAfterForInOrOf(*forHeadKind
, yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (*forInOrOfExpression) = mozTryVarTempResult_.unwrap(); } while
(0)
;
4834 } else {
4835 // Normal const declarations, and const declarations in for(;;)
4836 // heads, must be initialized.
4837 if (declKind == DeclarationKind::Const) {
4838 errorAt(namePos.begin, JSMSG_BAD_CONST_DECL);
4839 return errorResult();
4840 }
4841 }
4842 }
4843
4844 // Note the declared name after knowing whether or not we are in a for-of
4845 // loop, due to special early error semantics in Annex B.3.5.
4846 if (!noteDeclaredName(name, declKind, namePos)) {
4847 return errorResult();
4848 }
4849
4850 return declaration;
4851}
4852
4853template <class ParseHandler, typename Unit>
4854typename ParseHandler::DeclarationListNodeResult
4855GeneralParser<ParseHandler, Unit>::declarationList(
4856 YieldHandling yieldHandling, ParseNodeKind kind,
4857 ParseNodeKind* forHeadKind /* = nullptr */,
4858 Node* forInOrOfExpression /* = nullptr */) {
4859 MOZ_ASSERT(kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == ParseNodeKind::VarStmt || kind == ParseNodeKind
::LetDecl || kind == ParseNodeKind::ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
|| kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind
::AwaitUsingDecl endif)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(kind == ParseNodeKind::VarStmt
|| kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::
ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind ==
ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDecl
endif))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4865); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
")"); do { *((volatile int*)__null) = 4865; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4860 kind == ParseNodeKind::ConstDecldo { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == ParseNodeKind::VarStmt || kind == ParseNodeKind
::LetDecl || kind == ParseNodeKind::ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
|| kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind
::AwaitUsingDecl endif)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(kind == ParseNodeKind::VarStmt
|| kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::
ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind ==
ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDecl
endif))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4865); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
")"); do { *((volatile int*)__null) = 4865; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4861#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENTdo { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == ParseNodeKind::VarStmt || kind == ParseNodeKind
::LetDecl || kind == ParseNodeKind::ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
|| kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind
::AwaitUsingDecl endif)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(kind == ParseNodeKind::VarStmt
|| kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::
ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind ==
ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDecl
endif))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4865); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
")"); do { *((volatile int*)__null) = 4865; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4862 || kind == ParseNodeKind::UsingDecl ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == ParseNodeKind::VarStmt || kind == ParseNodeKind
::LetDecl || kind == ParseNodeKind::ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
|| kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind
::AwaitUsingDecl endif)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(kind == ParseNodeKind::VarStmt
|| kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::
ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind ==
ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDecl
endif))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4865); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
")"); do { *((volatile int*)__null) = 4865; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4863 kind == ParseNodeKind::AwaitUsingDecldo { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == ParseNodeKind::VarStmt || kind == ParseNodeKind
::LetDecl || kind == ParseNodeKind::ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
|| kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind
::AwaitUsingDecl endif)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(kind == ParseNodeKind::VarStmt
|| kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::
ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind ==
ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDecl
endif))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4865); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
")"); do { *((volatile int*)__null) = 4865; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4864#endifdo { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == ParseNodeKind::VarStmt || kind == ParseNodeKind
::LetDecl || kind == ParseNodeKind::ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
|| kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind
::AwaitUsingDecl endif)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(kind == ParseNodeKind::VarStmt
|| kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::
ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind ==
ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDecl
endif))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4865); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
")"); do { *((volatile int*)__null) = 4865; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4865 )do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == ParseNodeKind::VarStmt || kind == ParseNodeKind
::LetDecl || kind == ParseNodeKind::ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
|| kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind
::AwaitUsingDecl endif)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(kind == ParseNodeKind::VarStmt
|| kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::
ConstDecl ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind ==
ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDecl
endif))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4865); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == ParseNodeKind::VarStmt || kind == ParseNodeKind::LetDecl || kind == ParseNodeKind::ConstDeclifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == ParseNodeKind::UsingDecl || kind == ParseNodeKind::AwaitUsingDeclendif"
")"); do { *((volatile int*)__null) = 4865; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4866
4867 DeclarationKind declKind;
4868 switch (kind) {
4869 case ParseNodeKind::VarStmt:
4870 declKind = DeclarationKind::Var;
4871 break;
4872 case ParseNodeKind::ConstDecl:
4873 declKind = DeclarationKind::Const;
4874 break;
4875 case ParseNodeKind::LetDecl:
4876 declKind = DeclarationKind::Let;
4877 break;
4878#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
4879 case ParseNodeKind::UsingDecl:
4880 declKind = DeclarationKind::Using;
4881 break;
4882 case ParseNodeKind::AwaitUsingDecl:
4883 declKind = DeclarationKind::AwaitUsing;
4884 break;
4885#endif
4886 default:
4887 MOZ_CRASH("Unknown declaration kind")do { do { } while (false); MOZ_ReportCrash("" "Unknown declaration kind"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4887); AnnotateMozCrashReason("MOZ_CRASH(" "Unknown declaration kind"
")"); do { *((volatile int*)__null) = 4887; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
4888 }
4889
4890 DeclarationListNodeType decl;
4891 MOZ_TRY_VAR(decl, handler_.newDeclarationList(kind, pos()))do { auto mozTryVarTempResult_ = (handler_.newDeclarationList
(kind, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (decl) = mozTryVarTempResult_.unwrap(); } while (0)
;
4892
4893 bool moreDeclarations;
4894 bool initialDeclaration = true;
4895 do {
4896 MOZ_ASSERT_IF(!initialDeclaration && forHeadKind,do { if (!initialDeclaration && forHeadKind) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(*forHeadKind
== ParseNodeKind::ForHead)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(*forHeadKind == ParseNodeKind
::ForHead))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("*forHeadKind == ParseNodeKind::ForHead", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4897); AnnotateMozCrashReason("MOZ_ASSERT" "(" "*forHeadKind == ParseNodeKind::ForHead"
")"); do { *((volatile int*)__null) = 4897; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
4897 *forHeadKind == ParseNodeKind::ForHead)do { if (!initialDeclaration && forHeadKind) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(*forHeadKind
== ParseNodeKind::ForHead)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(*forHeadKind == ParseNodeKind
::ForHead))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("*forHeadKind == ParseNodeKind::ForHead", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4897); AnnotateMozCrashReason("MOZ_ASSERT" "(" "*forHeadKind == ParseNodeKind::ForHead"
")"); do { *((volatile int*)__null) = 4897; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
4898
4899 TokenKind tt;
4900 if (!tokenStream.getToken(&tt)) {
4901 return errorResult();
4902 }
4903
4904 Node binding;
4905 if (tt == TokenKind::LeftBracket || tt == TokenKind::LeftCurly) {
4906 MOZ_TRY_VAR(binding, declarationPattern(declKind, tt, initialDeclaration,do { auto mozTryVarTempResult_ = (declarationPattern(declKind
, tt, initialDeclaration, yieldHandling, forHeadKind, forInOrOfExpression
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (binding)
= mozTryVarTempResult_.unwrap(); } while (0)
4907 yieldHandling, forHeadKind,do { auto mozTryVarTempResult_ = (declarationPattern(declKind
, tt, initialDeclaration, yieldHandling, forHeadKind, forInOrOfExpression
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (binding)
= mozTryVarTempResult_.unwrap(); } while (0)
4908 forInOrOfExpression))do { auto mozTryVarTempResult_ = (declarationPattern(declKind
, tt, initialDeclaration, yieldHandling, forHeadKind, forInOrOfExpression
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (binding)
= mozTryVarTempResult_.unwrap(); } while (0)
;
4909 } else {
4910 MOZ_TRY_VAR(binding, declarationName(declKind, tt, initialDeclaration,do { auto mozTryVarTempResult_ = (declarationName(declKind, tt
, initialDeclaration, yieldHandling, forHeadKind, forInOrOfExpression
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (binding)
= mozTryVarTempResult_.unwrap(); } while (0)
4911 yieldHandling, forHeadKind,do { auto mozTryVarTempResult_ = (declarationName(declKind, tt
, initialDeclaration, yieldHandling, forHeadKind, forInOrOfExpression
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (binding)
= mozTryVarTempResult_.unwrap(); } while (0)
4912 forInOrOfExpression))do { auto mozTryVarTempResult_ = (declarationName(declKind, tt
, initialDeclaration, yieldHandling, forHeadKind, forInOrOfExpression
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (binding)
= mozTryVarTempResult_.unwrap(); } while (0)
;
4913 }
4914
4915 handler_.addList(decl, binding);
4916
4917 // If we have a for-in/of loop, the above call matches the entirety
4918 // of the loop head (up to the closing parenthesis).
4919 if (forHeadKind && *forHeadKind != ParseNodeKind::ForHead) {
4920 break;
4921 }
4922
4923 initialDeclaration = false;
4924
4925 if (!tokenStream.matchToken(&moreDeclarations, TokenKind::Comma,
4926 TokenStream::SlashIsRegExp)) {
4927 return errorResult();
4928 }
4929 } while (moreDeclarations);
4930
4931 return decl;
4932}
4933
4934template <class ParseHandler, typename Unit>
4935typename ParseHandler::DeclarationListNodeResult
4936GeneralParser<ParseHandler, Unit>::lexicalDeclaration(
4937 YieldHandling yieldHandling, DeclarationKind kind) {
4938 MOZ_ASSERT(kind == DeclarationKind::Const || kind == DeclarationKind::Letdo { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == DeclarationKind::Const || kind == DeclarationKind
::Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(kind == DeclarationKind::Const || kind == DeclarationKind::
Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4943); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
")"); do { *((volatile int*)__null) = 4943; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4939#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENTdo { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == DeclarationKind::Const || kind == DeclarationKind
::Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(kind == DeclarationKind::Const || kind == DeclarationKind::
Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4943); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
")"); do { *((volatile int*)__null) = 4943; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4940 || kind == DeclarationKind::Using ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == DeclarationKind::Const || kind == DeclarationKind
::Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(kind == DeclarationKind::Const || kind == DeclarationKind::
Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4943); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
")"); do { *((volatile int*)__null) = 4943; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4941 kind == DeclarationKind::AwaitUsingdo { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == DeclarationKind::Const || kind == DeclarationKind
::Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(kind == DeclarationKind::Const || kind == DeclarationKind::
Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4943); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
")"); do { *((volatile int*)__null) = 4943; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4942#endifdo { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == DeclarationKind::Const || kind == DeclarationKind
::Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(kind == DeclarationKind::Const || kind == DeclarationKind::
Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4943); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
")"); do { *((volatile int*)__null) = 4943; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
4943 )do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == DeclarationKind::Const || kind == DeclarationKind
::Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif)>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(kind == DeclarationKind::Const || kind == DeclarationKind::
Let ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind
::Using || kind == DeclarationKind::AwaitUsing endif))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4943); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == DeclarationKind::Const || kind == DeclarationKind::Letifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT || kind == DeclarationKind::Using || kind == DeclarationKind::AwaitUsingendif"
")"); do { *((volatile int*)__null) = 4943; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4944
4945 if (options().selfHostingMode) {
4946 error(JSMSG_SELFHOSTED_LEXICAL);
4947 return errorResult();
4948 }
4949
4950 /*
4951 * Parse body-level lets without a new block object. ES6 specs
4952 * that an execution environment's initial lexical environment
4953 * is the VariableEnvironment, i.e., body-level lets are in
4954 * the same environment record as vars.
4955 *
4956 * However, they cannot be parsed exactly as vars, as ES6
4957 * requires that uninitialized lets throw ReferenceError on use.
4958 *
4959 * See 8.1.1.1.6 and the note in 13.2.1.
4960 */
4961 DeclarationListNodeType decl;
4962 ParseNodeKind pnk;
4963 switch (kind) {
4964 case DeclarationKind::Const:
4965 pnk = ParseNodeKind::ConstDecl;
4966 break;
4967#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
4968 case DeclarationKind::Using:
4969 pnk = ParseNodeKind::UsingDecl;
4970 break;
4971 case DeclarationKind::AwaitUsing:
4972 pnk = ParseNodeKind::AwaitUsingDecl;
4973 break;
4974#endif
4975 case DeclarationKind::Let:
4976 pnk = ParseNodeKind::LetDecl;
4977 break;
4978 default:
4979 MOZ_CRASH("unexpected node kind")do { do { } while (false); MOZ_ReportCrash("" "unexpected node kind"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4979); AnnotateMozCrashReason("MOZ_CRASH(" "unexpected node kind"
")"); do { *((volatile int*)__null) = 4979; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
4980 }
4981 MOZ_TRY_VAR(decl, declarationList(yieldHandling, pnk))do { auto mozTryVarTempResult_ = (declarationList(yieldHandling
, pnk)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr(
)), 0))) { return mozTryVarTempResult_.propagateErr(); } (decl
) = mozTryVarTempResult_.unwrap(); } while (0)
;
4982 if (!matchOrInsertSemicolon()) {
4983 return errorResult();
4984 }
4985
4986 return decl;
4987}
4988
4989template <class ParseHandler, typename Unit>
4990typename ParseHandler::NameNodeResult
4991GeneralParser<ParseHandler, Unit>::moduleExportName() {
4992 MOZ_ASSERT(anyChars.currentToken().type == TokenKind::String)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.currentToken().type == TokenKind::String)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.currentToken().type == TokenKind::String)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.currentToken().type == TokenKind::String"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 4992); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.currentToken().type == TokenKind::String"
")"); do { *((volatile int*)__null) = 4992; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4993 TaggedParserAtomIndex name = anyChars.currentToken().atom();
4994 if (!this->parserAtoms().isModuleExportName(name)) {
4995 error(JSMSG_UNPAIRED_SURROGATE_EXPORT);
4996 return errorResult();
4997 }
4998 return handler_.newStringLiteral(name, pos());
4999}
5000
5001template <class ParseHandler, typename Unit>
5002bool GeneralParser<ParseHandler, Unit>::withClause(ListNodeType attributesSet) {
5003 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Assert) ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Assert) || anyChars
.isCurrentTokenType(TokenKind::With))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::Assert) || anyChars.isCurrentTokenType(TokenKind::
With)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::Assert) || anyChars.isCurrentTokenType(TokenKind::With)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5004); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Assert) || anyChars.isCurrentTokenType(TokenKind::With)"
")"); do { *((volatile int*)__null) = 5004; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5004 anyChars.isCurrentTokenType(TokenKind::With))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Assert) || anyChars
.isCurrentTokenType(TokenKind::With))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::Assert) || anyChars.isCurrentTokenType(TokenKind::
With)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::Assert) || anyChars.isCurrentTokenType(TokenKind::With)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5004); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Assert) || anyChars.isCurrentTokenType(TokenKind::With)"
")"); do { *((volatile int*)__null) = 5004; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5005
5006 if (!options().importAttributes()) {
5007 error(JSMSG_IMPORT_ASSERTIONS_NOT_SUPPORTED);
5008 return false;
5009 }
5010
5011 if (!abortIfSyntaxParser()) {
5012 return false;
5013 }
5014
5015 if (!mustMatchToken(TokenKind::LeftCurly, JSMSG_CURLY_AFTER_ASSERT)) {
5016 return false;
5017 }
5018
5019 // Handle the form |... assert {}|
5020 TokenKind token;
5021 if (!tokenStream.getToken(&token)) {
5022 return false;
5023 }
5024 if (token == TokenKind::RightCurly) {
5025 return true;
5026 }
5027
5028 js::HashSet<TaggedParserAtomIndex, TaggedParserAtomIndexHasher,
5029 js::SystemAllocPolicy>
5030 usedAssertionKeys;
5031
5032 for (;;) {
5033 TaggedParserAtomIndex keyName;
5034 if (TokenKindIsPossibleIdentifierName(token)) {
5035 keyName = anyChars.currentName();
5036 } else if (token == TokenKind::String) {
5037 keyName = anyChars.currentToken().atom();
5038 } else {
5039 error(JSMSG_ASSERT_KEY_EXPECTED);
5040 return false;
5041 }
5042
5043 auto p = usedAssertionKeys.lookupForAdd(keyName);
5044 if (p) {
5045 UniqueChars str = this->parserAtoms().toPrintableString(keyName);
5046 if (!str) {
5047 ReportOutOfMemory(this->fc_);
5048 return false;
5049 }
5050 error(JSMSG_DUPLICATE_ASSERT_KEY, str.get());
5051 return false;
5052 }
5053 if (!usedAssertionKeys.add(p, keyName)) {
5054 ReportOutOfMemory(this->fc_);
5055 return false;
5056 }
5057
5058 NameNodeType keyNode;
5059 MOZ_TRY_VAR_OR_RETURN(keyNode, newName(keyName), false)do { auto parserTryVarTempResult_ = (newName(keyName)); if ((
__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0))) { return
(false); } (keyNode) = parserTryVarTempResult_.unwrap(); } while
(0)
;
5060
5061 if (!mustMatchToken(TokenKind::Colon, JSMSG_COLON_AFTER_ASSERT_KEY)) {
5062 return false;
5063 }
5064 if (!mustMatchToken(TokenKind::String, JSMSG_ASSERT_STRING_LITERAL)) {
5065 return false;
5066 }
5067
5068 NameNodeType valueNode;
5069 MOZ_TRY_VAR_OR_RETURN(valueNode, stringLiteral(), false)do { auto parserTryVarTempResult_ = (stringLiteral()); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(valueNode) = parserTryVarTempResult_.unwrap(); } while (0)
;
5070
5071 BinaryNodeType importAttributeNode;
5072 MOZ_TRY_VAR_OR_RETURN(importAttributeNode,do { auto parserTryVarTempResult_ = (handler_.newImportAttribute
(keyNode, valueNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (importAttributeNode) = parserTryVarTempResult_
.unwrap(); } while (0)
5073 handler_.newImportAttribute(keyNode, valueNode),do { auto parserTryVarTempResult_ = (handler_.newImportAttribute
(keyNode, valueNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (importAttributeNode) = parserTryVarTempResult_
.unwrap(); } while (0)
5074 false)do { auto parserTryVarTempResult_ = (handler_.newImportAttribute
(keyNode, valueNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (importAttributeNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
5075
5076 handler_.addList(attributesSet, importAttributeNode);
5077
5078 if (!tokenStream.getToken(&token)) {
5079 return false;
5080 }
5081 if (token == TokenKind::Comma) {
5082 if (!tokenStream.getToken(&token)) {
5083 return false;
5084 }
5085 }
5086 if (token == TokenKind::RightCurly) {
5087 break;
5088 }
5089 }
5090
5091 return true;
5092}
5093
5094template <class ParseHandler, typename Unit>
5095bool GeneralParser<ParseHandler, Unit>::namedImports(
5096 ListNodeType importSpecSet) {
5097 if (!abortIfSyntaxParser()) {
5098 return false;
5099 }
5100
5101 while (true) {
5102 // Handle the forms |import {} from 'a'| and
5103 // |import { ..., } from 'a'| (where ... is non empty), by
5104 // escaping the loop early if the next token is }.
5105 TokenKind tt;
5106 if (!tokenStream.getToken(&tt)) {
5107 return false;
5108 }
5109
5110 if (tt == TokenKind::RightCurly) {
5111 break;
5112 }
5113
5114 TaggedParserAtomIndex importName;
5115 NameNodeType importNameNode = null();
5116 if (TokenKindIsPossibleIdentifierName(tt)) {
5117 importName = anyChars.currentName();
5118 MOZ_TRY_VAR_OR_RETURN(importNameNode, newName(importName), false)do { auto parserTryVarTempResult_ = (newName(importName)); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (importNameNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
5119 } else if (tt == TokenKind::String) {
5120 MOZ_TRY_VAR_OR_RETURN(importNameNode, moduleExportName(), false)do { auto parserTryVarTempResult_ = (moduleExportName()); if (
(__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0))) {
return (false); } (importNameNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
5121 } else {
5122 error(JSMSG_NO_IMPORT_NAME);
5123 return false;
5124 }
5125
5126 bool matched;
5127 if (!tokenStream.matchToken(&matched, TokenKind::As)) {
5128 return false;
5129 }
5130
5131 if (matched) {
5132 TokenKind afterAs;
5133 if (!tokenStream.getToken(&afterAs)) {
5134 return false;
5135 }
5136
5137 if (!TokenKindIsPossibleIdentifierName(afterAs)) {
5138 error(JSMSG_NO_BINDING_NAME);
5139 return false;
5140 }
5141 } else {
5142 // String export names can't refer to local bindings.
5143 if (tt == TokenKind::String) {
5144 error(JSMSG_AS_AFTER_STRING);
5145 return false;
5146 }
5147
5148 // Keywords cannot be bound to themselves, so an import name
5149 // that is a keyword is a syntax error if it is not followed
5150 // by the keyword 'as'.
5151 // See the ImportSpecifier production in ES6 section 15.2.2.
5152 MOZ_ASSERT(importName)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(importName)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(importName))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("importName", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5152); AnnotateMozCrashReason("MOZ_ASSERT" "(" "importName"
")"); do { *((volatile int*)__null) = 5152; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5153 if (IsKeyword(importName)) {
5154 error(JSMSG_AS_AFTER_RESERVED_WORD, ReservedWordToCharZ(importName));
5155 return false;
5156 }
5157 }
5158
5159 TaggedParserAtomIndex bindingAtom = importedBinding();
5160 if (!bindingAtom) {
5161 return false;
5162 }
5163
5164 NameNodeType bindingName;
5165 MOZ_TRY_VAR_OR_RETURN(bindingName, newName(bindingAtom), false)do { auto parserTryVarTempResult_ = (newName(bindingAtom)); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (bindingName) = parserTryVarTempResult_.
unwrap(); } while (0)
;
5166 if (!noteDeclaredName(bindingAtom, DeclarationKind::Import, pos())) {
5167 return false;
5168 }
5169
5170 BinaryNodeType importSpec;
5171 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newImportSpec(importNameNode
, bindingName)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (importSpec) = parserTryVarTempResult_
.unwrap(); } while (0)
5172 importSpec, handler_.newImportSpec(importNameNode, bindingName), false)do { auto parserTryVarTempResult_ = (handler_.newImportSpec(importNameNode
, bindingName)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (importSpec) = parserTryVarTempResult_
.unwrap(); } while (0)
;
5173
5174 handler_.addList(importSpecSet, importSpec);
5175
5176 TokenKind next;
5177 if (!tokenStream.getToken(&next)) {
5178 return false;
5179 }
5180
5181 if (next == TokenKind::RightCurly) {
5182 break;
5183 }
5184
5185 if (next != TokenKind::Comma) {
5186 error(JSMSG_RC_AFTER_IMPORT_SPEC_LIST);
5187 return false;
5188 }
5189 }
5190
5191 return true;
5192}
5193
5194template <class ParseHandler, typename Unit>
5195bool GeneralParser<ParseHandler, Unit>::namespaceImport(
5196 ListNodeType importSpecSet) {
5197 if (!abortIfSyntaxParser()) {
5198 return false;
5199 }
5200
5201 if (!mustMatchToken(TokenKind::As, JSMSG_AS_AFTER_IMPORT_STAR)) {
5202 return false;
5203 }
5204 uint32_t begin = pos().begin;
5205
5206 if (!mustMatchToken(TokenKindIsPossibleIdentifierName,
5207 JSMSG_NO_BINDING_NAME)) {
5208 return false;
5209 }
5210
5211 // Namespace imports are not indirect bindings but lexical
5212 // definitions that hold a module namespace object. They are treated
5213 // as const variables which are initialized during the
5214 // ModuleInstantiate step.
5215 TaggedParserAtomIndex bindingName = importedBinding();
5216 if (!bindingName) {
5217 return false;
5218 }
5219 NameNodeType bindingNameNode;
5220 MOZ_TRY_VAR_OR_RETURN(bindingNameNode, newName(bindingName), false)do { auto parserTryVarTempResult_ = (newName(bindingName)); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (bindingNameNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
5221 if (!noteDeclaredName(bindingName, DeclarationKind::Const, pos())) {
5222 return false;
5223 }
5224
5225 // The namespace import name is currently required to live on the
5226 // environment.
5227 pc_->varScope().lookupDeclaredName(bindingName)->value()->setClosedOver();
5228
5229 UnaryNodeType importSpec;
5230 MOZ_TRY_VAR_OR_RETURN(importSpec,do { auto parserTryVarTempResult_ = (handler_.newImportNamespaceSpec
(begin, bindingNameNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (importSpec) = parserTryVarTempResult_
.unwrap(); } while (0)
5231 handler_.newImportNamespaceSpec(begin, bindingNameNode),do { auto parserTryVarTempResult_ = (handler_.newImportNamespaceSpec
(begin, bindingNameNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (importSpec) = parserTryVarTempResult_
.unwrap(); } while (0)
5232 false)do { auto parserTryVarTempResult_ = (handler_.newImportNamespaceSpec
(begin, bindingNameNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (importSpec) = parserTryVarTempResult_
.unwrap(); } while (0)
;
5233
5234 handler_.addList(importSpecSet, importSpec);
5235
5236 return true;
5237}
5238
5239template <class ParseHandler, typename Unit>
5240typename ParseHandler::BinaryNodeResult
5241GeneralParser<ParseHandler, Unit>::importDeclaration() {
5242 if (!abortIfSyntaxParser()) {
5243 return errorResult();
5244 }
5245
5246 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Import))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Import))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Import)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Import)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5246); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Import)"
")"); do { *((volatile int*)__null) = 5246; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5247
5248 if (!pc_->atModuleLevel()) {
5249 error(JSMSG_IMPORT_DECL_AT_TOP_LEVEL);
5250 return errorResult();
5251 }
5252
5253 uint32_t begin = pos().begin;
5254 TokenKind tt;
5255 if (!tokenStream.getToken(&tt)) {
5256 return errorResult();
5257 }
5258
5259 ListNodeType importSpecSet;
5260 MOZ_TRY_VAR(importSpecSet,do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::ImportSpecList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importSpecSet) = mozTryVarTempResult_.unwrap(); } while (
0)
5261 handler_.newList(ParseNodeKind::ImportSpecList, pos()))do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::ImportSpecList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importSpecSet) = mozTryVarTempResult_.unwrap(); } while (
0)
;
5262
5263 if (tt == TokenKind::String) {
5264 // Handle the form |import 'a'| by leaving the list empty. This is
5265 // equivalent to |import {} from 'a'|.
5266 handler_.setEndPosition(importSpecSet, pos().begin);
5267 } else {
5268 if (tt == TokenKind::LeftCurly) {
5269 if (!namedImports(importSpecSet)) {
5270 return errorResult();
5271 }
5272 } else if (tt == TokenKind::Mul) {
5273 if (!namespaceImport(importSpecSet)) {
5274 return errorResult();
5275 }
5276 } else if (TokenKindIsPossibleIdentifierName(tt)) {
5277 // Handle the form |import a from 'b'|, by adding a single import
5278 // specifier to the list, with 'default' as the import name and
5279 // 'a' as the binding name. This is equivalent to
5280 // |import { default as a } from 'b'|.
5281 NameNodeType importName;
5282 MOZ_TRY_VAR(importName,do { auto mozTryVarTempResult_ = (newName(TaggedParserAtomIndex
::WellKnown::default_())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importName) = mozTryVarTempResult_.unwrap(); } while (0)
5283 newName(TaggedParserAtomIndex::WellKnown::default_()))do { auto mozTryVarTempResult_ = (newName(TaggedParserAtomIndex
::WellKnown::default_())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importName) = mozTryVarTempResult_.unwrap(); } while (0)
;
5284
5285 TaggedParserAtomIndex bindingAtom = importedBinding();
5286 if (!bindingAtom) {
5287 return errorResult();
5288 }
5289
5290 NameNodeType bindingName;
5291 MOZ_TRY_VAR(bindingName, newName(bindingAtom))do { auto mozTryVarTempResult_ = (newName(bindingAtom)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (bindingName) = mozTryVarTempResult_
.unwrap(); } while (0)
;
5292
5293 if (!noteDeclaredName(bindingAtom, DeclarationKind::Import, pos())) {
5294 return errorResult();
5295 }
5296
5297 BinaryNodeType importSpec;
5298 MOZ_TRY_VAR(importSpec, handler_.newImportSpec(importName, bindingName))do { auto mozTryVarTempResult_ = (handler_.newImportSpec(importName
, bindingName)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importSpec) = mozTryVarTempResult_.unwrap(); } while (0)
;
5299
5300 handler_.addList(importSpecSet, importSpec);
5301
5302 if (!tokenStream.peekToken(&tt)) {
5303 return errorResult();
5304 }
5305
5306 if (tt == TokenKind::Comma) {
5307 tokenStream.consumeKnownToken(tt);
5308 if (!tokenStream.getToken(&tt)) {
5309 return errorResult();
5310 }
5311
5312 if (tt == TokenKind::LeftCurly) {
5313 if (!namedImports(importSpecSet)) {
5314 return errorResult();
5315 }
5316 } else if (tt == TokenKind::Mul) {
5317 if (!namespaceImport(importSpecSet)) {
5318 return errorResult();
5319 }
5320 } else {
5321 error(JSMSG_NAMED_IMPORTS_OR_NAMESPACE_IMPORT);
5322 return errorResult();
5323 }
5324 }
5325 } else {
5326 error(JSMSG_DECLARATION_AFTER_IMPORT);
5327 return errorResult();
5328 }
5329
5330 if (!mustMatchToken(TokenKind::From, JSMSG_FROM_AFTER_IMPORT_CLAUSE)) {
5331 return errorResult();
5332 }
5333
5334 if (!mustMatchToken(TokenKind::String, JSMSG_MODULE_SPEC_AFTER_FROM)) {
5335 return errorResult();
5336 }
5337 }
5338
5339 NameNodeType moduleSpec;
5340 MOZ_TRY_VAR(moduleSpec, stringLiteral())do { auto mozTryVarTempResult_ = (stringLiteral()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (moduleSpec) = mozTryVarTempResult_.unwrap
(); } while (0)
;
5341
5342 // The `assert` keyword has a [no LineTerminator here] production before it in
5343 // the grammar -- `with` does not. We need to handle this distinction.
5344 if (!tokenStream.peekTokenSameLine(&tt, TokenStream::SlashIsRegExp)) {
5345 return errorResult();
5346 }
5347
5348 // `with` may have an EOL prior, so peek the next token and replace
5349 // EOL if the next token is `with`.
5350 if (tt == TokenKind::Eol) {
5351 // Doing a regular peek won't produce Eol, but the actual next token.
5352 TokenKind peekedToken;
5353 if (!tokenStream.peekToken(&peekedToken, TokenStream::SlashIsRegExp)) {
5354 return errorResult();
5355 }
5356
5357 if (peekedToken == TokenKind::With) {
5358 tt = TokenKind::With;
5359 }
5360 }
5361
5362 ListNodeType importAttributeList;
5363 MOZ_TRY_VAR(importAttributeList,do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::ImportAttributeList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importAttributeList) = mozTryVarTempResult_.unwrap(); } while
(0)
5364 handler_.newList(ParseNodeKind::ImportAttributeList, pos()))do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::ImportAttributeList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importAttributeList) = mozTryVarTempResult_.unwrap(); } while
(0)
;
5365
5366 if (tt == TokenKind::With ||
5367 (tt == TokenKind::Assert && options().importAttributesAssertSyntax())) {
5368 tokenStream.consumeKnownToken(tt, TokenStream::SlashIsRegExp);
5369
5370 if (!withClause(importAttributeList)) {
5371 return errorResult();
5372 }
5373 }
5374
5375 if (!matchOrInsertSemicolon(TokenStream::SlashIsRegExp)) {
5376 return errorResult();
5377 }
5378
5379 BinaryNodeType moduleRequest;
5380 MOZ_TRY_VAR(moduleRequest,do { auto mozTryVarTempResult_ = (handler_.newModuleRequest(moduleSpec
, importAttributeList, TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (moduleRequest) = mozTryVarTempResult_.unwrap
(); } while (0)
5381 handler_.newModuleRequest(moduleSpec, importAttributeList,do { auto mozTryVarTempResult_ = (handler_.newModuleRequest(moduleSpec
, importAttributeList, TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (moduleRequest) = mozTryVarTempResult_.unwrap
(); } while (0)
5382 TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newModuleRequest(moduleSpec
, importAttributeList, TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (moduleRequest) = mozTryVarTempResult_.unwrap
(); } while (0)
;
5383
5384 BinaryNodeType node;
5385 MOZ_TRY_VAR(node, handler_.newImportDeclaration(importSpecSet, moduleRequest,do { auto mozTryVarTempResult_ = (handler_.newImportDeclaration
(importSpecSet, moduleRequest, TokenPos(begin, pos().end))); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (node) = mozTryVarTempResult_
.unwrap(); } while (0)
5386 TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newImportDeclaration
(importSpecSet, moduleRequest, TokenPos(begin, pos().end))); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (node) = mozTryVarTempResult_
.unwrap(); } while (0)
;
5387 if (!processImport(node)) {
5388 return errorResult();
5389 }
5390
5391 return node;
5392}
5393
5394template <class ParseHandler, typename Unit>
5395inline typename ParseHandler::NodeResult
5396GeneralParser<ParseHandler, Unit>::importDeclarationOrImportExpr(
5397 YieldHandling yieldHandling) {
5398 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Import))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Import))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Import)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Import)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5398); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Import)"
")"); do { *((volatile int*)__null) = 5398; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5399
5400 TokenKind tt;
5401 if (!tokenStream.peekToken(&tt)) {
5402 return errorResult();
5403 }
5404
5405 if (tt == TokenKind::Dot || tt == TokenKind::LeftParen) {
5406 return expressionStatement(yieldHandling);
5407 }
5408
5409 return importDeclaration();
5410}
5411
5412template <typename Unit>
5413bool Parser<FullParseHandler, Unit>::checkExportedName(
5414 TaggedParserAtomIndex exportName) {
5415 if (!pc_->sc()->asModuleContext()->builder.hasExportedName(exportName)) {
5416 return true;
5417 }
5418
5419 UniqueChars str = this->parserAtoms().toPrintableString(exportName);
5420 if (!str) {
5421 ReportOutOfMemory(this->fc_);
5422 return false;
5423 }
5424
5425 error(JSMSG_DUPLICATE_EXPORT_NAME, str.get());
5426 return false;
5427}
5428
5429template <typename Unit>
5430inline bool Parser<SyntaxParseHandler, Unit>::checkExportedName(
5431 TaggedParserAtomIndex exportName) {
5432 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5432); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5432; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5433 return false;
5434}
5435
5436template <class ParseHandler, typename Unit>
5437inline bool GeneralParser<ParseHandler, Unit>::checkExportedName(
5438 TaggedParserAtomIndex exportName) {
5439 return asFinalParser()->checkExportedName(exportName);
5440}
5441
5442template <typename Unit>
5443bool Parser<FullParseHandler, Unit>::checkExportedNamesForArrayBinding(
5444 ListNode* array) {
5445 MOZ_ASSERT(array->isKind(ParseNodeKind::ArrayExpr))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(array->isKind(ParseNodeKind::ArrayExpr))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(array->isKind(ParseNodeKind::ArrayExpr)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("array->isKind(ParseNodeKind::ArrayExpr)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5445); AnnotateMozCrashReason("MOZ_ASSERT" "(" "array->isKind(ParseNodeKind::ArrayExpr)"
")"); do { *((volatile int*)__null) = 5445; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5446
5447 for (ParseNode* node : array->contents()) {
5448 if (node->isKind(ParseNodeKind::Elision)) {
5449 continue;
5450 }
5451
5452 ParseNode* binding;
5453 if (node->isKind(ParseNodeKind::Spread)) {
5454 binding = node->as<UnaryNode>().kid();
5455 } else if (node->isKind(ParseNodeKind::AssignExpr)) {
5456 binding = node->as<AssignmentNode>().left();
5457 } else {
5458 binding = node;
5459 }
5460
5461 if (!checkExportedNamesForDeclaration(binding)) {
5462 return false;
5463 }
5464 }
5465
5466 return true;
5467}
5468
5469template <typename Unit>
5470inline bool Parser<SyntaxParseHandler, Unit>::checkExportedNamesForArrayBinding(
5471 ListNodeType array) {
5472 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5472); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5472; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5473 return false;
5474}
5475
5476template <class ParseHandler, typename Unit>
5477inline bool
5478GeneralParser<ParseHandler, Unit>::checkExportedNamesForArrayBinding(
5479 ListNodeType array) {
5480 return asFinalParser()->checkExportedNamesForArrayBinding(array);
5481}
5482
5483template <typename Unit>
5484bool Parser<FullParseHandler, Unit>::checkExportedNamesForObjectBinding(
5485 ListNode* obj) {
5486 MOZ_ASSERT(obj->isKind(ParseNodeKind::ObjectExpr))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(obj->isKind(ParseNodeKind::ObjectExpr))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(obj->isKind(ParseNodeKind::ObjectExpr)))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("obj->isKind(ParseNodeKind::ObjectExpr)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5486); AnnotateMozCrashReason("MOZ_ASSERT" "(" "obj->isKind(ParseNodeKind::ObjectExpr)"
")"); do { *((volatile int*)__null) = 5486; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5487
5488 for (ParseNode* node : obj->contents()) {
5489 MOZ_ASSERT(node->isKind(ParseNodeKind::MutateProto) ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(node->isKind(ParseNodeKind::MutateProto) || node->
isKind(ParseNodeKind::PropertyDefinition) || node->isKind(
ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread
))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(node->isKind(ParseNodeKind::MutateProto) || node->
isKind(ParseNodeKind::PropertyDefinition) || node->isKind(
ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("node->isKind(ParseNodeKind::MutateProto) || node->isKind(ParseNodeKind::PropertyDefinition) || node->isKind(ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5492); AnnotateMozCrashReason("MOZ_ASSERT" "(" "node->isKind(ParseNodeKind::MutateProto) || node->isKind(ParseNodeKind::PropertyDefinition) || node->isKind(ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread)"
")"); do { *((volatile int*)__null) = 5492; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5490 node->isKind(ParseNodeKind::PropertyDefinition) ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(node->isKind(ParseNodeKind::MutateProto) || node->
isKind(ParseNodeKind::PropertyDefinition) || node->isKind(
ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread
))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(node->isKind(ParseNodeKind::MutateProto) || node->
isKind(ParseNodeKind::PropertyDefinition) || node->isKind(
ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("node->isKind(ParseNodeKind::MutateProto) || node->isKind(ParseNodeKind::PropertyDefinition) || node->isKind(ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5492); AnnotateMozCrashReason("MOZ_ASSERT" "(" "node->isKind(ParseNodeKind::MutateProto) || node->isKind(ParseNodeKind::PropertyDefinition) || node->isKind(ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread)"
")"); do { *((volatile int*)__null) = 5492; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5491 node->isKind(ParseNodeKind::Shorthand) ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(node->isKind(ParseNodeKind::MutateProto) || node->
isKind(ParseNodeKind::PropertyDefinition) || node->isKind(
ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread
))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(node->isKind(ParseNodeKind::MutateProto) || node->
isKind(ParseNodeKind::PropertyDefinition) || node->isKind(
ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("node->isKind(ParseNodeKind::MutateProto) || node->isKind(ParseNodeKind::PropertyDefinition) || node->isKind(ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5492); AnnotateMozCrashReason("MOZ_ASSERT" "(" "node->isKind(ParseNodeKind::MutateProto) || node->isKind(ParseNodeKind::PropertyDefinition) || node->isKind(ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread)"
")"); do { *((volatile int*)__null) = 5492; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5492 node->isKind(ParseNodeKind::Spread))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(node->isKind(ParseNodeKind::MutateProto) || node->
isKind(ParseNodeKind::PropertyDefinition) || node->isKind(
ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread
))>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(node->isKind(ParseNodeKind::MutateProto) || node->
isKind(ParseNodeKind::PropertyDefinition) || node->isKind(
ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("node->isKind(ParseNodeKind::MutateProto) || node->isKind(ParseNodeKind::PropertyDefinition) || node->isKind(ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5492); AnnotateMozCrashReason("MOZ_ASSERT" "(" "node->isKind(ParseNodeKind::MutateProto) || node->isKind(ParseNodeKind::PropertyDefinition) || node->isKind(ParseNodeKind::Shorthand) || node->isKind(ParseNodeKind::Spread)"
")"); do { *((volatile int*)__null) = 5492; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5493
5494 ParseNode* target;
5495 if (node->isKind(ParseNodeKind::Spread)) {
5496 target = node->as<UnaryNode>().kid();
5497 } else {
5498 if (node->isKind(ParseNodeKind::MutateProto)) {
5499 target = node->as<UnaryNode>().kid();
5500 } else {
5501 target = node->as<BinaryNode>().right();
5502 }
5503
5504 if (target->isKind(ParseNodeKind::AssignExpr)) {
5505 target = target->as<AssignmentNode>().left();
5506 }
5507 }
5508
5509 if (!checkExportedNamesForDeclaration(target)) {
5510 return false;
5511 }
5512 }
5513
5514 return true;
5515}
5516
5517template <typename Unit>
5518inline bool Parser<SyntaxParseHandler,
5519 Unit>::checkExportedNamesForObjectBinding(ListNodeType obj) {
5520 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5520); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5520; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5521 return false;
5522}
5523
5524template <class ParseHandler, typename Unit>
5525inline bool
5526GeneralParser<ParseHandler, Unit>::checkExportedNamesForObjectBinding(
5527 ListNodeType obj) {
5528 return asFinalParser()->checkExportedNamesForObjectBinding(obj);
5529}
5530
5531template <typename Unit>
5532bool Parser<FullParseHandler, Unit>::checkExportedNamesForDeclaration(
5533 ParseNode* node) {
5534 if (node->isKind(ParseNodeKind::Name)) {
5535 if (!checkExportedName(node->as<NameNode>().atom())) {
5536 return false;
5537 }
5538 } else if (node->isKind(ParseNodeKind::ArrayExpr)) {
5539 if (!checkExportedNamesForArrayBinding(&node->as<ListNode>())) {
5540 return false;
5541 }
5542 } else {
5543 MOZ_ASSERT(node->isKind(ParseNodeKind::ObjectExpr))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(node->isKind(ParseNodeKind::ObjectExpr))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(node->isKind(ParseNodeKind::ObjectExpr)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("node->isKind(ParseNodeKind::ObjectExpr)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5543); AnnotateMozCrashReason("MOZ_ASSERT" "(" "node->isKind(ParseNodeKind::ObjectExpr)"
")"); do { *((volatile int*)__null) = 5543; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5544 if (!checkExportedNamesForObjectBinding(&node->as<ListNode>())) {
5545 return false;
5546 }
5547 }
5548
5549 return true;
5550}
5551
5552template <typename Unit>
5553inline bool Parser<SyntaxParseHandler, Unit>::checkExportedNamesForDeclaration(
5554 Node node) {
5555 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5555); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5555; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5556 return false;
5557}
5558
5559template <class ParseHandler, typename Unit>
5560inline bool GeneralParser<ParseHandler, Unit>::checkExportedNamesForDeclaration(
5561 Node node) {
5562 return asFinalParser()->checkExportedNamesForDeclaration(node);
5563}
5564
5565template <typename Unit>
5566bool Parser<FullParseHandler, Unit>::checkExportedNamesForDeclarationList(
5567 DeclarationListNodeType node) {
5568 for (ParseNode* binding : node->contents()) {
5569 if (binding->isKind(ParseNodeKind::AssignExpr)) {
5570 binding = binding->as<AssignmentNode>().left();
5571 } else {
5572 MOZ_ASSERT(binding->isKind(ParseNodeKind::Name))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(binding->isKind(ParseNodeKind::Name))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(binding->isKind(ParseNodeKind::Name)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("binding->isKind(ParseNodeKind::Name)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5572); AnnotateMozCrashReason("MOZ_ASSERT" "(" "binding->isKind(ParseNodeKind::Name)"
")"); do { *((volatile int*)__null) = 5572; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5573 }
5574
5575 if (!checkExportedNamesForDeclaration(binding)) {
5576 return false;
5577 }
5578 }
5579
5580 return true;
5581}
5582
5583template <typename Unit>
5584inline bool
5585Parser<SyntaxParseHandler, Unit>::checkExportedNamesForDeclarationList(
5586 DeclarationListNodeType node) {
5587 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5587); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5587; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5588 return false;
5589}
5590
5591template <class ParseHandler, typename Unit>
5592inline bool
5593GeneralParser<ParseHandler, Unit>::checkExportedNamesForDeclarationList(
5594 DeclarationListNodeType node) {
5595 return asFinalParser()->checkExportedNamesForDeclarationList(node);
5596}
5597
5598template <typename Unit>
5599inline bool Parser<FullParseHandler, Unit>::checkExportedNameForClause(
5600 NameNode* nameNode) {
5601 return checkExportedName(nameNode->atom());
5602}
5603
5604template <typename Unit>
5605inline bool Parser<SyntaxParseHandler, Unit>::checkExportedNameForClause(
5606 NameNodeType nameNode) {
5607 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5607); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5607; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5608 return false;
5609}
5610
5611template <class ParseHandler, typename Unit>
5612inline bool GeneralParser<ParseHandler, Unit>::checkExportedNameForClause(
5613 NameNodeType nameNode) {
5614 return asFinalParser()->checkExportedNameForClause(nameNode);
5615}
5616
5617template <typename Unit>
5618bool Parser<FullParseHandler, Unit>::checkExportedNameForFunction(
5619 FunctionNode* funNode) {
5620 return checkExportedName(funNode->funbox()->explicitName());
5621}
5622
5623template <typename Unit>
5624inline bool Parser<SyntaxParseHandler, Unit>::checkExportedNameForFunction(
5625 FunctionNodeType funNode) {
5626 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5626); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5626; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5627 return false;
5628}
5629
5630template <class ParseHandler, typename Unit>
5631inline bool GeneralParser<ParseHandler, Unit>::checkExportedNameForFunction(
5632 FunctionNodeType funNode) {
5633 return asFinalParser()->checkExportedNameForFunction(funNode);
5634}
5635
5636template <typename Unit>
5637bool Parser<FullParseHandler, Unit>::checkExportedNameForClass(
5638 ClassNode* classNode) {
5639 MOZ_ASSERT(classNode->names())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(classNode->names())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(classNode->names()))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("classNode->names()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5639); AnnotateMozCrashReason("MOZ_ASSERT" "(" "classNode->names()"
")"); do { *((volatile int*)__null) = 5639; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5640 return checkExportedName(classNode->names()->innerBinding()->atom());
5641}
5642
5643template <typename Unit>
5644inline bool Parser<SyntaxParseHandler, Unit>::checkExportedNameForClass(
5645 ClassNodeType classNode) {
5646 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5646); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5646; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5647 return false;
5648}
5649
5650template <class ParseHandler, typename Unit>
5651inline bool GeneralParser<ParseHandler, Unit>::checkExportedNameForClass(
5652 ClassNodeType classNode) {
5653 return asFinalParser()->checkExportedNameForClass(classNode);
5654}
5655
5656template <>
5657inline bool PerHandlerParser<FullParseHandler>::processExport(ParseNode* node) {
5658 return pc_->sc()->asModuleContext()->builder.processExport(node);
5659}
5660
5661template <>
5662inline bool PerHandlerParser<SyntaxParseHandler>::processExport(Node node) {
5663 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5663); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5663; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5664 return false;
5665}
5666
5667template <>
5668inline bool PerHandlerParser<FullParseHandler>::processExportFrom(
5669 BinaryNodeType node) {
5670 return pc_->sc()->asModuleContext()->builder.processExportFrom(node);
5671}
5672
5673template <>
5674inline bool PerHandlerParser<SyntaxParseHandler>::processExportFrom(
5675 BinaryNodeType node) {
5676 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5676); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5676; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5677 return false;
5678}
5679
5680template <>
5681inline bool PerHandlerParser<FullParseHandler>::processImport(
5682 BinaryNodeType node) {
5683 return pc_->sc()->asModuleContext()->builder.processImport(node);
5684}
5685
5686template <>
5687inline bool PerHandlerParser<SyntaxParseHandler>::processImport(
5688 BinaryNodeType node) {
5689 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5689); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5689; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5690 return false;
5691}
5692
5693template <class ParseHandler, typename Unit>
5694typename ParseHandler::BinaryNodeResult
5695GeneralParser<ParseHandler, Unit>::exportFrom(uint32_t begin, Node specList) {
5696 if (!abortIfSyntaxParser()) {
5697 return errorResult();
5698 }
5699
5700 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::From))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::From))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::From)))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::From)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5700); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::From)"
")"); do { *((volatile int*)__null) = 5700; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5701
5702 if (!mustMatchToken(TokenKind::String, JSMSG_MODULE_SPEC_AFTER_FROM)) {
5703 return errorResult();
5704 }
5705
5706 NameNodeType moduleSpec;
5707 MOZ_TRY_VAR(moduleSpec, stringLiteral())do { auto mozTryVarTempResult_ = (stringLiteral()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (moduleSpec) = mozTryVarTempResult_.unwrap
(); } while (0)
;
5708
5709 TokenKind tt;
5710
5711 // The `assert` keyword has a [no LineTerminator here] production before it in
5712 // the grammar -- `with` does not. We need to handle this distinction.
5713 if (!tokenStream.peekTokenSameLine(&tt, TokenStream::SlashIsRegExp)) {
5714 return errorResult();
5715 }
5716
5717 // `with` may have an EOL prior, so peek the next token and replace
5718 // EOL if the next token is `with`.
5719 if (tt == TokenKind::Eol) {
5720 // Doing a regular peek won't produce Eol, but the actual next token.
5721 TokenKind peekedToken;
5722 if (!tokenStream.peekToken(&peekedToken, TokenStream::SlashIsRegExp)) {
5723 return errorResult();
5724 }
5725
5726 if (peekedToken == TokenKind::With) {
5727 tt = TokenKind::With;
5728 }
5729 }
5730
5731 uint32_t moduleSpecPos = pos().begin;
5732
5733 ListNodeType importAttributeList;
5734 MOZ_TRY_VAR(importAttributeList,do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::ImportAttributeList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importAttributeList) = mozTryVarTempResult_.unwrap(); } while
(0)
5735 handler_.newList(ParseNodeKind::ImportAttributeList, pos()))do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::ImportAttributeList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (importAttributeList) = mozTryVarTempResult_.unwrap(); } while
(0)
;
5736 if (tt == TokenKind::With ||
5737 (tt == TokenKind::Assert && options().importAttributesAssertSyntax())) {
5738 tokenStream.consumeKnownToken(tt, TokenStream::SlashIsRegExp);
5739
5740 if (!withClause(importAttributeList)) {
5741 return errorResult();
5742 }
5743 }
5744
5745 if (!matchOrInsertSemicolon(TokenStream::SlashIsRegExp)) {
5746 return errorResult();
5747 }
5748
5749 BinaryNodeType moduleRequest;
5750 MOZ_TRY_VAR(moduleRequest,do { auto mozTryVarTempResult_ = (handler_.newModuleRequest(moduleSpec
, importAttributeList, TokenPos(moduleSpecPos, pos().end))); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (moduleRequest) = mozTryVarTempResult_
.unwrap(); } while (0)
5751 handler_.newModuleRequest(moduleSpec, importAttributeList,do { auto mozTryVarTempResult_ = (handler_.newModuleRequest(moduleSpec
, importAttributeList, TokenPos(moduleSpecPos, pos().end))); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (moduleRequest) = mozTryVarTempResult_
.unwrap(); } while (0)
5752 TokenPos(moduleSpecPos, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newModuleRequest(moduleSpec
, importAttributeList, TokenPos(moduleSpecPos, pos().end))); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (moduleRequest) = mozTryVarTempResult_
.unwrap(); } while (0)
;
5753
5754 BinaryNodeType node;
5755 MOZ_TRY_VAR(do { auto mozTryVarTempResult_ = (handler_.newExportFromDeclaration
(begin, specList, moduleRequest)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (node) = mozTryVarTempResult_.unwrap(); } while (0)
5756 node, handler_.newExportFromDeclaration(begin, specList, moduleRequest))do { auto mozTryVarTempResult_ = (handler_.newExportFromDeclaration
(begin, specList, moduleRequest)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (node) = mozTryVarTempResult_.unwrap(); } while (0)
;
5757
5758 if (!processExportFrom(node)) {
5759 return errorResult();
5760 }
5761
5762 return node;
5763}
5764
5765template <class ParseHandler, typename Unit>
5766typename ParseHandler::BinaryNodeResult
5767GeneralParser<ParseHandler, Unit>::exportBatch(uint32_t begin) {
5768 if (!abortIfSyntaxParser()) {
5769 return errorResult();
5770 }
5771
5772 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Mul))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Mul))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::Mul)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Mul)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5772); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Mul)"
")"); do { *((volatile int*)__null) = 5772; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5773 uint32_t beginExportSpec = pos().begin;
5774
5775 ListNodeType kid;
5776 MOZ_TRY_VAR(kid, handler_.newList(ParseNodeKind::ExportSpecList, pos()))do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::ExportSpecList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
;
5777
5778 bool foundAs;
5779 if (!tokenStream.matchToken(&foundAs, TokenKind::As)) {
5780 return errorResult();
5781 }
5782
5783 if (foundAs) {
5784 TokenKind tt;
5785 if (!tokenStream.getToken(&tt)) {
5786 return errorResult();
5787 }
5788
5789 NameNodeType exportName = null();
5790 if (TokenKindIsPossibleIdentifierName(tt)) {
5791 MOZ_TRY_VAR(exportName, newName(anyChars.currentName()))do { auto mozTryVarTempResult_ = (newName(anyChars.currentName
())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()),
0))) { return mozTryVarTempResult_.propagateErr(); } (exportName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
5792 } else if (tt == TokenKind::String) {
5793 MOZ_TRY_VAR(exportName, moduleExportName())do { auto mozTryVarTempResult_ = (moduleExportName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (exportName) = mozTryVarTempResult_.unwrap
(); } while (0)
;
5794 } else {
5795 error(JSMSG_NO_EXPORT_NAME);
5796 return errorResult();
5797 }
5798
5799 if (!checkExportedNameForClause(exportName)) {
5800 return errorResult();
5801 }
5802
5803 UnaryNodeType exportSpec;
5804 MOZ_TRY_VAR(exportSpec,do { auto mozTryVarTempResult_ = (handler_.newExportNamespaceSpec
(beginExportSpec, exportName)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exportSpec) = mozTryVarTempResult_.unwrap(); } while (0)
5805 handler_.newExportNamespaceSpec(beginExportSpec, exportName))do { auto mozTryVarTempResult_ = (handler_.newExportNamespaceSpec
(beginExportSpec, exportName)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exportSpec) = mozTryVarTempResult_.unwrap(); } while (0)
;
5806
5807 handler_.addList(kid, exportSpec);
5808 } else {
5809 // Handle the form |export *| by adding a special export batch
5810 // specifier to the list.
5811 NullaryNodeType exportSpec;
5812 MOZ_TRY_VAR(exportSpec, handler_.newExportBatchSpec(pos()))do { auto mozTryVarTempResult_ = (handler_.newExportBatchSpec
(pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (exportSpec
) = mozTryVarTempResult_.unwrap(); } while (0)
;
5813
5814 handler_.addList(kid, exportSpec);
5815 }
5816
5817 if (!mustMatchToken(TokenKind::From, JSMSG_FROM_AFTER_EXPORT_STAR)) {
5818 return errorResult();
5819 }
5820
5821 return exportFrom(begin, kid);
5822}
5823
5824template <typename Unit>
5825bool Parser<FullParseHandler, Unit>::checkLocalExportNames(ListNode* node) {
5826 // ES 2017 draft 15.2.3.1.
5827 for (ParseNode* next : node->contents()) {
5828 ParseNode* name = next->as<BinaryNode>().left();
5829
5830 if (name->isKind(ParseNodeKind::StringExpr)) {
5831 errorAt(name->pn_pos.begin, JSMSG_BAD_LOCAL_STRING_EXPORT);
5832 return false;
5833 }
5834
5835 MOZ_ASSERT(name->isKind(ParseNodeKind::Name))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(name->isKind(ParseNodeKind::Name))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(name->isKind(ParseNodeKind
::Name)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("name->isKind(ParseNodeKind::Name)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5835); AnnotateMozCrashReason("MOZ_ASSERT" "(" "name->isKind(ParseNodeKind::Name)"
")"); do { *((volatile int*)__null) = 5835; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5836
5837 TaggedParserAtomIndex ident = name->as<NameNode>().atom();
5838 if (!checkLocalExportName(ident, name->pn_pos.begin)) {
5839 return false;
5840 }
5841 }
5842
5843 return true;
5844}
5845
5846template <typename Unit>
5847bool Parser<SyntaxParseHandler, Unit>::checkLocalExportNames(
5848 ListNodeType node) {
5849 MOZ_ALWAYS_FALSE(abortIfSyntaxParser())do { if ((__builtin_expect(!!(!(abortIfSyntaxParser())), 1)))
{ } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "!(abortIfSyntaxParser())"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5849); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "!(abortIfSyntaxParser())" ")"); do { *((volatile int*
)__null) = 5849; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false); } } while (false)
;
5850 return false;
5851}
5852
5853template <class ParseHandler, typename Unit>
5854inline bool GeneralParser<ParseHandler, Unit>::checkLocalExportNames(
5855 ListNodeType node) {
5856 return asFinalParser()->checkLocalExportNames(node);
5857}
5858
5859template <class ParseHandler, typename Unit>
5860typename ParseHandler::NodeResult
5861GeneralParser<ParseHandler, Unit>::exportClause(uint32_t begin) {
5862 if (!abortIfSyntaxParser()) {
5863 return errorResult();
5864 }
5865
5866 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftCurly))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftCurly))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftCurly))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5866); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
")"); do { *((volatile int*)__null) = 5866; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5867
5868 ListNodeType kid;
5869 MOZ_TRY_VAR(kid, handler_.newList(ParseNodeKind::ExportSpecList, pos()))do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::ExportSpecList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
;
5870
5871 TokenKind tt;
5872 while (true) {
5873 // Handle the forms |export {}| and |export { ..., }| (where ... is non
5874 // empty), by escaping the loop early if the next token is }.
5875 if (!tokenStream.getToken(&tt)) {
5876 return errorResult();
5877 }
5878
5879 if (tt == TokenKind::RightCurly) {
5880 break;
5881 }
5882
5883 NameNodeType bindingName = null();
5884 if (TokenKindIsPossibleIdentifierName(tt)) {
5885 MOZ_TRY_VAR(bindingName, newName(anyChars.currentName()))do { auto mozTryVarTempResult_ = (newName(anyChars.currentName
())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()),
0))) { return mozTryVarTempResult_.propagateErr(); } (bindingName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
5886 } else if (tt == TokenKind::String) {
5887 MOZ_TRY_VAR(bindingName, moduleExportName())do { auto mozTryVarTempResult_ = (moduleExportName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (bindingName) = mozTryVarTempResult_.unwrap
(); } while (0)
;
5888 } else {
5889 error(JSMSG_NO_BINDING_NAME);
5890 return errorResult();
5891 }
5892
5893 bool foundAs;
5894 if (!tokenStream.matchToken(&foundAs, TokenKind::As)) {
5895 return errorResult();
5896 }
5897
5898 NameNodeType exportName = null();
5899 if (foundAs) {
5900 TokenKind tt;
5901 if (!tokenStream.getToken(&tt)) {
5902 return errorResult();
5903 }
5904
5905 if (TokenKindIsPossibleIdentifierName(tt)) {
5906 MOZ_TRY_VAR(exportName, newName(anyChars.currentName()))do { auto mozTryVarTempResult_ = (newName(anyChars.currentName
())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()),
0))) { return mozTryVarTempResult_.propagateErr(); } (exportName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
5907 } else if (tt == TokenKind::String) {
5908 MOZ_TRY_VAR(exportName, moduleExportName())do { auto mozTryVarTempResult_ = (moduleExportName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (exportName) = mozTryVarTempResult_.unwrap
(); } while (0)
;
5909 } else {
5910 error(JSMSG_NO_EXPORT_NAME);
5911 return errorResult();
5912 }
5913 } else {
5914 if (tt != TokenKind::String) {
5915 MOZ_TRY_VAR(exportName, newName(anyChars.currentName()))do { auto mozTryVarTempResult_ = (newName(anyChars.currentName
())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()),
0))) { return mozTryVarTempResult_.propagateErr(); } (exportName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
5916 } else {
5917 MOZ_TRY_VAR(exportName, moduleExportName())do { auto mozTryVarTempResult_ = (moduleExportName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (exportName) = mozTryVarTempResult_.unwrap
(); } while (0)
;
5918 }
5919 }
5920
5921 if (!checkExportedNameForClause(exportName)) {
5922 return errorResult();
5923 }
5924
5925 BinaryNodeType exportSpec;
5926 MOZ_TRY_VAR(exportSpec, handler_.newExportSpec(bindingName, exportName))do { auto mozTryVarTempResult_ = (handler_.newExportSpec(bindingName
, exportName)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exportSpec) = mozTryVarTempResult_.unwrap(); } while (0)
;
5927
5928 handler_.addList(kid, exportSpec);
5929
5930 TokenKind next;
5931 if (!tokenStream.getToken(&next)) {
5932 return errorResult();
5933 }
5934
5935 if (next == TokenKind::RightCurly) {
5936 break;
5937 }
5938
5939 if (next != TokenKind::Comma) {
5940 error(JSMSG_RC_AFTER_EXPORT_SPEC_LIST);
5941 return errorResult();
5942 }
5943 }
5944
5945 // Careful! If |from| follows, even on a new line, it must start a
5946 // FromClause:
5947 //
5948 // export { x }
5949 // from "foo"; // a single ExportDeclaration
5950 //
5951 // But if it doesn't, we might have an ASI opportunity in SlashIsRegExp
5952 // context:
5953 //
5954 // export { x } // ExportDeclaration, terminated by ASI
5955 // fro\u006D // ExpressionStatement, the name "from"
5956 //
5957 // In that case let matchOrInsertSemicolon sort out ASI or any necessary
5958 // error.
5959 bool matched;
5960 if (!tokenStream.matchToken(&matched, TokenKind::From,
5961 TokenStream::SlashIsRegExp)) {
5962 return errorResult();
5963 }
5964
5965 if (matched) {
5966 return exportFrom(begin, kid);
5967 }
5968
5969 if (!matchOrInsertSemicolon()) {
5970 return errorResult();
5971 }
5972
5973 if (!checkLocalExportNames(kid)) {
5974 return errorResult();
5975 }
5976
5977 UnaryNodeType node;
5978 MOZ_TRY_VAR(node,do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
5979 handler_.newExportDeclaration(kid, TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
;
5980
5981 if (!processExport(node)) {
5982 return errorResult();
5983 }
5984
5985 return node;
5986}
5987
5988template <class ParseHandler, typename Unit>
5989typename ParseHandler::UnaryNodeResult
5990GeneralParser<ParseHandler, Unit>::exportVariableStatement(uint32_t begin) {
5991 if (!abortIfSyntaxParser()) {
5992 return errorResult();
5993 }
5994
5995 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Var))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Var))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::Var)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Var)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 5995); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Var)"
")"); do { *((volatile int*)__null) = 5995; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5996
5997 DeclarationListNodeType kid;
5998 MOZ_TRY_VAR(kid, declarationList(YieldIsName, ParseNodeKind::VarStmt))do { auto mozTryVarTempResult_ = (declarationList(YieldIsName
, ParseNodeKind::VarStmt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
;
5999 if (!matchOrInsertSemicolon()) {
6000 return errorResult();
6001 }
6002 if (!checkExportedNamesForDeclarationList(kid)) {
6003 return errorResult();
6004 }
6005
6006 UnaryNodeType node;
6007 MOZ_TRY_VAR(node,do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
6008 handler_.newExportDeclaration(kid, TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6009
6010 if (!processExport(node)) {
6011 return errorResult();
6012 }
6013
6014 return node;
6015}
6016
6017template <class ParseHandler, typename Unit>
6018typename ParseHandler::UnaryNodeResult
6019GeneralParser<ParseHandler, Unit>::exportFunctionDeclaration(
6020 uint32_t begin, uint32_t toStringStart,
6021 FunctionAsyncKind asyncKind /* = SyncFunction */) {
6022 if (!abortIfSyntaxParser()) {
6023 return errorResult();
6024 }
6025
6026 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Function))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Function))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Function)))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Function)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6026); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Function)"
")"); do { *((volatile int*)__null) = 6026; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6027
6028 Node kid;
6029 MOZ_TRY_VAR(do { auto mozTryVarTempResult_ = (functionStmt(toStringStart,
YieldIsName, NameRequired, asyncKind)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (kid) = mozTryVarTempResult_.unwrap(); } while
(0)
6030 kid, functionStmt(toStringStart, YieldIsName, NameRequired, asyncKind))do { auto mozTryVarTempResult_ = (functionStmt(toStringStart,
YieldIsName, NameRequired, asyncKind)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (kid) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6031
6032 if (!checkExportedNameForFunction(handler_.asFunctionNode(kid))) {
6033 return errorResult();
6034 }
6035
6036 UnaryNodeType node;
6037 MOZ_TRY_VAR(node,do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
6038 handler_.newExportDeclaration(kid, TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6039
6040 if (!processExport(node)) {
6041 return errorResult();
6042 }
6043
6044 return node;
6045}
6046
6047template <class ParseHandler, typename Unit>
6048typename ParseHandler::UnaryNodeResult
6049GeneralParser<ParseHandler, Unit>::exportClassDeclaration(uint32_t begin) {
6050 if (!abortIfSyntaxParser()) {
6051 return errorResult();
6052 }
6053
6054 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Class))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Class))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Class)))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Class)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6054); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Class)"
")"); do { *((volatile int*)__null) = 6054; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6055
6056 ClassNodeType kid;
6057 MOZ_TRY_VAR(kid, classDefinition(YieldIsName, ClassStatement, NameRequired))do { auto mozTryVarTempResult_ = (classDefinition(YieldIsName
, ClassStatement, NameRequired)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
;
6058
6059 if (!checkExportedNameForClass(kid)) {
6060 return errorResult();
6061 }
6062
6063 UnaryNodeType node;
6064 MOZ_TRY_VAR(node,do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
6065 handler_.newExportDeclaration(kid, TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6066
6067 if (!processExport(node)) {
6068 return errorResult();
6069 }
6070
6071 return node;
6072}
6073
6074template <class ParseHandler, typename Unit>
6075typename ParseHandler::UnaryNodeResult
6076GeneralParser<ParseHandler, Unit>::exportLexicalDeclaration(
6077 uint32_t begin, DeclarationKind kind) {
6078 if (!abortIfSyntaxParser()) {
6079 return errorResult();
6080 }
6081
6082 MOZ_ASSERT(kind == DeclarationKind::Const || kind == DeclarationKind::Let)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(kind == DeclarationKind::Const || kind == DeclarationKind
::Let)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(kind == DeclarationKind::Const || kind == DeclarationKind
::Let))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("kind == DeclarationKind::Const || kind == DeclarationKind::Let"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6082); AnnotateMozCrashReason("MOZ_ASSERT" "(" "kind == DeclarationKind::Const || kind == DeclarationKind::Let"
")"); do { *((volatile int*)__null) = 6082; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6083 MOZ_ASSERT_IF(kind == DeclarationKind::Const,do { if (kind == DeclarationKind::Const) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(anyChars
.isCurrentTokenType(TokenKind::Const))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::Const)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::Const)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6084); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Const)"
")"); do { *((volatile int*)__null) = 6084; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
6084 anyChars.isCurrentTokenType(TokenKind::Const))do { if (kind == DeclarationKind::Const) { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(anyChars
.isCurrentTokenType(TokenKind::Const))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::Const)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::Const)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6084); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Const)"
")"); do { *((volatile int*)__null) = 6084; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
6085 MOZ_ASSERT_IF(kind == DeclarationKind::Let,do { if (kind == DeclarationKind::Let) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(anyChars.isCurrentTokenType
(TokenKind::Let))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::Let)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::Let)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6086); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Let)"
")"); do { *((volatile int*)__null) = 6086; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
6086 anyChars.isCurrentTokenType(TokenKind::Let))do { if (kind == DeclarationKind::Let) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(anyChars.isCurrentTokenType
(TokenKind::Let))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::Let)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::Let)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6086); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Let)"
")"); do { *((volatile int*)__null) = 6086; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
6087
6088 DeclarationListNodeType kid;
6089 MOZ_TRY_VAR(kid, lexicalDeclaration(YieldIsName, kind))do { auto mozTryVarTempResult_ = (lexicalDeclaration(YieldIsName
, kind)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (kid
) = mozTryVarTempResult_.unwrap(); } while (0)
;
6090 if (!checkExportedNamesForDeclarationList(kid)) {
6091 return errorResult();
6092 }
6093
6094 UnaryNodeType node;
6095 MOZ_TRY_VAR(node,do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
6096 handler_.newExportDeclaration(kid, TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newExportDeclaration
(kid, TokenPos(begin, pos().end))); if ((__builtin_expect(!!(
mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6097
6098 if (!processExport(node)) {
6099 return errorResult();
6100 }
6101
6102 return node;
6103}
6104
6105template <class ParseHandler, typename Unit>
6106typename ParseHandler::BinaryNodeResult
6107GeneralParser<ParseHandler, Unit>::exportDefaultFunctionDeclaration(
6108 uint32_t begin, uint32_t toStringStart,
6109 FunctionAsyncKind asyncKind /* = SyncFunction */) {
6110 if (!abortIfSyntaxParser()) {
6111 return errorResult();
6112 }
6113
6114 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Function))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Function))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Function)))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Function)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6114); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Function)"
")"); do { *((volatile int*)__null) = 6114; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6115
6116 Node kid;
6117 MOZ_TRY_VAR(kid, functionStmt(toStringStart, YieldIsName, AllowDefaultName,do { auto mozTryVarTempResult_ = (functionStmt(toStringStart,
YieldIsName, AllowDefaultName, asyncKind)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (kid) = mozTryVarTempResult_.unwrap(); } while
(0)
6118 asyncKind))do { auto mozTryVarTempResult_ = (functionStmt(toStringStart,
YieldIsName, AllowDefaultName, asyncKind)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (kid) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6119
6120 BinaryNodeType node;
6121 MOZ_TRY_VAR(node, handler_.newExportDefaultDeclaration(do { auto mozTryVarTempResult_ = (handler_.newExportDefaultDeclaration
( kid, null(), TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
6122 kid, null(), TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newExportDefaultDeclaration
( kid, null(), TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6123
6124 if (!processExport(node)) {
6125 return errorResult();
6126 }
6127
6128 return node;
6129}
6130
6131template <class ParseHandler, typename Unit>
6132typename ParseHandler::BinaryNodeResult
6133GeneralParser<ParseHandler, Unit>::exportDefaultClassDeclaration(
6134 uint32_t begin) {
6135 if (!abortIfSyntaxParser()) {
6136 return errorResult();
6137 }
6138
6139 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Class))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Class))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Class)))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Class)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6139); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Class)"
")"); do { *((volatile int*)__null) = 6139; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6140
6141 ClassNodeType kid;
6142 MOZ_TRY_VAR(kid,do { auto mozTryVarTempResult_ = (classDefinition(YieldIsName
, ClassStatement, AllowDefaultName)); if ((__builtin_expect(!
!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (kid) = mozTryVarTempResult_.unwrap(); } while
(0)
6143 classDefinition(YieldIsName, ClassStatement, AllowDefaultName))do { auto mozTryVarTempResult_ = (classDefinition(YieldIsName
, ClassStatement, AllowDefaultName)); if ((__builtin_expect(!
!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (kid) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6144
6145 BinaryNodeType node;
6146 MOZ_TRY_VAR(node, handler_.newExportDefaultDeclaration(do { auto mozTryVarTempResult_ = (handler_.newExportDefaultDeclaration
( kid, null(), TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
6147 kid, null(), TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newExportDefaultDeclaration
( kid, null(), TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6148
6149 if (!processExport(node)) {
6150 return errorResult();
6151 }
6152
6153 return node;
6154}
6155
6156template <class ParseHandler, typename Unit>
6157typename ParseHandler::BinaryNodeResult
6158GeneralParser<ParseHandler, Unit>::exportDefaultAssignExpr(uint32_t begin) {
6159 if (!abortIfSyntaxParser()) {
6160 return errorResult();
6161 }
6162
6163 TaggedParserAtomIndex name = TaggedParserAtomIndex::WellKnown::default_();
6164 NameNodeType nameNode;
6165 MOZ_TRY_VAR(nameNode, newName(name))do { auto mozTryVarTempResult_ = (newName(name)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (nameNode) = mozTryVarTempResult_.unwrap()
; } while (0)
;
6166 if (!noteDeclaredName(name, DeclarationKind::Const, pos())) {
6167 return errorResult();
6168 }
6169
6170 Node kid;
6171 MOZ_TRY_VAR(kid, assignExpr(InAllowed, YieldIsName, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, YieldIsName
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
;
6172
6173 if (!matchOrInsertSemicolon()) {
6174 return errorResult();
6175 }
6176
6177 BinaryNodeType node;
6178 MOZ_TRY_VAR(node, handler_.newExportDefaultDeclaration(do { auto mozTryVarTempResult_ = (handler_.newExportDefaultDeclaration
( kid, nameNode, TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
6179 kid, nameNode, TokenPos(begin, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newExportDefaultDeclaration
( kid, nameNode, TokenPos(begin, pos().end))); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (node) = mozTryVarTempResult_.unwrap(); } while
(0)
;
6180
6181 if (!processExport(node)) {
6182 return errorResult();
6183 }
6184
6185 return node;
6186}
6187
6188template <class ParseHandler, typename Unit>
6189typename ParseHandler::BinaryNodeResult
6190GeneralParser<ParseHandler, Unit>::exportDefault(uint32_t begin) {
6191 if (!abortIfSyntaxParser()) {
6192 return errorResult();
6193 }
6194
6195 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Default))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Default))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Default)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Default)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6195); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Default)"
")"); do { *((volatile int*)__null) = 6195; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6196
6197 TokenKind tt;
6198 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
6199 return errorResult();
6200 }
6201
6202 if (!checkExportedName(TaggedParserAtomIndex::WellKnown::default_())) {
6203 return errorResult();
6204 }
6205
6206 switch (tt) {
6207 case TokenKind::Function:
6208 return exportDefaultFunctionDeclaration(begin, pos().begin);
6209
6210 case TokenKind::Async: {
6211 TokenKind nextSameLine = TokenKind::Eof;
6212 if (!tokenStream.peekTokenSameLine(&nextSameLine)) {
6213 return errorResult();
6214 }
6215
6216 if (nextSameLine == TokenKind::Function) {
6217 uint32_t toStringStart = pos().begin;
6218 tokenStream.consumeKnownToken(TokenKind::Function);
6219 return exportDefaultFunctionDeclaration(
6220 begin, toStringStart, FunctionAsyncKind::AsyncFunction);
6221 }
6222
6223 anyChars.ungetToken();
6224 return exportDefaultAssignExpr(begin);
6225 }
6226
6227 case TokenKind::Class:
6228 return exportDefaultClassDeclaration(begin);
6229
6230 default:
6231 anyChars.ungetToken();
6232 return exportDefaultAssignExpr(begin);
6233 }
6234}
6235
6236template <class ParseHandler, typename Unit>
6237typename ParseHandler::NodeResult
6238GeneralParser<ParseHandler, Unit>::exportDeclaration() {
6239 if (!abortIfSyntaxParser()) {
6240 return errorResult();
6241 }
6242
6243 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Export))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Export))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Export)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Export)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6243); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Export)"
")"); do { *((volatile int*)__null) = 6243; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6244
6245 if (!pc_->atModuleLevel()) {
6246 error(JSMSG_EXPORT_DECL_AT_TOP_LEVEL);
6247 return errorResult();
6248 }
6249
6250 uint32_t begin = pos().begin;
6251
6252 TokenKind tt;
6253 if (!tokenStream.getToken(&tt)) {
6254 return errorResult();
6255 }
6256 switch (tt) {
6257 case TokenKind::Mul:
6258 return exportBatch(begin);
6259
6260 case TokenKind::LeftCurly:
6261 return exportClause(begin);
6262
6263 case TokenKind::Var:
6264 return exportVariableStatement(begin);
6265
6266 case TokenKind::Function:
6267 return exportFunctionDeclaration(begin, pos().begin);
6268
6269 case TokenKind::Async: {
6270 TokenKind nextSameLine = TokenKind::Eof;
6271 if (!tokenStream.peekTokenSameLine(&nextSameLine)) {
6272 return errorResult();
6273 }
6274
6275 if (nextSameLine == TokenKind::Function) {
6276 uint32_t toStringStart = pos().begin;
6277 tokenStream.consumeKnownToken(TokenKind::Function);
6278 return exportFunctionDeclaration(begin, toStringStart,
6279 FunctionAsyncKind::AsyncFunction);
6280 }
6281
6282 error(JSMSG_DECLARATION_AFTER_EXPORT);
6283 return errorResult();
6284 }
6285
6286 case TokenKind::Class:
6287 return exportClassDeclaration(begin);
6288
6289 case TokenKind::Const:
6290 return exportLexicalDeclaration(begin, DeclarationKind::Const);
6291
6292 case TokenKind::Let:
6293 return exportLexicalDeclaration(begin, DeclarationKind::Let);
6294
6295 case TokenKind::Default:
6296 return exportDefault(begin);
6297
6298 default:
6299 error(JSMSG_DECLARATION_AFTER_EXPORT);
6300 return errorResult();
6301 }
6302}
6303
6304template <class ParseHandler, typename Unit>
6305typename ParseHandler::UnaryNodeResult
6306GeneralParser<ParseHandler, Unit>::expressionStatement(
6307 YieldHandling yieldHandling, InvokedPrediction invoked) {
6308 anyChars.ungetToken();
6309 Node pnexpr;
6310 MOZ_TRY_VAR(pnexpr, expr(InAllowed, yieldHandling, TripledotProhibited,do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited, nullptr, invoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (pnexpr) = mozTryVarTempResult_.unwrap(); }
while (0)
6311 /* possibleError = */ nullptr, invoked))do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited, nullptr, invoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (pnexpr) = mozTryVarTempResult_.unwrap(); }
while (0)
;
6312 if (!matchOrInsertSemicolon()) {
6313 return errorResult();
6314 }
6315 return handler_.newExprStatement(pnexpr, pos().end);
6316}
6317
6318template <class ParseHandler, typename Unit>
6319typename ParseHandler::NodeResult
6320GeneralParser<ParseHandler, Unit>::consequentOrAlternative(
6321 YieldHandling yieldHandling) {
6322 TokenKind next;
6323 if (!tokenStream.peekToken(&next, TokenStream::SlashIsRegExp)) {
6324 return errorResult();
6325 }
6326
6327 // Annex B.3.4 says that unbraced FunctionDeclarations under if/else in
6328 // non-strict code act as if they were braced: |if (x) function f() {}|
6329 // parses as |if (x) { function f() {} }|.
6330 //
6331 // Careful! FunctionDeclaration doesn't include generators or async
6332 // functions.
6333 if (next == TokenKind::Function) {
6334 tokenStream.consumeKnownToken(next, TokenStream::SlashIsRegExp);
6335
6336 // Parser::statement would handle this, but as this function handles
6337 // every other error case, it seems best to handle this.
6338 if (pc_->sc()->strict()) {
6339 error(JSMSG_FORBIDDEN_AS_STATEMENT, "function declarations");
6340 return errorResult();
6341 }
6342
6343 TokenKind maybeStar;
6344 if (!tokenStream.peekToken(&maybeStar)) {
6345 return errorResult();
6346 }
6347
6348 if (maybeStar == TokenKind::Mul) {
6349 error(JSMSG_FORBIDDEN_AS_STATEMENT, "generator declarations");
6350 return errorResult();
6351 }
6352
6353 ParseContext::Statement stmt(pc_, StatementKind::Block);
6354 ParseContext::Scope scope(this);
6355 if (!scope.init(pc_)) {
6356 return errorResult();
6357 }
6358
6359 TokenPos funcPos = pos();
6360 Node fun;
6361 MOZ_TRY_VAR(fun, functionStmt(pos().begin, yieldHandling, NameRequired))do { auto mozTryVarTempResult_ = (functionStmt(pos().begin, yieldHandling
, NameRequired)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (fun) = mozTryVarTempResult_.unwrap(); } while (0)
;
6362
6363 ListNodeType block;
6364 MOZ_TRY_VAR(block, handler_.newStatementList(funcPos))do { auto mozTryVarTempResult_ = (handler_.newStatementList(funcPos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (block) =
mozTryVarTempResult_.unwrap(); } while (0)
;
6365
6366 handler_.addStatementToList(block, fun);
6367 return finishLexicalScope(scope, block);
6368 }
6369
6370 return statement(yieldHandling);
6371}
6372
6373template <class ParseHandler, typename Unit>
6374typename ParseHandler::TernaryNodeResult
6375GeneralParser<ParseHandler, Unit>::ifStatement(YieldHandling yieldHandling) {
6376 Vector<Node, 4> condList(fc_), thenList(fc_);
6377 Vector<uint32_t, 4> posList(fc_);
6378 Node elseBranch;
6379
6380 ParseContext::Statement stmt(pc_, StatementKind::If);
6381
6382 while (true) {
6383 uint32_t begin = pos().begin;
6384
6385 /* An IF node has three kids: condition, then, and optional else. */
6386 Node cond;
6387 MOZ_TRY_VAR(cond, condition(InAllowed, yieldHandling))do { auto mozTryVarTempResult_ = (condition(InAllowed, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (cond) = mozTryVarTempResult_
.unwrap(); } while (0)
;
6388
6389 TokenKind tt;
6390 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
6391 return errorResult();
6392 }
6393
6394 Node thenBranch;
6395 MOZ_TRY_VAR(thenBranch, consequentOrAlternative(yieldHandling))do { auto mozTryVarTempResult_ = (consequentOrAlternative(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (thenBranch
) = mozTryVarTempResult_.unwrap(); } while (0)
;
6396
6397 if (!condList.append(cond) || !thenList.append(thenBranch) ||
6398 !posList.append(begin)) {
6399 return errorResult();
6400 }
6401
6402 bool matched;
6403 if (!tokenStream.matchToken(&matched, TokenKind::Else,
6404 TokenStream::SlashIsRegExp)) {
6405 return errorResult();
6406 }
6407 if (matched) {
6408 if (!tokenStream.matchToken(&matched, TokenKind::If,
6409 TokenStream::SlashIsRegExp)) {
6410 return errorResult();
6411 }
6412 if (matched) {
6413 continue;
6414 }
6415 MOZ_TRY_VAR(elseBranch, consequentOrAlternative(yieldHandling))do { auto mozTryVarTempResult_ = (consequentOrAlternative(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (elseBranch
) = mozTryVarTempResult_.unwrap(); } while (0)
;
6416 } else {
6417 elseBranch = null();
6418 }
6419 break;
6420 }
6421
6422 TernaryNodeType ifNode;
6423 for (int i = condList.length() - 1; i >= 0; i--) {
6424 MOZ_TRY_VAR(ifNode, handler_.newIfStatement(posList[i], condList[i],do { auto mozTryVarTempResult_ = (handler_.newIfStatement(posList
[i], condList[i], thenList[i], elseBranch)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (ifNode) = mozTryVarTempResult_.unwrap(); }
while (0)
6425 thenList[i], elseBranch))do { auto mozTryVarTempResult_ = (handler_.newIfStatement(posList
[i], condList[i], thenList[i], elseBranch)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (ifNode) = mozTryVarTempResult_.unwrap(); }
while (0)
;
6426 elseBranch = ifNode;
6427 }
6428
6429 return ifNode;
6430}
6431
6432template <class ParseHandler, typename Unit>
6433typename ParseHandler::BinaryNodeResult
6434GeneralParser<ParseHandler, Unit>::doWhileStatement(
6435 YieldHandling yieldHandling) {
6436 uint32_t begin = pos().begin;
6437 ParseContext::Statement stmt(pc_, StatementKind::DoLoop);
6438 Node body;
6439 MOZ_TRY_VAR(body, statement(yieldHandling))do { auto mozTryVarTempResult_ = (statement(yieldHandling)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (body) = mozTryVarTempResult_
.unwrap(); } while (0)
;
6440 if (!mustMatchToken(TokenKind::While, JSMSG_WHILE_AFTER_DO)) {
6441 return errorResult();
6442 }
6443 Node cond;
6444 MOZ_TRY_VAR(cond, condition(InAllowed, yieldHandling))do { auto mozTryVarTempResult_ = (condition(InAllowed, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (cond) = mozTryVarTempResult_
.unwrap(); } while (0)
;
6445
6446 // The semicolon after do-while is even more optional than most
6447 // semicolons in JS. Web compat required this by 2004:
6448 // http://bugzilla.mozilla.org/show_bug.cgi?id=238945
6449 // ES3 and ES5 disagreed, but ES6 conforms to Web reality:
6450 // https://bugs.ecmascript.org/show_bug.cgi?id=157
6451 // To parse |do {} while (true) false| correctly, use SlashIsRegExp.
6452 bool ignored;
6453 if (!tokenStream.matchToken(&ignored, TokenKind::Semi,
6454 TokenStream::SlashIsRegExp)) {
6455 return errorResult();
6456 }
6457 return handler_.newDoWhileStatement(body, cond, TokenPos(begin, pos().end));
6458}
6459
6460template <class ParseHandler, typename Unit>
6461typename ParseHandler::BinaryNodeResult
6462GeneralParser<ParseHandler, Unit>::whileStatement(YieldHandling yieldHandling) {
6463 uint32_t begin = pos().begin;
6464 ParseContext::Statement stmt(pc_, StatementKind::WhileLoop);
6465 Node cond;
6466 MOZ_TRY_VAR(cond, condition(InAllowed, yieldHandling))do { auto mozTryVarTempResult_ = (condition(InAllowed, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (cond) = mozTryVarTempResult_
.unwrap(); } while (0)
;
6467 Node body;
6468 MOZ_TRY_VAR(body, statement(yieldHandling))do { auto mozTryVarTempResult_ = (statement(yieldHandling)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (body) = mozTryVarTempResult_
.unwrap(); } while (0)
;
6469 return handler_.newWhileStatement(begin, cond, body);
6470}
6471
6472template <class ParseHandler, typename Unit>
6473bool GeneralParser<ParseHandler, Unit>::matchInOrOf(bool* isForInp,
6474 bool* isForOfp) {
6475 TokenKind tt;
6476 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
6477 return false;
6478 }
6479
6480 *isForInp = tt == TokenKind::In;
6481 *isForOfp = tt == TokenKind::Of;
6482 if (!*isForInp && !*isForOfp) {
6483 anyChars.ungetToken();
6484 }
6485
6486 MOZ_ASSERT_IF(*isForInp || *isForOfp, *isForInp != *isForOfp)do { if (*isForInp || *isForOfp) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(*isForInp != *isForOfp
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(*isForInp != *isForOfp))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("*isForInp != *isForOfp", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6486); AnnotateMozCrashReason("MOZ_ASSERT" "(" "*isForInp != *isForOfp"
")"); do { *((volatile int*)__null) = 6486; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
6487 return true;
6488}
6489
6490template <class ParseHandler, typename Unit>
6491bool GeneralParser<ParseHandler, Unit>::forHeadStart(
6492 YieldHandling yieldHandling, IteratorKind iterKind,
6493 ParseNodeKind* forHeadKind, Node* forInitialPart,
6494 Maybe<ParseContext::Scope>& forLoopLexicalScope,
6495 Node* forInOrOfExpression) {
6496 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftParen))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftParen))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftParen))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftParen)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6496); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftParen)"
")"); do { *((volatile int*)__null) = 6496; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6497
6498 TokenKind tt;
6499 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
6500 return false;
6501 }
6502
6503 // Super-duper easy case: |for (;| is a C-style for-loop with no init
6504 // component.
6505 if (tt == TokenKind::Semi) {
6506 *forInitialPart = null();
6507 *forHeadKind = ParseNodeKind::ForHead;
6508 return true;
6509 }
6510
6511 // Parsing after |for (var| is also relatively simple (from this method's
6512 // point of view). No block-related work complicates matters, so delegate
6513 // to Parser::declaration.
6514 if (tt == TokenKind::Var) {
6515 tokenStream.consumeKnownToken(tt, TokenStream::SlashIsRegExp);
6516
6517 // Pass null for block object because |var| declarations don't use one.
6518 MOZ_TRY_VAR_OR_RETURN(*forInitialPart,do { auto parserTryVarTempResult_ = (declarationList(yieldHandling
, ParseNodeKind::VarStmt, forHeadKind, forInOrOfExpression));
if ((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0
))) { return (false); } (*forInitialPart) = parserTryVarTempResult_
.unwrap(); } while (0)
6519 declarationList(yieldHandling, ParseNodeKind::VarStmt,do { auto parserTryVarTempResult_ = (declarationList(yieldHandling
, ParseNodeKind::VarStmt, forHeadKind, forInOrOfExpression));
if ((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0
))) { return (false); } (*forInitialPart) = parserTryVarTempResult_
.unwrap(); } while (0)
6520 forHeadKind, forInOrOfExpression),do { auto parserTryVarTempResult_ = (declarationList(yieldHandling
, ParseNodeKind::VarStmt, forHeadKind, forInOrOfExpression));
if ((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0
))) { return (false); } (*forInitialPart) = parserTryVarTempResult_
.unwrap(); } while (0)
6521 false)do { auto parserTryVarTempResult_ = (declarationList(yieldHandling
, ParseNodeKind::VarStmt, forHeadKind, forInOrOfExpression));
if ((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0
))) { return (false); } (*forInitialPart) = parserTryVarTempResult_
.unwrap(); } while (0)
;
6522 return true;
6523 }
6524
6525 // Otherwise we have a lexical declaration or an expression.
6526
6527 // For-in loop backwards compatibility requires that |let| starting a
6528 // for-loop that's not a (new to ES6) for-of loop, in non-strict mode code,
6529 // parse as an identifier. (|let| in for-of is always a declaration.)
6530 //
6531 // For-of loops can't start with the token sequence "async of", because that
6532 // leads to a shift-reduce conflict when parsing |for (async of => {};;)| or
6533 // |for (async of [])|.
6534 bool parsingLexicalDeclaration = false;
6535 bool letIsIdentifier = false;
6536 bool startsWithForOf = false;
6537
6538 if (tt == TokenKind::Const) {
6539 parsingLexicalDeclaration = true;
6540 tokenStream.consumeKnownToken(tt, TokenStream::SlashIsRegExp);
6541 }
6542#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
6543 else if (tt == TokenKind::Await) {
6544 if (!pc_->isAsync()) {
6545 if (pc_->atModuleTopLevel()) {
6546 if (!options().topLevelAwait) {
6547 error(JSMSG_TOP_LEVEL_AWAIT_NOT_SUPPORTED);
6548 return false;
6549 }
6550 pc_->sc()->asModuleContext()->setIsAsync();
6551 MOZ_ASSERT(pc_->isAsync())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isAsync())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isAsync()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("pc_->isAsync()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6551); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isAsync()"
")"); do { *((volatile int*)__null) = 6551; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6552 }
6553 }
6554 if (pc_->isAsync()) {
6555 // Try finding evidence of a AwaitUsingDeclaration the syntax for which
6556 // would be:
6557 // await [no LineTerminator here] using [no LineTerminator here]
6558 // identifier
6559 tokenStream.consumeKnownToken(tt, TokenStream::SlashIsRegExp);
6560
6561 TokenKind nextTok = TokenKind::Eof;
6562 if (!tokenStream.peekTokenSameLine(&nextTok,
6563 TokenStream::SlashIsRegExp)) {
6564 return false;
6565 }
6566
6567 if (nextTok == TokenKind::Using) {
6568 tokenStream.consumeKnownToken(nextTok, TokenStream::SlashIsRegExp);
6569
6570 TokenKind nextTokIdent = TokenKind::Eof;
6571 if (!tokenStream.peekTokenSameLine(&nextTokIdent)) {
6572 return false;
6573 }
6574
6575 if (TokenKindIsPossibleIdentifier(nextTokIdent)) {
6576 parsingLexicalDeclaration = true;
6577 } else {
6578 anyChars.ungetToken(); // put back using token
6579 anyChars.ungetToken(); // put back await token
6580 }
6581 } else {
6582 anyChars.ungetToken(); // put back await token
6583 }
6584 }
6585 } else if (tt == TokenKind::Using) {
6586 tokenStream.consumeKnownToken(tt, TokenStream::SlashIsRegExp);
6587
6588 // Look ahead to find either a 'of' token or if not identifier
6589 TokenKind nextTok = TokenKind::Eof;
6590 if (!tokenStream.peekTokenSameLine(&nextTok)) {
6591 return false;
6592 }
6593
6594 if (nextTok == TokenKind::Of || !TokenKindIsPossibleIdentifier(nextTok)) {
6595 anyChars.ungetToken(); // we didnt find a valid case of using decl put
6596 // back the token
6597 } else {
6598 parsingLexicalDeclaration = true;
6599 }
6600 }
6601#endif
6602 else if (tt == TokenKind::Let) {
6603 // We could have a {For,Lexical}Declaration, or we could have a
6604 // LeftHandSideExpression with lookahead restrictions so it's not
6605 // ambiguous with the former. Check for a continuation of the former
6606 // to decide which we have.
6607 tokenStream.consumeKnownToken(TokenKind::Let, TokenStream::SlashIsRegExp);
6608
6609 TokenKind next;
6610 if (!tokenStream.peekToken(&next)) {
6611 return false;
6612 }
6613
6614 parsingLexicalDeclaration = nextTokenContinuesLetDeclaration(next);
6615 if (!parsingLexicalDeclaration) {
6616 // If we end up here, we may have `for (let <reserved word> of/in ...`,
6617 // which is not valid.
6618 if (next != TokenKind::In && next != TokenKind::Of &&
6619 TokenKindIsReservedWord(next)) {
6620 tokenStream.consumeKnownToken(next);
6621 error(JSMSG_UNEXPECTED_TOKEN_NO_EXPECT, TokenKindToDesc(next));
6622 return false;
6623 }
6624
6625 anyChars.ungetToken();
6626 letIsIdentifier = true;
6627 }
6628 } else if (tt == TokenKind::Async && iterKind == IteratorKind::Sync) {
6629 tokenStream.consumeKnownToken(TokenKind::Async, TokenStream::SlashIsRegExp);
6630
6631 TokenKind next;
6632 if (!tokenStream.peekToken(&next)) {
6633 return false;
6634 }
6635
6636 if (next == TokenKind::Of) {
6637 startsWithForOf = true;
6638 }
6639 anyChars.ungetToken();
6640 }
6641
6642 if (parsingLexicalDeclaration) {
6643 if (options().selfHostingMode) {
6644 error(JSMSG_SELFHOSTED_LEXICAL);
6645 return false;
6646 }
6647
6648 forLoopLexicalScope.emplace(this);
6649 if (!forLoopLexicalScope->init(pc_)) {
6650 return false;
6651 }
6652
6653 // Push a temporary ForLoopLexicalHead Statement that allows for
6654 // lexical declarations, as they are usually allowed only in braced
6655 // statements.
6656 ParseContext::Statement forHeadStmt(pc_, StatementKind::ForLoopLexicalHead);
6657
6658 ParseNodeKind declKind;
6659 switch (tt) {
6660 case TokenKind::Const:
6661 declKind = ParseNodeKind::ConstDecl;
6662 break;
6663#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
6664 case TokenKind::Using:
6665 declKind = ParseNodeKind::UsingDecl;
6666 break;
6667 case TokenKind::Await:
6668 declKind = ParseNodeKind::AwaitUsingDecl;
6669 break;
6670#endif
6671 case TokenKind::Let:
6672 declKind = ParseNodeKind::LetDecl;
6673 break;
6674 default:
6675 MOZ_CRASH("unexpected node kind")do { do { } while (false); MOZ_ReportCrash("" "unexpected node kind"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6675); AnnotateMozCrashReason("MOZ_CRASH(" "unexpected node kind"
")"); do { *((volatile int*)__null) = 6675; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
6676 }
6677
6678 MOZ_TRY_VAR_OR_RETURN(*forInitialPart,do { auto parserTryVarTempResult_ = (declarationList(yieldHandling
, declKind, forHeadKind, forInOrOfExpression)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(*forInitialPart) = parserTryVarTempResult_.unwrap(); } while
(0)
6679 declarationList(yieldHandling, declKind, forHeadKind,do { auto parserTryVarTempResult_ = (declarationList(yieldHandling
, declKind, forHeadKind, forInOrOfExpression)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(*forInitialPart) = parserTryVarTempResult_.unwrap(); } while
(0)
6680 forInOrOfExpression),do { auto parserTryVarTempResult_ = (declarationList(yieldHandling
, declKind, forHeadKind, forInOrOfExpression)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(*forInitialPart) = parserTryVarTempResult_.unwrap(); } while
(0)
6681 false)do { auto parserTryVarTempResult_ = (declarationList(yieldHandling
, declKind, forHeadKind, forInOrOfExpression)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(*forInitialPart) = parserTryVarTempResult_.unwrap(); } while
(0)
;
6682 return true;
6683 }
6684
6685 uint32_t exprOffset;
6686 if (!tokenStream.peekOffset(&exprOffset, TokenStream::SlashIsRegExp)) {
6687 return false;
6688 }
6689
6690 // Finally, handle for-loops that start with expressions. Pass
6691 // |InProhibited| so that |in| isn't parsed in a RelationalExpression as a
6692 // binary operator. |in| makes it a for-in loop, *not* an |in| expression.
6693 PossibleError possibleError(*this);
6694 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (expr(InProhibited, yieldHandling
, TripledotProhibited, &possibleError)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(*forInitialPart) = parserTryVarTempResult_.unwrap(); } while
(0)
6695 *forInitialPart,do { auto parserTryVarTempResult_ = (expr(InProhibited, yieldHandling
, TripledotProhibited, &possibleError)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(*forInitialPart) = parserTryVarTempResult_.unwrap(); } while
(0)
6696 expr(InProhibited, yieldHandling, TripledotProhibited, &possibleError),do { auto parserTryVarTempResult_ = (expr(InProhibited, yieldHandling
, TripledotProhibited, &possibleError)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(*forInitialPart) = parserTryVarTempResult_.unwrap(); } while
(0)
6697 false)do { auto parserTryVarTempResult_ = (expr(InProhibited, yieldHandling
, TripledotProhibited, &possibleError)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(*forInitialPart) = parserTryVarTempResult_.unwrap(); } while
(0)
;
6698
6699 bool isForIn, isForOf;
6700 if (!matchInOrOf(&isForIn, &isForOf)) {
6701 return false;
6702 }
6703
6704 // If we don't encounter 'in'/'of', we have a for(;;) loop. We've handled
6705 // the init expression; the caller handles the rest.
6706 if (!isForIn && !isForOf) {
6707 if (!possibleError.checkForExpressionError()) {
6708 return false;
6709 }
6710
6711 *forHeadKind = ParseNodeKind::ForHead;
6712 return true;
6713 }
6714
6715 MOZ_ASSERT(isForIn != isForOf)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(isForIn != isForOf)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(isForIn != isForOf))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("isForIn != isForOf"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6715); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isForIn != isForOf"
")"); do { *((volatile int*)__null) = 6715; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6716
6717 // In a for-of loop, 'let' that starts the loop head is a |let| keyword,
6718 // per the [lookahead ≠ let] restriction on the LeftHandSideExpression
6719 // variant of such loops. Expressions that start with |let| can't be used
6720 // here.
6721 //
6722 // var let = {};
6723 // for (let.prop of [1]) // BAD
6724 // break;
6725 //
6726 // See ES6 13.7.
6727 if (isForOf && letIsIdentifier) {
6728 errorAt(exprOffset, JSMSG_BAD_STARTING_FOROF_LHS, "let");
6729 return false;
6730 }
6731
6732 // In a for-of loop, the LeftHandSideExpression isn't allowed to be an
6733 // identifier named "async" per the [lookahead ≠ async of] restriction.
6734 if (isForOf && startsWithForOf) {
6735 errorAt(exprOffset, JSMSG_BAD_STARTING_FOROF_LHS, "async of");
6736 return false;
6737 }
6738
6739 *forHeadKind = isForIn ? ParseNodeKind::ForIn : ParseNodeKind::ForOf;
6740
6741 // Verify the left-hand side expression doesn't have a forbidden form.
6742 if (handler_.isUnparenthesizedDestructuringPattern(*forInitialPart)) {
6743 if (!possibleError.checkForDestructuringErrorOrWarning()) {
6744 return false;
6745 }
6746 } else if (handler_.isName(*forInitialPart)) {
6747 if (const char* chars = nameIsArgumentsOrEval(*forInitialPart)) {
6748 // |chars| is "arguments" or "eval" here.
6749 if (!strictModeErrorAt(exprOffset, JSMSG_BAD_STRICT_ASSIGN, chars)) {
6750 return false;
6751 }
6752 }
6753 } else if (handler_.isArgumentsLength(*forInitialPart)) {
6754 pc_->sc()->setIneligibleForArgumentsLength();
6755 } else if (handler_.isPropertyOrPrivateMemberAccess(*forInitialPart)) {
6756 // Permitted: no additional testing/fixup needed.
6757 } else if (handler_.isFunctionCall(*forInitialPart)) {
6758 if (!strictModeErrorAt(exprOffset, JSMSG_BAD_FOR_LEFTSIDE)) {
6759 return false;
6760 }
6761 } else {
6762 errorAt(exprOffset, JSMSG_BAD_FOR_LEFTSIDE);
6763 return false;
6764 }
6765
6766 if (!possibleError.checkForExpressionError()) {
6767 return false;
6768 }
6769
6770 // Finally, parse the iterated expression, making the for-loop's closing
6771 // ')' the next token.
6772 MOZ_TRY_VAR_OR_RETURN(*forInOrOfExpression,do { auto parserTryVarTempResult_ = (expressionAfterForInOrOf
(*forHeadKind, yieldHandling)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (*forInOrOfExpression) = parserTryVarTempResult_
.unwrap(); } while (0)
6773 expressionAfterForInOrOf(*forHeadKind, yieldHandling),do { auto parserTryVarTempResult_ = (expressionAfterForInOrOf
(*forHeadKind, yieldHandling)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (*forInOrOfExpression) = parserTryVarTempResult_
.unwrap(); } while (0)
6774 false)do { auto parserTryVarTempResult_ = (expressionAfterForInOrOf
(*forHeadKind, yieldHandling)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (*forInOrOfExpression) = parserTryVarTempResult_
.unwrap(); } while (0)
;
6775 return true;
6776}
6777
6778template <class ParseHandler, typename Unit>
6779typename ParseHandler::NodeResult
6780GeneralParser<ParseHandler, Unit>::forStatement(YieldHandling yieldHandling) {
6781 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::For))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::For))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::For)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::For)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6781); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::For)"
")"); do { *((volatile int*)__null) = 6781; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6782
6783 uint32_t begin = pos().begin;
6784
6785 ParseContext::Statement stmt(pc_, StatementKind::ForLoop);
6786
6787 IteratorKind iterKind = IteratorKind::Sync;
6788 unsigned iflags = 0;
6789
6790 if (pc_->isAsync() || pc_->sc()->isModuleContext()) {
6791 bool matched;
6792 if (!tokenStream.matchToken(&matched, TokenKind::Await)) {
6793 return errorResult();
6794 }
6795
6796 // If we come across a top level await here, mark the module as async.
6797 if (matched && pc_->sc()->isModuleContext() && !pc_->isAsync()) {
6798 if (!options().topLevelAwait) {
6799 error(JSMSG_TOP_LEVEL_AWAIT_NOT_SUPPORTED);
6800 return errorResult();
6801 }
6802 pc_->sc()->asModuleContext()->setIsAsync();
6803 MOZ_ASSERT(pc_->isAsync())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isAsync())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isAsync()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("pc_->isAsync()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6803); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isAsync()"
")"); do { *((volatile int*)__null) = 6803; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6804 }
6805
6806 if (matched) {
6807 iflags |= JSITER_FORAWAITOF0x80;
6808 iterKind = IteratorKind::Async;
6809 }
6810 }
6811
6812 if (!mustMatchToken(TokenKind::LeftParen, [this](TokenKind actual) {
6813 this->error((actual == TokenKind::Await && !this->pc_->isAsync())
6814 ? JSMSG_FOR_AWAIT_OUTSIDE_ASYNC
6815 : JSMSG_PAREN_AFTER_FOR);
6816 })) {
6817 return errorResult();
6818 }
6819
6820 // ParseNodeKind::ForHead, ParseNodeKind::ForIn, or
6821 // ParseNodeKind::ForOf depending on the loop type.
6822 ParseNodeKind headKind;
6823
6824 // |x| in either |for (x; ...; ...)| or |for (x in/of ...)|.
6825 Node startNode;
6826
6827 // The next two variables are used to implement `for (let/const ...)`.
6828 //
6829 // We generate an implicit block, wrapping the whole loop, to store loop
6830 // variables declared this way. Note that if the loop uses `for (var...)`
6831 // instead, those variables go on some existing enclosing scope, so no
6832 // implicit block scope is created.
6833 //
6834 // Both variables remain null/none if the loop is any other form.
6835
6836 // The static block scope for the implicit block scope.
6837 Maybe<ParseContext::Scope> forLoopLexicalScope;
6838
6839 // The expression being iterated over, for for-in/of loops only. Unused
6840 // for for(;;) loops.
6841 Node iteratedExpr;
6842
6843 // Parse the entirety of the loop-head for a for-in/of loop (so the next
6844 // token is the closing ')'):
6845 //
6846 // for (... in/of ...) ...
6847 // ^next token
6848 //
6849 // ...OR, parse up to the first ';' in a C-style for-loop:
6850 //
6851 // for (...; ...; ...) ...
6852 // ^next token
6853 //
6854 // In either case the subsequent token can be consistently accessed using
6855 // TokenStream::SlashIsDiv semantics.
6856 if (!forHeadStart(yieldHandling, iterKind, &headKind, &startNode,
6857 forLoopLexicalScope, &iteratedExpr)) {
6858 return errorResult();
6859 }
6860
6861 MOZ_ASSERT(headKind == ParseNodeKind::ForIn ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind
::ForOf || headKind == ParseNodeKind::ForHead)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(headKind == ParseNodeKind::ForIn
|| headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind
::ForHead))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind::ForHead"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6863); AnnotateMozCrashReason("MOZ_ASSERT" "(" "headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind::ForHead"
")"); do { *((volatile int*)__null) = 6863; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
6862 headKind == ParseNodeKind::ForOf ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind
::ForOf || headKind == ParseNodeKind::ForHead)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(headKind == ParseNodeKind::ForIn
|| headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind
::ForHead))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind::ForHead"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6863); AnnotateMozCrashReason("MOZ_ASSERT" "(" "headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind::ForHead"
")"); do { *((volatile int*)__null) = 6863; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
6863 headKind == ParseNodeKind::ForHead)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind
::ForOf || headKind == ParseNodeKind::ForHead)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(headKind == ParseNodeKind::ForIn
|| headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind
::ForHead))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind::ForHead"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6863); AnnotateMozCrashReason("MOZ_ASSERT" "(" "headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf || headKind == ParseNodeKind::ForHead"
")"); do { *((volatile int*)__null) = 6863; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6864
6865 if (iterKind == IteratorKind::Async && headKind != ParseNodeKind::ForOf) {
6866 errorAt(begin, JSMSG_FOR_AWAIT_NOT_OF);
6867 return errorResult();
6868 }
6869
6870 TernaryNodeType forHead;
6871 if (headKind == ParseNodeKind::ForHead) {
6872 Node init = startNode;
6873
6874 // Look for an operand: |for (;| means we might have already examined
6875 // this semicolon with that modifier.
6876 if (!mustMatchToken(TokenKind::Semi, JSMSG_SEMI_AFTER_FOR_INIT)) {
6877 return errorResult();
6878 }
6879
6880 TokenKind tt;
6881 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
6882 return errorResult();
6883 }
6884
6885 Node test;
6886 if (tt == TokenKind::Semi) {
6887 test = null();
6888 } else {
6889 MOZ_TRY_VAR(test, expr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (test) = mozTryVarTempResult_.unwrap(); } while (0)
;
6890 }
6891
6892 if (!mustMatchToken(TokenKind::Semi, JSMSG_SEMI_AFTER_FOR_COND)) {
6893 return errorResult();
6894 }
6895
6896 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
6897 return errorResult();
6898 }
6899
6900 Node update;
6901 if (tt == TokenKind::RightParen) {
6902 update = null();
6903 } else {
6904 MOZ_TRY_VAR(update, expr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (update) = mozTryVarTempResult_.unwrap(); } while (0)
;
6905 }
6906
6907 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_FOR_CTRL)) {
6908 return errorResult();
6909 }
6910
6911 TokenPos headPos(begin, pos().end);
6912 MOZ_TRY_VAR(forHead, handler_.newForHead(init, test, update, headPos))do { auto mozTryVarTempResult_ = (handler_.newForHead(init, test
, update, headPos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (forHead) = mozTryVarTempResult_.unwrap(); } while (0)
;
6913 } else {
6914 MOZ_ASSERT(headKind == ParseNodeKind::ForIn ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind
::ForOf)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind
::ForOf))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6915); AnnotateMozCrashReason("MOZ_ASSERT" "(" "headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf"
")"); do { *((volatile int*)__null) = 6915; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
6915 headKind == ParseNodeKind::ForOf)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind
::ForOf)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind
::ForOf))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6915); AnnotateMozCrashReason("MOZ_ASSERT" "(" "headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf"
")"); do { *((volatile int*)__null) = 6915; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6916
6917 // |target| is the LeftHandSideExpression or declaration to which the
6918 // per-iteration value (an arbitrary value exposed by the iteration
6919 // protocol, or a string naming a property) is assigned.
6920 Node target = startNode;
6921
6922 // Parse the rest of the for-in/of head.
6923 if (headKind == ParseNodeKind::ForIn) {
6924 stmt.refineForKind(StatementKind::ForInLoop);
6925 } else {
6926 stmt.refineForKind(StatementKind::ForOfLoop);
6927 }
6928
6929 // Parser::declaration consumed everything up to the closing ')'. That
6930 // token follows an {Assignment,}Expression and so must be interpreted
6931 // as an operand to be consistent with normal expression tokenizing.
6932 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_FOR_CTRL)) {
6933 return errorResult();
6934 }
6935
6936 TokenPos headPos(begin, pos().end);
6937 MOZ_TRY_VAR(forHead, handler_.newForInOrOfHead(headKind, target,do { auto mozTryVarTempResult_ = (handler_.newForInOrOfHead(headKind
, target, iteratedExpr, headPos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (forHead) = mozTryVarTempResult_.unwrap(); } while (0)
6938 iteratedExpr, headPos))do { auto mozTryVarTempResult_ = (handler_.newForInOrOfHead(headKind
, target, iteratedExpr, headPos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (forHead) = mozTryVarTempResult_.unwrap(); } while (0)
;
6939 }
6940
6941 Node body;
6942 MOZ_TRY_VAR(body, statement(yieldHandling))do { auto mozTryVarTempResult_ = (statement(yieldHandling)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (body) = mozTryVarTempResult_
.unwrap(); } while (0)
;
6943
6944 ForNodeType forLoop;
6945 MOZ_TRY_VAR(forLoop, handler_.newForStatement(begin, forHead, body, iflags))do { auto mozTryVarTempResult_ = (handler_.newForStatement(begin
, forHead, body, iflags)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (forLoop) = mozTryVarTempResult_.unwrap(); } while (0)
;
6946
6947 if (forLoopLexicalScope) {
6948 return finishLexicalScope(*forLoopLexicalScope, forLoop);
6949 }
6950
6951 return forLoop;
6952}
6953
6954template <class ParseHandler, typename Unit>
6955typename ParseHandler::SwitchStatementResult
6956GeneralParser<ParseHandler, Unit>::switchStatement(
6957 YieldHandling yieldHandling) {
6958 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Switch))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Switch))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Switch)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Switch)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 6958); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Switch)"
")"); do { *((volatile int*)__null) = 6958; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6959 uint32_t begin = pos().begin;
6960
6961 if (!mustMatchToken(TokenKind::LeftParen, JSMSG_PAREN_BEFORE_SWITCH)) {
6962 return errorResult();
6963 }
6964
6965 Node discriminant;
6966 MOZ_TRY_VAR(discriminant,do { auto mozTryVarTempResult_ = (exprInParens(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (discriminant) = mozTryVarTempResult_.unwrap(); } while (0
)
6967 exprInParens(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (exprInParens(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (discriminant) = mozTryVarTempResult_.unwrap(); } while (0
)
;
6968
6969 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_SWITCH)) {
6970 return errorResult();
6971 }
6972 if (!mustMatchToken(TokenKind::LeftCurly, JSMSG_CURLY_BEFORE_SWITCH)) {
6973 return errorResult();
6974 }
6975
6976 ParseContext::Statement stmt(pc_, StatementKind::Switch);
6977 ParseContext::Scope scope(this);
6978 if (!scope.init(pc_)) {
6979 return errorResult();
6980 }
6981
6982 ListNodeType caseList;
6983 MOZ_TRY_VAR(caseList, handler_.newStatementList(pos()))do { auto mozTryVarTempResult_ = (handler_.newStatementList(pos
())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()),
0))) { return mozTryVarTempResult_.propagateErr(); } (caseList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
6984
6985 bool seenDefault = false;
6986 TokenKind tt;
6987 while (true) {
6988 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
6989 return errorResult();
6990 }
6991 if (tt == TokenKind::RightCurly) {
6992 break;
6993 }
6994 uint32_t caseBegin = pos().begin;
6995
6996 Node caseExpr;
6997 switch (tt) {
6998 case TokenKind::Default:
6999 if (seenDefault) {
7000 error(JSMSG_TOO_MANY_DEFAULTS);
7001 return errorResult();
7002 }
7003 seenDefault = true;
7004 caseExpr = null(); // The default case has pn_left == nullptr.
7005 break;
7006
7007 case TokenKind::Case:
7008 MOZ_TRY_VAR(caseExpr,do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (caseExpr) = mozTryVarTempResult_.unwrap(); } while (0)
7009 expr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (caseExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
7010 break;
7011
7012 default:
7013 error(JSMSG_BAD_SWITCH);
7014 return errorResult();
7015 }
7016
7017 if (!mustMatchToken(TokenKind::Colon, JSMSG_COLON_AFTER_CASE)) {
7018 return errorResult();
7019 }
7020
7021 ListNodeType body;
7022 MOZ_TRY_VAR(body, handler_.newStatementList(pos()))do { auto mozTryVarTempResult_ = (handler_.newStatementList(pos
())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()),
0))) { return mozTryVarTempResult_.propagateErr(); } (body) =
mozTryVarTempResult_.unwrap(); } while (0)
;
7023
7024 bool afterReturn = false;
7025 bool warnedAboutStatementsAfterReturn = false;
7026 uint32_t statementBegin = 0;
7027 while (true) {
7028 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
7029 return errorResult();
7030 }
7031 if (tt == TokenKind::RightCurly || tt == TokenKind::Case ||
7032 tt == TokenKind::Default) {
7033 break;
7034 }
7035 if (afterReturn) {
7036 if (!tokenStream.peekOffset(&statementBegin,
7037 TokenStream::SlashIsRegExp)) {
7038 return errorResult();
7039 }
7040 }
7041 Node stmt;
7042 MOZ_TRY_VAR(stmt, statementListItem(yieldHandling))do { auto mozTryVarTempResult_ = (statementListItem(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (stmt) = mozTryVarTempResult_
.unwrap(); } while (0)
;
7043 if (!warnedAboutStatementsAfterReturn) {
7044 if (afterReturn) {
7045 if (!handler_.isStatementPermittedAfterReturnStatement(stmt)) {
7046 if (!warningAt(statementBegin, JSMSG_STMT_AFTER_RETURN)) {
7047 return errorResult();
7048 }
7049
7050 warnedAboutStatementsAfterReturn = true;
7051 }
7052 } else if (handler_.isReturnStatement(stmt)) {
7053 afterReturn = true;
7054 }
7055 }
7056 handler_.addStatementToList(body, stmt);
7057 }
7058
7059 CaseClauseType caseClause;
7060 MOZ_TRY_VAR(caseClause,do { auto mozTryVarTempResult_ = (handler_.newCaseOrDefault(caseBegin
, caseExpr, body)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (caseClause) = mozTryVarTempResult_.unwrap(); } while (0)
7061 handler_.newCaseOrDefault(caseBegin, caseExpr, body))do { auto mozTryVarTempResult_ = (handler_.newCaseOrDefault(caseBegin
, caseExpr, body)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (caseClause) = mozTryVarTempResult_.unwrap(); } while (0)
;
7062 handler_.addCaseStatementToList(caseList, caseClause);
7063 }
7064
7065 LexicalScopeNodeType lexicalForCaseList;
7066 MOZ_TRY_VAR(lexicalForCaseList, finishLexicalScope(scope, caseList))do { auto mozTryVarTempResult_ = (finishLexicalScope(scope, caseList
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (lexicalForCaseList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
7067
7068 handler_.setEndPosition(lexicalForCaseList, pos().end);
7069
7070 return handler_.newSwitchStatement(begin, discriminant, lexicalForCaseList,
7071 seenDefault);
7072}
7073
7074template <class ParseHandler, typename Unit>
7075typename ParseHandler::ContinueStatementResult
7076GeneralParser<ParseHandler, Unit>::continueStatement(
7077 YieldHandling yieldHandling) {
7078 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Continue))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Continue))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Continue)))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Continue)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7078); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Continue)"
")"); do { *((volatile int*)__null) = 7078; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7079 uint32_t begin = pos().begin;
7080
7081 TaggedParserAtomIndex label;
7082 if (!matchLabel(yieldHandling, &label)) {
7083 return errorResult();
7084 }
7085
7086 auto validity = pc_->checkContinueStatement(label);
7087 if (validity.isErr()) {
7088 switch (validity.unwrapErr()) {
7089 case ParseContext::ContinueStatementError::NotInALoop:
7090 errorAt(begin, JSMSG_BAD_CONTINUE);
7091 break;
7092 case ParseContext::ContinueStatementError::LabelNotFound:
7093 error(JSMSG_LABEL_NOT_FOUND);
7094 break;
7095 }
7096 return errorResult();
7097 }
7098
7099 if (!matchOrInsertSemicolon()) {
7100 return errorResult();
7101 }
7102
7103 return handler_.newContinueStatement(label, TokenPos(begin, pos().end));
7104}
7105
7106template <class ParseHandler, typename Unit>
7107typename ParseHandler::BreakStatementResult
7108GeneralParser<ParseHandler, Unit>::breakStatement(YieldHandling yieldHandling) {
7109 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Break))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Break))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Break)))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Break)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7109); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Break)"
")"); do { *((volatile int*)__null) = 7109; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7110 uint32_t begin = pos().begin;
7111
7112 TaggedParserAtomIndex label;
7113 if (!matchLabel(yieldHandling, &label)) {
7114 return errorResult();
7115 }
7116
7117 auto validity = pc_->checkBreakStatement(label);
7118 if (validity.isErr()) {
7119 switch (validity.unwrapErr()) {
7120 case ParseContext::BreakStatementError::ToughBreak:
7121 errorAt(begin, JSMSG_TOUGH_BREAK);
7122 return errorResult();
7123 case ParseContext::BreakStatementError::LabelNotFound:
7124 error(JSMSG_LABEL_NOT_FOUND);
7125 return errorResult();
7126 }
7127 }
7128
7129 if (!matchOrInsertSemicolon()) {
7130 return errorResult();
7131 }
7132
7133 return handler_.newBreakStatement(label, TokenPos(begin, pos().end));
7134}
7135
7136template <class ParseHandler, typename Unit>
7137typename ParseHandler::UnaryNodeResult
7138GeneralParser<ParseHandler, Unit>::returnStatement(
7139 YieldHandling yieldHandling) {
7140 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Return))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Return))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Return)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Return)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7140); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Return)"
")"); do { *((volatile int*)__null) = 7140; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7141 uint32_t begin = pos().begin;
7142
7143 MOZ_ASSERT(pc_->isFunctionBox())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isFunctionBox())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isFunctionBox()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("pc_->isFunctionBox()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7143); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isFunctionBox()"
")"); do { *((volatile int*)__null) = 7143; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7144
7145 // Parse an optional operand.
7146 //
7147 // This is ugly, but we don't want to require a semicolon.
7148 Node exprNode;
7149 TokenKind tt = TokenKind::Eof;
7150 if (!tokenStream.peekTokenSameLine(&tt, TokenStream::SlashIsRegExp)) {
7151 return errorResult();
7152 }
7153 switch (tt) {
7154 case TokenKind::Eol:
7155 case TokenKind::Eof:
7156 case TokenKind::Semi:
7157 case TokenKind::RightCurly:
7158 exprNode = null();
7159 break;
7160 default: {
7161 MOZ_TRY_VAR(exprNode,do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exprNode) = mozTryVarTempResult_.unwrap(); } while (0)
7162 expr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exprNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
7163 }
7164 }
7165
7166 if (!matchOrInsertSemicolon()) {
7167 return errorResult();
7168 }
7169
7170 return handler_.newReturnStatement(exprNode, TokenPos(begin, pos().end));
7171}
7172
7173template <class ParseHandler, typename Unit>
7174typename ParseHandler::UnaryNodeResult
7175GeneralParser<ParseHandler, Unit>::yieldExpression(InHandling inHandling) {
7176 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Yield))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Yield))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Yield)))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Yield)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7176); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Yield)"
")"); do { *((volatile int*)__null) = 7176; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7177 uint32_t begin = pos().begin;
7178
7179 MOZ_ASSERT(pc_->isGenerator())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isGenerator())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isGenerator()))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("pc_->isGenerator()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7179); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isGenerator()"
")"); do { *((volatile int*)__null) = 7179; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7180 MOZ_ASSERT(pc_->isFunctionBox())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isFunctionBox())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isFunctionBox()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("pc_->isFunctionBox()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7180); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isFunctionBox()"
")"); do { *((volatile int*)__null) = 7180; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7181
7182 pc_->lastYieldOffset = begin;
7183
7184 Node exprNode;
7185 ParseNodeKind kind = ParseNodeKind::YieldExpr;
7186 TokenKind tt = TokenKind::Eof;
7187 if (!tokenStream.peekTokenSameLine(&tt, TokenStream::SlashIsRegExp)) {
7188 return errorResult();
7189 }
7190 switch (tt) {
7191 // TokenKind::Eol is special; it implements the [no LineTerminator here]
7192 // quirk in the grammar.
7193 case TokenKind::Eol:
7194 // The rest of these make up the complete set of tokens that can
7195 // appear after any of the places where AssignmentExpression is used
7196 // throughout the grammar. Conveniently, none of them can also be the
7197 // start an expression.
7198 case TokenKind::Eof:
7199 case TokenKind::Semi:
7200 case TokenKind::RightCurly:
7201 case TokenKind::RightBracket:
7202 case TokenKind::RightParen:
7203 case TokenKind::Colon:
7204 case TokenKind::Comma:
7205 case TokenKind::In: // Annex B.3.6 `for (x = yield in y) ;`
7206 // No value.
7207 exprNode = null();
7208 break;
7209 case TokenKind::Mul:
7210 kind = ParseNodeKind::YieldStarExpr;
7211 tokenStream.consumeKnownToken(TokenKind::Mul, TokenStream::SlashIsRegExp);
7212 [[fallthrough]];
7213 default:
7214 MOZ_TRY_VAR(exprNode,do { auto mozTryVarTempResult_ = (assignExpr(inHandling, YieldIsKeyword
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exprNode) = mozTryVarTempResult_.unwrap(); } while (0)
7215 assignExpr(inHandling, YieldIsKeyword, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(inHandling, YieldIsKeyword
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exprNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
7216 }
7217 if (kind == ParseNodeKind::YieldStarExpr) {
7218 return handler_.newYieldStarExpression(begin, exprNode);
7219 }
7220 return handler_.newYieldExpression(begin, exprNode);
7221}
7222
7223template <class ParseHandler, typename Unit>
7224typename ParseHandler::BinaryNodeResult
7225GeneralParser<ParseHandler, Unit>::withStatement(YieldHandling yieldHandling) {
7226 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::With))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::With))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::With)))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::With)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7226); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::With)"
")"); do { *((volatile int*)__null) = 7226; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7227 uint32_t begin = pos().begin;
7228
7229 if (pc_->sc()->strict()) {
7230 if (!strictModeError(JSMSG_STRICT_CODE_WITH)) {
7231 return errorResult();
7232 }
7233 }
7234
7235 if (!mustMatchToken(TokenKind::LeftParen, JSMSG_PAREN_BEFORE_WITH)) {
7236 return errorResult();
7237 }
7238
7239 Node objectExpr;
7240 MOZ_TRY_VAR(objectExpr,do { auto mozTryVarTempResult_ = (exprInParens(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (objectExpr) = mozTryVarTempResult_.unwrap(); } while (0)
7241 exprInParens(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (exprInParens(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (objectExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
7242
7243 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_WITH)) {
7244 return errorResult();
7245 }
7246
7247 Node innerBlock;
7248 {
7249 ParseContext::Statement stmt(pc_, StatementKind::With);
7250 MOZ_TRY_VAR(innerBlock, statement(yieldHandling))do { auto mozTryVarTempResult_ = (statement(yieldHandling)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (innerBlock) = mozTryVarTempResult_
.unwrap(); } while (0)
;
7251 }
7252
7253 pc_->sc()->setBindingsAccessedDynamically();
7254
7255 return handler_.newWithStatement(begin, objectExpr, innerBlock);
7256}
7257
7258template <class ParseHandler, typename Unit>
7259typename ParseHandler::NodeResult
7260GeneralParser<ParseHandler, Unit>::labeledItem(YieldHandling yieldHandling) {
7261 TokenKind tt;
7262 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
7263 return errorResult();
7264 }
7265
7266 if (tt == TokenKind::Function) {
7267 TokenKind next;
7268 if (!tokenStream.peekToken(&next)) {
7269 return errorResult();
7270 }
7271
7272 // GeneratorDeclaration is only matched by HoistableDeclaration in
7273 // StatementListItem, so generators can't be inside labels.
7274 if (next == TokenKind::Mul) {
7275 error(JSMSG_GENERATOR_LABEL);
7276 return errorResult();
7277 }
7278
7279 // Per 13.13.1 it's a syntax error if LabelledItem: FunctionDeclaration
7280 // is ever matched. Per Annex B.3.2 that modifies this text, this
7281 // applies only to strict mode code.
7282 if (pc_->sc()->strict()) {
7283 error(JSMSG_FUNCTION_LABEL);
7284 return errorResult();
7285 }
7286
7287 return functionStmt(pos().begin, yieldHandling, NameRequired);
7288 }
7289
7290 anyChars.ungetToken();
7291 return statement(yieldHandling);
7292}
7293
7294template <class ParseHandler, typename Unit>
7295typename ParseHandler::LabeledStatementResult
7296GeneralParser<ParseHandler, Unit>::labeledStatement(
7297 YieldHandling yieldHandling) {
7298 TaggedParserAtomIndex label = labelIdentifier(yieldHandling);
7299 if (!label) {
7300 return errorResult();
7301 }
7302
7303 auto hasSameLabel = [&label](ParseContext::LabelStatement* stmt) {
7304 return stmt->label() == label;
7305 };
7306
7307 uint32_t begin = pos().begin;
7308
7309 if (pc_->template findInnermostStatement<ParseContext::LabelStatement>(
7310 hasSameLabel)) {
7311 errorAt(begin, JSMSG_DUPLICATE_LABEL);
7312 return errorResult();
7313 }
7314
7315 tokenStream.consumeKnownToken(TokenKind::Colon);
7316
7317 /* Push a label struct and parse the statement. */
7318 ParseContext::LabelStatement stmt(pc_, label);
7319 Node pn;
7320 MOZ_TRY_VAR(pn, labeledItem(yieldHandling))do { auto mozTryVarTempResult_ = (labeledItem(yieldHandling))
; if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))
) { return mozTryVarTempResult_.propagateErr(); } (pn) = mozTryVarTempResult_
.unwrap(); } while (0)
;
7321
7322 return handler_.newLabeledStatement(label, pn, begin);
7323}
7324
7325template <class ParseHandler, typename Unit>
7326typename ParseHandler::UnaryNodeResult
7327GeneralParser<ParseHandler, Unit>::throwStatement(YieldHandling yieldHandling) {
7328 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Throw))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Throw))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Throw)))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Throw)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7328); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Throw)"
")"); do { *((volatile int*)__null) = 7328; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7329 uint32_t begin = pos().begin;
7330
7331 /* ECMA-262 Edition 3 says 'throw [no LineTerminator here] Expr'. */
7332 TokenKind tt = TokenKind::Eof;
7333 if (!tokenStream.peekTokenSameLine(&tt, TokenStream::SlashIsRegExp)) {
7334 return errorResult();
7335 }
7336 if (tt == TokenKind::Eof || tt == TokenKind::Semi ||
7337 tt == TokenKind::RightCurly) {
7338 error(JSMSG_MISSING_EXPR_AFTER_THROW);
7339 return errorResult();
7340 }
7341 if (tt == TokenKind::Eol) {
7342 error(JSMSG_LINE_BREAK_AFTER_THROW);
7343 return errorResult();
7344 }
7345
7346 Node throwExpr;
7347 MOZ_TRY_VAR(throwExpr, expr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (throwExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
7348
7349 if (!matchOrInsertSemicolon()) {
7350 return errorResult();
7351 }
7352
7353 return handler_.newThrowStatement(throwExpr, TokenPos(begin, pos().end));
7354}
7355
7356template <class ParseHandler, typename Unit>
7357typename ParseHandler::TernaryNodeResult
7358GeneralParser<ParseHandler, Unit>::tryStatement(YieldHandling yieldHandling) {
7359 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Try))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Try))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::Try)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Try)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7359); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Try)"
")"); do { *((volatile int*)__null) = 7359; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
7360 uint32_t begin = pos().begin;
7361
7362 /*
7363 * try nodes are ternary.
7364 * kid1 is the try statement
7365 * kid2 is the catch node list or null
7366 * kid3 is the finally statement
7367 *
7368 * catch nodes are binary.
7369 * left is the catch-name/pattern or null
7370 * right is the catch block
7371 *
7372 * catch lvalue nodes are either:
7373 * a single identifier
7374 * TokenKind::RightBracket for a destructuring left-hand side
7375 * TokenKind::RightCurly for a destructuring left-hand side
7376 *
7377 * finally nodes are TokenKind::LeftCurly statement lists.
7378 */
7379
7380 Node innerBlock;
7381 {
7382 if (!mustMatchToken(TokenKind::LeftCurly, JSMSG_CURLY_BEFORE_TRY)) {
7383 return errorResult();
7384 }
7385
7386 uint32_t openedPos = pos().begin;
7387
7388 ParseContext::Statement stmt(pc_, StatementKind::Try);
7389 ParseContext::Scope scope(this);
7390 if (!scope.init(pc_)) {
7391 return errorResult();
7392 }
7393
7394 MOZ_TRY_VAR(innerBlock, statementList(yieldHandling))do { auto mozTryVarTempResult_ = (statementList(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (innerBlock
) = mozTryVarTempResult_.unwrap(); } while (0)
;
7395
7396 MOZ_TRY_VAR(innerBlock, finishLexicalScope(scope, innerBlock))do { auto mozTryVarTempResult_ = (finishLexicalScope(scope, innerBlock
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (innerBlock
) = mozTryVarTempResult_.unwrap(); } while (0)
;
7397
7398 if (!mustMatchToken(
7399 TokenKind::RightCurly, [this, openedPos](TokenKind actual) {
7400 this->reportMissingClosing(JSMSG_CURLY_AFTER_TRY,
7401 JSMSG_CURLY_OPENED, openedPos);
7402 })) {
7403 return errorResult();
7404 }
7405 }
7406
7407 LexicalScopeNodeType catchScope = null();
7408 TokenKind tt;
7409 if (!tokenStream.getToken(&tt)) {
7410 return errorResult();
7411 }
7412 if (tt == TokenKind::Catch) {
7413 /*
7414 * Create a lexical scope node around the whole catch clause,
7415 * including the head.
7416 */
7417 ParseContext::Statement stmt(pc_, StatementKind::Catch);
7418 ParseContext::Scope scope(this);
7419 if (!scope.init(pc_)) {
7420 return errorResult();
7421 }
7422
7423 /*
7424 * Legal catch forms are:
7425 * catch (lhs) {
7426 * catch {
7427 * where lhs is a name or a destructuring left-hand side.
7428 */
7429 bool omittedBinding;
7430 if (!tokenStream.matchToken(&omittedBinding, TokenKind::LeftCurly)) {
7431 return errorResult();
7432 }
7433
7434 Node catchName;
7435 if (omittedBinding) {
7436 catchName = null();
7437 } else {
7438 if (!mustMatchToken(TokenKind::LeftParen, JSMSG_PAREN_BEFORE_CATCH)) {
7439 return errorResult();
7440 }
7441
7442 if (!tokenStream.getToken(&tt)) {
7443 return errorResult();
7444 }
7445 switch (tt) {
7446 case TokenKind::LeftBracket:
7447 case TokenKind::LeftCurly:
7448 MOZ_TRY_VAR(catchName,do { auto mozTryVarTempResult_ = (destructuringDeclaration(DeclarationKind
::CatchParameter, yieldHandling, tt)); if ((__builtin_expect(
!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (catchName) = mozTryVarTempResult_.unwrap(
); } while (0)
7449 destructuringDeclaration(DeclarationKind::CatchParameter,do { auto mozTryVarTempResult_ = (destructuringDeclaration(DeclarationKind
::CatchParameter, yieldHandling, tt)); if ((__builtin_expect(
!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (catchName) = mozTryVarTempResult_.unwrap(
); } while (0)
7450 yieldHandling, tt))do { auto mozTryVarTempResult_ = (destructuringDeclaration(DeclarationKind
::CatchParameter, yieldHandling, tt)); if ((__builtin_expect(
!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (catchName) = mozTryVarTempResult_.unwrap(
); } while (0)
;
7451 break;
7452
7453 default: {
7454 if (!TokenKindIsPossibleIdentifierName(tt)) {
7455 error(JSMSG_CATCH_IDENTIFIER);
7456 return errorResult();
7457 }
7458
7459 MOZ_TRY_VAR(catchName,do { auto mozTryVarTempResult_ = (bindingIdentifier(DeclarationKind
::SimpleCatchParameter, yieldHandling)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (catchName) = mozTryVarTempResult_.unwrap(
); } while (0)
7460 bindingIdentifier(DeclarationKind::SimpleCatchParameter,do { auto mozTryVarTempResult_ = (bindingIdentifier(DeclarationKind
::SimpleCatchParameter, yieldHandling)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (catchName) = mozTryVarTempResult_.unwrap(
); } while (0)
7461 yieldHandling))do { auto mozTryVarTempResult_ = (bindingIdentifier(DeclarationKind
::SimpleCatchParameter, yieldHandling)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (catchName) = mozTryVarTempResult_.unwrap(
); } while (0)
;
7462 break;
7463 }
7464 }
7465
7466 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_CATCH)) {
7467 return errorResult();
7468 }
7469
7470 if (!mustMatchToken(TokenKind::LeftCurly, JSMSG_CURLY_BEFORE_CATCH)) {
7471 return errorResult();
7472 }
7473 }
7474
7475 LexicalScopeNodeType catchBody;
7476 MOZ_TRY_VAR(catchBody, catchBlockStatement(yieldHandling, scope))do { auto mozTryVarTempResult_ = (catchBlockStatement(yieldHandling
, scope)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (catchBody
) = mozTryVarTempResult_.unwrap(); } while (0)
;
7477
7478 MOZ_TRY_VAR(catchScope, finishLexicalScope(scope, catchBody))do { auto mozTryVarTempResult_ = (finishLexicalScope(scope, catchBody
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (catchScope
) = mozTryVarTempResult_.unwrap(); } while (0)
;
7479
7480 if (!handler_.setupCatchScope(catchScope, catchName, catchBody)) {
7481 return errorResult();
7482 }
7483 handler_.setEndPosition(catchScope, pos().end);
7484
7485 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
7486 return errorResult();
7487 }
7488 }
7489
7490 Node finallyBlock = null();
7491
7492 if (tt == TokenKind::Finally) {
7493 if (!mustMatchToken(TokenKind::LeftCurly, JSMSG_CURLY_BEFORE_FINALLY)) {
7494 return errorResult();
7495 }
7496
7497 uint32_t openedPos = pos().begin;
7498
7499 ParseContext::Statement stmt(pc_, StatementKind::Finally);
7500 ParseContext::Scope scope(this);
7501 if (!scope.init(pc_)) {
7502 return errorResult();
7503 }
7504
7505 MOZ_TRY_VAR(finallyBlock, statementList(yieldHandling))do { auto mozTryVarTempResult_ = (statementList(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (finallyBlock
) = mozTryVarTempResult_.unwrap(); } while (0)
;
7506
7507 MOZ_TRY_VAR(finallyBlock, finishLexicalScope(scope, finallyBlock))do { auto mozTryVarTempResult_ = (finishLexicalScope(scope, finallyBlock
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (finallyBlock
) = mozTryVarTempResult_.unwrap(); } while (0)
;
7508
7509 if (!mustMatchToken(
7510 TokenKind::RightCurly, [this, openedPos](TokenKind actual) {
7511 this->reportMissingClosing(JSMSG_CURLY_AFTER_FINALLY,
7512 JSMSG_CURLY_OPENED, openedPos);
7513 })) {
7514 return errorResult();
7515 }
7516 } else {
7517 anyChars.ungetToken();
7518 }
7519 if (!catchScope && !finallyBlock) {
7520 error(JSMSG_CATCH_OR_FINALLY);
7521 return errorResult();
7522 }
7523
7524 return handler_.newTryStatement(begin, innerBlock, catchScope, finallyBlock);
7525}
7526
7527template <class ParseHandler, typename Unit>
7528typename ParseHandler::LexicalScopeNodeResult
7529GeneralParser<ParseHandler, Unit>::catchBlockStatement(
7530 YieldHandling yieldHandling, ParseContext::Scope& catchParamScope) {
7531 uint32_t openedPos = pos().begin;
7532
7533 ParseContext::Statement stmt(pc_, StatementKind::Block);
7534
7535 // ES 13.15.7 CatchClauseEvaluation
7536 //
7537 // Step 8 means that the body of a catch block always has an additional
7538 // lexical scope.
7539 ParseContext::Scope scope(this);
7540 if (!scope.init(pc_)) {
7541 return errorResult();
7542 }
7543
7544 // The catch parameter names cannot be redeclared inside the catch
7545 // block, so declare the name in the inner scope.
7546 if (!scope.addCatchParameters(pc_, catchParamScope)) {
7547 return errorResult();
7548 }
7549
7550 ListNodeType list;
7551 MOZ_TRY_VAR(list, statementList(yieldHandling))do { auto mozTryVarTempResult_ = (statementList(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (list) = mozTryVarTempResult_
.unwrap(); } while (0)
;
7552
7553 if (!mustMatchToken(
7554 TokenKind::RightCurly, [this, openedPos](TokenKind actual) {
7555 this->reportMissingClosing(JSMSG_CURLY_AFTER_CATCH,
7556 JSMSG_CURLY_OPENED, openedPos);
7557 })) {
7558 return errorResult();
7559 }
7560
7561 // The catch parameter names are not bound in the body scope, so remove
7562 // them before generating bindings.
7563 scope.removeCatchParameters(pc_, catchParamScope);
7564 return finishLexicalScope(scope, list);
7565}
7566
7567template <class ParseHandler, typename Unit>
7568typename ParseHandler::DebuggerStatementResult
7569GeneralParser<ParseHandler, Unit>::debuggerStatement() {
7570 TokenPos p;
7571 p.begin = pos().begin;
7572 if (!matchOrInsertSemicolon()) {
7573 return errorResult();
7574 }
7575 p.end = pos().end;
7576
7577 return handler_.newDebuggerStatement(p);
7578}
7579
7580static AccessorType ToAccessorType(PropertyType propType) {
7581 switch (propType) {
7582 case PropertyType::Getter:
7583 return AccessorType::Getter;
7584 case PropertyType::Setter:
7585 return AccessorType::Setter;
7586 case PropertyType::Normal:
7587 case PropertyType::Method:
7588 case PropertyType::GeneratorMethod:
7589 case PropertyType::AsyncMethod:
7590 case PropertyType::AsyncGeneratorMethod:
7591 case PropertyType::Constructor:
7592 case PropertyType::DerivedConstructor:
7593 return AccessorType::None;
7594 default:
7595 MOZ_CRASH("unexpected property type")do { do { } while (false); MOZ_ReportCrash("" "unexpected property type"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7595); AnnotateMozCrashReason("MOZ_CRASH(" "unexpected property type"
")"); do { *((volatile int*)__null) = 7595; __attribute__((nomerge
)) ::abort(); } while (false); } while (false)
;
7596 }
7597}
7598
7599#ifdef ENABLE_DECORATORS
7600template <class ParseHandler, typename Unit>
7601typename ParseHandler::ListNodeResult
7602GeneralParser<ParseHandler, Unit>::decoratorList(YieldHandling yieldHandling) {
7603 ListNodeType decorators;
7604 MOZ_TRY_VAR(decorators,do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::DecoratorList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (decorators) = mozTryVarTempResult_.unwrap(); } while (0)
7605 handler_.newList(ParseNodeKind::DecoratorList, pos()))do { auto mozTryVarTempResult_ = (handler_.newList(ParseNodeKind
::DecoratorList, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (decorators) = mozTryVarTempResult_.unwrap(); } while (0)
;
7606
7607 // Build a decorator list element. At each entry point to this loop we have
7608 // already consumed the |@| token
7609 TokenKind tt;
7610 for (;;) {
7611 if (!tokenStream.getToken(&tt, TokenStream::SlashIsInvalid)) {
7612 return errorResult();
7613 }
7614
7615 Node decorator;
7616 MOZ_TRY_VAR(decorator, decoratorExpr(yieldHandling, tt))do { auto mozTryVarTempResult_ = (decoratorExpr(yieldHandling
, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()
), 0))) { return mozTryVarTempResult_.propagateErr(); } (decorator
) = mozTryVarTempResult_.unwrap(); } while (0)
;
7617
7618 handler_.addList(decorators, decorator);
7619
7620 if (!tokenStream.getToken(&tt)) {
7621 return errorResult();
7622 }
7623 if (tt != TokenKind::At) {
7624 anyChars.ungetToken();
7625 break;
7626 }
7627 }
7628 return decorators;
7629}
7630#endif
7631
7632template <class ParseHandler, typename Unit>
7633bool GeneralParser<ParseHandler, Unit>::classMember(
7634 YieldHandling yieldHandling, const ParseContext::ClassStatement& classStmt,
7635 TaggedParserAtomIndex className, uint32_t classStartOffset,
7636 HasHeritage hasHeritage, ClassInitializedMembers& classInitializedMembers,
7637 ListNodeType& classMembers, bool* done) {
7638 *done = false;
7639
7640 TokenKind tt;
7641 if (!tokenStream.getToken(&tt, TokenStream::SlashIsInvalid)) {
7642 return false;
7643 }
7644 if (tt == TokenKind::RightCurly) {
7645 *done = true;
7646 return true;
7647 }
7648
7649 if (tt == TokenKind::Semi) {
7650 return true;
7651 }
7652
7653#ifdef ENABLE_DECORATORS
7654 ListNodeType decorators = null();
7655 if (tt == TokenKind::At) {
7656 MOZ_TRY_VAR_OR_RETURN(decorators, decoratorList(yieldHandling), false)do { auto parserTryVarTempResult_ = (decoratorList(yieldHandling
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (decorators) = parserTryVarTempResult_
.unwrap(); } while (0)
;
7657
7658 if (!tokenStream.getToken(&tt, TokenStream::SlashIsInvalid)) {
7659 return false;
7660 }
7661 }
7662#endif
7663
7664 bool isStatic = false;
7665 if (tt == TokenKind::Static) {
7666 if (!tokenStream.peekToken(&tt)) {
7667 return false;
7668 }
7669
7670 if (tt == TokenKind::LeftCurly) {
7671 /* Parsing static class block: static { ... } */
7672 FunctionNodeType staticBlockBody;
7673 MOZ_TRY_VAR_OR_RETURN(staticBlockBody,do { auto parserTryVarTempResult_ = (staticClassBlock(classInitializedMembers
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (staticBlockBody) = parserTryVarTempResult_
.unwrap(); } while (0)
7674 staticClassBlock(classInitializedMembers), false)do { auto parserTryVarTempResult_ = (staticClassBlock(classInitializedMembers
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (staticBlockBody) = parserTryVarTempResult_
.unwrap(); } while (0)
;
7675
7676 StaticClassBlockType classBlock;
7677 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newStaticClassBlock
(staticBlockBody)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (classBlock) = parserTryVarTempResult_
.unwrap(); } while (0)
7678 classBlock, handler_.newStaticClassBlock(staticBlockBody), false)do { auto parserTryVarTempResult_ = (handler_.newStaticClassBlock
(staticBlockBody)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (classBlock) = parserTryVarTempResult_
.unwrap(); } while (0)
;
7679
7680 return handler_.addClassMemberDefinition(classMembers, classBlock);
7681 }
7682
7683 if (tt != TokenKind::LeftParen && tt != TokenKind::Assign &&
7684 tt != TokenKind::Semi && tt != TokenKind::RightCurly) {
7685 isStatic = true;
7686 } else {
7687 anyChars.ungetToken();
7688 }
7689 } else {
7690 anyChars.ungetToken();
7691 }
7692
7693 uint32_t propNameOffset;
7694 if (!tokenStream.peekOffset(&propNameOffset, TokenStream::SlashIsInvalid)) {
7695 return false;
7696 }
7697
7698 TaggedParserAtomIndex propAtom;
7699 PropertyType propType;
7700 Node propName;
7701 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInClass, Nothing(), classMembers, &propType
, &propAtom)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (propName) = parserTryVarTempResult_
.unwrap(); } while (0)
7702 propName,do { auto parserTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInClass, Nothing(), classMembers, &propType
, &propAtom)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (propName) = parserTryVarTempResult_
.unwrap(); } while (0)
7703 propertyOrMethodName(yieldHandling, PropertyNameInClass,do { auto parserTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInClass, Nothing(), classMembers, &propType
, &propAtom)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (propName) = parserTryVarTempResult_
.unwrap(); } while (0)
7704 /* maybeDecl = */ Nothing(), classMembers, &propType,do { auto parserTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInClass, Nothing(), classMembers, &propType
, &propAtom)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (propName) = parserTryVarTempResult_
.unwrap(); } while (0)
7705 &propAtom),do { auto parserTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInClass, Nothing(), classMembers, &propType
, &propAtom)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (propName) = parserTryVarTempResult_
.unwrap(); } while (0)
7706 false)do { auto parserTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInClass, Nothing(), classMembers, &propType
, &propAtom)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (propName) = parserTryVarTempResult_
.unwrap(); } while (0)
;
7707
7708 if (propType == PropertyType::Field ||
7709 propType == PropertyType::FieldWithAccessor) {
7710 if (isStatic) {
7711 if (propAtom == TaggedParserAtomIndex::WellKnown::prototype()) {
7712 errorAt(propNameOffset, JSMSG_CLASS_STATIC_PROTO);
7713 return false;
7714 }
7715 }
7716
7717 if (propAtom == TaggedParserAtomIndex::WellKnown::constructor()) {
7718 errorAt(propNameOffset, JSMSG_BAD_CONSTRUCTOR_DEF);
7719 return false;
7720 }
7721
7722 if (handler_.isPrivateName(propName)) {
7723 if (propAtom == TaggedParserAtomIndex::WellKnown::hash_constructor_()) {
7724 errorAt(propNameOffset, JSMSG_BAD_CONSTRUCTOR_DEF);
7725 return false;
7726 }
7727
7728 auto privateName = propAtom;
7729 if (!noteDeclaredPrivateName(
7730 propName, privateName, propType,
7731 isStatic ? FieldPlacement::Static : FieldPlacement::Instance,
7732 pos())) {
7733 return false;
7734 }
7735 }
7736
7737#ifdef ENABLE_DECORATORS
7738 ClassMethodType accessorGetterNode = null();
7739 ClassMethodType accessorSetterNode = null();
7740 if (propType == PropertyType::FieldWithAccessor) {
7741 // Decorators Proposal
7742 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-runtime-semantics-classfielddefinitionevaluation
7743 //
7744 // FieldDefinition : accessor ClassElementName Initializeropt
7745 //
7746 // Step 1. Let name be the result of evaluating ClassElementName.
7747 // ...
7748 // Step 3. Let privateStateDesc be the string-concatenation of name
7749 // and " accessor storage".
7750 StringBuffer privateStateDesc(fc_);
7751 if (!privateStateDesc.append(this->parserAtoms(), propAtom)) {
7752 return false;
7753 }
7754 if (!privateStateDesc.append(" accessor storage")) {
7755 return false;
7756 }
7757 // Step 4. Let privateStateName be a new Private Name whose
7758 // [[Description]] value is privateStateDesc.
7759 TokenPos propNamePos(propNameOffset, pos().end);
7760 auto privateStateName =
7761 privateStateDesc.finishParserAtom(this->parserAtoms(), fc_);
7762 if (!noteDeclaredPrivateName(
7763 propName, privateStateName, propType,
7764 isStatic ? FieldPlacement::Static : FieldPlacement::Instance,
7765 propNamePos)) {
7766 return false;
7767 }
7768
7769 // Step 5. Let getter be MakeAutoAccessorGetter(homeObject, name,
7770 // privateStateName).
7771 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Getter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorGetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7772 accessorGetterNode,do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Getter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorGetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7773 synthesizeAccessor(propName, propNamePos, propAtom, privateStateName,do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Getter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorGetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7774 isStatic, FunctionSyntaxKind::Getter,do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Getter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorGetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7775 classInitializedMembers),do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Getter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorGetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7776 false)do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Getter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorGetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
;
7777
7778 // If the accessor is not decorated or is a non-static private field,
7779 // add it to the class here. Otherwise, we'll handle this when the
7780 // decorators are called. We don't need to keep a reference to the node
7781 // after this except for non-static private accessors. Please see the
7782 // comment in the definition of ClassField for details.
7783 bool addAccessorImmediately =
7784 !decorators || (!isStatic && handler_.isPrivateName(propName));
7785 if (addAccessorImmediately) {
7786 if (!handler_.addClassMemberDefinition(classMembers,
7787 accessorGetterNode)) {
7788 return false;
7789 }
7790 if (!handler_.isPrivateName(propName)) {
7791 accessorGetterNode = null();
7792 }
7793 }
7794
7795 // Step 6. Let setter be MakeAutoAccessorSetter(homeObject, name,
7796 // privateStateName).
7797 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Setter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorSetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7798 accessorSetterNode,do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Setter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorSetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7799 synthesizeAccessor(propName, propNamePos, propAtom, privateStateName,do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Setter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorSetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7800 isStatic, FunctionSyntaxKind::Setter,do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Setter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorSetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7801 classInitializedMembers),do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Setter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorSetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
7802 false)do { auto parserTryVarTempResult_ = (synthesizeAccessor(propName
, propNamePos, propAtom, privateStateName, isStatic, FunctionSyntaxKind
::Setter, classInitializedMembers)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
accessorSetterNode) = parserTryVarTempResult_.unwrap(); } while
(0)
;
7803
7804 if (addAccessorImmediately) {
7805 if (!handler_.addClassMemberDefinition(classMembers,
7806 accessorSetterNode)) {
7807 return false;
7808 }
7809 if (!handler_.isPrivateName(propName)) {
7810 accessorSetterNode = null();
7811 }
7812 }
7813
7814 // Step 10. Return ClassElementDefinition Record { [[Key]]: name,
7815 // [[Kind]]: accessor, [[Get]]: getter, [[Set]]: setter,
7816 // [[BackingStorageKey]]: privateStateName, [[Initializers]]:
7817 // initializers, [[Decorators]]: empty }.
7818 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newPrivateName(
privateStateName, pos())); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (propName) = parserTryVarTempResult_
.unwrap(); } while (0)
7819 propName, handler_.newPrivateName(privateStateName, pos()), false)do { auto parserTryVarTempResult_ = (handler_.newPrivateName(
privateStateName, pos())); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (propName) = parserTryVarTempResult_
.unwrap(); } while (0)
;
7820 propAtom = privateStateName;
7821 // We maintain `decorators` here to perform this step at the same time:
7822 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-static-semantics-classelementevaluation
7823 // 4. Set fieldDefinition.[[Decorators]] to decorators.
7824 }
7825#endif
7826 if (isStatic) {
7827 classInitializedMembers.staticFields++;
7828 } else {
7829 classInitializedMembers.instanceFields++;
7830#ifdef ENABLE_DECORATORS
7831 if (decorators) {
7832 classInitializedMembers.hasInstanceDecorators = true;
7833 }
7834#endif
7835 }
7836
7837 TokenPos propNamePos(propNameOffset, pos().end);
7838 FunctionNodeType initializer;
7839 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (fieldInitializerOpt(propNamePos
, propName, propAtom, classInitializedMembers, isStatic, hasHeritage
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (initializer) = parserTryVarTempResult_
.unwrap(); } while (0)
7840 initializer,do { auto parserTryVarTempResult_ = (fieldInitializerOpt(propNamePos
, propName, propAtom, classInitializedMembers, isStatic, hasHeritage
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (initializer) = parserTryVarTempResult_
.unwrap(); } while (0)
7841 fieldInitializerOpt(propNamePos, propName, propAtom,do { auto parserTryVarTempResult_ = (fieldInitializerOpt(propNamePos
, propName, propAtom, classInitializedMembers, isStatic, hasHeritage
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (initializer) = parserTryVarTempResult_
.unwrap(); } while (0)
7842 classInitializedMembers, isStatic, hasHeritage),do { auto parserTryVarTempResult_ = (fieldInitializerOpt(propNamePos
, propName, propAtom, classInitializedMembers, isStatic, hasHeritage
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (initializer) = parserTryVarTempResult_
.unwrap(); } while (0)
7843 false)do { auto parserTryVarTempResult_ = (fieldInitializerOpt(propNamePos
, propName, propAtom, classInitializedMembers, isStatic, hasHeritage
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (initializer) = parserTryVarTempResult_
.unwrap(); } while (0)
;
7844
7845 if (!matchOrInsertSemicolon(TokenStream::SlashIsInvalid)) {
7846 return false;
7847 }
7848
7849 ClassFieldType field;
7850 MOZ_TRY_VAR_OR_RETURN(field,do { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
7851 handler_.newClassFieldDefinition(do { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
7852 propName, initializer, isStaticdo { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
7853#ifdef ENABLE_DECORATORSdo { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
7854 ,do { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
7855 decorators, accessorGetterNode, accessorSetterNodedo { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
7856#endifdo { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
7857 ),do { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
7858 false)do { auto parserTryVarTempResult_ = (handler_.newClassFieldDefinition
( propName, initializer, isStatic ifdef ENABLE_DECORATORS , decorators
, accessorGetterNode, accessorSetterNode endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(field) = parserTryVarTempResult_.unwrap(); } while (0)
;
7859
7860 return handler_.addClassMemberDefinition(classMembers, field);
7861 }
7862
7863 if (propType != PropertyType::Getter && propType != PropertyType::Setter &&
7864 propType != PropertyType::Method &&
7865 propType != PropertyType::GeneratorMethod &&
7866 propType != PropertyType::AsyncMethod &&
7867 propType != PropertyType::AsyncGeneratorMethod) {
7868 errorAt(propNameOffset, JSMSG_BAD_CLASS_MEMBER_DEF);
7869 return false;
7870 }
7871
7872 bool isConstructor =
7873 !isStatic && propAtom == TaggedParserAtomIndex::WellKnown::constructor();
7874 if (isConstructor) {
7875 if (propType != PropertyType::Method) {
7876 errorAt(propNameOffset, JSMSG_BAD_CONSTRUCTOR_DEF);
7877 return false;
7878 }
7879 if (classStmt.constructorBox) {
7880 errorAt(propNameOffset, JSMSG_DUPLICATE_CONSTRUCTOR);
7881 return false;
7882 }
7883 propType = hasHeritage == HasHeritage::Yes
7884 ? PropertyType::DerivedConstructor
7885 : PropertyType::Constructor;
7886 } else if (isStatic &&
7887 propAtom == TaggedParserAtomIndex::WellKnown::prototype()) {
7888 errorAt(propNameOffset, JSMSG_CLASS_STATIC_PROTO);
7889 return false;
7890 }
7891
7892 TaggedParserAtomIndex funName;
7893 switch (propType) {
7894 case PropertyType::Getter:
7895 case PropertyType::Setter: {
7896 bool hasStaticName =
7897 !anyChars.isCurrentTokenType(TokenKind::RightBracket) && propAtom;
7898 if (hasStaticName) {
7899 funName = prefixAccessorName(propType, propAtom);
7900 if (!funName) {
7901 return false;
7902 }
7903 }
7904 break;
7905 }
7906 case PropertyType::Constructor:
7907 case PropertyType::DerivedConstructor:
7908 funName = className;
7909 break;
7910 default:
7911 if (!anyChars.isCurrentTokenType(TokenKind::RightBracket)) {
7912 funName = propAtom;
7913 }
7914 }
7915
7916 // When |super()| is invoked, we search for the nearest scope containing
7917 // |.initializers| to initialize the class fields. This set-up precludes
7918 // declaring |.initializers| in the class scope, because in some syntactic
7919 // contexts |super()| can appear nested in a class, while actually belonging
7920 // to an outer class definition.
7921 //
7922 // Example:
7923 // class Outer extends Base {
7924 // field = 1;
7925 // constructor() {
7926 // class Inner {
7927 // field = 2;
7928 //
7929 // // The super() call in the computed property name mustn't access
7930 // // Inner's |.initializers| array, but instead Outer's.
7931 // [super()]() {}
7932 // }
7933 // }
7934 // }
7935 Maybe<ParseContext::Scope> dotInitializersScope;
7936 if (isConstructor && !options().selfHostingMode) {
7937 dotInitializersScope.emplace(this);
7938 if (!dotInitializersScope->init(pc_)) {
7939 return false;
7940 }
7941
7942 if (!noteDeclaredName(TaggedParserAtomIndex::WellKnown::dot_initializers_(),
7943 DeclarationKind::Let, pos())) {
7944 return false;
7945 }
7946
7947#ifdef ENABLE_DECORATORS
7948 if (!noteDeclaredName(
7949 TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_(),
7950 DeclarationKind::Let, pos())) {
7951 return false;
7952 }
7953#endif
7954 }
7955
7956 // Calling toString on constructors need to return the source text for
7957 // the entire class. The end offset is unknown at this point in
7958 // parsing and will be amended when class parsing finishes below.
7959 FunctionNodeType funNode;
7960 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (methodDefinition(isConstructor
? classStartOffset : propNameOffset, propType, funName)); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (funNode) = parserTryVarTempResult_.unwrap
(); } while (0)
7961 funNode,do { auto parserTryVarTempResult_ = (methodDefinition(isConstructor
? classStartOffset : propNameOffset, propType, funName)); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (funNode) = parserTryVarTempResult_.unwrap
(); } while (0)
7962 methodDefinition(isConstructor ? classStartOffset : propNameOffset,do { auto parserTryVarTempResult_ = (methodDefinition(isConstructor
? classStartOffset : propNameOffset, propType, funName)); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (funNode) = parserTryVarTempResult_.unwrap
(); } while (0)
7963 propType, funName),do { auto parserTryVarTempResult_ = (methodDefinition(isConstructor
? classStartOffset : propNameOffset, propType, funName)); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (funNode) = parserTryVarTempResult_.unwrap
(); } while (0)
7964 false)do { auto parserTryVarTempResult_ = (methodDefinition(isConstructor
? classStartOffset : propNameOffset, propType, funName)); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (funNode) = parserTryVarTempResult_.unwrap
(); } while (0)
;
7965
7966 AccessorType atype = ToAccessorType(propType);
7967
7968 Maybe<FunctionNodeType> initializerIfPrivate = Nothing();
7969 if (handler_.isPrivateName(propName)) {
7970 if (propAtom == TaggedParserAtomIndex::WellKnown::hash_constructor_()) {
7971 // #constructor is an invalid private name.
7972 errorAt(propNameOffset, JSMSG_BAD_CONSTRUCTOR_DEF);
7973 return false;
7974 }
7975
7976 TaggedParserAtomIndex privateName = propAtom;
7977 if (!noteDeclaredPrivateName(
7978 propName, privateName, propType,
7979 isStatic ? FieldPlacement::Static : FieldPlacement::Instance,
7980 pos())) {
7981 return false;
7982 }
7983
7984 // Private non-static methods are stored in the class body environment.
7985 // Private non-static accessors are stamped onto every instance using
7986 // initializers. Private static methods are stamped onto the constructor
7987 // during class evaluation; see BytecodeEmitter::emitPropertyList.
7988 if (!isStatic) {
7989 if (atype == AccessorType::Getter || atype == AccessorType::Setter) {
7990 classInitializedMembers.privateAccessors++;
7991 TokenPos propNamePos(propNameOffset, pos().end);
7992 FunctionNodeType initializerNode;
7993 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (synthesizePrivateMethodInitializer
(propAtom, atype, propNamePos)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (initializerNode) = parserTryVarTempResult_
.unwrap(); } while (0)
7994 initializerNode,do { auto parserTryVarTempResult_ = (synthesizePrivateMethodInitializer
(propAtom, atype, propNamePos)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (initializerNode) = parserTryVarTempResult_
.unwrap(); } while (0)
7995 synthesizePrivateMethodInitializer(propAtom, atype, propNamePos),do { auto parserTryVarTempResult_ = (synthesizePrivateMethodInitializer
(propAtom, atype, propNamePos)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (initializerNode) = parserTryVarTempResult_
.unwrap(); } while (0)
7996 false)do { auto parserTryVarTempResult_ = (synthesizePrivateMethodInitializer
(propAtom, atype, propNamePos)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (initializerNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
7997 initializerIfPrivate = Some(initializerNode);
7998 } else {
7999 MOZ_ASSERT(atype == AccessorType::None)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(atype == AccessorType::None)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(atype == AccessorType::None)
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("atype == AccessorType::None"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 7999); AnnotateMozCrashReason("MOZ_ASSERT" "(" "atype == AccessorType::None"
")"); do { *((volatile int*)__null) = 7999; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8000 classInitializedMembers.privateMethods++;
8001 }
8002 }
8003 }
8004
8005#ifdef ENABLE_DECORATORS
8006 if (decorators) {
8007 classInitializedMembers.hasInstanceDecorators = true;
8008 }
8009#endif
8010
8011 Node method;
8012 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8013 method,do { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8014 handler_.newClassMethodDefinition(propName, funNode, atype, isStatic,do { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8015 initializerIfPrivatedo { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8016#ifdef ENABLE_DECORATORSdo { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8017 ,do { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8018 decoratorsdo { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8019#endifdo { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8020 ),do { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8021 false)do { auto parserTryVarTempResult_ = (handler_.newClassMethodDefinition
(propName, funNode, atype, isStatic, initializerIfPrivate ifdef
ENABLE_DECORATORS , decorators endif )); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
;
8022
8023 if (dotInitializersScope.isSome()) {
8024 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (finishLexicalScope(*dotInitializersScope
, method)); if ((__builtin_expect(!!(parserTryVarTempResult_.
isErr()), 0))) { return (false); } (method) = parserTryVarTempResult_
.unwrap(); } while (0)
8025 method, finishLexicalScope(*dotInitializersScope, method), false)do { auto parserTryVarTempResult_ = (finishLexicalScope(*dotInitializersScope
, method)); if ((__builtin_expect(!!(parserTryVarTempResult_.
isErr()), 0))) { return (false); } (method) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8026 dotInitializersScope.reset();
8027 }
8028
8029 return handler_.addClassMemberDefinition(classMembers, method);
8030}
8031
8032template <class ParseHandler, typename Unit>
8033bool GeneralParser<ParseHandler, Unit>::finishClassConstructor(
8034 const ParseContext::ClassStatement& classStmt,
8035 TaggedParserAtomIndex className, HasHeritage hasHeritage,
8036 uint32_t classStartOffset, uint32_t classEndOffset,
8037 const ClassInitializedMembers& classInitializedMembers,
8038 ListNodeType& classMembers) {
8039 if (classStmt.constructorBox == nullptr) {
8040 MOZ_ASSERT(!options().selfHostingMode)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!options().selfHostingMode)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!options().selfHostingMode))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!options().selfHostingMode"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8040); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!options().selfHostingMode"
")"); do { *((volatile int*)__null) = 8040; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8041 // Unconditionally create the scope here, because it's always the
8042 // constructor.
8043 ParseContext::Scope dotInitializersScope(this);
8044 if (!dotInitializersScope.init(pc_)) {
8045 return false;
8046 }
8047
8048 if (!noteDeclaredName(TaggedParserAtomIndex::WellKnown::dot_initializers_(),
8049 DeclarationKind::Let, pos())) {
8050 return false;
8051 }
8052
8053#ifdef ENABLE_DECORATORS
8054 if (!noteDeclaredName(
8055 TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_(),
8056 DeclarationKind::Let, pos(), ClosedOver::Yes)) {
8057 return false;
8058 }
8059#endif
8060
8061 // synthesizeConstructor assigns to classStmt.constructorBox
8062 TokenPos synthesizedBodyPos(classStartOffset, classEndOffset);
8063 FunctionNodeType synthesizedCtor;
8064 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (synthesizeConstructor(className
, synthesizedBodyPos, hasHeritage)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
synthesizedCtor) = parserTryVarTempResult_.unwrap(); } while (
0)
8065 synthesizedCtor,do { auto parserTryVarTempResult_ = (synthesizeConstructor(className
, synthesizedBodyPos, hasHeritage)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
synthesizedCtor) = parserTryVarTempResult_.unwrap(); } while (
0)
8066 synthesizeConstructor(className, synthesizedBodyPos, hasHeritage),do { auto parserTryVarTempResult_ = (synthesizeConstructor(className
, synthesizedBodyPos, hasHeritage)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
synthesizedCtor) = parserTryVarTempResult_.unwrap(); } while (
0)
8067 false)do { auto parserTryVarTempResult_ = (synthesizeConstructor(className
, synthesizedBodyPos, hasHeritage)); if ((__builtin_expect(!!
(parserTryVarTempResult_.isErr()), 0))) { return (false); } (
synthesizedCtor) = parserTryVarTempResult_.unwrap(); } while (
0)
;
8068
8069 // Note: the *function* has the name of the class, but the *property*
8070 // containing the function has the name "constructor"
8071 Node constructorNameNode;
8072 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newObjectLiteralPropertyName
( TaggedParserAtomIndex::WellKnown::constructor(), pos())); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (constructorNameNode) = parserTryVarTempResult_
.unwrap(); } while (0)
8073 constructorNameNode,do { auto parserTryVarTempResult_ = (handler_.newObjectLiteralPropertyName
( TaggedParserAtomIndex::WellKnown::constructor(), pos())); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (constructorNameNode) = parserTryVarTempResult_
.unwrap(); } while (0)
8074 handler_.newObjectLiteralPropertyName(do { auto parserTryVarTempResult_ = (handler_.newObjectLiteralPropertyName
( TaggedParserAtomIndex::WellKnown::constructor(), pos())); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (constructorNameNode) = parserTryVarTempResult_
.unwrap(); } while (0)
8075 TaggedParserAtomIndex::WellKnown::constructor(), pos()),do { auto parserTryVarTempResult_ = (handler_.newObjectLiteralPropertyName
( TaggedParserAtomIndex::WellKnown::constructor(), pos())); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (constructorNameNode) = parserTryVarTempResult_
.unwrap(); } while (0)
8076 false)do { auto parserTryVarTempResult_ = (handler_.newObjectLiteralPropertyName
( TaggedParserAtomIndex::WellKnown::constructor(), pos())); if
((__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0)))
{ return (false); } (constructorNameNode) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8077 ClassMethodType method;
8078 MOZ_TRY_VAR_OR_RETURN(method,do { auto parserTryVarTempResult_ = (handler_.newDefaultClassConstructor
( constructorNameNode, synthesizedCtor)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8079 handler_.newDefaultClassConstructor(do { auto parserTryVarTempResult_ = (handler_.newDefaultClassConstructor
( constructorNameNode, synthesizedCtor)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8080 constructorNameNode, synthesizedCtor),do { auto parserTryVarTempResult_ = (handler_.newDefaultClassConstructor
( constructorNameNode, synthesizedCtor)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
8081 false)do { auto parserTryVarTempResult_ = (handler_.newDefaultClassConstructor
( constructorNameNode, synthesizedCtor)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(method) = parserTryVarTempResult_.unwrap(); } while (0)
;
8082 LexicalScopeNodeType scope;
8083 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (finishLexicalScope(dotInitializersScope
, method)); if ((__builtin_expect(!!(parserTryVarTempResult_.
isErr()), 0))) { return (false); } (scope) = parserTryVarTempResult_
.unwrap(); } while (0)
8084 scope, finishLexicalScope(dotInitializersScope, method), false)do { auto parserTryVarTempResult_ = (finishLexicalScope(dotInitializersScope
, method)); if ((__builtin_expect(!!(parserTryVarTempResult_.
isErr()), 0))) { return (false); } (scope) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8085 if (!handler_.addClassMemberDefinition(classMembers, scope)) {
8086 return false;
8087 }
8088 }
8089
8090 MOZ_ASSERT(classStmt.constructorBox)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(classStmt.constructorBox)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(classStmt.constructorBox))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("classStmt.constructorBox"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8090); AnnotateMozCrashReason("MOZ_ASSERT" "(" "classStmt.constructorBox"
")"); do { *((volatile int*)__null) = 8090; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8091 FunctionBox* ctorbox = classStmt.constructorBox;
8092
8093 // Amend the toStringEnd offset for the constructor now that we've
8094 // finished parsing the class.
8095 ctorbox->setCtorToStringEnd(classEndOffset);
8096
8097 size_t numMemberInitializers = classInitializedMembers.privateAccessors +
8098 classInitializedMembers.instanceFields;
8099 bool hasPrivateBrand = classInitializedMembers.hasPrivateBrand();
8100 if (hasPrivateBrand || numMemberInitializers > 0) {
8101 // Now that we have full set of initializers, update the constructor.
8102 MemberInitializers initializers(
8103 hasPrivateBrand,
8104#ifdef ENABLE_DECORATORS
8105 classInitializedMembers.hasInstanceDecorators,
8106#endif
8107 numMemberInitializers);
8108 ctorbox->setMemberInitializers(initializers);
8109
8110 // Field initialization need access to `this`.
8111 ctorbox->setCtorFunctionHasThisBinding();
8112 }
8113
8114 return true;
8115}
8116
8117template <class ParseHandler, typename Unit>
8118typename ParseHandler::ClassNodeResult
8119GeneralParser<ParseHandler, Unit>::classDefinition(
8120 YieldHandling yieldHandling, ClassContext classContext,
8121 DefaultHandling defaultHandling) {
8122#ifdef ENABLE_DECORATORS
8123 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::At) ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::At) || anyChars
.isCurrentTokenType(TokenKind::Class))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::At) || anyChars.isCurrentTokenType(TokenKind::Class
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::At) || anyChars.isCurrentTokenType(TokenKind::Class)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8124); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::At) || anyChars.isCurrentTokenType(TokenKind::Class)"
")"); do { *((volatile int*)__null) = 8124; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
8124 anyChars.isCurrentTokenType(TokenKind::Class))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::At) || anyChars
.isCurrentTokenType(TokenKind::Class))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::At) || anyChars.isCurrentTokenType(TokenKind::Class
)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::At) || anyChars.isCurrentTokenType(TokenKind::Class)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8124); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::At) || anyChars.isCurrentTokenType(TokenKind::Class)"
")"); do { *((volatile int*)__null) = 8124; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8125
8126 ListNodeType decorators = null();
8127 FunctionNodeType addInitializerFunction = null();
8128 if (anyChars.isCurrentTokenType(TokenKind::At)) {
8129 MOZ_TRY_VAR(decorators, decoratorList(yieldHandling))do { auto mozTryVarTempResult_ = (decoratorList(yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (decorators
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8130 TokenKind next;
8131 if (!tokenStream.getToken(&next)) {
8132 return errorResult();
8133 }
8134 if (next != TokenKind::Class) {
8135 error(JSMSG_CLASS_EXPECTED);
8136 return errorResult();
8137 }
8138 }
8139#else
8140 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Class))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Class))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Class)))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Class)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8140); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Class)"
")"); do { *((volatile int*)__null) = 8140; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8141#endif
8142
8143 uint32_t classStartOffset = pos().begin;
8144 bool savedStrictness = setLocalStrictMode(true);
8145
8146 // Classes are quite broken in self-hosted code.
8147 if (options().selfHostingMode) {
8148 error(JSMSG_SELFHOSTED_CLASS);
8149 return errorResult();
8150 }
8151
8152 TokenKind tt;
8153 if (!tokenStream.getToken(&tt)) {
8154 return errorResult();
8155 }
8156
8157 TaggedParserAtomIndex className;
8158 if (TokenKindIsPossibleIdentifier(tt)) {
8159 className = bindingIdentifier(yieldHandling);
8160 if (!className) {
8161 return errorResult();
8162 }
8163 } else if (classContext == ClassStatement) {
8164 if (defaultHandling == AllowDefaultName) {
8165 className = TaggedParserAtomIndex::WellKnown::default_();
8166 anyChars.ungetToken();
8167 } else {
8168 // Class statements must have a bound name
8169 error(JSMSG_UNNAMED_CLASS_STMT);
8170 return errorResult();
8171 }
8172 } else {
8173 // Make sure to put it back, whatever it was
8174 anyChars.ungetToken();
8175 }
8176
8177 // Because the binding definitions keep track of their blockId, we need to
8178 // create at least the inner binding later. Keep track of the name's
8179 // position in order to provide it for the nodes created later.
8180 TokenPos namePos = pos();
8181
8182 auto isClass = [](ParseContext::Statement* stmt) {
8183 return stmt->kind() == StatementKind::Class;
8184 };
8185
8186 bool isInClass = pc_->sc()->inClass() || pc_->findInnermostStatement(isClass);
8187
8188 // Push a ParseContext::ClassStatement to keep track of the constructor
8189 // funbox.
8190 ParseContext::ClassStatement classStmt(pc_);
8191
8192 NameNodeType innerName;
8193 Node nameNode = null();
8194 Node classHeritage = null();
8195 LexicalScopeNodeType classBlock = null();
8196 ClassBodyScopeNodeType classBodyBlock = null();
8197 uint32_t classEndOffset;
8198 {
8199 // A named class creates a new lexical scope with a const binding of the
8200 // class name for the "inner name".
8201 ParseContext::Statement innerScopeStmt(pc_, StatementKind::Block);
8202 ParseContext::Scope innerScope(this);
8203 if (!innerScope.init(pc_)) {
8204 return errorResult();
8205 }
8206
8207 bool hasHeritageBool;
8208 if (!tokenStream.matchToken(&hasHeritageBool, TokenKind::Extends)) {
8209 return errorResult();
8210 }
8211 HasHeritage hasHeritage =
8212 hasHeritageBool ? HasHeritage::Yes : HasHeritage::No;
8213 if (hasHeritage == HasHeritage::Yes) {
8214 if (!tokenStream.getToken(&tt)) {
8215 return errorResult();
8216 }
8217 MOZ_TRY_VAR(classHeritage,do { auto mozTryVarTempResult_ = (optionalExpr(yieldHandling,
TripledotProhibited, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (classHeritage) = mozTryVarTempResult_.unwrap(); } while (
0)
8218 optionalExpr(yieldHandling, TripledotProhibited, tt))do { auto mozTryVarTempResult_ = (optionalExpr(yieldHandling,
TripledotProhibited, tt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (classHeritage) = mozTryVarTempResult_.unwrap(); } while (
0)
;
8219 }
8220
8221 if (!mustMatchToken(TokenKind::LeftCurly, JSMSG_CURLY_BEFORE_CLASS)) {
8222 return errorResult();
8223 }
8224
8225 {
8226 ParseContext::Statement bodyScopeStmt(pc_, StatementKind::Block);
8227 ParseContext::Scope bodyScope(this);
8228 if (!bodyScope.init(pc_)) {
8229 return errorResult();
8230 }
8231
8232 ListNodeType classMembers;
8233 MOZ_TRY_VAR(classMembers, handler_.newClassMemberList(pos().begin))do { auto mozTryVarTempResult_ = (handler_.newClassMemberList
(pos().begin)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (classMembers) = mozTryVarTempResult_.unwrap(); } while (0
)
;
8234
8235 ClassInitializedMembers classInitializedMembers{};
8236 for (;;) {
8237 bool done;
8238 if (!classMember(yieldHandling, classStmt, className, classStartOffset,
8239 hasHeritage, classInitializedMembers, classMembers,
8240 &done)) {
8241 return errorResult();
8242 }
8243 if (done) {
8244 break;
8245 }
8246 }
8247#ifdef ENABLE_DECORATORS
8248 if (classInitializedMembers.hasInstanceDecorators) {
8249 MOZ_TRY_VAR(addInitializerFunction,do { auto mozTryVarTempResult_ = (synthesizeAddInitializerFunction
( TaggedParserAtomIndex::WellKnown:: dot_instanceExtraInitializers_
(), yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (addInitializerFunction) = mozTryVarTempResult_.unwrap(); }
while (0)
8250 synthesizeAddInitializerFunction(do { auto mozTryVarTempResult_ = (synthesizeAddInitializerFunction
( TaggedParserAtomIndex::WellKnown:: dot_instanceExtraInitializers_
(), yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (addInitializerFunction) = mozTryVarTempResult_.unwrap(); }
while (0)
8251 TaggedParserAtomIndex::WellKnown::do { auto mozTryVarTempResult_ = (synthesizeAddInitializerFunction
( TaggedParserAtomIndex::WellKnown:: dot_instanceExtraInitializers_
(), yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (addInitializerFunction) = mozTryVarTempResult_.unwrap(); }
while (0)
8252 dot_instanceExtraInitializers_(),do { auto mozTryVarTempResult_ = (synthesizeAddInitializerFunction
( TaggedParserAtomIndex::WellKnown:: dot_instanceExtraInitializers_
(), yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (addInitializerFunction) = mozTryVarTempResult_.unwrap(); }
while (0)
8253 yieldHandling))do { auto mozTryVarTempResult_ = (synthesizeAddInitializerFunction
( TaggedParserAtomIndex::WellKnown:: dot_instanceExtraInitializers_
(), yieldHandling)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (addInitializerFunction) = mozTryVarTempResult_.unwrap(); }
while (0)
;
8254 }
8255#endif
8256
8257 if (classInitializedMembers.privateMethods +
8258 classInitializedMembers.privateAccessors >
8259 0) {
8260 // We declare `.privateBrand` as ClosedOver because the constructor
8261 // always uses it, even a default constructor. We could equivalently
8262 // `noteUsedName` when parsing the constructor, except that at that
8263 // time, we don't necessarily know if the class has a private brand.
8264 if (!noteDeclaredName(
8265 TaggedParserAtomIndex::WellKnown::dot_privateBrand_(),
8266 DeclarationKind::Synthetic, namePos, ClosedOver::Yes)) {
8267 return errorResult();
8268 }
8269 }
8270
8271 if (classInitializedMembers.instanceFieldKeys > 0) {
8272 if (!noteDeclaredName(
8273 TaggedParserAtomIndex::WellKnown::dot_fieldKeys_(),
8274 DeclarationKind::Synthetic, namePos)) {
8275 return errorResult();
8276 }
8277 }
8278
8279 if (classInitializedMembers.staticFields > 0) {
8280 if (!noteDeclaredName(
8281 TaggedParserAtomIndex::WellKnown::dot_staticInitializers_(),
8282 DeclarationKind::Synthetic, namePos)) {
8283 return errorResult();
8284 }
8285 }
8286
8287 if (classInitializedMembers.staticFieldKeys > 0) {
8288 if (!noteDeclaredName(
8289 TaggedParserAtomIndex::WellKnown::dot_staticFieldKeys_(),
8290 DeclarationKind::Synthetic, namePos)) {
8291 return errorResult();
8292 }
8293 }
8294
8295 classEndOffset = pos().end;
8296 if (!finishClassConstructor(classStmt, className, hasHeritage,
8297 classStartOffset, classEndOffset,
8298 classInitializedMembers, classMembers)) {
8299 return errorResult();
8300 }
8301
8302 MOZ_TRY_VAR(classBodyBlock,do { auto mozTryVarTempResult_ = (finishClassBodyScope(bodyScope
, classMembers)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (classBodyBlock) = mozTryVarTempResult_.unwrap(); } while (
0)
8303 finishClassBodyScope(bodyScope, classMembers))do { auto mozTryVarTempResult_ = (finishClassBodyScope(bodyScope
, classMembers)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (classBodyBlock) = mozTryVarTempResult_.unwrap(); } while (
0)
;
8304
8305 // Pop the class body scope
8306 }
8307
8308 if (className) {
8309 // The inner name is immutable.
8310 if (!noteDeclaredName(className, DeclarationKind::Const, namePos)) {
8311 return errorResult();
8312 }
8313
8314 MOZ_TRY_VAR(innerName, newName(className, namePos))do { auto mozTryVarTempResult_ = (newName(className, namePos)
); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)
)) { return mozTryVarTempResult_.propagateErr(); } (innerName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8315 }
8316
8317 MOZ_TRY_VAR(classBlock, finishLexicalScope(innerScope, classBodyBlock))do { auto mozTryVarTempResult_ = (finishLexicalScope(innerScope
, classBodyBlock)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (classBlock) = mozTryVarTempResult_.unwrap(); } while (0)
;
8318
8319 // Pop the inner scope.
8320 }
8321
8322 if (className) {
8323 NameNodeType outerName = null();
8324 if (classContext == ClassStatement) {
8325 // The outer name is mutable.
8326 if (!noteDeclaredName(className, DeclarationKind::Class, namePos)) {
8327 return errorResult();
8328 }
8329
8330 MOZ_TRY_VAR(outerName, newName(className, namePos))do { auto mozTryVarTempResult_ = (newName(className, namePos)
); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)
)) { return mozTryVarTempResult_.propagateErr(); } (outerName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8331 }
8332
8333 MOZ_TRY_VAR(nameNode,do { auto mozTryVarTempResult_ = (handler_.newClassNames(outerName
, innerName, namePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (nameNode) = mozTryVarTempResult_.unwrap(); } while (0)
8334 handler_.newClassNames(outerName, innerName, namePos))do { auto mozTryVarTempResult_ = (handler_.newClassNames(outerName
, innerName, namePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (nameNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
8335 }
8336 MOZ_ALWAYS_TRUE(setLocalStrictMode(savedStrictness))do { if ((__builtin_expect(!!(setLocalStrictMode(savedStrictness
)), 1))) { } else { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(false)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("false" " (" "setLocalStrictMode(savedStrictness)"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8336); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "setLocalStrictMode(savedStrictness)" ")"); do { *((volatile
int*)__null) = 8336; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false); } } while (false)
;
8337 // We're leaving a class definition that was not itself nested within a class
8338 if (!isInClass) {
8339 mozilla::Maybe<UnboundPrivateName> maybeUnboundName;
8340 if (!usedNames_.hasUnboundPrivateNames(fc_, maybeUnboundName)) {
8341 return errorResult();
8342 }
8343 if (maybeUnboundName) {
8344 UniqueChars str =
8345 this->parserAtoms().toPrintableString(maybeUnboundName->atom);
8346 if (!str) {
8347 ReportOutOfMemory(this->fc_);
8348 return errorResult();
8349 }
8350
8351 errorAt(maybeUnboundName->position.begin, JSMSG_MISSING_PRIVATE_DECL,
8352 str.get());
8353 return errorResult();
8354 }
8355 }
8356
8357 return handler_.newClass(nameNode, classHeritage, classBlock,
8358#ifdef ENABLE_DECORATORS
8359 decorators, addInitializerFunction,
8360#endif
8361 TokenPos(classStartOffset, classEndOffset));
8362}
8363
8364template <class ParseHandler, typename Unit>
8365typename ParseHandler::FunctionNodeResult
8366GeneralParser<ParseHandler, Unit>::synthesizeConstructor(
8367 TaggedParserAtomIndex className, TokenPos synthesizedBodyPos,
8368 HasHeritage hasHeritage) {
8369 FunctionSyntaxKind functionSyntaxKind =
8370 hasHeritage == HasHeritage::Yes
8371 ? FunctionSyntaxKind::DerivedClassConstructor
8372 : FunctionSyntaxKind::ClassConstructor;
8373
8374 bool isSelfHosting = options().selfHostingMode;
8375 FunctionFlags flags =
8376 InitialFunctionFlags(functionSyntaxKind, GeneratorKind::NotGenerator,
8377 FunctionAsyncKind::SyncFunction, isSelfHosting);
8378
8379 // Create the top-level field initializer node.
8380 FunctionNodeType funNode;
8381 MOZ_TRY_VAR(funNode,do { auto mozTryVarTempResult_ = (handler_.newFunction(functionSyntaxKind
, synthesizedBodyPos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (funNode) = mozTryVarTempResult_.unwrap(); } while (0)
8382 handler_.newFunction(functionSyntaxKind, synthesizedBodyPos))do { auto mozTryVarTempResult_ = (handler_.newFunction(functionSyntaxKind
, synthesizedBodyPos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (funNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
8383
8384 // If we see any inner function, note it on our current context. The bytecode
8385 // emitter may eliminate the function later, but we use a conservative
8386 // definition for consistency between lazy and full parsing.
8387 pc_->sc()->setHasInnerFunctions();
8388
8389 // When fully parsing a lazy script, we do not fully reparse its inner
8390 // functions, which are also lazy. Instead, their free variables and source
8391 // extents are recorded and may be skipped.
8392 if (handler_.reuseLazyInnerFunctions()) {
8393 if (!skipLazyInnerFunction(funNode, synthesizedBodyPos.begin,
8394 /* tryAnnexB = */ false)) {
8395 return errorResult();
8396 }
8397
8398 return funNode;
8399 }
8400
8401 // Create the FunctionBox and link it to the function object.
8402 Directives directives(true);
8403 FunctionBox* funbox = newFunctionBox(
8404 funNode, className, flags, synthesizedBodyPos.begin, directives,
8405 GeneratorKind::NotGenerator, FunctionAsyncKind::SyncFunction);
8406 if (!funbox) {
8407 return errorResult();
8408 }
8409 funbox->initWithEnclosingParseContext(pc_, functionSyntaxKind);
8410 setFunctionEndFromCurrentToken(funbox);
8411
8412 // Mark this function as being synthesized by the parser. This means special
8413 // handling in delazification will be used since we don't have typical
8414 // function syntax.
8415 funbox->setSyntheticFunction();
8416
8417 // Push a SourceParseContext on to the stack.
8418 ParseContext* outerpc = pc_;
8419 SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
8420 if (!funpc.init()) {
8421 return errorResult();
8422 }
8423
8424 if (!synthesizeConstructorBody(synthesizedBodyPos, hasHeritage, funNode,
8425 funbox)) {
8426 return errorResult();
8427 }
8428
8429 if (!leaveInnerFunction(outerpc)) {
8430 return errorResult();
8431 }
8432
8433 return funNode;
8434}
8435
8436template <class ParseHandler, typename Unit>
8437bool GeneralParser<ParseHandler, Unit>::synthesizeConstructorBody(
8438 TokenPos synthesizedBodyPos, HasHeritage hasHeritage,
8439 FunctionNodeType funNode, FunctionBox* funbox) {
8440 MOZ_ASSERT(funbox->isClassConstructor())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funbox->isClassConstructor())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(funbox->isClassConstructor
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("funbox->isClassConstructor()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8440); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funbox->isClassConstructor()"
")"); do { *((volatile int*)__null) = 8440; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
21
Taking false branch
22
Loop condition is false. Exiting loop
8441
8442 // Create a ParamsBodyNode for the parameters + body (there are no
8443 // parameters).
8444 ParamsBodyNodeType argsbody;
8445 MOZ_TRY_VAR_OR_RETURN(argsbody, handler_.newParamsBody(synthesizedBodyPos),do { auto parserTryVarTempResult_ = (handler_.newParamsBody(synthesizedBodyPos
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (argsbody) = parserTryVarTempResult_
.unwrap(); } while (0)
23
Taking false branch
24
Loop condition is false. Exiting loop
8446 false)do { auto parserTryVarTempResult_ = (handler_.newParamsBody(synthesizedBodyPos
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (argsbody) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8447 handler_.setFunctionFormalParametersAndBody(funNode, argsbody);
8448 setFunctionStartAtPosition(funbox, synthesizedBodyPos);
8449
8450 if (hasHeritage
24.1
'hasHeritage' is equal to Yes
== HasHeritage::Yes) {
25
Taking true branch
8451 // Synthesize the equivalent to `function f(...args)`
8452 funbox->setHasRest();
8453 if (!notePositionalFormalParameter(
27
Calling 'GeneralParser::notePositionalFormalParameter'
8454 funNode, TaggedParserAtomIndex::WellKnown::dot_args_(),
8455 synthesizedBodyPos.begin,
8456 /* disallowDuplicateParams = */ false,
8457 /* duplicatedParam = */ nullptr)) {
26
Passing null pointer value via 5th parameter 'duplicatedParam'
8458 return false;
8459 }
8460 funbox->setArgCount(1);
8461 } else {
8462 funbox->setArgCount(0);
8463 }
8464
8465 pc_->functionScope().useAsVarScope(pc_);
8466
8467 ListNodeType stmtList;
8468 MOZ_TRY_VAR_OR_RETURN(stmtList, handler_.newStatementList(synthesizedBodyPos),do { auto parserTryVarTempResult_ = (handler_.newStatementList
(synthesizedBodyPos)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (stmtList) = parserTryVarTempResult_
.unwrap(); } while (0)
8469 false)do { auto parserTryVarTempResult_ = (handler_.newStatementList
(synthesizedBodyPos)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (stmtList) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8470
8471 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::dot_this_())) {
8472 return false;
8473 }
8474
8475 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::dot_initializers_())) {
8476 return false;
8477 }
8478
8479#ifdef ENABLE_DECORATORS
8480 if (!noteUsedName(
8481 TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_())) {
8482 return false;
8483 }
8484#endif
8485
8486 if (hasHeritage == HasHeritage::Yes) {
8487 // |super()| implicitly reads |new.target|.
8488 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::dot_newTarget_())) {
8489 return false;
8490 }
8491
8492 NameNodeType thisName;
8493 MOZ_TRY_VAR_OR_RETURN(thisName, newThisName(), false)do { auto parserTryVarTempResult_ = (newThisName()); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(thisName) = parserTryVarTempResult_.unwrap(); } while (0)
;
8494
8495 UnaryNodeType superBase;
8496 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newSuperBase(thisName
, synthesizedBodyPos)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (superBase) = parserTryVarTempResult_
.unwrap(); } while (0)
8497 superBase, handler_.newSuperBase(thisName, synthesizedBodyPos), false)do { auto parserTryVarTempResult_ = (handler_.newSuperBase(thisName
, synthesizedBodyPos)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (superBase) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8498
8499 ListNodeType arguments;
8500 MOZ_TRY_VAR_OR_RETURN(arguments, handler_.newArguments(synthesizedBodyPos),do { auto parserTryVarTempResult_ = (handler_.newArguments(synthesizedBodyPos
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (arguments) = parserTryVarTempResult_
.unwrap(); } while (0)
8501 false)do { auto parserTryVarTempResult_ = (handler_.newArguments(synthesizedBodyPos
)); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr())
, 0))) { return (false); } (arguments) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8502
8503 NameNodeType argsNameNode;
8504 MOZ_TRY_VAR_OR_RETURN(argsNameNode,do { auto parserTryVarTempResult_ = (newName(TaggedParserAtomIndex
::WellKnown::dot_args_(), synthesizedBodyPos)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(argsNameNode) = parserTryVarTempResult_.unwrap(); } while (
0)
8505 newName(TaggedParserAtomIndex::WellKnown::dot_args_(),do { auto parserTryVarTempResult_ = (newName(TaggedParserAtomIndex
::WellKnown::dot_args_(), synthesizedBodyPos)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(argsNameNode) = parserTryVarTempResult_.unwrap(); } while (
0)
8506 synthesizedBodyPos),do { auto parserTryVarTempResult_ = (newName(TaggedParserAtomIndex
::WellKnown::dot_args_(), synthesizedBodyPos)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(argsNameNode) = parserTryVarTempResult_.unwrap(); } while (
0)
8507 false)do { auto parserTryVarTempResult_ = (newName(TaggedParserAtomIndex
::WellKnown::dot_args_(), synthesizedBodyPos)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(argsNameNode) = parserTryVarTempResult_.unwrap(); } while (
0)
;
8508 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::dot_args_())) {
8509 return false;
8510 }
8511
8512 UnaryNodeType spreadArgs;
8513 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newSpread(synthesizedBodyPos
.begin, argsNameNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (spreadArgs) = parserTryVarTempResult_
.unwrap(); } while (0)
8514 spreadArgs, handler_.newSpread(synthesizedBodyPos.begin, argsNameNode),do { auto parserTryVarTempResult_ = (handler_.newSpread(synthesizedBodyPos
.begin, argsNameNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (spreadArgs) = parserTryVarTempResult_
.unwrap(); } while (0)
8515 false)do { auto parserTryVarTempResult_ = (handler_.newSpread(synthesizedBodyPos
.begin, argsNameNode)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (spreadArgs) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8516 handler_.addList(arguments, spreadArgs);
8517
8518 CallNodeType superCall;
8519 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newSuperCall(superBase
, arguments, true)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (superCall) = parserTryVarTempResult_
.unwrap(); } while (0)
8520 superCall,do { auto parserTryVarTempResult_ = (handler_.newSuperCall(superBase
, arguments, true)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (superCall) = parserTryVarTempResult_
.unwrap(); } while (0)
8521 handler_.newSuperCall(superBase, arguments, /* isSpread = */ true),do { auto parserTryVarTempResult_ = (handler_.newSuperCall(superBase
, arguments, true)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (superCall) = parserTryVarTempResult_
.unwrap(); } while (0)
8522 false)do { auto parserTryVarTempResult_ = (handler_.newSuperCall(superBase
, arguments, true)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (superCall) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8523
8524 BinaryNodeType setThis;
8525 MOZ_TRY_VAR_OR_RETURN(setThis, handler_.newSetThis(thisName, superCall),do { auto parserTryVarTempResult_ = (handler_.newSetThis(thisName
, superCall)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (setThis) = parserTryVarTempResult_
.unwrap(); } while (0)
8526 false)do { auto parserTryVarTempResult_ = (handler_.newSetThis(thisName
, superCall)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (setThis) = parserTryVarTempResult_
.unwrap(); } while (0)
;
8527
8528 UnaryNodeType exprStatement;
8529 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newExprStatement
(setThis, synthesizedBodyPos.end)); if ((__builtin_expect(!!(
parserTryVarTempResult_.isErr()), 0))) { return (false); } (exprStatement
) = parserTryVarTempResult_.unwrap(); } while (0)
8530 exprStatement,do { auto parserTryVarTempResult_ = (handler_.newExprStatement
(setThis, synthesizedBodyPos.end)); if ((__builtin_expect(!!(
parserTryVarTempResult_.isErr()), 0))) { return (false); } (exprStatement
) = parserTryVarTempResult_.unwrap(); } while (0)
8531 handler_.newExprStatement(setThis, synthesizedBodyPos.end), false)do { auto parserTryVarTempResult_ = (handler_.newExprStatement
(setThis, synthesizedBodyPos.end)); if ((__builtin_expect(!!(
parserTryVarTempResult_.isErr()), 0))) { return (false); } (exprStatement
) = parserTryVarTempResult_.unwrap(); } while (0)
;
8532
8533 handler_.addStatementToList(stmtList, exprStatement);
8534 }
8535
8536 bool canSkipLazyClosedOverBindings = handler_.reuseClosedOverBindings();
8537 if (!pc_->declareFunctionThis(usedNames_, canSkipLazyClosedOverBindings)) {
8538 return false;
8539 }
8540 if (!pc_->declareNewTarget(usedNames_, canSkipLazyClosedOverBindings)) {
8541 return false;
8542 }
8543
8544 LexicalScopeNodeType initializerBody;
8545 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(initializerBody) = parserTryVarTempResult_.unwrap(); } while
(0)
8546 initializerBody,do { auto parserTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(initializerBody) = parserTryVarTempResult_.unwrap(); } while
(0)
8547 finishLexicalScope(pc_->varScope(), stmtList, ScopeKind::FunctionLexical),do { auto parserTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(initializerBody) = parserTryVarTempResult_.unwrap(); } while
(0)
8548 false)do { auto parserTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(parserTryVarTempResult_.isErr()), 0))) { return (false); }
(initializerBody) = parserTryVarTempResult_.unwrap(); } while
(0)
;
8549 handler_.setBeginPosition(initializerBody, stmtList);
8550 handler_.setEndPosition(initializerBody, stmtList);
8551
8552 handler_.setFunctionBody(funNode, initializerBody);
8553
8554 return finishFunction();
8555}
8556
8557template <class ParseHandler, typename Unit>
8558typename ParseHandler::FunctionNodeResult
8559GeneralParser<ParseHandler, Unit>::privateMethodInitializer(
8560 TokenPos propNamePos, TaggedParserAtomIndex propAtom,
8561 TaggedParserAtomIndex storedMethodAtom) {
8562 if (!abortIfSyntaxParser()) {
8563 return errorResult();
8564 }
8565
8566 // Synthesize an initializer function that the constructor can use to stamp a
8567 // private method onto an instance object.
8568 FunctionSyntaxKind syntaxKind = FunctionSyntaxKind::FieldInitializer;
8569 FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction;
8570 GeneratorKind generatorKind = GeneratorKind::NotGenerator;
8571 bool isSelfHosting = options().selfHostingMode;
8572 FunctionFlags flags =
8573 InitialFunctionFlags(syntaxKind, generatorKind, asyncKind, isSelfHosting);
8574
8575 FunctionNodeType funNode;
8576 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, propNamePos))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, propNamePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (funNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
8577
8578 Directives directives(true);
8579 FunctionBox* funbox =
8580 newFunctionBox(funNode, TaggedParserAtomIndex::null(), flags,
8581 propNamePos.begin, directives, generatorKind, asyncKind);
8582 if (!funbox) {
8583 return errorResult();
8584 }
8585 funbox->initWithEnclosingParseContext(pc_, syntaxKind);
8586
8587 // Push a SourceParseContext on to the stack.
8588 ParseContext* outerpc = pc_;
8589 SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
8590 if (!funpc.init()) {
8591 return errorResult();
8592 }
8593 pc_->functionScope().useAsVarScope(pc_);
8594
8595 // Add empty parameter list.
8596 ParamsBodyNodeType argsbody;
8597 MOZ_TRY_VAR(argsbody, handler_.newParamsBody(propNamePos))do { auto mozTryVarTempResult_ = (handler_.newParamsBody(propNamePos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (argsbody
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8598 handler_.setFunctionFormalParametersAndBody(funNode, argsbody);
8599 setFunctionStartAtCurrentToken(funbox);
8600 funbox->setArgCount(0);
8601
8602 // Note both the stored private method body and it's private name as being
8603 // used in the initializer. They will be emitted into the method body in the
8604 // BCE.
8605 if (!noteUsedName(storedMethodAtom)) {
8606 return errorResult();
8607 }
8608 MOZ_TRY(privateNameReference(propAtom))do { auto mozTryTempResult_ = ::mozilla::ToResult(privateNameReference
(propAtom)); if ((__builtin_expect(!!(mozTryTempResult_.isErr
()), 0))) { return mozTryTempResult_.propagateErr(); } } while
(0)
;
8609
8610 // Unlike field initializers, private method initializers are not created with
8611 // a body of synthesized AST nodes. Instead, the body is left empty and the
8612 // initializer is synthesized at the bytecode level.
8613 // See BytecodeEmitter::emitPrivateMethodInitializer.
8614 ListNodeType stmtList;
8615 MOZ_TRY_VAR(stmtList, handler_.newStatementList(propNamePos))do { auto mozTryVarTempResult_ = (handler_.newStatementList(propNamePos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (stmtList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8616
8617 bool canSkipLazyClosedOverBindings = handler_.reuseClosedOverBindings();
8618 if (!pc_->declareFunctionThis(usedNames_, canSkipLazyClosedOverBindings)) {
8619 return errorResult();
8620 }
8621 if (!pc_->declareNewTarget(usedNames_, canSkipLazyClosedOverBindings)) {
8622 return errorResult();
8623 }
8624
8625 LexicalScopeNodeType initializerBody;
8626 MOZ_TRY_VAR(initializerBody, finishLexicalScope(pc_->varScope(), stmtList,do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializerBody) = mozTryVarTempResult_.unwrap
(); } while (0)
8627 ScopeKind::FunctionLexical))do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializerBody) = mozTryVarTempResult_.unwrap
(); } while (0)
;
8628 handler_.setBeginPosition(initializerBody, stmtList);
8629 handler_.setEndPosition(initializerBody, stmtList);
8630 handler_.setFunctionBody(funNode, initializerBody);
8631
8632 // Set field-initializer lambda boundary to start at property name and end
8633 // after method body.
8634 setFunctionStartAtPosition(funbox, propNamePos);
8635 setFunctionEndFromCurrentToken(funbox);
8636
8637 if (!finishFunction()) {
8638 return errorResult();
8639 }
8640
8641 if (!leaveInnerFunction(outerpc)) {
8642 return errorResult();
8643 }
8644
8645 return funNode;
8646}
8647
8648template <class ParseHandler, typename Unit>
8649typename ParseHandler::FunctionNodeResult
8650GeneralParser<ParseHandler, Unit>::staticClassBlock(
8651 ClassInitializedMembers& classInitializedMembers) {
8652 // Both for getting-this-done, and because this will invariably be executed,
8653 // syntax parsing should be aborted.
8654 if (!abortIfSyntaxParser()) {
8655 return errorResult();
8656 }
8657
8658 FunctionSyntaxKind syntaxKind = FunctionSyntaxKind::StaticClassBlock;
8659 FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction;
8660 GeneratorKind generatorKind = GeneratorKind::NotGenerator;
8661 bool isSelfHosting = options().selfHostingMode;
8662 FunctionFlags flags =
8663 InitialFunctionFlags(syntaxKind, generatorKind, asyncKind, isSelfHosting);
8664
8665 AutoAwaitIsKeyword awaitIsKeyword(this, AwaitHandling::AwaitIsDisallowed);
8666
8667 // Create the function node for the static class body.
8668 FunctionNodeType funNode;
8669 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, pos()))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (funNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8670
8671 // Create the FunctionBox and link it to the function object.
8672 Directives directives(true);
8673 FunctionBox* funbox =
8674 newFunctionBox(funNode, TaggedParserAtomIndex::null(), flags, pos().begin,
8675 directives, generatorKind, asyncKind);
8676 if (!funbox) {
8677 return errorResult();
8678 }
8679 funbox->initWithEnclosingParseContext(pc_, syntaxKind);
8680 MOZ_ASSERT(funbox->isSyntheticFunction())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funbox->isSyntheticFunction())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(funbox->isSyntheticFunction
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("funbox->isSyntheticFunction()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8680); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funbox->isSyntheticFunction()"
")"); do { *((volatile int*)__null) = 8680; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8681 MOZ_ASSERT(!funbox->allowSuperCall())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!funbox->allowSuperCall())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!funbox->allowSuperCall()
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"!funbox->allowSuperCall()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8681); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!funbox->allowSuperCall()"
")"); do { *((volatile int*)__null) = 8681; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8682 MOZ_ASSERT(!funbox->allowArguments())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!funbox->allowArguments())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!funbox->allowArguments()
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"!funbox->allowArguments()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8682); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!funbox->allowArguments()"
")"); do { *((volatile int*)__null) = 8682; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8683 MOZ_ASSERT(!funbox->allowReturn())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!funbox->allowReturn())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!funbox->allowReturn())))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("!funbox->allowReturn()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8683); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!funbox->allowReturn()"
")"); do { *((volatile int*)__null) = 8683; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8684
8685 // Set start at `static` token.
8686 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Static))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Static))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Static)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Static)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8686); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Static)"
")"); do { *((volatile int*)__null) = 8686; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8687 setFunctionStartAtCurrentToken(funbox);
8688
8689 // Push a SourceParseContext on to the stack.
8690 ParseContext* outerpc = pc_;
8691 SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
8692 if (!funpc.init()) {
8693 return errorResult();
8694 }
8695
8696 pc_->functionScope().useAsVarScope(pc_);
8697
8698 uint32_t start = pos().begin;
8699
8700 tokenStream.consumeKnownToken(TokenKind::LeftCurly);
8701
8702 // Static class blocks are code-generated as if they were static field
8703 // initializers, so we bump the staticFields count here, which ensures
8704 // .staticInitializers is noted as used.
8705 classInitializedMembers.staticFields++;
8706
8707 LexicalScopeNodeType body;
8708 MOZ_TRY_VAR(body,do { auto mozTryVarTempResult_ = (functionBody(InHandling::InAllowed
, YieldHandling::YieldIsKeyword, syntaxKind, FunctionBodyType
::StatementListBody)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (body) = mozTryVarTempResult_.unwrap(); } while (0)
8709 functionBody(InHandling::InAllowed, YieldHandling::YieldIsKeyword,do { auto mozTryVarTempResult_ = (functionBody(InHandling::InAllowed
, YieldHandling::YieldIsKeyword, syntaxKind, FunctionBodyType
::StatementListBody)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (body) = mozTryVarTempResult_.unwrap(); } while (0)
8710 syntaxKind, FunctionBodyType::StatementListBody))do { auto mozTryVarTempResult_ = (functionBody(InHandling::InAllowed
, YieldHandling::YieldIsKeyword, syntaxKind, FunctionBodyType
::StatementListBody)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (body) = mozTryVarTempResult_.unwrap(); } while (0)
;
8711
8712 if (anyChars.isEOF()) {
8713 error(JSMSG_UNTERMINATED_STATIC_CLASS_BLOCK);
8714 return errorResult();
8715 }
8716
8717 tokenStream.consumeKnownToken(TokenKind::RightCurly,
8718 TokenStream::Modifier::SlashIsRegExp);
8719
8720 TokenPos wholeBodyPos(start, pos().end);
8721
8722 handler_.setEndPosition(funNode, wholeBodyPos.end);
8723 setFunctionEndFromCurrentToken(funbox);
8724
8725 // Create a ParamsBodyNode for the parameters + body (there are no
8726 // parameters).
8727 ParamsBodyNodeType argsbody;
8728 MOZ_TRY_VAR(argsbody, handler_.newParamsBody(wholeBodyPos))do { auto mozTryVarTempResult_ = (handler_.newParamsBody(wholeBodyPos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (argsbody
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8729
8730 handler_.setFunctionFormalParametersAndBody(funNode, argsbody);
8731 funbox->setArgCount(0);
8732
8733 if (pc_->superScopeNeedsHomeObject()) {
8734 funbox->setNeedsHomeObject();
8735 }
8736
8737 handler_.setEndPosition(body, pos().begin);
8738 handler_.setEndPosition(funNode, pos().end);
8739 handler_.setFunctionBody(funNode, body);
8740
8741 if (!finishFunction()) {
8742 return errorResult();
8743 }
8744
8745 if (!leaveInnerFunction(outerpc)) {
8746 return errorResult();
8747 }
8748
8749 return funNode;
8750}
8751
8752template <class ParseHandler, typename Unit>
8753typename ParseHandler::FunctionNodeResult
8754GeneralParser<ParseHandler, Unit>::fieldInitializerOpt(
8755 TokenPos propNamePos, Node propName, TaggedParserAtomIndex propAtom,
8756 ClassInitializedMembers& classInitializedMembers, bool isStatic,
8757 HasHeritage hasHeritage) {
8758 if (!abortIfSyntaxParser()) {
8759 return errorResult();
8760 }
8761
8762 bool hasInitializer = false;
8763 if (!tokenStream.matchToken(&hasInitializer, TokenKind::Assign,
8764 TokenStream::SlashIsDiv)) {
8765 return errorResult();
8766 }
8767
8768 FunctionSyntaxKind syntaxKind = FunctionSyntaxKind::FieldInitializer;
8769 FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction;
8770 GeneratorKind generatorKind = GeneratorKind::NotGenerator;
8771 bool isSelfHosting = options().selfHostingMode;
8772 FunctionFlags flags =
8773 InitialFunctionFlags(syntaxKind, generatorKind, asyncKind, isSelfHosting);
8774
8775 // Create the top-level field initializer node.
8776 FunctionNodeType funNode;
8777 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, propNamePos))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, propNamePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (funNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
8778
8779 // Create the FunctionBox and link it to the function object.
8780 Directives directives(true);
8781 FunctionBox* funbox =
8782 newFunctionBox(funNode, TaggedParserAtomIndex::null(), flags,
8783 propNamePos.begin, directives, generatorKind, asyncKind);
8784 if (!funbox) {
8785 return errorResult();
8786 }
8787 funbox->initWithEnclosingParseContext(pc_, syntaxKind);
8788 MOZ_ASSERT(funbox->isSyntheticFunction())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(funbox->isSyntheticFunction())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(funbox->isSyntheticFunction
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("funbox->isSyntheticFunction()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8788); AnnotateMozCrashReason("MOZ_ASSERT" "(" "funbox->isSyntheticFunction()"
")"); do { *((volatile int*)__null) = 8788; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8789
8790 // We can't use setFunctionStartAtCurrentToken because that uses pos().begin,
8791 // which is incorrect for fields without initializers (pos() points to the
8792 // field identifier)
8793 setFunctionStartAtPosition(funbox, propNamePos);
8794
8795 // Push a SourceParseContext on to the stack.
8796 ParseContext* outerpc = pc_;
8797 SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
8798 if (!funpc.init()) {
8799 return errorResult();
8800 }
8801
8802 pc_->functionScope().useAsVarScope(pc_);
8803
8804 Node initializerExpr;
8805 if (hasInitializer) {
8806 // Parse the expression for the field initializer.
8807 {
8808 AutoAwaitIsKeyword awaitHandling(this, AwaitIsName);
8809 MOZ_TRY_VAR(initializerExpr,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, YieldIsName
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (initializerExpr) = mozTryVarTempResult_.unwrap(); } while
(0)
8810 assignExpr(InAllowed, YieldIsName, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, YieldIsName
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (initializerExpr) = mozTryVarTempResult_.unwrap(); } while
(0)
;
8811 }
8812
8813 handler_.checkAndSetIsDirectRHSAnonFunction(initializerExpr);
8814 } else {
8815 MOZ_TRY_VAR(initializerExpr, handler_.newRawUndefinedLiteral(propNamePos))do { auto mozTryVarTempResult_ = (handler_.newRawUndefinedLiteral
(propNamePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (initializerExpr) = mozTryVarTempResult_.unwrap(); } while
(0)
;
8816 }
8817
8818 TokenPos wholeInitializerPos(propNamePos.begin, pos().end);
8819
8820 // Update the end position of the parse node.
8821 handler_.setEndPosition(funNode, wholeInitializerPos.end);
8822 setFunctionEndFromCurrentToken(funbox);
8823
8824 // Create a ParamsBodyNode for the parameters + body (there are no
8825 // parameters).
8826 ParamsBodyNodeType argsbody;
8827 MOZ_TRY_VAR(argsbody, handler_.newParamsBody(wholeInitializerPos))do { auto mozTryVarTempResult_ = (handler_.newParamsBody(wholeInitializerPos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (argsbody
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8828 handler_.setFunctionFormalParametersAndBody(funNode, argsbody);
8829 funbox->setArgCount(0);
8830
8831 NameNodeType thisName;
8832 MOZ_TRY_VAR(thisName, newThisName())do { auto mozTryVarTempResult_ = (newThisName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (thisName) = mozTryVarTempResult_.unwrap()
; } while (0)
;
8833
8834 // Build `this.field` expression.
8835 ThisLiteralType propAssignThis;
8836 MOZ_TRY_VAR(propAssignThis,do { auto mozTryVarTempResult_ = (handler_.newThisLiteral(wholeInitializerPos
, thisName)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propAssignThis
) = mozTryVarTempResult_.unwrap(); } while (0)
8837 handler_.newThisLiteral(wholeInitializerPos, thisName))do { auto mozTryVarTempResult_ = (handler_.newThisLiteral(wholeInitializerPos
, thisName)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propAssignThis
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8838
8839 Node propAssignFieldAccess;
8840 uint32_t indexValue;
8841 if (!propAtom) {
8842 // See BytecodeEmitter::emitCreateFieldKeys for an explanation of what
8843 // .fieldKeys means and its purpose.
8844 NameNodeType fieldKeysName;
8845 if (isStatic) {
8846 MOZ_TRY_VAR(do { auto mozTryVarTempResult_ = (newInternalDotName( TaggedParserAtomIndex
::WellKnown::dot_staticFieldKeys_())); if ((__builtin_expect(
!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (fieldKeysName) = mozTryVarTempResult_.unwrap
(); } while (0)
8847 fieldKeysName,do { auto mozTryVarTempResult_ = (newInternalDotName( TaggedParserAtomIndex
::WellKnown::dot_staticFieldKeys_())); if ((__builtin_expect(
!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (fieldKeysName) = mozTryVarTempResult_.unwrap
(); } while (0)
8848 newInternalDotName(do { auto mozTryVarTempResult_ = (newInternalDotName( TaggedParserAtomIndex
::WellKnown::dot_staticFieldKeys_())); if ((__builtin_expect(
!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (fieldKeysName) = mozTryVarTempResult_.unwrap
(); } while (0)
8849 TaggedParserAtomIndex::WellKnown::dot_staticFieldKeys_()))do { auto mozTryVarTempResult_ = (newInternalDotName( TaggedParserAtomIndex
::WellKnown::dot_staticFieldKeys_())); if ((__builtin_expect(
!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (fieldKeysName) = mozTryVarTempResult_.unwrap
(); } while (0)
;
8850 } else {
8851 MOZ_TRY_VAR(fieldKeysName,do { auto mozTryVarTempResult_ = (newInternalDotName( TaggedParserAtomIndex
::WellKnown::dot_fieldKeys_())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (fieldKeysName) = mozTryVarTempResult_.unwrap(); } while (
0)
8852 newInternalDotName(do { auto mozTryVarTempResult_ = (newInternalDotName( TaggedParserAtomIndex
::WellKnown::dot_fieldKeys_())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (fieldKeysName) = mozTryVarTempResult_.unwrap(); } while (
0)
8853 TaggedParserAtomIndex::WellKnown::dot_fieldKeys_()))do { auto mozTryVarTempResult_ = (newInternalDotName( TaggedParserAtomIndex
::WellKnown::dot_fieldKeys_())); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (fieldKeysName) = mozTryVarTempResult_.unwrap(); } while (
0)
;
8854 }
8855 if (!fieldKeysName) {
8856 return errorResult();
8857 }
8858
8859 double fieldKeyIndex;
8860 if (isStatic) {
8861 fieldKeyIndex = classInitializedMembers.staticFieldKeys++;
8862 } else {
8863 fieldKeyIndex = classInitializedMembers.instanceFieldKeys++;
8864 }
8865 Node fieldKeyIndexNode;
8866 MOZ_TRY_VAR(fieldKeyIndexNode,do { auto mozTryVarTempResult_ = (handler_.newNumber(fieldKeyIndex
, DecimalPoint::NoDecimal, wholeInitializerPos)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (fieldKeyIndexNode) = mozTryVarTempResult_
.unwrap(); } while (0)
8867 handler_.newNumber(fieldKeyIndex, DecimalPoint::NoDecimal,do { auto mozTryVarTempResult_ = (handler_.newNumber(fieldKeyIndex
, DecimalPoint::NoDecimal, wholeInitializerPos)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (fieldKeyIndexNode) = mozTryVarTempResult_
.unwrap(); } while (0)
8868 wholeInitializerPos))do { auto mozTryVarTempResult_ = (handler_.newNumber(fieldKeyIndex
, DecimalPoint::NoDecimal, wholeInitializerPos)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (fieldKeyIndexNode) = mozTryVarTempResult_
.unwrap(); } while (0)
;
8869
8870 Node fieldKeyValue;
8871 MOZ_TRY_VAR(fieldKeyValue,do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(fieldKeysName, fieldKeyIndexNode, wholeInitializerPos.end));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (fieldKeyValue
) = mozTryVarTempResult_.unwrap(); } while (0)
8872 handler_.newPropertyByValue(fieldKeysName, fieldKeyIndexNode,do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(fieldKeysName, fieldKeyIndexNode, wholeInitializerPos.end));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (fieldKeyValue
) = mozTryVarTempResult_.unwrap(); } while (0)
8873 wholeInitializerPos.end))do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(fieldKeysName, fieldKeyIndexNode, wholeInitializerPos.end));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (fieldKeyValue
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8874
8875 MOZ_TRY_VAR(propAssignFieldAccess,do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(propAssignThis, fieldKeyValue, wholeInitializerPos.end)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (propAssignFieldAccess
) = mozTryVarTempResult_.unwrap(); } while (0)
8876 handler_.newPropertyByValue(propAssignThis, fieldKeyValue,do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(propAssignThis, fieldKeyValue, wholeInitializerPos.end)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (propAssignFieldAccess
) = mozTryVarTempResult_.unwrap(); } while (0)
8877 wholeInitializerPos.end))do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(propAssignThis, fieldKeyValue, wholeInitializerPos.end)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (propAssignFieldAccess
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8878 } else if (handler_.isPrivateName(propName)) {
8879 // It would be nice if we could tweak this here such that only if
8880 // HasHeritage::Yes we end up emitting CheckPrivateField, but otherwise we
8881 // emit InitElem -- this is an optimization to minimize HasOwn checks
8882 // in InitElem for classes without heritage.
8883 //
8884 // Further tweaking would be to ultimately only do CheckPrivateField for the
8885 // -first- field in a derived class, which would suffice to match the
8886 // semantic check.
8887
8888 NameNodeType privateNameNode;
8889 MOZ_TRY_VAR(privateNameNode, privateNameReference(propAtom))do { auto mozTryVarTempResult_ = (privateNameReference(propAtom
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (privateNameNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8890
8891 MOZ_TRY_VAR(propAssignFieldAccess,do { auto mozTryVarTempResult_ = (handler_.newPrivateMemberAccess
(propAssignThis, privateNameNode, wholeInitializerPos.end)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (propAssignFieldAccess
) = mozTryVarTempResult_.unwrap(); } while (0)
8892 handler_.newPrivateMemberAccess(propAssignThis, privateNameNode,do { auto mozTryVarTempResult_ = (handler_.newPrivateMemberAccess
(propAssignThis, privateNameNode, wholeInitializerPos.end)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (propAssignFieldAccess
) = mozTryVarTempResult_.unwrap(); } while (0)
8893 wholeInitializerPos.end))do { auto mozTryVarTempResult_ = (handler_.newPrivateMemberAccess
(propAssignThis, privateNameNode, wholeInitializerPos.end)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (propAssignFieldAccess
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8894 } else if (this->parserAtoms().isIndex(propAtom, &indexValue)) {
8895 MOZ_TRY_VAR(propAssignFieldAccess,do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(propAssignThis, propName, wholeInitializerPos.end)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (propAssignFieldAccess) = mozTryVarTempResult_
.unwrap(); } while (0)
8896 handler_.newPropertyByValue(propAssignThis, propName,do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(propAssignThis, propName, wholeInitializerPos.end)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (propAssignFieldAccess) = mozTryVarTempResult_
.unwrap(); } while (0)
8897 wholeInitializerPos.end))do { auto mozTryVarTempResult_ = (handler_.newPropertyByValue
(propAssignThis, propName, wholeInitializerPos.end)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (propAssignFieldAccess) = mozTryVarTempResult_
.unwrap(); } while (0)
;
8898 } else {
8899 NameNodeType propAssignName;
8900 MOZ_TRY_VAR(propAssignName,do { auto mozTryVarTempResult_ = (handler_.newPropertyName(propAtom
, wholeInitializerPos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propAssignName) = mozTryVarTempResult_.unwrap(); } while (
0)
8901 handler_.newPropertyName(propAtom, wholeInitializerPos))do { auto mozTryVarTempResult_ = (handler_.newPropertyName(propAtom
, wholeInitializerPos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propAssignName) = mozTryVarTempResult_.unwrap(); } while (
0)
;
8902
8903 MOZ_TRY_VAR(propAssignFieldAccess,do { auto mozTryVarTempResult_ = (handler_.newPropertyAccess(
propAssignThis, propAssignName)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propAssignFieldAccess) = mozTryVarTempResult_.unwrap(); }
while (0)
8904 handler_.newPropertyAccess(propAssignThis, propAssignName))do { auto mozTryVarTempResult_ = (handler_.newPropertyAccess(
propAssignThis, propAssignName)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propAssignFieldAccess) = mozTryVarTempResult_.unwrap(); }
while (0)
;
8905 }
8906
8907 // Synthesize an property init.
8908 BinaryNodeType initializerPropInit;
8909 MOZ_TRY_VAR(initializerPropInit,do { auto mozTryVarTempResult_ = (handler_.newInitExpr(propAssignFieldAccess
, initializerExpr)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (initializerPropInit) = mozTryVarTempResult_.unwrap(); } while
(0)
8910 handler_.newInitExpr(propAssignFieldAccess, initializerExpr))do { auto mozTryVarTempResult_ = (handler_.newInitExpr(propAssignFieldAccess
, initializerExpr)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (initializerPropInit) = mozTryVarTempResult_.unwrap(); } while
(0)
;
8911
8912 UnaryNodeType exprStatement;
8913 MOZ_TRY_VAR(exprStatement, handler_.newExprStatement(do { auto mozTryVarTempResult_ = (handler_.newExprStatement( initializerPropInit
, wholeInitializerPos.end)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exprStatement) = mozTryVarTempResult_.unwrap(); } while (
0)
8914 initializerPropInit, wholeInitializerPos.end))do { auto mozTryVarTempResult_ = (handler_.newExprStatement( initializerPropInit
, wholeInitializerPos.end)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (exprStatement) = mozTryVarTempResult_.unwrap(); } while (
0)
;
8915
8916 ListNodeType statementList;
8917 MOZ_TRY_VAR(statementList, handler_.newStatementList(wholeInitializerPos))do { auto mozTryVarTempResult_ = (handler_.newStatementList(wholeInitializerPos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (statementList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
8918 handler_.addStatementToList(statementList, exprStatement);
8919
8920 bool canSkipLazyClosedOverBindings = handler_.reuseClosedOverBindings();
8921 if (!pc_->declareFunctionThis(usedNames_, canSkipLazyClosedOverBindings)) {
8922 return errorResult();
8923 }
8924 if (!pc_->declareNewTarget(usedNames_, canSkipLazyClosedOverBindings)) {
8925 return errorResult();
8926 }
8927
8928 // Set the function's body to the field assignment.
8929 LexicalScopeNodeType initializerBody;
8930 MOZ_TRY_VAR(initializerBody,do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), statementList, ScopeKind::FunctionLexical)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (initializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
8931 finishLexicalScope(pc_->varScope(), statementList,do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), statementList, ScopeKind::FunctionLexical)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (initializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
8932 ScopeKind::FunctionLexical))do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), statementList, ScopeKind::FunctionLexical)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (initializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
;
8933
8934 handler_.setFunctionBody(funNode, initializerBody);
8935
8936 if (pc_->superScopeNeedsHomeObject()) {
8937 funbox->setNeedsHomeObject();
8938 }
8939
8940 if (!finishFunction()) {
8941 return errorResult();
8942 }
8943
8944 if (!leaveInnerFunction(outerpc)) {
8945 return errorResult();
8946 }
8947
8948 return funNode;
8949}
8950
8951template <class ParseHandler, typename Unit>
8952typename ParseHandler::FunctionNodeResult
8953GeneralParser<ParseHandler, Unit>::synthesizePrivateMethodInitializer(
8954 TaggedParserAtomIndex propAtom, AccessorType accessorType,
8955 TokenPos propNamePos) {
8956 if (!abortIfSyntaxParser()) {
8957 return errorResult();
8958 }
8959
8960 // Synthesize a name for the lexical variable that will store the
8961 // accessor body.
8962 StringBuffer storedMethodName(fc_);
8963 if (!storedMethodName.append(this->parserAtoms(), propAtom)) {
8964 return errorResult();
8965 }
8966 if (!storedMethodName.append(
8967 accessorType == AccessorType::Getter ? ".getter" : ".setter")) {
8968 return errorResult();
8969 }
8970 auto storedMethodProp =
8971 storedMethodName.finishParserAtom(this->parserAtoms(), fc_);
8972 if (!storedMethodProp) {
8973 return errorResult();
8974 }
8975 if (!noteDeclaredName(storedMethodProp, DeclarationKind::Synthetic, pos())) {
8976 return errorResult();
8977 }
8978
8979 return privateMethodInitializer(propNamePos, propAtom, storedMethodProp);
8980}
8981
8982#ifdef ENABLE_DECORATORS
8983template <class ParseHandler, typename Unit>
8984typename ParseHandler::FunctionNodeResult
8985GeneralParser<ParseHandler, Unit>::synthesizeAddInitializerFunction(
8986 TaggedParserAtomIndex initializers, YieldHandling yieldHandling) {
8987 if (!abortIfSyntaxParser()) {
8988 return errorResult();
8989 }
8990
8991 // TODO: Add support for static and class extra initializers, see bug 1868220
8992 // and bug 1868221.
8993 MOZ_ASSERT(do { static_assert( mozilla::detail::AssertionConditionType<
decltype(initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8995); AnnotateMozCrashReason("MOZ_ASSERT" "(" "initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_()"
")"); do { *((volatile int*)__null) = 8995; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
8994 initializers ==do { static_assert( mozilla::detail::AssertionConditionType<
decltype(initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8995); AnnotateMozCrashReason("MOZ_ASSERT" "(" "initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_()"
")"); do { *((volatile int*)__null) = 8995; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
8995 TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 8995); AnnotateMozCrashReason("MOZ_ASSERT" "(" "initializers == TaggedParserAtomIndex::WellKnown::dot_instanceExtraInitializers_()"
")"); do { *((volatile int*)__null) = 8995; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
8996
8997 TokenPos propNamePos = pos();
8998
8999 // Synthesize an addInitializer function that can be used to append to
9000 // .initializers
9001 FunctionSyntaxKind syntaxKind = FunctionSyntaxKind::Statement;
9002 FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction;
9003 GeneratorKind generatorKind = GeneratorKind::NotGenerator;
9004 bool isSelfHosting = options().selfHostingMode;
9005 FunctionFlags flags =
9006 InitialFunctionFlags(syntaxKind, generatorKind, asyncKind, isSelfHosting);
9007
9008 FunctionNodeType funNode;
9009 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, propNamePos))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, propNamePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (funNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
9010
9011 Directives directives(true);
9012 FunctionBox* funbox =
9013 newFunctionBox(funNode, TaggedParserAtomIndex::null(), flags,
9014 propNamePos.begin, directives, generatorKind, asyncKind);
9015 if (!funbox) {
9016 return errorResult();
9017 }
9018 funbox->initWithEnclosingParseContext(pc_, syntaxKind);
9019
9020 ParseContext* outerpc = pc_;
9021 SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
9022 if (!funpc.init()) {
9023 return errorResult();
9024 }
9025 pc_->functionScope().useAsVarScope(pc_);
9026
9027 // Takes a single parameter, `initializer`.
9028 ParamsBodyNodeType params;
9029 MOZ_TRY_VAR(params, handler_.newParamsBody(propNamePos))do { auto mozTryVarTempResult_ = (handler_.newParamsBody(propNamePos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (params) =
mozTryVarTempResult_.unwrap(); } while (0)
;
9030
9031 handler_.setFunctionFormalParametersAndBody(funNode, params);
9032
9033 constexpr bool disallowDuplicateParams = true;
9034 bool duplicatedParam = false;
9035 if (!notePositionalFormalParameter(
9036 funNode, TaggedParserAtomIndex::WellKnown::initializer(), pos().begin,
9037 disallowDuplicateParams, &duplicatedParam)) {
9038 return null();
9039 }
9040 MOZ_ASSERT(!duplicatedParam)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!duplicatedParam)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!duplicatedParam))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("!duplicatedParam"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9040); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!duplicatedParam"
")"); do { *((volatile int*)__null) = 9040; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9041 MOZ_ASSERT(pc_->positionalFormalParameterNames().length() == 1)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->positionalFormalParameterNames().length() ==
1)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(pc_->positionalFormalParameterNames().length() ==
1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("pc_->positionalFormalParameterNames().length() == 1", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9041); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->positionalFormalParameterNames().length() == 1"
")"); do { *((volatile int*)__null) = 9041; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9042
9043 funbox->setLength(1);
9044 funbox->setArgCount(1);
9045 setFunctionStartAtCurrentToken(funbox);
9046
9047 // Like private method initializers, the addInitializer method is not created
9048 // with a body of synthesized AST nodes. Instead, the body is left empty and
9049 // the initializer is synthesized at the bytecode level. See
9050 // DecoratorEmitter::emitCreateAddInitializerFunction.
9051 ListNodeType stmtList;
9052 MOZ_TRY_VAR(stmtList, handler_.newStatementList(propNamePos))do { auto mozTryVarTempResult_ = (handler_.newStatementList(propNamePos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (stmtList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
9053
9054 if (!noteUsedName(initializers)) {
9055 return null();
9056 }
9057
9058 bool canSkipLazyClosedOverBindings = handler_.reuseClosedOverBindings();
9059 if (!pc_->declareFunctionThis(usedNames_, canSkipLazyClosedOverBindings)) {
9060 return null();
9061 }
9062 if (!pc_->declareNewTarget(usedNames_, canSkipLazyClosedOverBindings)) {
9063 return null();
9064 }
9065
9066 LexicalScopeNodeType addInitializerBody;
9067 MOZ_TRY_VAR(addInitializerBody,do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (addInitializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
9068 finishLexicalScope(pc_->varScope(), stmtList,do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (addInitializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
9069 ScopeKind::FunctionLexical))do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), stmtList, ScopeKind::FunctionLexical)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (addInitializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
;
9070 handler_.setBeginPosition(addInitializerBody, stmtList);
9071 handler_.setEndPosition(addInitializerBody, stmtList);
9072 handler_.setFunctionBody(funNode, addInitializerBody);
9073
9074 // Set field-initializer lambda boundary to start at property name and end
9075 // after method body.
9076 setFunctionStartAtPosition(funbox, propNamePos);
9077 setFunctionEndFromCurrentToken(funbox);
9078
9079 if (!finishFunction()) {
9080 return errorResult();
9081 }
9082
9083 if (!leaveInnerFunction(outerpc)) {
9084 return errorResult();
9085 }
9086
9087 return funNode;
9088}
9089
9090template <class ParseHandler, typename Unit>
9091typename ParseHandler::ClassMethodResult
9092GeneralParser<ParseHandler, Unit>::synthesizeAccessor(
9093 Node propName, TokenPos propNamePos, TaggedParserAtomIndex propAtom,
9094 TaggedParserAtomIndex privateStateNameAtom, bool isStatic,
9095 FunctionSyntaxKind syntaxKind,
9096 ClassInitializedMembers& classInitializedMembers) {
9097 // Decorators Proposal
9098 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-makeautoaccessorgetter
9099 // The abstract operation MakeAutoAccessorGetter takes arguments homeObject
9100 // (an Object), name (a property key or Private Name), and privateStateName (a
9101 // Private Name) and returns a function object.
9102 //
9103 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-makeautoaccessorsetter
9104 // The abstract operation MakeAutoAccessorSetter takes arguments homeObject
9105 // (an Object), name (a property key or Private Name), and privateStateName (a
9106 // Private Name) and returns a function object.
9107 if (!abortIfSyntaxParser()) {
9108 return errorResult();
9109 }
9110
9111 AccessorType accessorType = syntaxKind == FunctionSyntaxKind::Getter
9112 ? AccessorType::Getter
9113 : AccessorType::Setter;
9114
9115 mozilla::Maybe<FunctionNodeType> initializerIfPrivate = Nothing();
9116 if (!isStatic && handler_.isPrivateName(propName)) {
9117 classInitializedMembers.privateAccessors++;
9118 FunctionNodeType initializerNode;
9119 MOZ_TRY_VAR(initializerNode, synthesizePrivateMethodInitializer(do { auto mozTryVarTempResult_ = (synthesizePrivateMethodInitializer
( propAtom, accessorType, propNamePos)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializerNode) = mozTryVarTempResult_.unwrap
(); } while (0)
9120 propAtom, accessorType, propNamePos))do { auto mozTryVarTempResult_ = (synthesizePrivateMethodInitializer
( propAtom, accessorType, propNamePos)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializerNode) = mozTryVarTempResult_.unwrap
(); } while (0)
;
9121 initializerIfPrivate = Some(initializerNode);
9122 handler_.setPrivateNameKind(propName, PrivateNameKind::GetterSetter);
9123 }
9124
9125 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-makeautoaccessorgetter
9126 // 2. Let getter be CreateBuiltinFunction(getterClosure, 0, "get", « »).
9127 //
9128 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-makeautoaccessorsetter
9129 // 2. Let setter be CreateBuiltinFunction(setterClosure, 1, "set", « »).
9130 StringBuffer storedMethodName(fc_);
9131 if (!storedMethodName.append(accessorType == AccessorType::Getter ? "get"
9132 : "set")) {
9133 return errorResult();
9134 }
9135 TaggedParserAtomIndex funNameAtom =
9136 storedMethodName.finishParserAtom(this->parserAtoms(), fc_);
9137
9138 FunctionNodeType funNode;
9139 MOZ_TRY_VAR(funNode,do { auto mozTryVarTempResult_ = (synthesizeAccessorBody(funNameAtom
, propNamePos, privateStateNameAtom, syntaxKind)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (funNode) = mozTryVarTempResult_.unwrap();
} while (0)
9140 synthesizeAccessorBody(funNameAtom, propNamePos,do { auto mozTryVarTempResult_ = (synthesizeAccessorBody(funNameAtom
, propNamePos, privateStateNameAtom, syntaxKind)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (funNode) = mozTryVarTempResult_.unwrap();
} while (0)
9141 privateStateNameAtom, syntaxKind))do { auto mozTryVarTempResult_ = (synthesizeAccessorBody(funNameAtom
, propNamePos, privateStateNameAtom, syntaxKind)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (funNode) = mozTryVarTempResult_.unwrap();
} while (0)
;
9142
9143 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-makeautoaccessorgetter
9144 // 3. Perform MakeMethod(getter, homeObject).
9145 // 4. Return getter.
9146 //
9147 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-makeautoaccessorsetter
9148 // 3. Perform MakeMethod(setter, homeObject).
9149 // 4. Return setter.
9150 return handler_.newClassMethodDefinition(
9151 propName, funNode, accessorType, isStatic, initializerIfPrivate, null());
9152}
9153
9154template <class ParseHandler, typename Unit>
9155typename ParseHandler::FunctionNodeResult
9156GeneralParser<ParseHandler, Unit>::synthesizeAccessorBody(
9157 TaggedParserAtomIndex funNameAtom, TokenPos propNamePos,
9158 TaggedParserAtomIndex propNameAtom, FunctionSyntaxKind syntaxKind) {
9159 if (!abortIfSyntaxParser()) {
9160 return errorResult();
9161 }
9162
9163 FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction;
9164 GeneratorKind generatorKind = GeneratorKind::NotGenerator;
9165 bool isSelfHosting = options().selfHostingMode;
9166 FunctionFlags flags =
9167 InitialFunctionFlags(syntaxKind, generatorKind, asyncKind, isSelfHosting);
9168
9169 // Create the top-level function node.
9170 FunctionNodeType funNode;
9171 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, propNamePos))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, propNamePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (funNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
9172
9173 // Create the FunctionBox and link it to the function object.
9174 Directives directives(true);
9175 FunctionBox* funbox =
9176 newFunctionBox(funNode, funNameAtom, flags, propNamePos.begin, directives,
9177 generatorKind, asyncKind);
9178 if (!funbox) {
9179 return errorResult();
9180 }
9181 funbox->initWithEnclosingParseContext(pc_, syntaxKind);
9182 funbox->setSyntheticFunction();
9183
9184 // Push a SourceParseContext on to the stack.
9185 ParseContext* outerpc = pc_;
9186 SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
9187 if (!funpc.init()) {
9188 return errorResult();
9189 }
9190
9191 pc_->functionScope().useAsVarScope(pc_);
9192
9193 // The function we synthesize is located at the field with the
9194 // accessor.
9195 setFunctionStartAtCurrentToken(funbox);
9196 setFunctionEndFromCurrentToken(funbox);
9197
9198 // Create a ListNode for the parameters + body
9199 ParamsBodyNodeType paramsbody;
9200 MOZ_TRY_VAR(paramsbody, handler_.newParamsBody(propNamePos))do { auto mozTryVarTempResult_ = (handler_.newParamsBody(propNamePos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (paramsbody
) = mozTryVarTempResult_.unwrap(); } while (0)
;
9201 handler_.setFunctionFormalParametersAndBody(funNode, paramsbody);
9202
9203 if (syntaxKind == FunctionSyntaxKind::Getter) {
9204 funbox->setArgCount(0);
9205 } else {
9206 funbox->setArgCount(1);
9207 }
9208
9209 // Build `this` expression to access the privateStateName for use in the
9210 // operations to create the getter and setter below.
9211 NameNodeType thisName;
9212 MOZ_TRY_VAR(thisName, newThisName())do { auto mozTryVarTempResult_ = (newThisName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (thisName) = mozTryVarTempResult_.unwrap()
; } while (0)
;
9213
9214 ThisLiteralType propThis;
9215 MOZ_TRY_VAR(propThis, handler_.newThisLiteral(propNamePos, thisName))do { auto mozTryVarTempResult_ = (handler_.newThisLiteral(propNamePos
, thisName)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propThis
) = mozTryVarTempResult_.unwrap(); } while (0)
;
9216
9217 NameNodeType privateNameNode;
9218 MOZ_TRY_VAR(privateNameNode, privateNameReference(propNameAtom))do { auto mozTryVarTempResult_ = (privateNameReference(propNameAtom
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (privateNameNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
9219
9220 Node propFieldAccess;
9221 MOZ_TRY_VAR(propFieldAccess, handler_.newPrivateMemberAccess(do { auto mozTryVarTempResult_ = (handler_.newPrivateMemberAccess
( propThis, privateNameNode, propNamePos.end)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (propFieldAccess) = mozTryVarTempResult_.unwrap
(); } while (0)
9222 propThis, privateNameNode, propNamePos.end))do { auto mozTryVarTempResult_ = (handler_.newPrivateMemberAccess
( propThis, privateNameNode, propNamePos.end)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (propFieldAccess) = mozTryVarTempResult_.unwrap
(); } while (0)
;
9223
9224 Node accessorBody;
9225 if (syntaxKind == FunctionSyntaxKind::Getter) {
9226 // Decorators Proposal
9227 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-makeautoaccessorgetter
9228 // 1. Let getterClosure be a new Abstract Closure with no parameters that
9229 // captures privateStateName and performs the following steps when called:
9230 // 1.a. Let o be the this value.
9231 // 1.b. Return ? PrivateGet(privateStateName, o).
9232 MOZ_TRY_VAR(accessorBody,do { auto mozTryVarTempResult_ = (handler_.newReturnStatement
(propFieldAccess, propNamePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (accessorBody) = mozTryVarTempResult_.unwrap(); } while (0
)
9233 handler_.newReturnStatement(propFieldAccess, propNamePos))do { auto mozTryVarTempResult_ = (handler_.newReturnStatement
(propFieldAccess, propNamePos)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (accessorBody) = mozTryVarTempResult_.unwrap(); } while (0
)
;
9234 } else {
9235 // Decorators Proposal
9236 // https://arai-a.github.io/ecma262-compare/?pr=2417&id=sec-makeautoaccessorsetter
9237 // The abstract operation MakeAutoAccessorSetter takes arguments homeObject
9238 // (an Object), name (a property key or Private Name), and privateStateName
9239 // (a Private Name) and returns a function object.
9240 // 1. Let setterClosure be a new Abstract Closure with parameters (value)
9241 // that captures privateStateName and performs the following steps when
9242 // called:
9243 // 1.a. Let o be the this value.
9244 notePositionalFormalParameter(funNode,
9245 TaggedParserAtomIndex::WellKnown::value(),
9246 /* pos = */ 0, false,
9247 /* duplicatedParam = */ nullptr);
9248
9249 Node initializerExpr;
9250 MOZ_TRY_VAR(initializerExpr,do { auto mozTryVarTempResult_ = (handler_.newName(TaggedParserAtomIndex
::WellKnown::value(), propNamePos)); if ((__builtin_expect(!!
(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializerExpr) = mozTryVarTempResult_.unwrap
(); } while (0)
9251 handler_.newName(TaggedParserAtomIndex::WellKnown::value(),do { auto mozTryVarTempResult_ = (handler_.newName(TaggedParserAtomIndex
::WellKnown::value(), propNamePos)); if ((__builtin_expect(!!
(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializerExpr) = mozTryVarTempResult_.unwrap
(); } while (0)
9252 propNamePos))do { auto mozTryVarTempResult_ = (handler_.newName(TaggedParserAtomIndex
::WellKnown::value(), propNamePos)); if ((__builtin_expect(!!
(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (initializerExpr) = mozTryVarTempResult_.unwrap
(); } while (0)
;
9253
9254 // 1.b. Perform ? PrivateSet(privateStateName, o, value).
9255 Node assignment;
9256 MOZ_TRY_VAR(assignment,do { auto mozTryVarTempResult_ = (handler_.newAssignment(ParseNodeKind
::AssignExpr, propFieldAccess, initializerExpr)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (assignment) = mozTryVarTempResult_.unwrap
(); } while (0)
9257 handler_.newAssignment(ParseNodeKind::AssignExpr,do { auto mozTryVarTempResult_ = (handler_.newAssignment(ParseNodeKind
::AssignExpr, propFieldAccess, initializerExpr)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (assignment) = mozTryVarTempResult_.unwrap
(); } while (0)
9258 propFieldAccess, initializerExpr))do { auto mozTryVarTempResult_ = (handler_.newAssignment(ParseNodeKind
::AssignExpr, propFieldAccess, initializerExpr)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (assignment) = mozTryVarTempResult_.unwrap
(); } while (0)
;
9259
9260 MOZ_TRY_VAR(accessorBody,do { auto mozTryVarTempResult_ = (handler_.newExprStatement(assignment
, propNamePos.end)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (accessorBody) = mozTryVarTempResult_.unwrap(); } while (0
)
9261 handler_.newExprStatement(assignment, propNamePos.end))do { auto mozTryVarTempResult_ = (handler_.newExprStatement(assignment
, propNamePos.end)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (accessorBody) = mozTryVarTempResult_.unwrap(); } while (0
)
;
9262
9263 // 1.c. Return undefined.
9264 }
9265
9266 ListNodeType statementList;
9267 MOZ_TRY_VAR(statementList, handler_.newStatementList(propNamePos))do { auto mozTryVarTempResult_ = (handler_.newStatementList(propNamePos
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (statementList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
9268 handler_.addStatementToList(statementList, accessorBody);
9269
9270 bool canSkipLazyClosedOverBindings = handler_.reuseClosedOverBindings();
9271 if (!pc_->declareFunctionThis(usedNames_, canSkipLazyClosedOverBindings)) {
9272 return errorResult();
9273 }
9274 if (!pc_->declareNewTarget(usedNames_, canSkipLazyClosedOverBindings)) {
9275 return errorResult();
9276 }
9277
9278 LexicalScopeNodeType initializerBody;
9279 MOZ_TRY_VAR(initializerBody,do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), statementList, ScopeKind::FunctionLexical)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (initializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
9280 finishLexicalScope(pc_->varScope(), statementList,do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), statementList, ScopeKind::FunctionLexical)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (initializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
9281 ScopeKind::FunctionLexical))do { auto mozTryVarTempResult_ = (finishLexicalScope(pc_->
varScope(), statementList, ScopeKind::FunctionLexical)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (initializerBody) = mozTryVarTempResult_
.unwrap(); } while (0)
;
9282
9283 handler_.setFunctionBody(funNode, initializerBody);
9284
9285 if (pc_->superScopeNeedsHomeObject()) {
9286 funbox->setNeedsHomeObject();
9287 }
9288
9289 if (!finishFunction()) {
9290 return errorResult();
9291 }
9292
9293 if (!leaveInnerFunction(outerpc)) {
9294 return errorResult();
9295 }
9296
9297 return funNode;
9298}
9299
9300#endif
9301
9302bool ParserBase::nextTokenContinuesLetDeclaration(TokenKind next) {
9303 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Let))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Let))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::Let)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Let)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9303); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Let)"
")"); do { *((volatile int*)__null) = 9303; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9304 MOZ_ASSERT(anyChars.nextToken().type == next)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.nextToken().type == next)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.nextToken().type ==
next))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.nextToken().type == next", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9304); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.nextToken().type == next"
")"); do { *((volatile int*)__null) = 9304; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9305
9306 TokenStreamShared::verifyConsistentModifier(TokenStreamShared::SlashIsDiv,
9307 anyChars.nextToken());
9308
9309 // Destructuring continues a let declaration.
9310 if (next == TokenKind::LeftBracket || next == TokenKind::LeftCurly) {
9311 return true;
9312 }
9313
9314 // A "let" edge case deserves special comment. Consider this:
9315 //
9316 // let // not an ASI opportunity
9317 // let;
9318 //
9319 // Static semantics in §13.3.1.1 turn a LexicalDeclaration that binds
9320 // "let" into an early error. Does this retroactively permit ASI so
9321 // that we should parse this as two ExpressionStatements? No. ASI
9322 // resolves during parsing. Static semantics only apply to the full
9323 // parse tree with ASI applied. No backsies!
9324
9325 // Otherwise a let declaration must have a name.
9326 return TokenKindIsPossibleIdentifier(next);
9327}
9328
9329template <class ParseHandler, typename Unit>
9330typename ParseHandler::DeclarationListNodeResult
9331GeneralParser<ParseHandler, Unit>::variableStatement(
9332 YieldHandling yieldHandling) {
9333 DeclarationListNodeType vars;
9334 MOZ_TRY_VAR(vars, declarationList(yieldHandling, ParseNodeKind::VarStmt))do { auto mozTryVarTempResult_ = (declarationList(yieldHandling
, ParseNodeKind::VarStmt)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (vars) = mozTryVarTempResult_.unwrap(); } while (0)
;
9335 if (!matchOrInsertSemicolon()) {
9336 return errorResult();
9337 }
9338 return vars;
9339}
9340
9341template <class ParseHandler, typename Unit>
9342typename ParseHandler::NodeResult GeneralParser<ParseHandler, Unit>::statement(
9343 YieldHandling yieldHandling) {
9344 MOZ_ASSERT(checkOptionsCalled_)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(checkOptionsCalled_)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(checkOptionsCalled_))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("checkOptionsCalled_"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9344); AnnotateMozCrashReason("MOZ_ASSERT" "(" "checkOptionsCalled_"
")"); do { *((volatile int*)__null) = 9344; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9345
9346 AutoCheckRecursionLimit recursion(this->fc_);
9347 if (!recursion.check(this->fc_)) {
9348 return errorResult();
9349 }
9350
9351 TokenKind tt;
9352 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
9353 return errorResult();
9354 }
9355
9356 switch (tt) {
9357 // BlockStatement[?Yield, ?Return]
9358 case TokenKind::LeftCurly:
9359 return blockStatement(yieldHandling);
9360
9361 // VariableStatement[?Yield]
9362 case TokenKind::Var:
9363 return variableStatement(yieldHandling);
9364
9365 // EmptyStatement
9366 case TokenKind::Semi:
9367 return handler_.newEmptyStatement(pos());
9368
9369 // ExpressionStatement[?Yield].
9370
9371 case TokenKind::Yield: {
9372 // Don't use a ternary operator here due to obscure linker issues
9373 // around using static consts in the arms of a ternary.
9374 Modifier modifier;
9375 if (yieldExpressionsSupported()) {
9376 modifier = TokenStream::SlashIsRegExp;
9377 } else {
9378 modifier = TokenStream::SlashIsDiv;
9379 }
9380
9381 TokenKind next;
9382 if (!tokenStream.peekToken(&next, modifier)) {
9383 return errorResult();
9384 }
9385
9386 if (next == TokenKind::Colon) {
9387 return labeledStatement(yieldHandling);
9388 }
9389
9390 return expressionStatement(yieldHandling);
9391 }
9392
9393 default: {
9394 // If we encounter an await in a module, and the module is not marked
9395 // as async, mark the module as async.
9396 if (tt == TokenKind::Await && !pc_->isAsync()) {
9397 if (pc_->atModuleTopLevel()) {
9398 if (!options().topLevelAwait) {
9399 error(JSMSG_TOP_LEVEL_AWAIT_NOT_SUPPORTED);
9400 return errorResult();
9401 }
9402 pc_->sc()->asModuleContext()->setIsAsync();
9403 MOZ_ASSERT(pc_->isAsync())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isAsync())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isAsync()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("pc_->isAsync()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9403); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isAsync()"
")"); do { *((volatile int*)__null) = 9403; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9404 }
9405 }
9406
9407 // Avoid getting next token with SlashIsDiv.
9408 if (tt == TokenKind::Await && pc_->isAsync()) {
9409 return expressionStatement(yieldHandling);
9410 }
9411
9412 if (!TokenKindIsPossibleIdentifier(tt)) {
9413 return expressionStatement(yieldHandling);
9414 }
9415
9416 TokenKind next;
9417 if (!tokenStream.peekToken(&next)) {
9418 return errorResult();
9419 }
9420
9421 // |let| here can only be an Identifier, not a declaration. Give nicer
9422 // errors for declaration-looking typos.
9423 if (tt == TokenKind::Let) {
9424 bool forbiddenLetDeclaration = false;
9425
9426 if (next == TokenKind::LeftBracket) {
9427 // Enforce ExpressionStatement's 'let [' lookahead restriction.
9428 forbiddenLetDeclaration = true;
9429 } else if (next == TokenKind::LeftCurly ||
9430 TokenKindIsPossibleIdentifier(next)) {
9431 // 'let {' and 'let foo' aren't completely forbidden, if ASI
9432 // causes 'let' to be the entire Statement. But if they're
9433 // same-line, we can aggressively give a better error message.
9434 //
9435 // Note that this ignores 'yield' as TokenKind::Yield: we'll handle it
9436 // correctly but with a worse error message.
9437 TokenKind nextSameLine;
9438 if (!tokenStream.peekTokenSameLine(&nextSameLine)) {
9439 return errorResult();
9440 }
9441
9442 MOZ_ASSERT(TokenKindIsPossibleIdentifier(nextSameLine) ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine
== TokenKind::LeftCurly || nextSameLine == TokenKind::Eol)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine
== TokenKind::LeftCurly || nextSameLine == TokenKind::Eol)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine == TokenKind::LeftCurly || nextSameLine == TokenKind::Eol"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9444); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine == TokenKind::LeftCurly || nextSameLine == TokenKind::Eol"
")"); do { *((volatile int*)__null) = 9444; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
9443 nextSameLine == TokenKind::LeftCurly ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine
== TokenKind::LeftCurly || nextSameLine == TokenKind::Eol)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine
== TokenKind::LeftCurly || nextSameLine == TokenKind::Eol)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine == TokenKind::LeftCurly || nextSameLine == TokenKind::Eol"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9444); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine == TokenKind::LeftCurly || nextSameLine == TokenKind::Eol"
")"); do { *((volatile int*)__null) = 9444; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
9444 nextSameLine == TokenKind::Eol)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine
== TokenKind::LeftCurly || nextSameLine == TokenKind::Eol)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine
== TokenKind::LeftCurly || nextSameLine == TokenKind::Eol)))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine == TokenKind::LeftCurly || nextSameLine == TokenKind::Eol"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9444); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsPossibleIdentifier(nextSameLine) || nextSameLine == TokenKind::LeftCurly || nextSameLine == TokenKind::Eol"
")"); do { *((volatile int*)__null) = 9444; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9445
9446 forbiddenLetDeclaration = nextSameLine != TokenKind::Eol;
9447 }
9448
9449 if (forbiddenLetDeclaration) {
9450 error(JSMSG_FORBIDDEN_AS_STATEMENT, "lexical declarations");
9451 return errorResult();
9452 }
9453 } else if (tt == TokenKind::Async) {
9454 // Peek only on the same line: ExpressionStatement's lookahead
9455 // restriction is phrased as
9456 //
9457 // [lookahead ∉ { '{',
9458 // function,
9459 // async [no LineTerminator here] function,
9460 // class,
9461 // let '[' }]
9462 //
9463 // meaning that code like this is valid:
9464 //
9465 // if (true)
9466 // async // ASI opportunity
9467 // function clownshoes() {}
9468 TokenKind maybeFunction;
9469 if (!tokenStream.peekTokenSameLine(&maybeFunction)) {
9470 return errorResult();
9471 }
9472
9473 if (maybeFunction == TokenKind::Function) {
9474 error(JSMSG_FORBIDDEN_AS_STATEMENT, "async function declarations");
9475 return errorResult();
9476 }
9477
9478 // Otherwise this |async| begins an ExpressionStatement or is a
9479 // label name.
9480 }
9481
9482 // NOTE: It's unfortunately allowed to have a label named 'let' in
9483 // non-strict code. 💯
9484 if (next == TokenKind::Colon) {
9485 return labeledStatement(yieldHandling);
9486 }
9487
9488 return expressionStatement(yieldHandling);
9489 }
9490
9491 case TokenKind::New:
9492 return expressionStatement(yieldHandling, PredictInvoked);
9493
9494 // IfStatement[?Yield, ?Return]
9495 case TokenKind::If:
9496 return ifStatement(yieldHandling);
9497
9498 // BreakableStatement[?Yield, ?Return]
9499 //
9500 // BreakableStatement[Yield, Return]:
9501 // IterationStatement[?Yield, ?Return]
9502 // SwitchStatement[?Yield, ?Return]
9503 case TokenKind::Do:
9504 return doWhileStatement(yieldHandling);
9505
9506 case TokenKind::While:
9507 return whileStatement(yieldHandling);
9508
9509 case TokenKind::For:
9510 return forStatement(yieldHandling);
9511
9512 case TokenKind::Switch:
9513 return switchStatement(yieldHandling);
9514
9515 // ContinueStatement[?Yield]
9516 case TokenKind::Continue:
9517 return continueStatement(yieldHandling);
9518
9519 // BreakStatement[?Yield]
9520 case TokenKind::Break:
9521 return breakStatement(yieldHandling);
9522
9523 // [+Return] ReturnStatement[?Yield]
9524 case TokenKind::Return:
9525 // The Return parameter is only used here, and the effect is easily
9526 // detected this way, so don't bother passing around an extra parameter
9527 // everywhere.
9528 if (!pc_->allowReturn()) {
9529 error(JSMSG_BAD_RETURN_OR_YIELD, "return");
9530 return errorResult();
9531 }
9532 return returnStatement(yieldHandling);
9533
9534 // WithStatement[?Yield, ?Return]
9535 case TokenKind::With:
9536 return withStatement(yieldHandling);
9537
9538 // LabelledStatement[?Yield, ?Return]
9539 // This is really handled by default and TokenKind::Yield cases above.
9540
9541 // ThrowStatement[?Yield]
9542 case TokenKind::Throw:
9543 return throwStatement(yieldHandling);
9544
9545 // TryStatement[?Yield, ?Return]
9546 case TokenKind::Try:
9547 return tryStatement(yieldHandling);
9548
9549 // DebuggerStatement
9550 case TokenKind::Debugger:
9551 return debuggerStatement();
9552
9553 // |function| is forbidden by lookahead restriction (unless as child
9554 // statement of |if| or |else|, but Parser::consequentOrAlternative
9555 // handles that).
9556 case TokenKind::Function:
9557 error(JSMSG_FORBIDDEN_AS_STATEMENT, "function declarations");
9558 return errorResult();
9559
9560 // |class| is also forbidden by lookahead restriction.
9561 case TokenKind::Class:
9562 error(JSMSG_FORBIDDEN_AS_STATEMENT, "classes");
9563 return errorResult();
9564
9565 // ImportDeclaration (only inside modules)
9566 case TokenKind::Import:
9567 return importDeclarationOrImportExpr(yieldHandling);
9568
9569 // ExportDeclaration (only inside modules)
9570 case TokenKind::Export:
9571 return exportDeclaration();
9572
9573 // Miscellaneous error cases arguably better caught here than elsewhere.
9574
9575 case TokenKind::Catch:
9576 error(JSMSG_CATCH_WITHOUT_TRY);
9577 return errorResult();
9578
9579 case TokenKind::Finally:
9580 error(JSMSG_FINALLY_WITHOUT_TRY);
9581 return errorResult();
9582
9583 // NOTE: default case handled in the ExpressionStatement section.
9584 }
9585}
9586
9587template <class ParseHandler, typename Unit>
9588typename ParseHandler::NodeResult
9589GeneralParser<ParseHandler, Unit>::statementListItem(
9590 YieldHandling yieldHandling, bool canHaveDirectives /* = false */) {
9591 MOZ_ASSERT(checkOptionsCalled_)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(checkOptionsCalled_)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(checkOptionsCalled_))), 0)))
{ do { } while (false); MOZ_ReportAssertionFailure("checkOptionsCalled_"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9591); AnnotateMozCrashReason("MOZ_ASSERT" "(" "checkOptionsCalled_"
")"); do { *((volatile int*)__null) = 9591; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9592
9593 AutoCheckRecursionLimit recursion(this->fc_);
9594 if (!recursion.check(this->fc_)) {
9595 return errorResult();
9596 }
9597
9598 TokenKind tt;
9599 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
9600 return errorResult();
9601 }
9602
9603 switch (tt) {
9604 // BlockStatement[?Yield, ?Return]
9605 case TokenKind::LeftCurly:
9606 return blockStatement(yieldHandling);
9607
9608 // VariableStatement[?Yield]
9609 case TokenKind::Var:
9610 return variableStatement(yieldHandling);
9611
9612 // EmptyStatement
9613 case TokenKind::Semi:
9614 return handler_.newEmptyStatement(pos());
9615
9616 // ExpressionStatement[?Yield].
9617 //
9618 // These should probably be handled by a single ExpressionStatement
9619 // function in a default, not split up this way.
9620 case TokenKind::String:
9621 if (!canHaveDirectives &&
9622 anyChars.currentToken().atom() ==
9623 TaggedParserAtomIndex::WellKnown::use_asm_()) {
9624 if (!warning(JSMSG_USE_ASM_DIRECTIVE_FAIL)) {
9625 return errorResult();
9626 }
9627 }
9628 return expressionStatement(yieldHandling);
9629
9630 case TokenKind::Yield: {
9631 // Don't use a ternary operator here due to obscure linker issues
9632 // around using static consts in the arms of a ternary.
9633 Modifier modifier;
9634 if (yieldExpressionsSupported()) {
9635 modifier = TokenStream::SlashIsRegExp;
9636 } else {
9637 modifier = TokenStream::SlashIsDiv;
9638 }
9639
9640 TokenKind next;
9641 if (!tokenStream.peekToken(&next, modifier)) {
9642 return errorResult();
9643 }
9644
9645 if (next == TokenKind::Colon) {
9646 return labeledStatement(yieldHandling);
9647 }
9648
9649 return expressionStatement(yieldHandling);
9650 }
9651
9652 default: {
9653 // If we encounter an await in a module, and the module is not marked
9654 // as async, mark the module as async.
9655 if (tt == TokenKind::Await && !pc_->isAsync()) {
9656 if (pc_->atModuleTopLevel()) {
9657 if (!options().topLevelAwait) {
9658 error(JSMSG_TOP_LEVEL_AWAIT_NOT_SUPPORTED);
9659 return errorResult();
9660 }
9661 pc_->sc()->asModuleContext()->setIsAsync();
9662 MOZ_ASSERT(pc_->isAsync())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isAsync())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isAsync()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("pc_->isAsync()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9662); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isAsync()"
")"); do { *((volatile int*)__null) = 9662; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9663 }
9664 }
9665
9666 if (tt == TokenKind::Await && pc_->isAsync()) {
9667#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
9668 // Try finding evidence of a AwaitUsingDeclaration the syntax for which
9669 // would be:
9670 // await [no LineTerminator here] using [no LineTerminator here]
9671 // identifier
9672
9673 TokenKind nextTokUsing = TokenKind::Eof;
9674 // Scan with regex modifier because when its await expression, `/`
9675 // should be treated as a regexp.
9676 if (!tokenStream.peekTokenSameLine(&nextTokUsing,
9677 TokenStream::SlashIsRegExp)) {
9678 return errorResult();
9679 }
9680
9681 if (nextTokUsing == TokenKind::Using &&
9682 this->pc_->isUsingSyntaxAllowed()) {
9683 tokenStream.consumeKnownToken(nextTokUsing,
9684 TokenStream::SlashIsRegExp);
9685 TokenKind nextTokIdentifier = TokenKind::Eof;
9686 // Here we can use the Div modifier because if the next token is using
9687 // then a `/` as the next token can only be considered a division.
9688 if (!tokenStream.peekTokenSameLine(&nextTokIdentifier)) {
9689 return errorResult();
9690 }
9691 if (TokenKindIsPossibleIdentifier(nextTokIdentifier)) {
9692 return lexicalDeclaration(yieldHandling,
9693 DeclarationKind::AwaitUsing);
9694 }
9695 anyChars.ungetToken(); // put back using.
9696 }
9697#endif
9698 return expressionStatement(yieldHandling);
9699 }
9700
9701 if (!TokenKindIsPossibleIdentifier(tt)) {
9702 return expressionStatement(yieldHandling);
9703 }
9704
9705 TokenKind next;
9706 if (!tokenStream.peekToken(&next)) {
9707 return errorResult();
9708 }
9709
9710 if (tt == TokenKind::Let && nextTokenContinuesLetDeclaration(next)) {
9711 return lexicalDeclaration(yieldHandling, DeclarationKind::Let);
9712 }
9713
9714 if (tt == TokenKind::Async) {
9715 TokenKind nextSameLine = TokenKind::Eof;
9716 if (!tokenStream.peekTokenSameLine(&nextSameLine)) {
9717 return errorResult();
9718 }
9719 if (nextSameLine == TokenKind::Function) {
9720 uint32_t toStringStart = pos().begin;
9721 tokenStream.consumeKnownToken(TokenKind::Function);
9722 return functionStmt(toStringStart, yieldHandling, NameRequired,
9723 FunctionAsyncKind::AsyncFunction);
9724 }
9725 }
9726
9727 if (next == TokenKind::Colon) {
9728 return labeledStatement(yieldHandling);
9729 }
9730
9731 return expressionStatement(yieldHandling);
9732 }
9733
9734 case TokenKind::New:
9735 return expressionStatement(yieldHandling, PredictInvoked);
9736
9737 // IfStatement[?Yield, ?Return]
9738 case TokenKind::If:
9739 return ifStatement(yieldHandling);
9740
9741 // BreakableStatement[?Yield, ?Return]
9742 //
9743 // BreakableStatement[Yield, Return]:
9744 // IterationStatement[?Yield, ?Return]
9745 // SwitchStatement[?Yield, ?Return]
9746 case TokenKind::Do:
9747 return doWhileStatement(yieldHandling);
9748
9749 case TokenKind::While:
9750 return whileStatement(yieldHandling);
9751
9752 case TokenKind::For:
9753 return forStatement(yieldHandling);
9754
9755 case TokenKind::Switch:
9756 return switchStatement(yieldHandling);
9757
9758 // ContinueStatement[?Yield]
9759 case TokenKind::Continue:
9760 return continueStatement(yieldHandling);
9761
9762 // BreakStatement[?Yield]
9763 case TokenKind::Break:
9764 return breakStatement(yieldHandling);
9765
9766 // [+Return] ReturnStatement[?Yield]
9767 case TokenKind::Return:
9768 // The Return parameter is only used here, and the effect is easily
9769 // detected this way, so don't bother passing around an extra parameter
9770 // everywhere.
9771 if (!pc_->allowReturn()) {
9772 error(JSMSG_BAD_RETURN_OR_YIELD, "return");
9773 return errorResult();
9774 }
9775 return returnStatement(yieldHandling);
9776
9777 // WithStatement[?Yield, ?Return]
9778 case TokenKind::With:
9779 return withStatement(yieldHandling);
9780
9781 // LabelledStatement[?Yield, ?Return]
9782 // This is really handled by default and TokenKind::Yield cases above.
9783
9784 // ThrowStatement[?Yield]
9785 case TokenKind::Throw:
9786 return throwStatement(yieldHandling);
9787
9788 // TryStatement[?Yield, ?Return]
9789 case TokenKind::Try:
9790 return tryStatement(yieldHandling);
9791
9792 // DebuggerStatement
9793 case TokenKind::Debugger:
9794 return debuggerStatement();
9795
9796 // Declaration[Yield]:
9797
9798 // HoistableDeclaration[?Yield, ~Default]
9799 case TokenKind::Function:
9800 return functionStmt(pos().begin, yieldHandling, NameRequired);
9801
9802 // DecoratorList[?Yield, ?Await] opt ClassDeclaration[?Yield, ~Default]
9803#ifdef ENABLE_DECORATORS
9804 case TokenKind::At:
9805 return classDefinition(yieldHandling, ClassStatement, NameRequired);
9806#endif
9807
9808 case TokenKind::Class:
9809 return classDefinition(yieldHandling, ClassStatement, NameRequired);
9810
9811 // LexicalDeclaration[In, ?Yield]
9812 // LetOrConst BindingList[?In, ?Yield]
9813 case TokenKind::Const:
9814 // [In] is the default behavior, because for-loops specially parse
9815 // their heads to handle |in| in this situation.
9816 return lexicalDeclaration(yieldHandling, DeclarationKind::Const);
9817
9818#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
9819 case TokenKind::Using: {
9820 TokenKind nextTok = TokenKind::Eol;
9821 if (!tokenStream.peekTokenSameLine(&nextTok)) {
9822 return errorResult();
9823 }
9824 if (!TokenKindIsPossibleIdentifier(nextTok) ||
9825 !this->pc_->isUsingSyntaxAllowed()) {
9826 if (!tokenStream.peekToken(&nextTok)) {
9827 return errorResult();
9828 }
9829 // labelled statement could be like using\n:\nexpr
9830 if (nextTok == TokenKind::Colon) {
9831 return labeledStatement(yieldHandling);
9832 }
9833 return expressionStatement(yieldHandling);
9834 }
9835 return lexicalDeclaration(yieldHandling, DeclarationKind::Using);
9836 }
9837#endif
9838
9839 // ImportDeclaration (only inside modules)
9840 case TokenKind::Import:
9841 return importDeclarationOrImportExpr(yieldHandling);
9842
9843 // ExportDeclaration (only inside modules)
9844 case TokenKind::Export:
9845 return exportDeclaration();
9846
9847 // Miscellaneous error cases arguably better caught here than elsewhere.
9848
9849 case TokenKind::Catch:
9850 error(JSMSG_CATCH_WITHOUT_TRY);
9851 return errorResult();
9852
9853 case TokenKind::Finally:
9854 error(JSMSG_FINALLY_WITHOUT_TRY);
9855 return errorResult();
9856
9857 // NOTE: default case handled in the ExpressionStatement section.
9858 }
9859}
9860
9861template <class ParseHandler, typename Unit>
9862typename ParseHandler::NodeResult GeneralParser<ParseHandler, Unit>::expr(
9863 InHandling inHandling, YieldHandling yieldHandling,
9864 TripledotHandling tripledotHandling,
9865 PossibleError* possibleError /* = nullptr */,
9866 InvokedPrediction invoked /* = PredictUninvoked */) {
9867 Node pn;
9868 MOZ_TRY_VAR(pn, assignExpr(inHandling, yieldHandling, tripledotHandling,do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, tripledotHandling, possibleError, invoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (pn) = mozTryVarTempResult_.unwrap(); } while
(0)
9869 possibleError, invoked))do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, tripledotHandling, possibleError, invoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (pn) = mozTryVarTempResult_.unwrap(); } while
(0)
;
9870
9871 bool matched;
9872 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
9873 TokenStream::SlashIsRegExp)) {
9874 return errorResult();
9875 }
9876 if (!matched) {
9877 return pn;
9878 }
9879
9880 ListNodeType seq;
9881 MOZ_TRY_VAR(seq, handler_.newCommaExpressionList(pn))do { auto mozTryVarTempResult_ = (handler_.newCommaExpressionList
(pn)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr())
, 0))) { return mozTryVarTempResult_.propagateErr(); } (seq) =
mozTryVarTempResult_.unwrap(); } while (0)
;
9882 while (true) {
9883 // Trailing comma before the closing parenthesis is valid in an arrow
9884 // function parameters list: `(a, b, ) => body`. Check if we are
9885 // directly under CoverParenthesizedExpressionAndArrowParameterList,
9886 // and the next two tokens are closing parenthesis and arrow. If all
9887 // are present allow the trailing comma.
9888 if (tripledotHandling == TripledotAllowed) {
9889 TokenKind tt;
9890 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
9891 return errorResult();
9892 }
9893
9894 if (tt == TokenKind::RightParen) {
9895 tokenStream.consumeKnownToken(TokenKind::RightParen,
9896 TokenStream::SlashIsRegExp);
9897
9898 if (!tokenStream.peekToken(&tt)) {
9899 return errorResult();
9900 }
9901 if (tt != TokenKind::Arrow) {
9902 error(JSMSG_UNEXPECTED_TOKEN, "expression",
9903 TokenKindToDesc(TokenKind::RightParen));
9904 return errorResult();
9905 }
9906
9907 anyChars.ungetToken(); // put back right paren
9908 break;
9909 }
9910 }
9911
9912 // Additional calls to assignExpr should not reuse the possibleError
9913 // which had been passed into the function. Otherwise we would lose
9914 // information needed to determine whether or not we're dealing with
9915 // a non-recoverable situation.
9916 PossibleError possibleErrorInner(*this);
9917 MOZ_TRY_VAR(pn, assignExpr(inHandling, yieldHandling, tripledotHandling,do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, tripledotHandling, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (pn) = mozTryVarTempResult_.unwrap(); } while
(0)
9918 &possibleErrorInner))do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, tripledotHandling, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (pn) = mozTryVarTempResult_.unwrap(); } while
(0)
;
9919
9920 if (!possibleError) {
9921 // Report any pending expression error.
9922 if (!possibleErrorInner.checkForExpressionError()) {
9923 return errorResult();
9924 }
9925 } else {
9926 possibleErrorInner.transferErrorsTo(possibleError);
9927 }
9928
9929 handler_.addList(seq, pn);
9930
9931 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
9932 TokenStream::SlashIsRegExp)) {
9933 return errorResult();
9934 }
9935 if (!matched) {
9936 break;
9937 }
9938 }
9939 return seq;
9940}
9941
9942static ParseNodeKind BinaryOpTokenKindToParseNodeKind(TokenKind tok) {
9943 MOZ_ASSERT(TokenKindIsBinaryOp(tok))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsBinaryOp(tok))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(TokenKindIsBinaryOp(tok)))),
0))) { do { } while (false); MOZ_ReportAssertionFailure("TokenKindIsBinaryOp(tok)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9943); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsBinaryOp(tok)"
")"); do { *((volatile int*)__null) = 9943; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9944 return ParseNodeKind(size_t(ParseNodeKind::BinOpFirst) +
9945 (size_t(tok) - size_t(TokenKind::BinOpFirst)));
9946}
9947
9948// This list must be kept in the same order in several places:
9949// - The binary operators in ParseNode.h ,
9950// - the binary operators in TokenKind.h
9951// - the JSOp code list in BytecodeEmitter.cpp
9952static const int PrecedenceTable[] = {
9953 1, /* ParseNodeKind::Coalesce */
9954 2, /* ParseNodeKind::Or */
9955 3, /* ParseNodeKind::And */
9956 4, /* ParseNodeKind::BitOr */
9957 5, /* ParseNodeKind::BitXor */
9958 6, /* ParseNodeKind::BitAnd */
9959 7, /* ParseNodeKind::StrictEq */
9960 7, /* ParseNodeKind::Eq */
9961 7, /* ParseNodeKind::StrictNe */
9962 7, /* ParseNodeKind::Ne */
9963 8, /* ParseNodeKind::Lt */
9964 8, /* ParseNodeKind::Le */
9965 8, /* ParseNodeKind::Gt */
9966 8, /* ParseNodeKind::Ge */
9967 8, /* ParseNodeKind::InstanceOf */
9968 8, /* ParseNodeKind::In */
9969 8, /* ParseNodeKind::PrivateIn */
9970 9, /* ParseNodeKind::Lsh */
9971 9, /* ParseNodeKind::Rsh */
9972 9, /* ParseNodeKind::Ursh */
9973 10, /* ParseNodeKind::Add */
9974 10, /* ParseNodeKind::Sub */
9975 11, /* ParseNodeKind::Star */
9976 11, /* ParseNodeKind::Div */
9977 11, /* ParseNodeKind::Mod */
9978 12 /* ParseNodeKind::Pow */
9979};
9980
9981static const int PRECEDENCE_CLASSES = 12;
9982
9983static int Precedence(ParseNodeKind pnk) {
9984 // Everything binds tighter than ParseNodeKind::Limit, because we want
9985 // to reduce all nodes to a single node when we reach a token that is not
9986 // another binary operator.
9987 if (pnk == ParseNodeKind::Limit) {
9988 return 0;
9989 }
9990
9991 MOZ_ASSERT(pnk >= ParseNodeKind::BinOpFirst)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pnk >= ParseNodeKind::BinOpFirst)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pnk >= ParseNodeKind::BinOpFirst
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"pnk >= ParseNodeKind::BinOpFirst", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9991); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pnk >= ParseNodeKind::BinOpFirst"
")"); do { *((volatile int*)__null) = 9991; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9992 MOZ_ASSERT(pnk <= ParseNodeKind::BinOpLast)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pnk <= ParseNodeKind::BinOpLast)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pnk <= ParseNodeKind::BinOpLast
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"pnk <= ParseNodeKind::BinOpLast", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 9992); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pnk <= ParseNodeKind::BinOpLast"
")"); do { *((volatile int*)__null) = 9992; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
9993 return PrecedenceTable[size_t(pnk) - size_t(ParseNodeKind::BinOpFirst)];
9994}
9995
9996enum class EnforcedParentheses : uint8_t { CoalesceExpr, AndOrExpr, None };
9997
9998template <class ParseHandler, typename Unit>
9999MOZ_ALWAYS_INLINEinline typename ParseHandler::NodeResult
10000GeneralParser<ParseHandler, Unit>::orExpr(InHandling inHandling,
10001 YieldHandling yieldHandling,
10002 TripledotHandling tripledotHandling,
10003 PossibleError* possibleError,
10004 InvokedPrediction invoked) {
10005 // Shift-reduce parser for the binary operator part of the JS expression
10006 // syntax.
10007
10008 // Conceptually there's just one stack, a stack of pairs (lhs, op).
10009 // It's implemented using two separate arrays, though.
10010 Node nodeStack[PRECEDENCE_CLASSES];
10011 ParseNodeKind kindStack[PRECEDENCE_CLASSES];
10012 int depth = 0;
10013 Node pn;
10014 EnforcedParentheses unparenthesizedExpression = EnforcedParentheses::None;
10015 for (;;) {
10016 MOZ_TRY_VAR(do { auto mozTryVarTempResult_ = (unaryExpr(yieldHandling, tripledotHandling
, possibleError, invoked, PrivateNameHandling::PrivateNameAllowed
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (pn) = mozTryVarTempResult_
.unwrap(); } while (0)
10017 pn, unaryExpr(yieldHandling, tripledotHandling, possibleError, invoked,do { auto mozTryVarTempResult_ = (unaryExpr(yieldHandling, tripledotHandling
, possibleError, invoked, PrivateNameHandling::PrivateNameAllowed
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (pn) = mozTryVarTempResult_
.unwrap(); } while (0)
10018 PrivateNameHandling::PrivateNameAllowed))do { auto mozTryVarTempResult_ = (unaryExpr(yieldHandling, tripledotHandling
, possibleError, invoked, PrivateNameHandling::PrivateNameAllowed
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (pn) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10019
10020 // If a binary operator follows, consume it and compute the
10021 // corresponding operator.
10022 TokenKind tok;
10023 if (!tokenStream.getToken(&tok)) {
10024 return errorResult();
10025 }
10026
10027 // Ensure that if we have a private name lhs we are legally constructing a
10028 // `#x in obj` expessions:
10029 if (handler_.isPrivateName(pn)) {
10030 if (tok != TokenKind::In || inHandling != InAllowed) {
10031 error(JSMSG_ILLEGAL_PRIVATE_NAME);
10032 return errorResult();
10033 }
10034 }
10035
10036 ParseNodeKind pnk;
10037 if (tok == TokenKind::In ? inHandling == InAllowed
10038 : TokenKindIsBinaryOp(tok)) {
10039 // We're definitely not in a destructuring context, so report any
10040 // pending expression error now.
10041 if (possibleError && !possibleError->checkForExpressionError()) {
10042 return errorResult();
10043 }
10044
10045 bool isErgonomicBrandCheck = false;
10046 switch (tok) {
10047 // Report an error for unary expressions on the LHS of **.
10048 case TokenKind::Pow:
10049 if (handler_.isUnparenthesizedUnaryExpression(pn)) {
10050 error(JSMSG_BAD_POW_LEFTSIDE);
10051 return errorResult();
10052 }
10053 break;
10054
10055 case TokenKind::Or:
10056 case TokenKind::And:
10057 // In the case that the `??` is on the left hand side of the
10058 // expression: Disallow Mixing of ?? and other logical operators (||
10059 // and &&) unless one expression is parenthesized
10060 if (unparenthesizedExpression == EnforcedParentheses::CoalesceExpr) {
10061 error(JSMSG_BAD_COALESCE_MIXING);
10062 return errorResult();
10063 }
10064 // If we have not detected a mixing error at this point, record that
10065 // we have an unparenthesized expression, in case we have one later.
10066 unparenthesizedExpression = EnforcedParentheses::AndOrExpr;
10067 break;
10068
10069 case TokenKind::Coalesce:
10070 if (unparenthesizedExpression == EnforcedParentheses::AndOrExpr) {
10071 error(JSMSG_BAD_COALESCE_MIXING);
10072 return errorResult();
10073 }
10074 // If we have not detected a mixing error at this point, record that
10075 // we have an unparenthesized expression, in case we have one later.
10076 unparenthesizedExpression = EnforcedParentheses::CoalesceExpr;
10077 break;
10078
10079 case TokenKind::In:
10080 // if the LHS is a private name, and the operator is In,
10081 // ensure we're construcing an ergonomic brand check of
10082 // '#x in y', rather than having a higher precedence operator
10083 // like + cause a different reduction, such as
10084 // 1 + #x in y.
10085 if (handler_.isPrivateName(pn)) {
10086 if (depth > 0 && Precedence(kindStack[depth - 1]) >=
10087 Precedence(ParseNodeKind::InExpr)) {
10088 error(JSMSG_INVALID_PRIVATE_NAME_PRECEDENCE);
10089 return errorResult();
10090 }
10091
10092 isErgonomicBrandCheck = true;
10093 }
10094 break;
10095
10096 default:
10097 // do nothing in other cases
10098 break;
10099 }
10100
10101 if (isErgonomicBrandCheck) {
10102 pnk = ParseNodeKind::PrivateInExpr;
10103 } else {
10104 pnk = BinaryOpTokenKindToParseNodeKind(tok);
10105 }
10106
10107 } else {
10108 tok = TokenKind::Eof;
10109 pnk = ParseNodeKind::Limit;
10110 }
10111
10112 // From this point on, destructuring defaults are definitely an error.
10113 possibleError = nullptr;
10114
10115 // If pnk has precedence less than or equal to another operator on the
10116 // stack, reduce. This combines nodes on the stack until we form the
10117 // actual lhs of pnk.
10118 //
10119 // The >= in this condition works because it is appendOrCreateList's
10120 // job to decide if the operator in question is left- or
10121 // right-associative, and build the corresponding tree.
10122 while (depth > 0 && Precedence(kindStack[depth - 1]) >= Precedence(pnk)) {
10123 depth--;
10124 ParseNodeKind combiningPnk = kindStack[depth];
10125 MOZ_TRY_VAR(pn, handler_.appendOrCreateList(combiningPnk,do { auto mozTryVarTempResult_ = (handler_.appendOrCreateList
(combiningPnk, nodeStack[depth], pn, pc_)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (pn) = mozTryVarTempResult_.unwrap(); } while
(0)
10126 nodeStack[depth], pn, pc_))do { auto mozTryVarTempResult_ = (handler_.appendOrCreateList
(combiningPnk, nodeStack[depth], pn, pc_)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (pn) = mozTryVarTempResult_.unwrap(); } while
(0)
;
10127 }
10128
10129 if (pnk == ParseNodeKind::Limit) {
10130 break;
10131 }
10132
10133 nodeStack[depth] = pn;
10134 kindStack[depth] = pnk;
10135 depth++;
10136 MOZ_ASSERT(depth <= PRECEDENCE_CLASSES)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(depth <= PRECEDENCE_CLASSES)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(depth <= PRECEDENCE_CLASSES
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"depth <= PRECEDENCE_CLASSES", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10136); AnnotateMozCrashReason("MOZ_ASSERT" "(" "depth <= PRECEDENCE_CLASSES"
")"); do { *((volatile int*)__null) = 10136; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
10137 }
10138
10139 anyChars.ungetToken();
10140
10141 // Had the next token been a Div, we would have consumed it. So there's no
10142 // ambiguity if we later (after ASI) re-get this token with SlashIsRegExp.
10143 anyChars.allowGettingNextTokenWithSlashIsRegExp();
10144
10145 MOZ_ASSERT(depth == 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(depth == 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(depth == 0))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("depth == 0", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10145); AnnotateMozCrashReason("MOZ_ASSERT" "(" "depth == 0"
")"); do { *((volatile int*)__null) = 10145; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
10146 return pn;
10147}
10148
10149template <class ParseHandler, typename Unit>
10150MOZ_ALWAYS_INLINEinline typename ParseHandler::NodeResult
10151GeneralParser<ParseHandler, Unit>::condExpr(InHandling inHandling,
10152 YieldHandling yieldHandling,
10153 TripledotHandling tripledotHandling,
10154 PossibleError* possibleError,
10155 InvokedPrediction invoked) {
10156 Node condition;
10157 MOZ_TRY_VAR(condition, orExpr(inHandling, yieldHandling, tripledotHandling,do { auto mozTryVarTempResult_ = (orExpr(inHandling, yieldHandling
, tripledotHandling, possibleError, invoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (condition) = mozTryVarTempResult_.unwrap(
); } while (0)
10158 possibleError, invoked))do { auto mozTryVarTempResult_ = (orExpr(inHandling, yieldHandling
, tripledotHandling, possibleError, invoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (condition) = mozTryVarTempResult_.unwrap(
); } while (0)
;
10159
10160 bool matched;
10161 if (!tokenStream.matchToken(&matched, TokenKind::Hook,
10162 TokenStream::SlashIsInvalid)) {
10163 return errorResult();
10164 }
10165 if (!matched) {
10166 return condition;
10167 }
10168
10169 Node thenExpr;
10170 MOZ_TRY_VAR(thenExpr,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (thenExpr) = mozTryVarTempResult_.unwrap(); } while (0)
10171 assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (thenExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
10172
10173 if (!mustMatchToken(TokenKind::Colon, JSMSG_COLON_IN_COND)) {
10174 return errorResult();
10175 }
10176
10177 Node elseExpr;
10178 MOZ_TRY_VAR(elseExpr,do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (elseExpr) = mozTryVarTempResult_.unwrap(); } while (0)
10179 assignExpr(inHandling, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (elseExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
10180
10181 return handler_.newConditional(condition, thenExpr, elseExpr);
10182}
10183
10184template <class ParseHandler, typename Unit>
10185typename ParseHandler::NodeResult GeneralParser<ParseHandler, Unit>::assignExpr(
10186 InHandling inHandling, YieldHandling yieldHandling,
10187 TripledotHandling tripledotHandling,
10188 PossibleError* possibleError /* = nullptr */,
10189 InvokedPrediction invoked /* = PredictUninvoked */) {
10190 AutoCheckRecursionLimit recursion(this->fc_);
10191 if (!recursion.check(this->fc_)) {
10192 return errorResult();
10193 }
10194
10195 // It's very common at this point to have a "detectably simple" expression,
10196 // i.e. a name/number/string token followed by one of the following tokens
10197 // that obviously isn't part of an expression: , ; : ) ] }
10198 //
10199 // (In Parsemark this happens 81.4% of the time; in code with large
10200 // numeric arrays, such as some Kraken benchmarks, it happens more often.)
10201 //
10202 // In such cases, we can avoid the full expression parsing route through
10203 // assignExpr(), condExpr(), orExpr(), unaryExpr(), memberExpr(), and
10204 // primaryExpr().
10205
10206 TokenKind firstToken;
10207 if (!tokenStream.getToken(&firstToken, TokenStream::SlashIsRegExp)) {
10208 return errorResult();
10209 }
10210
10211 TokenPos exprPos = pos();
10212
10213 bool endsExpr;
10214
10215 // This only handles identifiers that *never* have special meaning anywhere
10216 // in the language. Contextual keywords, reserved words in strict mode,
10217 // and other hard cases are handled outside this fast path.
10218 if (firstToken == TokenKind::Name) {
10219 if (!tokenStream.nextTokenEndsExpr(&endsExpr)) {
10220 return errorResult();
10221 }
10222 if (endsExpr) {
10223 TaggedParserAtomIndex name = identifierReference(yieldHandling);
10224 if (!name) {
10225 return errorResult();
10226 }
10227
10228 return identifierReference(name);
10229 }
10230 }
10231
10232 if (firstToken == TokenKind::Number) {
10233 if (!tokenStream.nextTokenEndsExpr(&endsExpr)) {
10234 return errorResult();
10235 }
10236 if (endsExpr) {
10237 return newNumber(anyChars.currentToken());
10238 }
10239 }
10240
10241 if (firstToken == TokenKind::String) {
10242 if (!tokenStream.nextTokenEndsExpr(&endsExpr)) {
10243 return errorResult();
10244 }
10245 if (endsExpr) {
10246 return stringLiteral();
10247 }
10248 }
10249
10250 if (firstToken == TokenKind::Yield && yieldExpressionsSupported()) {
10251 return yieldExpression(inHandling);
10252 }
10253
10254 bool maybeAsyncArrow = false;
10255 if (firstToken == TokenKind::Async) {
10256 TokenKind nextSameLine = TokenKind::Eof;
10257 if (!tokenStream.peekTokenSameLine(&nextSameLine)) {
10258 return errorResult();
10259 }
10260
10261 if (TokenKindIsPossibleIdentifier(nextSameLine)) {
10262 maybeAsyncArrow = true;
10263 }
10264 }
10265
10266 anyChars.ungetToken();
10267
10268 // Save the tokenizer state in case we find an arrow function and have to
10269 // rewind.
10270 Position start(tokenStream);
10271 auto ghostToken = this->compilationState_.getPosition();
10272
10273 PossibleError possibleErrorInner(*this);
10274 Node lhs;
10275 TokenKind tokenAfterLHS;
10276 bool isArrow;
10277 if (maybeAsyncArrow) {
10278 tokenStream.consumeKnownToken(TokenKind::Async, TokenStream::SlashIsRegExp);
10279
10280 TokenKind tokenAfterAsync;
10281 if (!tokenStream.getToken(&tokenAfterAsync)) {
10282 return errorResult();
10283 }
10284 MOZ_ASSERT(TokenKindIsPossibleIdentifier(tokenAfterAsync))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsPossibleIdentifier(tokenAfterAsync))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(TokenKindIsPossibleIdentifier(tokenAfterAsync)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("TokenKindIsPossibleIdentifier(tokenAfterAsync)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10284); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsPossibleIdentifier(tokenAfterAsync)"
")"); do { *((volatile int*)__null) = 10284; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
10285
10286 // Check yield validity here.
10287 TaggedParserAtomIndex name = bindingIdentifier(yieldHandling);
10288 if (!name) {
10289 return errorResult();
10290 }
10291
10292 if (!tokenStream.peekToken(&tokenAfterLHS, TokenStream::SlashIsRegExp)) {
10293 return errorResult();
10294 }
10295
10296 isArrow = tokenAfterLHS == TokenKind::Arrow;
10297
10298 // |async [no LineTerminator] of| without being followed by => is only
10299 // possible in for-await-of loops, e.g. |for await (async of [])|. Pretend
10300 // the |async| token was parsed an identifier reference and then proceed
10301 // with the rest of this function.
10302 if (!isArrow) {
10303 anyChars.ungetToken(); // unget the binding identifier
10304
10305 // The next token is guaranteed to never be a Div (, because it's an
10306 // identifier), so it's okay to re-get the token with SlashIsRegExp.
10307 anyChars.allowGettingNextTokenWithSlashIsRegExp();
10308
10309 TaggedParserAtomIndex asyncName = identifierReference(yieldHandling);
10310 if (!asyncName) {
10311 return errorResult();
10312 }
10313
10314 MOZ_TRY_VAR(lhs, identifierReference(asyncName))do { auto mozTryVarTempResult_ = (identifierReference(asyncName
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (lhs) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10315 }
10316 } else {
10317 MOZ_TRY_VAR(lhs, condExpr(inHandling, yieldHandling, tripledotHandling,do { auto mozTryVarTempResult_ = (condExpr(inHandling, yieldHandling
, tripledotHandling, &possibleErrorInner, invoked)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (lhs) = mozTryVarTempResult_
.unwrap(); } while (0)
10318 &possibleErrorInner, invoked))do { auto mozTryVarTempResult_ = (condExpr(inHandling, yieldHandling
, tripledotHandling, &possibleErrorInner, invoked)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (lhs) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10319
10320 // Use SlashIsRegExp here because the ConditionalExpression parsed above
10321 // could be the entirety of this AssignmentExpression, and then ASI
10322 // permits this token to be a regular expression.
10323 if (!tokenStream.peekToken(&tokenAfterLHS, TokenStream::SlashIsRegExp)) {
10324 return errorResult();
10325 }
10326
10327 isArrow = tokenAfterLHS == TokenKind::Arrow;
10328 }
10329
10330 if (isArrow) {
10331 // Rewind to reparse as an arrow function.
10332 //
10333 // Note: We do not call CompilationState::rewind here because parsing
10334 // during delazification will see the same rewind and need the same sequence
10335 // of inner functions to skip over.
10336 // Instead, we mark inner functions as "ghost".
10337 //
10338 // See GHOST_FUNCTION in FunctionFlags.h for more details.
10339 tokenStream.rewind(start);
10340 this->compilationState_.markGhost(ghostToken);
10341
10342 TokenKind next;
10343 if (!tokenStream.getToken(&next, TokenStream::SlashIsRegExp)) {
10344 return errorResult();
10345 }
10346 TokenPos startPos = pos();
10347 uint32_t toStringStart = startPos.begin;
10348 anyChars.ungetToken();
10349
10350 FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction;
10351
10352 if (next == TokenKind::Async) {
10353 tokenStream.consumeKnownToken(next, TokenStream::SlashIsRegExp);
10354
10355 TokenKind nextSameLine = TokenKind::Eof;
10356 if (!tokenStream.peekTokenSameLine(&nextSameLine)) {
10357 return errorResult();
10358 }
10359
10360 // The AsyncArrowFunction production are
10361 // async [no LineTerminator here] AsyncArrowBindingIdentifier ...
10362 // async [no LineTerminator here] ArrowFormalParameters ...
10363 if (TokenKindIsPossibleIdentifier(nextSameLine) ||
10364 nextSameLine == TokenKind::LeftParen) {
10365 asyncKind = FunctionAsyncKind::AsyncFunction;
10366 } else {
10367 anyChars.ungetToken();
10368 }
10369 }
10370
10371 FunctionSyntaxKind syntaxKind = FunctionSyntaxKind::Arrow;
10372 FunctionNodeType funNode;
10373 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, startPos))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, startPos)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (funNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
10374
10375 return functionDefinition(funNode, toStringStart, inHandling, yieldHandling,
10376 TaggedParserAtomIndex::null(), syntaxKind,
10377 GeneratorKind::NotGenerator, asyncKind);
10378 }
10379
10380 MOZ_ALWAYS_TRUE(do { if ((__builtin_expect(!!(tokenStream.getToken(&tokenAfterLHS
, TokenStream::SlashIsRegExp)), 1))) { } else { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(false)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(false))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("false" " (" "tokenStream.getToken(&tokenAfterLHS, TokenStream::SlashIsRegExp)"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10381); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "tokenStream.getToken(&tokenAfterLHS, TokenStream::SlashIsRegExp)"
")"); do { *((volatile int*)__null) = 10381; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false); } } while
(false)
10381 tokenStream.getToken(&tokenAfterLHS, TokenStream::SlashIsRegExp))do { if ((__builtin_expect(!!(tokenStream.getToken(&tokenAfterLHS
, TokenStream::SlashIsRegExp)), 1))) { } else { do { static_assert
( mozilla::detail::AssertionConditionType<decltype(false)>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(false))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("false" " (" "tokenStream.getToken(&tokenAfterLHS, TokenStream::SlashIsRegExp)"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10381); AnnotateMozCrashReason("MOZ_DIAGNOSTIC_ASSERT" "(" "false"
") (" "tokenStream.getToken(&tokenAfterLHS, TokenStream::SlashIsRegExp)"
")"); do { *((volatile int*)__null) = 10381; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false); } } while
(false)
;
10382
10383 ParseNodeKind kind;
10384 switch (tokenAfterLHS) {
10385 case TokenKind::Assign:
10386 kind = ParseNodeKind::AssignExpr;
10387 break;
10388 case TokenKind::AddAssign:
10389 kind = ParseNodeKind::AddAssignExpr;
10390 break;
10391 case TokenKind::SubAssign:
10392 kind = ParseNodeKind::SubAssignExpr;
10393 break;
10394 case TokenKind::CoalesceAssign:
10395 kind = ParseNodeKind::CoalesceAssignExpr;
10396 break;
10397 case TokenKind::OrAssign:
10398 kind = ParseNodeKind::OrAssignExpr;
10399 break;
10400 case TokenKind::AndAssign:
10401 kind = ParseNodeKind::AndAssignExpr;
10402 break;
10403 case TokenKind::BitOrAssign:
10404 kind = ParseNodeKind::BitOrAssignExpr;
10405 break;
10406 case TokenKind::BitXorAssign:
10407 kind = ParseNodeKind::BitXorAssignExpr;
10408 break;
10409 case TokenKind::BitAndAssign:
10410 kind = ParseNodeKind::BitAndAssignExpr;
10411 break;
10412 case TokenKind::LshAssign:
10413 kind = ParseNodeKind::LshAssignExpr;
10414 break;
10415 case TokenKind::RshAssign:
10416 kind = ParseNodeKind::RshAssignExpr;
10417 break;
10418 case TokenKind::UrshAssign:
10419 kind = ParseNodeKind::UrshAssignExpr;
10420 break;
10421 case TokenKind::MulAssign:
10422 kind = ParseNodeKind::MulAssignExpr;
10423 break;
10424 case TokenKind::DivAssign:
10425 kind = ParseNodeKind::DivAssignExpr;
10426 break;
10427 case TokenKind::ModAssign:
10428 kind = ParseNodeKind::ModAssignExpr;
10429 break;
10430 case TokenKind::PowAssign:
10431 kind = ParseNodeKind::PowAssignExpr;
10432 break;
10433
10434 default:
10435 MOZ_ASSERT(!anyChars.isCurrentTokenAssignment())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!anyChars.isCurrentTokenAssignment())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!anyChars.isCurrentTokenAssignment
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("!anyChars.isCurrentTokenAssignment()", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10435); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!anyChars.isCurrentTokenAssignment()"
")"); do { *((volatile int*)__null) = 10435; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
10436 if (!possibleError) {
10437 if (!possibleErrorInner.checkForExpressionError()) {
10438 return errorResult();
10439 }
10440 } else {
10441 possibleErrorInner.transferErrorsTo(possibleError);
10442 }
10443
10444 anyChars.ungetToken();
10445 return lhs;
10446 }
10447
10448 // Verify the left-hand side expression doesn't have a forbidden form.
10449 if (handler_.isUnparenthesizedDestructuringPattern(lhs)) {
10450 if (kind != ParseNodeKind::AssignExpr) {
10451 error(JSMSG_BAD_DESTRUCT_ASS);
10452 return errorResult();
10453 }
10454
10455 if (!possibleErrorInner.checkForDestructuringErrorOrWarning()) {
10456 return errorResult();
10457 }
10458 } else if (handler_.isName(lhs)) {
10459 if (const char* chars = nameIsArgumentsOrEval(lhs)) {
10460 // |chars| is "arguments" or "eval" here.
10461 if (!strictModeErrorAt(exprPos.begin, JSMSG_BAD_STRICT_ASSIGN, chars)) {
10462 return errorResult();
10463 }
10464 }
10465 } else if (handler_.isArgumentsLength(lhs)) {
10466 pc_->sc()->setIneligibleForArgumentsLength();
10467 } else if (handler_.isPropertyOrPrivateMemberAccess(lhs)) {
10468 // Permitted: no additional testing/fixup needed.
10469 } else if (handler_.isFunctionCall(lhs)) {
10470 // We don't have to worry about backward compatibility issues with the new
10471 // compound assignment operators, so we always throw here. Also that way we
10472 // don't have to worry if |f() &&= expr| should always throw an error or
10473 // only if |f()| returns true.
10474 if (kind == ParseNodeKind::CoalesceAssignExpr ||
10475 kind == ParseNodeKind::OrAssignExpr ||
10476 kind == ParseNodeKind::AndAssignExpr) {
10477 errorAt(exprPos.begin, JSMSG_BAD_LEFTSIDE_OF_ASS);
10478 return errorResult();
10479 }
10480
10481 if (!strictModeErrorAt(exprPos.begin, JSMSG_BAD_LEFTSIDE_OF_ASS)) {
10482 return errorResult();
10483 }
10484
10485 if (possibleError) {
10486 possibleError->setPendingDestructuringErrorAt(exprPos,
10487 JSMSG_BAD_DESTRUCT_TARGET);
10488 }
10489 } else {
10490 errorAt(exprPos.begin, JSMSG_BAD_LEFTSIDE_OF_ASS);
10491 return errorResult();
10492 }
10493
10494 if (!possibleErrorInner.checkForExpressionError()) {
10495 return errorResult();
10496 }
10497
10498 Node rhs;
10499 MOZ_TRY_VAR(rhs, assignExpr(inHandling, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(inHandling, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (rhs) = mozTryVarTempResult_.unwrap(); } while (0)
;
10500
10501 return handler_.newAssignment(kind, lhs, rhs);
10502}
10503
10504template <class ParseHandler>
10505const char* PerHandlerParser<ParseHandler>::nameIsArgumentsOrEval(Node node) {
10506 MOZ_ASSERT(handler_.isName(node),do { static_assert( mozilla::detail::AssertionConditionType<
decltype(handler_.isName(node))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(handler_.isName(node)))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("handler_.isName(node)"
" (" "must only call this function on known names" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10507); AnnotateMozCrashReason("MOZ_ASSERT" "(" "handler_.isName(node)"
") (" "must only call this function on known names" ")"); do
{ *((volatile int*)__null) = 10507; __attribute__((nomerge))
::abort(); } while (false); } } while (false)
10507 "must only call this function on known names")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(handler_.isName(node))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(handler_.isName(node)))), 0)
)) { do { } while (false); MOZ_ReportAssertionFailure("handler_.isName(node)"
" (" "must only call this function on known names" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10507); AnnotateMozCrashReason("MOZ_ASSERT" "(" "handler_.isName(node)"
") (" "must only call this function on known names" ")"); do
{ *((volatile int*)__null) = 10507; __attribute__((nomerge))
::abort(); } while (false); } } while (false)
;
10508
10509 if (handler_.isEvalName(node)) {
10510 return "eval";
10511 }
10512 if (handler_.isArgumentsName(node)) {
10513 return "arguments";
10514 }
10515 return nullptr;
10516}
10517
10518template <class ParseHandler, typename Unit>
10519bool GeneralParser<ParseHandler, Unit>::checkIncDecOperand(
10520 Node operand, uint32_t operandOffset) {
10521 if (handler_.isName(operand)) {
10522 if (const char* chars = nameIsArgumentsOrEval(operand)) {
10523 if (!strictModeErrorAt(operandOffset, JSMSG_BAD_STRICT_ASSIGN, chars)) {
10524 return false;
10525 }
10526 }
10527 } else if (handler_.isArgumentsLength(operand)) {
10528 pc_->sc()->setIneligibleForArgumentsLength();
10529 } else if (handler_.isPropertyOrPrivateMemberAccess(operand)) {
10530 // Permitted: no additional testing/fixup needed.
10531 } else if (handler_.isFunctionCall(operand)) {
10532 // Assignment to function calls is forbidden in ES6. We're still
10533 // somewhat concerned about sites using this in dead code, so forbid it
10534 // only in strict mode code.
10535 if (!strictModeErrorAt(operandOffset, JSMSG_BAD_INCOP_OPERAND)) {
10536 return false;
10537 }
10538 } else {
10539 errorAt(operandOffset, JSMSG_BAD_INCOP_OPERAND);
10540 return false;
10541 }
10542 return true;
10543}
10544
10545template <class ParseHandler, typename Unit>
10546typename ParseHandler::UnaryNodeResult
10547GeneralParser<ParseHandler, Unit>::unaryOpExpr(YieldHandling yieldHandling,
10548 ParseNodeKind kind,
10549 uint32_t begin) {
10550 Node kid;
10551 MOZ_TRY_VAR(kid, unaryExpr(yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (unaryExpr(yieldHandling, TripledotProhibited
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (kid) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10552 return handler_.newUnary(kind, begin, kid);
10553}
10554
10555template <class ParseHandler, typename Unit>
10556typename ParseHandler::NodeResult
10557GeneralParser<ParseHandler, Unit>::optionalExpr(
10558 YieldHandling yieldHandling, TripledotHandling tripledotHandling,
10559 TokenKind tt, PossibleError* possibleError /* = nullptr */,
10560 InvokedPrediction invoked /* = PredictUninvoked */) {
10561 AutoCheckRecursionLimit recursion(this->fc_);
10562 if (!recursion.check(this->fc_)) {
10563 return errorResult();
10564 }
10565
10566 uint32_t begin = pos().begin;
10567
10568 Node lhs;
10569 MOZ_TRY_VAR(lhs,do { auto mozTryVarTempResult_ = (memberExpr(yieldHandling, tripledotHandling
, tt, true, possibleError, invoked)); if ((__builtin_expect(!
!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (lhs) = mozTryVarTempResult_.unwrap(); } while
(0)
10570 memberExpr(yieldHandling, tripledotHandling, tt,do { auto mozTryVarTempResult_ = (memberExpr(yieldHandling, tripledotHandling
, tt, true, possibleError, invoked)); if ((__builtin_expect(!
!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (lhs) = mozTryVarTempResult_.unwrap(); } while
(0)
10571 /* allowCallSyntax = */ true, possibleError, invoked))do { auto mozTryVarTempResult_ = (memberExpr(yieldHandling, tripledotHandling
, tt, true, possibleError, invoked)); if ((__builtin_expect(!
!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (lhs) = mozTryVarTempResult_.unwrap(); } while
(0)
;
10572
10573 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsDiv)) {
10574 return errorResult();
10575 }
10576
10577 if (tt != TokenKind::OptionalChain) {
10578 return lhs;
10579 }
10580
10581 while (true) {
10582 if (!tokenStream.getToken(&tt)) {
10583 return errorResult();
10584 }
10585
10586 if (tt == TokenKind::Eof) {
10587 anyChars.ungetToken();
10588 break;
10589 }
10590
10591 Node nextMember;
10592 if (tt == TokenKind::OptionalChain) {
10593 if (!tokenStream.getToken(&tt)) {
10594 return errorResult();
10595 }
10596 if (TokenKindIsPossibleIdentifierName(tt)) {
10597 MOZ_TRY_VAR(nextMember,do { auto mozTryVarTempResult_ = (memberPropertyAccess(lhs, OptionalKind
::Optional)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
10598 memberPropertyAccess(lhs, OptionalKind::Optional))do { auto mozTryVarTempResult_ = (memberPropertyAccess(lhs, OptionalKind
::Optional)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
;
10599 } else if (tt == TokenKind::PrivateName) {
10600 MOZ_TRY_VAR(nextMember,do { auto mozTryVarTempResult_ = (memberPrivateAccess(lhs, OptionalKind
::Optional)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
10601 memberPrivateAccess(lhs, OptionalKind::Optional))do { auto mozTryVarTempResult_ = (memberPrivateAccess(lhs, OptionalKind
::Optional)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
;
10602 } else if (tt == TokenKind::LeftBracket) {
10603 MOZ_TRY_VAR(nextMember, memberElemAccess(lhs, yieldHandling,do { auto mozTryVarTempResult_ = (memberElemAccess(lhs, yieldHandling
, OptionalKind::Optional)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (nextMember) = mozTryVarTempResult_.unwrap(); } while (0)
10604 OptionalKind::Optional))do { auto mozTryVarTempResult_ = (memberElemAccess(lhs, yieldHandling
, OptionalKind::Optional)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (nextMember) = mozTryVarTempResult_.unwrap(); } while (0)
;
10605 } else if (tt == TokenKind::LeftParen) {
10606 MOZ_TRY_VAR(nextMember,do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, possibleError, OptionalKind::Optional)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (nextMember) = mozTryVarTempResult_.unwrap
(); } while (0)
10607 memberCall(tt, lhs, yieldHandling, possibleError,do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, possibleError, OptionalKind::Optional)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (nextMember) = mozTryVarTempResult_.unwrap
(); } while (0)
10608 OptionalKind::Optional))do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, possibleError, OptionalKind::Optional)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (nextMember) = mozTryVarTempResult_.unwrap
(); } while (0)
;
10609 } else {
10610 error(JSMSG_NAME_AFTER_DOT);
10611 return errorResult();
10612 }
10613 } else if (tt == TokenKind::Dot) {
10614 if (!tokenStream.getToken(&tt)) {
10615 return errorResult();
10616 }
10617 if (TokenKindIsPossibleIdentifierName(tt)) {
10618 MOZ_TRY_VAR(nextMember, memberPropertyAccess(lhs))do { auto mozTryVarTempResult_ = (memberPropertyAccess(lhs));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (nextMember)
= mozTryVarTempResult_.unwrap(); } while (0)
;
10619 } else if (tt == TokenKind::PrivateName) {
10620 MOZ_TRY_VAR(nextMember, memberPrivateAccess(lhs))do { auto mozTryVarTempResult_ = (memberPrivateAccess(lhs)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (nextMember) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10621 } else {
10622 error(JSMSG_NAME_AFTER_DOT);
10623 return errorResult();
10624 }
10625 } else if (tt == TokenKind::LeftBracket) {
10626 MOZ_TRY_VAR(nextMember, memberElemAccess(lhs, yieldHandling))do { auto mozTryVarTempResult_ = (memberElemAccess(lhs, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
;
10627 } else if (tt == TokenKind::LeftParen) {
10628 MOZ_TRY_VAR(nextMember,do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, possibleError)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (nextMember) = mozTryVarTempResult_.unwrap(); } while (0)
10629 memberCall(tt, lhs, yieldHandling, possibleError))do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, possibleError)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (nextMember) = mozTryVarTempResult_.unwrap(); } while (0)
;
10630 } else if (tt == TokenKind::TemplateHead ||
10631 tt == TokenKind::NoSubsTemplate) {
10632 error(JSMSG_BAD_OPTIONAL_TEMPLATE);
10633 return errorResult();
10634 } else {
10635 anyChars.ungetToken();
10636 break;
10637 }
10638
10639 MOZ_ASSERT(nextMember)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(nextMember)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(nextMember))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("nextMember", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10639); AnnotateMozCrashReason("MOZ_ASSERT" "(" "nextMember"
")"); do { *((volatile int*)__null) = 10639; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
10640 lhs = nextMember;
10641 }
10642
10643 return handler_.newOptionalChain(begin, lhs);
10644}
10645
10646template <class ParseHandler, typename Unit>
10647typename ParseHandler::NodeResult GeneralParser<ParseHandler, Unit>::unaryExpr(
10648 YieldHandling yieldHandling, TripledotHandling tripledotHandling,
10649 PossibleError* possibleError /* = nullptr */,
10650 InvokedPrediction invoked /* = PredictUninvoked */,
10651 PrivateNameHandling privateNameHandling /* = PrivateNameProhibited */) {
10652 AutoCheckRecursionLimit recursion(this->fc_);
10653 if (!recursion.check(this->fc_)) {
10654 return errorResult();
10655 }
10656
10657 TokenKind tt;
10658 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
10659 return errorResult();
10660 }
10661 uint32_t begin = pos().begin;
10662 switch (tt) {
10663 case TokenKind::Void:
10664 return unaryOpExpr(yieldHandling, ParseNodeKind::VoidExpr, begin);
10665 case TokenKind::Not:
10666 return unaryOpExpr(yieldHandling, ParseNodeKind::NotExpr, begin);
10667 case TokenKind::BitNot:
10668 return unaryOpExpr(yieldHandling, ParseNodeKind::BitNotExpr, begin);
10669 case TokenKind::Add:
10670 return unaryOpExpr(yieldHandling, ParseNodeKind::PosExpr, begin);
10671 case TokenKind::Sub:
10672 return unaryOpExpr(yieldHandling, ParseNodeKind::NegExpr, begin);
10673
10674 case TokenKind::TypeOf: {
10675 // The |typeof| operator is specially parsed to distinguish its
10676 // application to a name, from its application to a non-name
10677 // expression:
10678 //
10679 // // Looks up the name, doesn't find it and so evaluates to
10680 // // "undefined".
10681 // assertEq(typeof nonExistentName, "undefined");
10682 //
10683 // // Evaluates expression, triggering a runtime ReferenceError for
10684 // // the undefined name.
10685 // typeof (1, nonExistentName);
10686 Node kid;
10687 MOZ_TRY_VAR(kid, unaryExpr(yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (unaryExpr(yieldHandling, TripledotProhibited
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (kid) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10688
10689 return handler_.newTypeof(begin, kid);
10690 }
10691
10692 case TokenKind::Inc:
10693 case TokenKind::Dec: {
10694 TokenKind tt2;
10695 if (!tokenStream.getToken(&tt2, TokenStream::SlashIsRegExp)) {
10696 return errorResult();
10697 }
10698
10699 uint32_t operandOffset = pos().begin;
10700 Node operand;
10701 MOZ_TRY_VAR(operand,do { auto mozTryVarTempResult_ = (optionalExpr(yieldHandling,
TripledotProhibited, tt2)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (operand) = mozTryVarTempResult_.unwrap(); } while (0)
10702 optionalExpr(yieldHandling, TripledotProhibited, tt2))do { auto mozTryVarTempResult_ = (optionalExpr(yieldHandling,
TripledotProhibited, tt2)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (operand) = mozTryVarTempResult_.unwrap(); } while (0)
;
10703 if (!checkIncDecOperand(operand, operandOffset)) {
10704 return errorResult();
10705 }
10706 ParseNodeKind pnk = (tt == TokenKind::Inc)
10707 ? ParseNodeKind::PreIncrementExpr
10708 : ParseNodeKind::PreDecrementExpr;
10709 return handler_.newUpdate(pnk, begin, operand);
10710 }
10711 case TokenKind::PrivateName: {
10712 if (privateNameHandling == PrivateNameHandling::PrivateNameAllowed) {
10713 TaggedParserAtomIndex field = anyChars.currentName();
10714 return privateNameReference(field);
10715 }
10716 error(JSMSG_INVALID_PRIVATE_NAME_IN_UNARY_EXPR);
10717 return errorResult();
10718 }
10719
10720 case TokenKind::Delete: {
10721 uint32_t exprOffset;
10722 if (!tokenStream.peekOffset(&exprOffset, TokenStream::SlashIsRegExp)) {
10723 return errorResult();
10724 }
10725
10726 Node expr;
10727 MOZ_TRY_VAR(expr, unaryExpr(yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (unaryExpr(yieldHandling, TripledotProhibited
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (expr) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10728
10729 // Per spec, deleting most unary expressions is valid -- it simply
10730 // returns true -- except for two cases:
10731 // 1. `var x; ...; delete x` is a syntax error in strict mode.
10732 // 2. Private fields cannot be deleted.
10733 if (handler_.isName(expr)) {
10734 if (!strictModeErrorAt(exprOffset, JSMSG_DEPRECATED_DELETE_OPERAND)) {
10735 return errorResult();
10736 }
10737
10738 pc_->sc()->setBindingsAccessedDynamically();
10739 }
10740
10741 if (handler_.isPrivateMemberAccess(expr)) {
10742 errorAt(exprOffset, JSMSG_PRIVATE_DELETE);
10743 return errorResult();
10744 }
10745
10746 return handler_.newDelete(begin, expr);
10747 }
10748 case TokenKind::Await: {
10749 // If we encounter an await in a module, mark it as async.
10750 if (!pc_->isAsync() && pc_->sc()->isModule()) {
10751 if (!options().topLevelAwait) {
10752 error(JSMSG_TOP_LEVEL_AWAIT_NOT_SUPPORTED);
10753 return errorResult();
10754 }
10755 pc_->sc()->asModuleContext()->setIsAsync();
10756 MOZ_ASSERT(pc_->isAsync())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->isAsync())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(pc_->isAsync()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("pc_->isAsync()"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10756); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->isAsync()"
")"); do { *((volatile int*)__null) = 10756; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
10757 }
10758
10759 if (pc_->isAsync()) {
10760 if (inParametersOfAsyncFunction()) {
10761 error(JSMSG_AWAIT_IN_PARAMETER);
10762 return errorResult();
10763 }
10764 Node kid;
10765 MOZ_TRY_VAR(kid, unaryExpr(yieldHandling, tripledotHandling,do { auto mozTryVarTempResult_ = (unaryExpr(yieldHandling, tripledotHandling
, possibleError, invoked)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
10766 possibleError, invoked))do { auto mozTryVarTempResult_ = (unaryExpr(yieldHandling, tripledotHandling
, possibleError, invoked)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (kid) = mozTryVarTempResult_.unwrap(); } while (0)
;
10767 pc_->lastAwaitOffset = begin;
10768 return handler_.newAwaitExpression(begin, kid);
10769 }
10770 }
10771
10772 [[fallthrough]];
10773
10774 default: {
10775 Node expr;
10776 MOZ_TRY_VAR(expr, optionalExpr(yieldHandling, tripledotHandling, tt,do { auto mozTryVarTempResult_ = (optionalExpr(yieldHandling,
tripledotHandling, tt, possibleError, invoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (expr) = mozTryVarTempResult_.unwrap(); } while
(0)
10777 possibleError, invoked))do { auto mozTryVarTempResult_ = (optionalExpr(yieldHandling,
tripledotHandling, tt, possibleError, invoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (expr) = mozTryVarTempResult_.unwrap(); } while
(0)
;
10778
10779 /* Don't look across a newline boundary for a postfix incop. */
10780 if (!tokenStream.peekTokenSameLine(&tt)) {
10781 return errorResult();
10782 }
10783
10784 if (tt != TokenKind::Inc && tt != TokenKind::Dec) {
10785 return expr;
10786 }
10787
10788 tokenStream.consumeKnownToken(tt);
10789 if (!checkIncDecOperand(expr, begin)) {
10790 return errorResult();
10791 }
10792
10793 ParseNodeKind pnk = (tt == TokenKind::Inc)
10794 ? ParseNodeKind::PostIncrementExpr
10795 : ParseNodeKind::PostDecrementExpr;
10796 return handler_.newUpdate(pnk, begin, expr);
10797 }
10798 }
10799}
10800
10801template <class ParseHandler, typename Unit>
10802typename ParseHandler::NodeResult
10803GeneralParser<ParseHandler, Unit>::assignExprWithoutYieldOrAwait(
10804 YieldHandling yieldHandling) {
10805 uint32_t startYieldOffset = pc_->lastYieldOffset;
10806 uint32_t startAwaitOffset = pc_->lastAwaitOffset;
10807
10808 Node res;
10809 MOZ_TRY_VAR(res, assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (res) = mozTryVarTempResult_.unwrap(); } while (0)
;
10810
10811 if (pc_->lastYieldOffset != startYieldOffset) {
10812 errorAt(pc_->lastYieldOffset, JSMSG_YIELD_IN_PARAMETER);
10813 return errorResult();
10814 }
10815 if (pc_->lastAwaitOffset != startAwaitOffset) {
10816 errorAt(pc_->lastAwaitOffset, JSMSG_AWAIT_IN_PARAMETER);
10817 return errorResult();
10818 }
10819 return res;
10820}
10821
10822template <class ParseHandler, typename Unit>
10823typename ParseHandler::ListNodeResult
10824GeneralParser<ParseHandler, Unit>::argumentList(
10825 YieldHandling yieldHandling, bool* isSpread,
10826 PossibleError* possibleError /* = nullptr */) {
10827 ListNodeType argsList;
10828 MOZ_TRY_VAR(argsList, handler_.newArguments(pos()))do { auto mozTryVarTempResult_ = (handler_.newArguments(pos()
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (argsList
) = mozTryVarTempResult_.unwrap(); } while (0)
;
10829
10830 bool matched;
10831 if (!tokenStream.matchToken(&matched, TokenKind::RightParen,
10832 TokenStream::SlashIsRegExp)) {
10833 return errorResult();
10834 }
10835 if (matched) {
10836 handler_.setEndPosition(argsList, pos().end);
10837 return argsList;
10838 }
10839
10840 while (true) {
10841 bool spread = false;
10842 uint32_t begin = 0;
10843 if (!tokenStream.matchToken(&matched, TokenKind::TripleDot,
10844 TokenStream::SlashIsRegExp)) {
10845 return errorResult();
10846 }
10847 if (matched) {
10848 spread = true;
10849 begin = pos().begin;
10850 *isSpread = true;
10851 }
10852
10853 Node argNode;
10854 MOZ_TRY_VAR(argNode, assignExpr(InAllowed, yieldHandling,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, possibleError)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (argNode) = mozTryVarTempResult_.unwrap();
} while (0)
10855 TripledotProhibited, possibleError))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, possibleError)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (argNode) = mozTryVarTempResult_.unwrap();
} while (0)
;
10856 if (spread) {
10857 MOZ_TRY_VAR(argNode, handler_.newSpread(begin, argNode))do { auto mozTryVarTempResult_ = (handler_.newSpread(begin, argNode
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (argNode)
= mozTryVarTempResult_.unwrap(); } while (0)
;
10858 }
10859
10860 handler_.addList(argsList, argNode);
10861
10862 bool matched;
10863 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
10864 TokenStream::SlashIsRegExp)) {
10865 return errorResult();
10866 }
10867 if (!matched) {
10868 break;
10869 }
10870
10871 TokenKind tt;
10872 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
10873 return errorResult();
10874 }
10875 if (tt == TokenKind::RightParen) {
10876 break;
10877 }
10878 }
10879
10880 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_ARGS)) {
10881 return errorResult();
10882 }
10883
10884 handler_.setEndPosition(argsList, pos().end);
10885 return argsList;
10886}
10887
10888bool ParserBase::checkAndMarkSuperScope() {
10889 if (!pc_->sc()->allowSuperProperty()) {
10890 return false;
10891 }
10892
10893 pc_->setSuperScopeNeedsHomeObject();
10894 return true;
10895}
10896
10897template <class ParseHandler, typename Unit>
10898bool GeneralParser<ParseHandler, Unit>::computeErrorMetadata(
10899 ErrorMetadata* err, const ErrorReportMixin::ErrorOffset& offset) const {
10900 if (offset.is<ErrorReportMixin::Current>()) {
10901 return tokenStream.computeErrorMetadata(err, AsVariant(pos().begin));
10902 }
10903 return tokenStream.computeErrorMetadata(err, offset);
10904}
10905
10906template <class ParseHandler, typename Unit>
10907typename ParseHandler::NodeResult GeneralParser<ParseHandler, Unit>::memberExpr(
10908 YieldHandling yieldHandling, TripledotHandling tripledotHandling,
10909 TokenKind tt, bool allowCallSyntax, PossibleError* possibleError,
10910 InvokedPrediction invoked) {
10911 MOZ_ASSERT(anyChars.isCurrentTokenType(tt))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(tt))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
tt)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(tt)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10911); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(tt)"
")"); do { *((volatile int*)__null) = 10911; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
10912
10913 Node lhs;
10914
10915 AutoCheckRecursionLimit recursion(this->fc_);
10916 if (!recursion.check(this->fc_)) {
10917 return errorResult();
10918 }
10919
10920 /* Check for new expression first. */
10921 if (tt == TokenKind::New) {
10922 uint32_t newBegin = pos().begin;
10923 // Make sure this wasn't a |new.target| in disguise.
10924 NewTargetNodeType newTarget;
10925 if (!tryNewTarget(&newTarget)) {
10926 return errorResult();
10927 }
10928 if (newTarget) {
10929 lhs = newTarget;
10930 } else {
10931 // Gotten by tryNewTarget
10932 tt = anyChars.currentToken().type;
10933 Node ctorExpr;
10934 MOZ_TRY_VAR(ctorExpr,do { auto mozTryVarTempResult_ = (memberExpr(yieldHandling, TripledotProhibited
, tt, false, nullptr, PredictInvoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (ctorExpr) = mozTryVarTempResult_.unwrap()
; } while (0)
10935 memberExpr(yieldHandling, TripledotProhibited, tt,do { auto mozTryVarTempResult_ = (memberExpr(yieldHandling, TripledotProhibited
, tt, false, nullptr, PredictInvoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (ctorExpr) = mozTryVarTempResult_.unwrap()
; } while (0)
10936 /* allowCallSyntax = */ false,do { auto mozTryVarTempResult_ = (memberExpr(yieldHandling, TripledotProhibited
, tt, false, nullptr, PredictInvoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (ctorExpr) = mozTryVarTempResult_.unwrap()
; } while (0)
10937 /* possibleError = */ nullptr, PredictInvoked))do { auto mozTryVarTempResult_ = (memberExpr(yieldHandling, TripledotProhibited
, tt, false, nullptr, PredictInvoked)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (ctorExpr) = mozTryVarTempResult_.unwrap()
; } while (0)
;
10938
10939 // If we have encountered an optional chain, in the form of `new
10940 // ClassName?.()` then we need to throw, as this is disallowed by the
10941 // spec.
10942 bool optionalToken;
10943 if (!tokenStream.matchToken(&optionalToken, TokenKind::OptionalChain)) {
10944 return errorResult();
10945 }
10946 if (optionalToken) {
10947 errorAt(newBegin, JSMSG_BAD_NEW_OPTIONAL);
10948 return errorResult();
10949 }
10950
10951 bool matched;
10952 if (!tokenStream.matchToken(&matched, TokenKind::LeftParen)) {
10953 return errorResult();
10954 }
10955
10956 bool isSpread = false;
10957 ListNodeType args;
10958 if (matched) {
10959 MOZ_TRY_VAR(args, argumentList(yieldHandling, &isSpread))do { auto mozTryVarTempResult_ = (argumentList(yieldHandling,
&isSpread)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (args) = mozTryVarTempResult_.unwrap(); } while (0)
;
10960 } else {
10961 MOZ_TRY_VAR(args, handler_.newArguments(pos()))do { auto mozTryVarTempResult_ = (handler_.newArguments(pos()
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (args) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10962 }
10963
10964 if (!args) {
10965 return errorResult();
10966 }
10967
10968 MOZ_TRY_VAR(do { auto mozTryVarTempResult_ = (handler_.newNewExpression(newBegin
, ctorExpr, args, isSpread)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (lhs) = mozTryVarTempResult_.unwrap(); } while (0)
10969 lhs, handler_.newNewExpression(newBegin, ctorExpr, args, isSpread))do { auto mozTryVarTempResult_ = (handler_.newNewExpression(newBegin
, ctorExpr, args, isSpread)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (lhs) = mozTryVarTempResult_.unwrap(); } while (0)
;
10970 }
10971 } else if (tt == TokenKind::Super) {
10972 NameNodeType thisName;
10973 MOZ_TRY_VAR(thisName, newThisName())do { auto mozTryVarTempResult_ = (newThisName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (thisName) = mozTryVarTempResult_.unwrap()
; } while (0)
;
10974 MOZ_TRY_VAR(lhs, handler_.newSuperBase(thisName, pos()))do { auto mozTryVarTempResult_ = (handler_.newSuperBase(thisName
, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (lhs
) = mozTryVarTempResult_.unwrap(); } while (0)
;
10975 } else if (tt == TokenKind::Import) {
10976 MOZ_TRY_VAR(lhs, importExpr(yieldHandling, allowCallSyntax))do { auto mozTryVarTempResult_ = (importExpr(yieldHandling, allowCallSyntax
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (lhs) = mozTryVarTempResult_
.unwrap(); } while (0)
;
10977 } else {
10978 MOZ_TRY_VAR(lhs, primaryExpr(yieldHandling, tripledotHandling, tt,do { auto mozTryVarTempResult_ = (primaryExpr(yieldHandling, tripledotHandling
, tt, possibleError, invoked)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (lhs) = mozTryVarTempResult_.unwrap(); } while (0)
10979 possibleError, invoked))do { auto mozTryVarTempResult_ = (primaryExpr(yieldHandling, tripledotHandling
, tt, possibleError, invoked)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (lhs) = mozTryVarTempResult_.unwrap(); } while (0)
;
10980 }
10981
10982 MOZ_ASSERT_IF(handler_.isSuperBase(lhs),do { if (handler_.isSuperBase(lhs)) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(anyChars.isCurrentTokenType
(TokenKind::Super))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::Super)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::Super)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10983); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Super)"
")"); do { *((volatile int*)__null) = 10983; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false); } } while
(false)
10983 anyChars.isCurrentTokenType(TokenKind::Super))do { if (handler_.isSuperBase(lhs)) { do { static_assert( mozilla
::detail::AssertionConditionType<decltype(anyChars.isCurrentTokenType
(TokenKind::Super))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
TokenKind::Super)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(TokenKind::Super)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 10983); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Super)"
")"); do { *((volatile int*)__null) = 10983; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false); } } while
(false)
;
10984
10985 while (true) {
10986 if (!tokenStream.getToken(&tt)) {
10987 return errorResult();
10988 }
10989 if (tt == TokenKind::Eof) {
10990 anyChars.ungetToken();
10991 break;
10992 }
10993
10994 Node nextMember;
10995 if (tt == TokenKind::Dot) {
10996 if (!tokenStream.getToken(&tt)) {
10997 return errorResult();
10998 }
10999
11000 if (TokenKindIsPossibleIdentifierName(tt)) {
11001 MOZ_TRY_VAR(nextMember, memberPropertyAccess(lhs))do { auto mozTryVarTempResult_ = (memberPropertyAccess(lhs));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (nextMember)
= mozTryVarTempResult_.unwrap(); } while (0)
;
11002 } else if (tt == TokenKind::PrivateName) {
11003 MOZ_TRY_VAR(nextMember, memberPrivateAccess(lhs))do { auto mozTryVarTempResult_ = (memberPrivateAccess(lhs)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (nextMember) = mozTryVarTempResult_
.unwrap(); } while (0)
;
11004 } else {
11005 error(JSMSG_NAME_AFTER_DOT);
11006 return errorResult();
11007 }
11008 } else if (tt == TokenKind::LeftBracket) {
11009 MOZ_TRY_VAR(nextMember, memberElemAccess(lhs, yieldHandling))do { auto mozTryVarTempResult_ = (memberElemAccess(lhs, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
;
11010 } else if ((allowCallSyntax && tt == TokenKind::LeftParen) ||
11011 tt == TokenKind::TemplateHead ||
11012 tt == TokenKind::NoSubsTemplate) {
11013 if (handler_.isSuperBase(lhs)) {
11014 if (!pc_->sc()->allowSuperCall()) {
11015 error(JSMSG_BAD_SUPERCALL);
11016 return errorResult();
11017 }
11018
11019 if (tt != TokenKind::LeftParen) {
11020 error(JSMSG_BAD_SUPER);
11021 return errorResult();
11022 }
11023
11024 MOZ_TRY_VAR(nextMember, memberSuperCall(lhs, yieldHandling))do { auto mozTryVarTempResult_ = (memberSuperCall(lhs, yieldHandling
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
;
11025
11026 if (!noteUsedName(
11027 TaggedParserAtomIndex::WellKnown::dot_initializers_())) {
11028 return errorResult();
11029 }
11030#ifdef ENABLE_DECORATORS
11031 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::
11032 dot_instanceExtraInitializers_())) {
11033 return null();
11034 }
11035#endif
11036 } else {
11037 MOZ_TRY_VAR(nextMember,do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, possibleError)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (nextMember) = mozTryVarTempResult_.unwrap(); } while (0)
11038 memberCall(tt, lhs, yieldHandling, possibleError))do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, possibleError)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (nextMember) = mozTryVarTempResult_.unwrap(); } while (0)
;
11039 }
11040 } else {
11041 anyChars.ungetToken();
11042 if (handler_.isSuperBase(lhs)) {
11043 break;
11044 }
11045 return lhs;
11046 }
11047
11048 lhs = nextMember;
11049 }
11050
11051 if (handler_.isSuperBase(lhs)) {
11052 error(JSMSG_BAD_SUPER);
11053 return errorResult();
11054 }
11055
11056 return lhs;
11057}
11058
11059template <class ParseHandler, typename Unit>
11060typename ParseHandler::NodeResult
11061GeneralParser<ParseHandler, Unit>::decoratorExpr(YieldHandling yieldHandling,
11062 TokenKind tt) {
11063 MOZ_ASSERT(anyChars.isCurrentTokenType(tt))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(tt))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
tt)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(tt)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11063); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(tt)"
")"); do { *((volatile int*)__null) = 11063; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11064
11065 AutoCheckRecursionLimit recursion(this->fc_);
11066 if (!recursion.check(this->fc_)) {
11067 return errorResult();
11068 }
11069
11070 if (tt == TokenKind::LeftParen) {
11071 // DecoratorParenthesizedExpression
11072 Node expr;
11073 MOZ_TRY_VAR(expr, exprInParens(InAllowed, yieldHandling, TripledotAllowed,do { auto mozTryVarTempResult_ = (exprInParens(InAllowed, yieldHandling
, TripledotAllowed, nullptr)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (expr) = mozTryVarTempResult_.unwrap(); } while (0)
11074 /* possibleError*/ nullptr))do { auto mozTryVarTempResult_ = (exprInParens(InAllowed, yieldHandling
, TripledotAllowed, nullptr)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (expr) = mozTryVarTempResult_.unwrap(); } while (0)
;
11075 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_DECORATOR)) {
11076 return errorResult();
11077 }
11078
11079 return handler_.parenthesize(expr);
11080 }
11081
11082 if (!TokenKindIsPossibleIdentifier(tt)) {
11083 error(JSMSG_DECORATOR_NAME_EXPECTED);
11084 return errorResult();
11085 }
11086
11087 TaggedParserAtomIndex name = identifierReference(yieldHandling);
11088 if (!name) {
11089 return errorResult();
11090 }
11091
11092 Node lhs;
11093 MOZ_TRY_VAR(lhs, identifierReference(name))do { auto mozTryVarTempResult_ = (identifierReference(name));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (lhs) = mozTryVarTempResult_
.unwrap(); } while (0)
;
11094
11095 while (true) {
11096 if (!tokenStream.getToken(&tt)) {
11097 return errorResult();
11098 }
11099 if (tt == TokenKind::Eof) {
11100 anyChars.ungetToken();
11101 break;
11102 }
11103
11104 Node nextMember;
11105 if (tt == TokenKind::Dot) {
11106 if (!tokenStream.getToken(&tt)) {
11107 return errorResult();
11108 }
11109
11110 if (TokenKindIsPossibleIdentifierName(tt)) {
11111 MOZ_TRY_VAR(nextMember, memberPropertyAccess(lhs))do { auto mozTryVarTempResult_ = (memberPropertyAccess(lhs));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (nextMember)
= mozTryVarTempResult_.unwrap(); } while (0)
;
11112 } else if (tt == TokenKind::PrivateName) {
11113 MOZ_TRY_VAR(nextMember, memberPrivateAccess(lhs))do { auto mozTryVarTempResult_ = (memberPrivateAccess(lhs)); if
((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (nextMember) = mozTryVarTempResult_
.unwrap(); } while (0)
;
11114 } else {
11115 error(JSMSG_NAME_AFTER_DOT);
11116 return errorResult();
11117 }
11118 } else if (tt == TokenKind::LeftParen) {
11119 MOZ_TRY_VAR(nextMember, memberCall(tt, lhs, yieldHandling,do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, nullptr)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
11120 /* possibleError */ nullptr))do { auto mozTryVarTempResult_ = (memberCall(tt, lhs, yieldHandling
, nullptr)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (nextMember
) = mozTryVarTempResult_.unwrap(); } while (0)
;
11121 lhs = nextMember;
11122 // This is a `DecoratorCallExpression` and it's defined at the top level
11123 // of `Decorator`, no other `DecoratorMemberExpression` is allowed to
11124 // follow after the arguments.
11125 break;
11126 } else {
11127 anyChars.ungetToken();
11128 break;
11129 }
11130
11131 lhs = nextMember;
11132 }
11133
11134 return lhs;
11135}
11136
11137template <class ParseHandler>
11138inline typename ParseHandler::NameNodeResult
11139PerHandlerParser<ParseHandler>::newName(TaggedParserAtomIndex name) {
11140 return newName(name, pos());
11141}
11142
11143template <class ParseHandler>
11144inline typename ParseHandler::NameNodeResult
11145PerHandlerParser<ParseHandler>::newName(TaggedParserAtomIndex name,
11146 TokenPos pos) {
11147 if (name == TaggedParserAtomIndex::WellKnown::arguments()) {
11148 this->pc_->numberOfArgumentsNames++;
11149 }
11150 return handler_.newName(name, pos);
11151}
11152
11153template <class ParseHandler>
11154inline typename ParseHandler::NameNodeResult
11155PerHandlerParser<ParseHandler>::newPrivateName(TaggedParserAtomIndex name) {
11156 return handler_.newPrivateName(name, pos());
11157}
11158
11159template <class ParseHandler, typename Unit>
11160typename ParseHandler::NodeResult
11161GeneralParser<ParseHandler, Unit>::memberPropertyAccess(
11162 Node lhs, OptionalKind optionalKind /* = OptionalKind::NonOptional */) {
11163 MOZ_ASSERT(TokenKindIsPossibleIdentifierName(anyChars.currentToken().type) ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsPossibleIdentifierName(anyChars.currentToken
().type) || anyChars.currentToken().type == TokenKind::PrivateName
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(TokenKindIsPossibleIdentifierName(anyChars.currentToken
().type) || anyChars.currentToken().type == TokenKind::PrivateName
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"TokenKindIsPossibleIdentifierName(anyChars.currentToken().type) || anyChars.currentToken().type == TokenKind::PrivateName"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11164); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsPossibleIdentifierName(anyChars.currentToken().type) || anyChars.currentToken().type == TokenKind::PrivateName"
")"); do { *((volatile int*)__null) = 11164; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
11164 anyChars.currentToken().type == TokenKind::PrivateName)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(TokenKindIsPossibleIdentifierName(anyChars.currentToken
().type) || anyChars.currentToken().type == TokenKind::PrivateName
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(TokenKindIsPossibleIdentifierName(anyChars.currentToken
().type) || anyChars.currentToken().type == TokenKind::PrivateName
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"TokenKindIsPossibleIdentifierName(anyChars.currentToken().type) || anyChars.currentToken().type == TokenKind::PrivateName"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11164); AnnotateMozCrashReason("MOZ_ASSERT" "(" "TokenKindIsPossibleIdentifierName(anyChars.currentToken().type) || anyChars.currentToken().type == TokenKind::PrivateName"
")"); do { *((volatile int*)__null) = 11164; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11165 TaggedParserAtomIndex field = anyChars.currentName();
11166 if (handler_.isSuperBase(lhs) && !checkAndMarkSuperScope()) {
11167 error(JSMSG_BAD_SUPERPROP, "property");
11168 return errorResult();
11169 }
11170
11171 NameNodeType name;
11172 MOZ_TRY_VAR(name, handler_.newPropertyName(field, pos()))do { auto mozTryVarTempResult_ = (handler_.newPropertyName(field
, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (name
) = mozTryVarTempResult_.unwrap(); } while (0)
;
11173
11174 if (optionalKind == OptionalKind::Optional) {
11175 MOZ_ASSERT(!handler_.isSuperBase(lhs))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!handler_.isSuperBase(lhs))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!handler_.isSuperBase(lhs)))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!handler_.isSuperBase(lhs)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11175); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!handler_.isSuperBase(lhs)"
")"); do { *((volatile int*)__null) = 11175; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11176 return handler_.newOptionalPropertyAccess(lhs, name);
11177 }
11178
11179 if (handler_.isArgumentsName(lhs) && handler_.isLengthName(name)) {
11180 MOZ_ASSERT(pc_->numberOfArgumentsNames > 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(pc_->numberOfArgumentsNames > 0)>::isValid,
"invalid assertion condition"); if ((__builtin_expect(!!(!(!
!(pc_->numberOfArgumentsNames > 0))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("pc_->numberOfArgumentsNames > 0"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11180); AnnotateMozCrashReason("MOZ_ASSERT" "(" "pc_->numberOfArgumentsNames > 0"
")"); do { *((volatile int*)__null) = 11180; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11181 pc_->numberOfArgumentsNames--;
11182 // Currently when resuming Generators don't get their argument length set
11183 // in the interpreter frame (see InterpreterStack::resumeGeneratorCallFrame,
11184 // and its call to initCallFrame).
11185 if (pc_->isGeneratorOrAsync()) {
11186 pc_->sc()->setIneligibleForArgumentsLength();
11187 }
11188 return handler_.newArgumentsLength(lhs, name);
11189 }
11190
11191 return handler_.newPropertyAccess(lhs, name);
11192}
11193
11194template <class ParseHandler, typename Unit>
11195typename ParseHandler::NodeResult
11196GeneralParser<ParseHandler, Unit>::memberPrivateAccess(
11197 Node lhs, OptionalKind optionalKind /* = OptionalKind::NonOptional */) {
11198 MOZ_ASSERT(anyChars.currentToken().type == TokenKind::PrivateName)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.currentToken().type == TokenKind::PrivateName
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.currentToken().type == TokenKind::PrivateName
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"anyChars.currentToken().type == TokenKind::PrivateName", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11198); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.currentToken().type == TokenKind::PrivateName"
")"); do { *((volatile int*)__null) = 11198; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11199
11200 TaggedParserAtomIndex field = anyChars.currentName();
11201 // Cannot access private fields on super.
11202 if (handler_.isSuperBase(lhs)) {
11203 error(JSMSG_BAD_SUPERPRIVATE);
11204 return errorResult();
11205 }
11206
11207 NameNodeType privateName;
11208 MOZ_TRY_VAR(privateName, privateNameReference(field))do { auto mozTryVarTempResult_ = (privateNameReference(field)
); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)
)) { return mozTryVarTempResult_.propagateErr(); } (privateName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
11209
11210 if (optionalKind == OptionalKind::Optional) {
11211 MOZ_ASSERT(!handler_.isSuperBase(lhs))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!handler_.isSuperBase(lhs))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!handler_.isSuperBase(lhs)))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!handler_.isSuperBase(lhs)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11211); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!handler_.isSuperBase(lhs)"
")"); do { *((volatile int*)__null) = 11211; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11212 return handler_.newOptionalPrivateMemberAccess(lhs, privateName, pos().end);
11213 }
11214 return handler_.newPrivateMemberAccess(lhs, privateName, pos().end);
11215}
11216
11217template <class ParseHandler, typename Unit>
11218typename ParseHandler::NodeResult
11219GeneralParser<ParseHandler, Unit>::memberElemAccess(
11220 Node lhs, YieldHandling yieldHandling,
11221 OptionalKind optionalKind /* = OptionalKind::NonOptional */) {
11222 MOZ_ASSERT(anyChars.currentToken().type == TokenKind::LeftBracket)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.currentToken().type == TokenKind::LeftBracket
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.currentToken().type == TokenKind::LeftBracket
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"anyChars.currentToken().type == TokenKind::LeftBracket", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11222); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.currentToken().type == TokenKind::LeftBracket"
")"); do { *((volatile int*)__null) = 11222; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11223 Node propExpr;
11224 MOZ_TRY_VAR(propExpr, expr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (expr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
11225
11226 if (!mustMatchToken(TokenKind::RightBracket, JSMSG_BRACKET_IN_INDEX)) {
11227 return errorResult();
11228 }
11229
11230 if (handler_.isSuperBase(lhs) && !checkAndMarkSuperScope()) {
11231 error(JSMSG_BAD_SUPERPROP, "member");
11232 return errorResult();
11233 }
11234 if (optionalKind == OptionalKind::Optional) {
11235 MOZ_ASSERT(!handler_.isSuperBase(lhs))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!handler_.isSuperBase(lhs))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!handler_.isSuperBase(lhs)))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!handler_.isSuperBase(lhs)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11235); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!handler_.isSuperBase(lhs)"
")"); do { *((volatile int*)__null) = 11235; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11236 return handler_.newOptionalPropertyByValue(lhs, propExpr, pos().end);
11237 }
11238 return handler_.newPropertyByValue(lhs, propExpr, pos().end);
11239}
11240
11241template <class ParseHandler, typename Unit>
11242typename ParseHandler::NodeResult
11243GeneralParser<ParseHandler, Unit>::memberSuperCall(
11244 Node lhs, YieldHandling yieldHandling) {
11245 MOZ_ASSERT(anyChars.currentToken().type == TokenKind::LeftParen)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.currentToken().type == TokenKind::LeftParen
)>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.currentToken().type == TokenKind::LeftParen
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"anyChars.currentToken().type == TokenKind::LeftParen", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11245); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.currentToken().type == TokenKind::LeftParen"
")"); do { *((volatile int*)__null) = 11245; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11246 // Despite the fact that it's impossible to have |super()| in a
11247 // generator, we still inherit the yieldHandling of the
11248 // memberExpression, per spec. Curious.
11249 bool isSpread = false;
11250 ListNodeType args;
11251 MOZ_TRY_VAR(args, argumentList(yieldHandling, &isSpread))do { auto mozTryVarTempResult_ = (argumentList(yieldHandling,
&isSpread)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (args) = mozTryVarTempResult_.unwrap(); } while (0)
;
11252
11253 CallNodeType superCall;
11254 MOZ_TRY_VAR(superCall, handler_.newSuperCall(lhs, args, isSpread))do { auto mozTryVarTempResult_ = (handler_.newSuperCall(lhs, args
, isSpread)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (superCall
) = mozTryVarTempResult_.unwrap(); } while (0)
;
11255
11256 // |super()| implicitly reads |new.target|.
11257 if (!noteUsedName(TaggedParserAtomIndex::WellKnown::dot_newTarget_())) {
11258 return errorResult();
11259 }
11260
11261 NameNodeType thisName;
11262 MOZ_TRY_VAR(thisName, newThisName())do { auto mozTryVarTempResult_ = (newThisName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (thisName) = mozTryVarTempResult_.unwrap()
; } while (0)
;
11263
11264 return handler_.newSetThis(thisName, superCall);
11265}
11266
11267template <class ParseHandler, typename Unit>
11268typename ParseHandler::NodeResult GeneralParser<ParseHandler, Unit>::memberCall(
11269 TokenKind tt, Node lhs, YieldHandling yieldHandling,
11270 PossibleError* possibleError /* = nullptr */,
11271 OptionalKind optionalKind /* = OptionalKind::NonOptional */) {
11272 if (options().selfHostingMode &&
11273 (handler_.isPropertyOrPrivateMemberAccess(lhs) ||
11274 handler_.isOptionalPropertyOrPrivateMemberAccess(lhs))) {
11275 error(JSMSG_SELFHOSTED_METHOD_CALL);
11276 return errorResult();
11277 }
11278
11279 MOZ_ASSERT(tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead ||do { static_assert( mozilla::detail::AssertionConditionType<
decltype(tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead
|| tt == TokenKind::NoSubsTemplate)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(tt == TokenKind::LeftParen ||
tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate"
" (" "Unexpected token kind for member call" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11281); AnnotateMozCrashReason("MOZ_ASSERT" "(" "tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate"
") (" "Unexpected token kind for member call" ")"); do { *((
volatile int*)__null) = 11281; __attribute__((nomerge)) ::abort
(); } while (false); } } while (false)
11280 tt == TokenKind::NoSubsTemplate,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead
|| tt == TokenKind::NoSubsTemplate)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(tt == TokenKind::LeftParen ||
tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate"
" (" "Unexpected token kind for member call" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11281); AnnotateMozCrashReason("MOZ_ASSERT" "(" "tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate"
") (" "Unexpected token kind for member call" ")"); do { *((
volatile int*)__null) = 11281; __attribute__((nomerge)) ::abort
(); } while (false); } } while (false)
11281 "Unexpected token kind for member call")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead
|| tt == TokenKind::NoSubsTemplate)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(tt == TokenKind::LeftParen ||
tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate"
" (" "Unexpected token kind for member call" ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11281); AnnotateMozCrashReason("MOZ_ASSERT" "(" "tt == TokenKind::LeftParen || tt == TokenKind::TemplateHead || tt == TokenKind::NoSubsTemplate"
") (" "Unexpected token kind for member call" ")"); do { *((
volatile int*)__null) = 11281; __attribute__((nomerge)) ::abort
(); } while (false); } } while (false)
;
11282
11283 JSOp op = JSOp::Call;
11284 bool maybeAsyncArrow = false;
11285 if (tt == TokenKind::LeftParen && optionalKind == OptionalKind::NonOptional) {
11286 if (handler_.isAsyncKeyword(lhs)) {
11287 // |async (| can be the start of an async arrow
11288 // function, so we need to defer reporting possible
11289 // errors from destructuring syntax. To give better
11290 // error messages, we only allow the AsyncArrowHead
11291 // part of the CoverCallExpressionAndAsyncArrowHead
11292 // syntax when the initial name is "async".
11293 maybeAsyncArrow = true;
11294 } else if (handler_.isEvalName(lhs)) {
11295 // Select the right Eval op and flag pc_ as having a
11296 // direct eval.
11297 op = pc_->sc()->strict() ? JSOp::StrictEval : JSOp::Eval;
11298 pc_->sc()->setBindingsAccessedDynamically();
11299 pc_->sc()->setHasDirectEval();
11300
11301 // In non-strict mode code, direct calls to eval can
11302 // add variables to the call object.
11303 if (pc_->isFunctionBox() && !pc_->sc()->strict()) {
11304 pc_->functionBox()->setFunHasExtensibleScope();
11305 }
11306
11307 // If we're in a method, mark the method as requiring
11308 // support for 'super', since direct eval code can use
11309 // it. (If we're not in a method, that's fine, so
11310 // ignore the return value.)
11311 checkAndMarkSuperScope();
11312 }
11313 }
11314
11315 if (tt == TokenKind::LeftParen) {
11316 bool isSpread = false;
11317 PossibleError* asyncPossibleError =
11318 maybeAsyncArrow ? possibleError : nullptr;
11319 ListNodeType args;
11320 MOZ_TRY_VAR(args,do { auto mozTryVarTempResult_ = (argumentList(yieldHandling,
&isSpread, asyncPossibleError)); if ((__builtin_expect(!
!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (args) = mozTryVarTempResult_.unwrap(); } while
(0)
11321 argumentList(yieldHandling, &isSpread, asyncPossibleError))do { auto mozTryVarTempResult_ = (argumentList(yieldHandling,
&isSpread, asyncPossibleError)); if ((__builtin_expect(!
!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (args) = mozTryVarTempResult_.unwrap(); } while
(0)
;
11322 if (isSpread) {
11323 if (op == JSOp::Eval) {
11324 op = JSOp::SpreadEval;
11325 } else if (op == JSOp::StrictEval) {
11326 op = JSOp::StrictSpreadEval;
11327 } else {
11328 op = JSOp::SpreadCall;
11329 }
11330 }
11331
11332 if (optionalKind == OptionalKind::Optional) {
11333 return handler_.newOptionalCall(lhs, args, op);
11334 }
11335 return handler_.newCall(lhs, args, op);
11336 }
11337
11338 ListNodeType args;
11339 MOZ_TRY_VAR(args, handler_.newArguments(pos()))do { auto mozTryVarTempResult_ = (handler_.newArguments(pos()
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (args) = mozTryVarTempResult_
.unwrap(); } while (0)
;
11340
11341 if (!taggedTemplate(yieldHandling, args, tt)) {
11342 return errorResult();
11343 }
11344
11345 if (optionalKind == OptionalKind::Optional) {
11346 error(JSMSG_BAD_OPTIONAL_TEMPLATE);
11347 return errorResult();
11348 }
11349
11350 return handler_.newTaggedTemplate(lhs, args, op);
11351}
11352
11353template <class ParseHandler, typename Unit>
11354bool GeneralParser<ParseHandler, Unit>::checkLabelOrIdentifierReference(
11355 TaggedParserAtomIndex ident, uint32_t offset, YieldHandling yieldHandling,
11356 TokenKind hint /* = TokenKind::Limit */) {
11357 TokenKind tt;
11358 if (hint == TokenKind::Limit) {
11359 tt = ReservedWordTokenKind(ident);
11360 } else {
11361 // All non-reserved word kinds are folded into TokenKind::Limit in
11362 // ReservedWordTokenKind and the following code.
11363 if (hint == TokenKind::Name || hint == TokenKind::PrivateName) {
11364 hint = TokenKind::Limit;
11365 }
11366 MOZ_ASSERT(hint == ReservedWordTokenKind(ident),do { static_assert( mozilla::detail::AssertionConditionType<
decltype(hint == ReservedWordTokenKind(ident))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(hint == ReservedWordTokenKind
(ident)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("hint == ReservedWordTokenKind(ident)" " (" "hint doesn't match actual token kind"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11367); AnnotateMozCrashReason("MOZ_ASSERT" "(" "hint == ReservedWordTokenKind(ident)"
") (" "hint doesn't match actual token kind" ")"); do { *((volatile
int*)__null) = 11367; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
11367 "hint doesn't match actual token kind")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(hint == ReservedWordTokenKind(ident))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(hint == ReservedWordTokenKind
(ident)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("hint == ReservedWordTokenKind(ident)" " (" "hint doesn't match actual token kind"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11367); AnnotateMozCrashReason("MOZ_ASSERT" "(" "hint == ReservedWordTokenKind(ident)"
") (" "hint doesn't match actual token kind" ")"); do { *((volatile
int*)__null) = 11367; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
11368 tt = hint;
11369 }
11370
11371 if (!pc_->sc()->allowArguments() &&
11372 ident == TaggedParserAtomIndex::WellKnown::arguments()) {
11373 error(JSMSG_BAD_ARGUMENTS);
11374 return false;
11375 }
11376
11377 if (tt == TokenKind::Limit) {
11378 // Either TokenKind::Name or TokenKind::PrivateName
11379 return true;
11380 }
11381 if (TokenKindIsContextualKeyword(tt)) {
11382 if (tt == TokenKind::Yield) {
11383 if (yieldHandling == YieldIsKeyword) {
11384 errorAt(offset, JSMSG_RESERVED_ID, "yield");
11385 return false;
11386 }
11387 if (pc_->sc()->strict()) {
11388 if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "yield")) {
11389 return false;
11390 }
11391 }
11392 return true;
11393 }
11394 if (tt == TokenKind::Await) {
11395 if (awaitIsKeyword() || awaitIsDisallowed()) {
11396 errorAt(offset, JSMSG_RESERVED_ID, "await");
11397 return false;
11398 }
11399 return true;
11400 }
11401 if (pc_->sc()->strict()) {
11402 if (tt == TokenKind::Let) {
11403 if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "let")) {
11404 return false;
11405 }
11406 return true;
11407 }
11408 if (tt == TokenKind::Static) {
11409 if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "static")) {
11410 return false;
11411 }
11412 return true;
11413 }
11414 }
11415 return true;
11416 }
11417 if (TokenKindIsStrictReservedWord(tt)) {
11418 if (pc_->sc()->strict()) {
11419 if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID,
11420 ReservedWordToCharZ(tt))) {
11421 return false;
11422 }
11423 }
11424 return true;
11425 }
11426 if (TokenKindIsKeyword(tt) || TokenKindIsReservedWordLiteral(tt)) {
11427 errorAt(offset, JSMSG_INVALID_ID, ReservedWordToCharZ(tt));
11428 return false;
11429 }
11430 if (TokenKindIsFutureReservedWord(tt)) {
11431 errorAt(offset, JSMSG_RESERVED_ID, ReservedWordToCharZ(tt));
11432 return false;
11433 }
11434 MOZ_ASSERT_UNREACHABLE("Unexpected reserved word kind.")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(false)>::isValid, "invalid assertion condition");
if ((__builtin_expect(!!(!(!!(false))), 0))) { do { } while (
false); MOZ_ReportAssertionFailure("false" " (" "MOZ_ASSERT_UNREACHABLE: "
"Unexpected reserved word kind." ")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11434); AnnotateMozCrashReason("MOZ_ASSERT" "(" "false" ") ("
"MOZ_ASSERT_UNREACHABLE: " "Unexpected reserved word kind." ")"
); do { *((volatile int*)__null) = 11434; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
11435 return false;
11436}
11437
11438template <class ParseHandler, typename Unit>
11439bool GeneralParser<ParseHandler, Unit>::checkBindingIdentifier(
11440 TaggedParserAtomIndex ident, uint32_t offset, YieldHandling yieldHandling,
11441 TokenKind hint /* = TokenKind::Limit */) {
11442 if (pc_->sc()->strict()) {
11443 if (ident == TaggedParserAtomIndex::WellKnown::arguments()) {
11444 if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "arguments")) {
11445 return false;
11446 }
11447 return true;
11448 }
11449
11450 if (ident == TaggedParserAtomIndex::WellKnown::eval()) {
11451 if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "eval")) {
11452 return false;
11453 }
11454 return true;
11455 }
11456 }
11457
11458 return checkLabelOrIdentifierReference(ident, offset, yieldHandling, hint);
11459}
11460
11461template <class ParseHandler, typename Unit>
11462TaggedParserAtomIndex
11463GeneralParser<ParseHandler, Unit>::labelOrIdentifierReference(
11464 YieldHandling yieldHandling) {
11465 // ES 2017 draft 12.1.1.
11466 // StringValue of IdentifierName normalizes any Unicode escape sequences
11467 // in IdentifierName hence such escapes cannot be used to write an
11468 // Identifier whose code point sequence is the same as a ReservedWord.
11469 //
11470 // Use const ParserName* instead of TokenKind to reflect the normalization.
11471
11472 // Unless the name contains escapes, we can reuse the current TokenKind
11473 // to determine if the name is a restricted identifier.
11474 TokenKind hint = !anyChars.currentNameHasEscapes(this->parserAtoms())
11475 ? anyChars.currentToken().type
11476 : TokenKind::Limit;
11477 TaggedParserAtomIndex ident = anyChars.currentName();
11478 if (!checkLabelOrIdentifierReference(ident, pos().begin, yieldHandling,
11479 hint)) {
11480 return TaggedParserAtomIndex::null();
11481 }
11482 return ident;
11483}
11484
11485template <class ParseHandler, typename Unit>
11486TaggedParserAtomIndex GeneralParser<ParseHandler, Unit>::bindingIdentifier(
11487 YieldHandling yieldHandling) {
11488 TokenKind hint = !anyChars.currentNameHasEscapes(this->parserAtoms())
11489 ? anyChars.currentToken().type
11490 : TokenKind::Limit;
11491 TaggedParserAtomIndex ident = anyChars.currentName();
11492 if (!checkBindingIdentifier(ident, pos().begin, yieldHandling, hint)) {
11493 return TaggedParserAtomIndex::null();
11494 }
11495 return ident;
11496}
11497
11498template <class ParseHandler>
11499typename ParseHandler::NameNodeResult
11500PerHandlerParser<ParseHandler>::identifierReference(
11501 TaggedParserAtomIndex name) {
11502 NameNodeType id;
11503 MOZ_TRY_VAR(id, newName(name))do { auto mozTryVarTempResult_ = (newName(name)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (id) = mozTryVarTempResult_.unwrap(); } while
(0)
;
11504
11505 if (!noteUsedName(name)) {
11506 return errorResult();
11507 }
11508
11509 return id;
11510}
11511
11512template <class ParseHandler>
11513typename ParseHandler::NameNodeResult
11514PerHandlerParser<ParseHandler>::privateNameReference(
11515 TaggedParserAtomIndex name) {
11516 NameNodeType id;
11517 MOZ_TRY_VAR(id, newPrivateName(name))do { auto mozTryVarTempResult_ = (newPrivateName(name)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (id) = mozTryVarTempResult_
.unwrap(); } while (0)
;
11518
11519 if (!noteUsedName(name, NameVisibility::Private, Some(pos()))) {
11520 return errorResult();
11521 }
11522
11523 return id;
11524}
11525
11526template <class ParseHandler>
11527typename ParseHandler::NameNodeResult
11528PerHandlerParser<ParseHandler>::stringLiteral() {
11529 return handler_.newStringLiteral(anyChars.currentToken().atom(), pos());
11530}
11531
11532template <class ParseHandler>
11533typename ParseHandler::NodeResult
11534PerHandlerParser<ParseHandler>::noSubstitutionTaggedTemplate() {
11535 if (anyChars.hasInvalidTemplateEscape()) {
11536 anyChars.clearInvalidTemplateEscape();
11537 return handler_.newRawUndefinedLiteral(pos());
11538 }
11539
11540 return handler_.newTemplateStringLiteral(anyChars.currentToken().atom(),
11541 pos());
11542}
11543
11544template <class ParseHandler, typename Unit>
11545typename ParseHandler::NameNodeResult
11546GeneralParser<ParseHandler, Unit>::noSubstitutionUntaggedTemplate() {
11547 if (!tokenStream.checkForInvalidTemplateEscapeError()) {
11548 return errorResult();
11549 }
11550
11551 return handler_.newTemplateStringLiteral(anyChars.currentToken().atom(),
11552 pos());
11553}
11554
11555template <typename Unit>
11556FullParseHandler::RegExpLiteralResult
11557Parser<FullParseHandler, Unit>::newRegExp() {
11558 MOZ_ASSERT(!options().selfHostingMode)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!options().selfHostingMode)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!options().selfHostingMode))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!options().selfHostingMode"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11558); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!options().selfHostingMode"
")"); do { *((volatile int*)__null) = 11558; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11559
11560 // Create the regexp and check its syntax.
11561 const auto& chars = tokenStream.getCharBuffer();
11562 mozilla::Range<const char16_t> range(chars.begin(), chars.length());
11563 RegExpFlags flags = anyChars.currentToken().regExpFlags();
11564
11565 uint32_t offset = anyChars.currentToken().pos.begin;
11566 uint32_t line;
11567 JS::LimitedColumnNumberOneOrigin column;
11568 tokenStream.computeLineAndColumn(offset, &line, &column);
11569
11570 if (!handler_.reuseRegexpSyntaxParse()) {
11571 // Verify that the Regexp will syntax parse when the time comes to
11572 // instantiate it. If we have already done a syntax parse, we can
11573 // skip this.
11574 if (!irregexp::CheckPatternSyntax(
11575 this->alloc_, this->fc_->stackLimit(), anyChars, range, flags,
11576 Some(line), Some(JS::ColumnNumberOneOrigin(column)))) {
11577 return errorResult();
11578 }
11579 }
11580
11581 auto atom =
11582 this->parserAtoms().internChar16(fc_, chars.begin(), chars.length());
11583 if (!atom) {
11584 return errorResult();
11585 }
11586 // RegExp patterm must be atomized.
11587 this->parserAtoms().markUsedByStencil(atom, ParserAtom::Atomize::Yes);
11588
11589 RegExpIndex index(this->compilationState_.regExpData.length());
11590 if (uint32_t(index) >= TaggedScriptThingIndex::IndexLimit) {
11591 ReportAllocationOverflow(fc_);
11592 return errorResult();
11593 }
11594 if (!this->compilationState_.regExpData.emplaceBack(atom, flags)) {
11595 js::ReportOutOfMemory(this->fc_);
11596 return errorResult();
11597 }
11598
11599 return handler_.newRegExp(index, pos());
11600}
11601
11602template <typename Unit>
11603SyntaxParseHandler::RegExpLiteralResult
11604Parser<SyntaxParseHandler, Unit>::newRegExp() {
11605 MOZ_ASSERT(!options().selfHostingMode)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!options().selfHostingMode)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!options().selfHostingMode))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!options().selfHostingMode"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11605); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!options().selfHostingMode"
")"); do { *((volatile int*)__null) = 11605; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11606
11607 // Only check the regexp's syntax, but don't create a regexp object.
11608 const auto& chars = tokenStream.getCharBuffer();
11609 RegExpFlags flags = anyChars.currentToken().regExpFlags();
11610
11611 uint32_t offset = anyChars.currentToken().pos.begin;
11612 uint32_t line;
11613 JS::LimitedColumnNumberOneOrigin column;
11614 tokenStream.computeLineAndColumn(offset, &line, &column);
11615
11616 mozilla::Range<const char16_t> source(chars.begin(), chars.length());
11617 if (!irregexp::CheckPatternSyntax(this->alloc_, this->fc_->stackLimit(),
11618 anyChars, source, flags, Some(line),
11619 Some(JS::ColumnNumberOneOrigin(column)))) {
11620 return errorResult();
11621 }
11622
11623 return handler_.newRegExp(SyntaxParseHandler::Node::NodeGeneric, pos());
11624}
11625
11626template <class ParseHandler, typename Unit>
11627typename ParseHandler::RegExpLiteralResult
11628GeneralParser<ParseHandler, Unit>::newRegExp() {
11629 return asFinalParser()->newRegExp();
11630}
11631
11632template <typename Unit>
11633FullParseHandler::BigIntLiteralResult
11634Parser<FullParseHandler, Unit>::newBigInt() {
11635 // The token's charBuffer contains the DecimalIntegerLiteral or
11636 // NonDecimalIntegerLiteral production, and as such does not include the
11637 // BigIntLiteralSuffix (the trailing "n"). Note that NonDecimalIntegerLiteral
11638 // productions start with 0[bBoOxX], indicating binary/octal/hex.
11639 const auto& chars = tokenStream.getCharBuffer();
11640 if (chars.length() > UINT32_MAX(4294967295U)) {
11641 ReportAllocationOverflow(fc_);
11642 return errorResult();
11643 }
11644
11645 BigIntIndex index(this->compilationState_.bigIntData.length());
11646 if (uint32_t(index) >= TaggedScriptThingIndex::IndexLimit) {
11647 ReportAllocationOverflow(fc_);
11648 return errorResult();
11649 }
11650 if (!this->compilationState_.bigIntData.emplaceBack()) {
11651 js::ReportOutOfMemory(this->fc_);
11652 return errorResult();
11653 }
11654
11655 if (!this->compilationState_.bigIntData[index].init(
11656 this->fc_, this->stencilAlloc(), chars)) {
11657 return errorResult();
11658 }
11659
11660 bool isZero = this->compilationState_.bigIntData[index].isZero();
11661
11662 // Should the operations below fail, the buffer held by data will
11663 // be cleaned up by the CompilationState destructor.
11664 return handler_.newBigInt(index, isZero, pos());
11665}
11666
11667template <typename Unit>
11668SyntaxParseHandler::BigIntLiteralResult
11669Parser<SyntaxParseHandler, Unit>::newBigInt() {
11670 // The tokenizer has already checked the syntax of the bigint.
11671
11672 return handler_.newBigInt();
11673}
11674
11675template <class ParseHandler, typename Unit>
11676typename ParseHandler::BigIntLiteralResult
11677GeneralParser<ParseHandler, Unit>::newBigInt() {
11678 return asFinalParser()->newBigInt();
11679}
11680
11681// |exprPossibleError| is the PossibleError state within |expr|,
11682// |possibleError| is the surrounding PossibleError state.
11683template <class ParseHandler, typename Unit>
11684bool GeneralParser<ParseHandler, Unit>::checkDestructuringAssignmentTarget(
11685 Node expr, TokenPos exprPos, PossibleError* exprPossibleError,
11686 PossibleError* possibleError, TargetBehavior behavior) {
11687 // Report any pending expression error if we're definitely not in a
11688 // destructuring context or the possible destructuring target is a
11689 // property accessor.
11690 if (!possibleError || handler_.isPropertyOrPrivateMemberAccess(expr)) {
11691 return exprPossibleError->checkForExpressionError();
11692 }
11693
11694 // |expr| may end up as a destructuring assignment target, so we need to
11695 // validate it's either a name or can be parsed as a nested destructuring
11696 // pattern. Property accessors are also valid assignment targets, but
11697 // those are already handled above.
11698
11699 exprPossibleError->transferErrorsTo(possibleError);
11700
11701 // Return early if a pending destructuring error is already present.
11702 if (possibleError->hasPendingDestructuringError()) {
11703 return true;
11704 }
11705
11706 if (handler_.isName(expr)) {
11707 checkDestructuringAssignmentName(handler_.asNameNode(expr), exprPos,
11708 possibleError);
11709 return true;
11710 }
11711
11712 if (handler_.isUnparenthesizedDestructuringPattern(expr)) {
11713 if (behavior == TargetBehavior::ForbidAssignmentPattern) {
11714 possibleError->setPendingDestructuringErrorAt(exprPos,
11715 JSMSG_BAD_DESTRUCT_TARGET);
11716 }
11717 return true;
11718 }
11719
11720 // Parentheses are forbidden around destructuring *patterns* (but allowed
11721 // around names). Use our nicer error message for parenthesized, nested
11722 // patterns if nested destructuring patterns are allowed.
11723 if (handler_.isParenthesizedDestructuringPattern(expr) &&
11724 behavior != TargetBehavior::ForbidAssignmentPattern) {
11725 possibleError->setPendingDestructuringErrorAt(exprPos,
11726 JSMSG_BAD_DESTRUCT_PARENS);
11727 } else {
11728 possibleError->setPendingDestructuringErrorAt(exprPos,
11729 JSMSG_BAD_DESTRUCT_TARGET);
11730 }
11731
11732 return true;
11733}
11734
11735template <class ParseHandler, typename Unit>
11736void GeneralParser<ParseHandler, Unit>::checkDestructuringAssignmentName(
11737 NameNodeType name, TokenPos namePos, PossibleError* possibleError) {
11738#ifdef DEBUG1
11739 // GCC 8.0.1 crashes if this is a one-liner.
11740 bool isName = handler_.isName(name);
11741 MOZ_ASSERT(isName)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(isName)>::isValid, "invalid assertion condition")
; if ((__builtin_expect(!!(!(!!(isName))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("isName", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11741); AnnotateMozCrashReason("MOZ_ASSERT" "(" "isName" ")"
); do { *((volatile int*)__null) = 11741; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
11742#endif
11743
11744 // Return early if a pending destructuring error is already present.
11745 if (possibleError->hasPendingDestructuringError()) {
11746 return;
11747 }
11748
11749 if (handler_.isArgumentsLength(name)) {
11750 pc_->sc()->setIneligibleForArgumentsLength();
11751 }
11752
11753 if (pc_->sc()->strict()) {
11754 if (handler_.isArgumentsName(name)) {
11755 if (pc_->sc()->strict()) {
11756 possibleError->setPendingDestructuringErrorAt(
11757 namePos, JSMSG_BAD_STRICT_ASSIGN_ARGUMENTS);
11758 } else {
11759 possibleError->setPendingDestructuringWarningAt(
11760 namePos, JSMSG_BAD_STRICT_ASSIGN_ARGUMENTS);
11761 }
11762 return;
11763 }
11764
11765 if (handler_.isEvalName(name)) {
11766 if (pc_->sc()->strict()) {
11767 possibleError->setPendingDestructuringErrorAt(
11768 namePos, JSMSG_BAD_STRICT_ASSIGN_EVAL);
11769 } else {
11770 possibleError->setPendingDestructuringWarningAt(
11771 namePos, JSMSG_BAD_STRICT_ASSIGN_EVAL);
11772 }
11773 return;
11774 }
11775 }
11776}
11777
11778template <class ParseHandler, typename Unit>
11779bool GeneralParser<ParseHandler, Unit>::checkDestructuringAssignmentElement(
11780 Node expr, TokenPos exprPos, PossibleError* exprPossibleError,
11781 PossibleError* possibleError) {
11782 // ES2018 draft rev 0719f44aab93215ed9a626b2f45bd34f36916834
11783 // 12.15.5 Destructuring Assignment
11784 //
11785 // AssignmentElement[Yield, Await]:
11786 // DestructuringAssignmentTarget[?Yield, ?Await]
11787 // DestructuringAssignmentTarget[?Yield, ?Await] Initializer[+In,
11788 // ?Yield,
11789 // ?Await]
11790
11791 // If |expr| is an assignment element with an initializer expression, its
11792 // destructuring assignment target was already validated in assignExpr().
11793 // Otherwise we need to check that |expr| is a valid destructuring target.
11794 if (handler_.isUnparenthesizedAssignment(expr)) {
11795 // Report any pending expression error if we're definitely not in a
11796 // destructuring context.
11797 if (!possibleError) {
11798 return exprPossibleError->checkForExpressionError();
11799 }
11800
11801 exprPossibleError->transferErrorsTo(possibleError);
11802 return true;
11803 }
11804 return checkDestructuringAssignmentTarget(expr, exprPos, exprPossibleError,
11805 possibleError);
11806}
11807
11808template <class ParseHandler, typename Unit>
11809typename ParseHandler::ListNodeResult
11810GeneralParser<ParseHandler, Unit>::arrayInitializer(
11811 YieldHandling yieldHandling, PossibleError* possibleError) {
11812 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftBracket))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftBracket))
>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftBracket))
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftBracket)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 11812); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftBracket)"
")"); do { *((volatile int*)__null) = 11812; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
11813
11814 uint32_t begin = pos().begin;
11815 ListNodeType literal;
11816 MOZ_TRY_VAR(literal, handler_.newArrayLiteral(begin))do { auto mozTryVarTempResult_ = (handler_.newArrayLiteral(begin
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (literal)
= mozTryVarTempResult_.unwrap(); } while (0)
;
11817
11818 TokenKind tt;
11819 if (!tokenStream.getToken(&tt, TokenStream::SlashIsRegExp)) {
11820 return errorResult();
11821 }
11822
11823 if (tt == TokenKind::RightBracket) {
11824 /*
11825 * Mark empty arrays as non-constant, since we cannot easily
11826 * determine their type.
11827 */
11828 handler_.setListHasNonConstInitializer(literal);
11829 } else {
11830 anyChars.ungetToken();
11831
11832 for (uint32_t index = 0;; index++) {
11833 if (index >= NativeObject::MAX_DENSE_ELEMENTS_COUNT) {
11834 error(JSMSG_ARRAY_INIT_TOO_BIG);
11835 return errorResult();
11836 }
11837
11838 TokenKind tt;
11839 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
11840 return errorResult();
11841 }
11842 if (tt == TokenKind::RightBracket) {
11843 break;
11844 }
11845
11846 if (tt == TokenKind::Comma) {
11847 tokenStream.consumeKnownToken(TokenKind::Comma,
11848 TokenStream::SlashIsRegExp);
11849 if (!handler_.addElision(literal, pos())) {
11850 return errorResult();
11851 }
11852 continue;
11853 }
11854
11855 if (tt == TokenKind::TripleDot) {
11856 tokenStream.consumeKnownToken(TokenKind::TripleDot,
11857 TokenStream::SlashIsRegExp);
11858 uint32_t begin = pos().begin;
11859
11860 TokenPos innerPos;
11861 if (!tokenStream.peekTokenPos(&innerPos, TokenStream::SlashIsRegExp)) {
11862 return errorResult();
11863 }
11864
11865 PossibleError possibleErrorInner(*this);
11866 Node inner;
11867 MOZ_TRY_VAR(inner,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (inner) = mozTryVarTempResult_.unwrap(); }
while (0)
11868 assignExpr(InAllowed, yieldHandling, TripledotProhibited,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (inner) = mozTryVarTempResult_.unwrap(); }
while (0)
11869 &possibleErrorInner))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (inner) = mozTryVarTempResult_.unwrap(); }
while (0)
;
11870 if (!checkDestructuringAssignmentTarget(
11871 inner, innerPos, &possibleErrorInner, possibleError)) {
11872 return errorResult();
11873 }
11874
11875 if (!handler_.addSpreadElement(literal, begin, inner)) {
11876 return errorResult();
11877 }
11878 } else {
11879 TokenPos elementPos;
11880 if (!tokenStream.peekTokenPos(&elementPos,
11881 TokenStream::SlashIsRegExp)) {
11882 return errorResult();
11883 }
11884
11885 PossibleError possibleErrorInner(*this);
11886 Node element;
11887 MOZ_TRY_VAR(element,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (element) = mozTryVarTempResult_.unwrap();
} while (0)
11888 assignExpr(InAllowed, yieldHandling, TripledotProhibited,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (element) = mozTryVarTempResult_.unwrap();
} while (0)
11889 &possibleErrorInner))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (element) = mozTryVarTempResult_.unwrap();
} while (0)
;
11890 if (!checkDestructuringAssignmentElement(
11891 element, elementPos, &possibleErrorInner, possibleError)) {
11892 return errorResult();
11893 }
11894 handler_.addArrayElement(literal, element);
11895 }
11896
11897 bool matched;
11898 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
11899 TokenStream::SlashIsRegExp)) {
11900 return errorResult();
11901 }
11902 if (!matched) {
11903 break;
11904 }
11905
11906 if (tt == TokenKind::TripleDot && possibleError) {
11907 possibleError->setPendingDestructuringErrorAt(pos(),
11908 JSMSG_REST_WITH_COMMA);
11909 }
11910 }
11911
11912 if (!mustMatchToken(
11913 TokenKind::RightBracket, [this, begin](TokenKind actual) {
11914 this->reportMissingClosing(JSMSG_BRACKET_AFTER_LIST,
11915 JSMSG_BRACKET_OPENED, begin);
11916 })) {
11917 return errorResult();
11918 }
11919 }
11920
11921 handler_.setEndPosition(literal, pos().end);
11922 return literal;
11923}
11924
11925template <class ParseHandler, typename Unit>
11926typename ParseHandler::NodeResult
11927GeneralParser<ParseHandler, Unit>::propertyName(
11928 YieldHandling yieldHandling, PropertyNameContext propertyNameContext,
11929 const Maybe<DeclarationKind>& maybeDecl, ListNodeType propList,
11930 TaggedParserAtomIndex* propAtomOut) {
11931 // PropertyName[Yield, Await]:
11932 // LiteralPropertyName
11933 // ComputedPropertyName[?Yield, ?Await]
11934 //
11935 // LiteralPropertyName:
11936 // IdentifierName
11937 // StringLiteral
11938 // NumericLiteral
11939 TokenKind ltok = anyChars.currentToken().type;
11940
11941 *propAtomOut = TaggedParserAtomIndex::null();
11942 switch (ltok) {
11943 case TokenKind::Number: {
11944 auto numAtom = NumberToParserAtom(fc_, this->parserAtoms(),
11945 anyChars.currentToken().number());
11946 if (!numAtom) {
11947 return errorResult();
11948 }
11949 *propAtomOut = numAtom;
11950 return newNumber(anyChars.currentToken());
11951 }
11952
11953 case TokenKind::BigInt: {
11954 Node biNode;
11955 MOZ_TRY_VAR(biNode, newBigInt())do { auto mozTryVarTempResult_ = (newBigInt()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (biNode) = mozTryVarTempResult_.unwrap(); }
while (0)
;
11956 return handler_.newSyntheticComputedName(biNode, pos().begin, pos().end);
11957 }
11958 case TokenKind::String: {
11959 auto str = anyChars.currentToken().atom();
11960 *propAtomOut = str;
11961 uint32_t index;
11962 if (this->parserAtoms().isIndex(str, &index)) {
11963 return handler_.newNumber(index, NoDecimal, pos());
11964 }
11965 return stringLiteral();
11966 }
11967
11968 case TokenKind::LeftBracket:
11969 return computedPropertyName(yieldHandling, maybeDecl, propertyNameContext,
11970 propList);
11971
11972 case TokenKind::PrivateName: {
11973 if (propertyNameContext != PropertyNameContext::PropertyNameInClass) {
11974 error(JSMSG_ILLEGAL_PRIVATE_FIELD);
11975 return errorResult();
11976 }
11977
11978 TaggedParserAtomIndex propName = anyChars.currentName();
11979 *propAtomOut = propName;
11980 return privateNameReference(propName);
11981 }
11982
11983 default: {
11984 if (!TokenKindIsPossibleIdentifierName(ltok)) {
11985 error(JSMSG_UNEXPECTED_TOKEN, "property name", TokenKindToDesc(ltok));
11986 return errorResult();
11987 }
11988
11989 TaggedParserAtomIndex name = anyChars.currentName();
11990 *propAtomOut = name;
11991 return handler_.newObjectLiteralPropertyName(name, pos());
11992 }
11993 }
11994}
11995
11996// True if `kind` can be the first token of a PropertyName.
11997static bool TokenKindCanStartPropertyName(TokenKind tt) {
11998 return TokenKindIsPossibleIdentifierName(tt) || tt == TokenKind::String ||
11999 tt == TokenKind::Number || tt == TokenKind::LeftBracket ||
12000 tt == TokenKind::Mul || tt == TokenKind::BigInt ||
12001 tt == TokenKind::PrivateName;
12002}
12003
12004template <class ParseHandler, typename Unit>
12005typename ParseHandler::NodeResult
12006GeneralParser<ParseHandler, Unit>::propertyOrMethodName(
12007 YieldHandling yieldHandling, PropertyNameContext propertyNameContext,
12008 const Maybe<DeclarationKind>& maybeDecl, ListNodeType propList,
12009 PropertyType* propType, TaggedParserAtomIndex* propAtomOut) {
12010 // We're parsing an object literal, class, or destructuring pattern;
12011 // propertyNameContext tells which one. This method parses any of the
12012 // following, storing the corresponding PropertyType in `*propType` to tell
12013 // the caller what we parsed:
12014 //
12015 // async [no LineTerminator here] PropertyName
12016 // ==> PropertyType::AsyncMethod
12017 // async [no LineTerminator here] * PropertyName
12018 // ==> PropertyType::AsyncGeneratorMethod
12019 // * PropertyName ==> PropertyType::GeneratorMethod
12020 // get PropertyName ==> PropertyType::Getter
12021 // set PropertyName ==> PropertyType::Setter
12022 // accessor PropertyName ==> PropertyType::FieldWithAccessor
12023 // PropertyName : ==> PropertyType::Normal
12024 // PropertyName ==> see below
12025 //
12026 // In the last case, where there's not a `:` token to consume, we peek at
12027 // (but don't consume) the next token to decide how to set `*propType`.
12028 //
12029 // `,` or `}` ==> PropertyType::Shorthand
12030 // `(` ==> PropertyType::Method
12031 // `=`, not in a class ==> PropertyType::CoverInitializedName
12032 // '=', in a class ==> PropertyType::Field
12033 // any token, in a class ==> PropertyType::Field (ASI)
12034 //
12035 // The caller must check `*propType` and throw if whatever we parsed isn't
12036 // allowed here (for example, a getter in a destructuring pattern).
12037 //
12038 // This method does *not* match `static` (allowed in classes) or `...`
12039 // (allowed in object literals and patterns). The caller must take care of
12040 // those before calling this method.
12041
12042 TokenKind ltok;
12043 if (!tokenStream.getToken(&ltok, TokenStream::SlashIsInvalid)) {
12044 return errorResult();
12045 }
12046
12047 MOZ_ASSERT(ltok != TokenKind::RightCurly,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(ltok != TokenKind::RightCurly)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(ltok != TokenKind::RightCurly
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"ltok != TokenKind::RightCurly" " (" "caller should have handled TokenKind::RightCurly"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12048); AnnotateMozCrashReason("MOZ_ASSERT" "(" "ltok != TokenKind::RightCurly"
") (" "caller should have handled TokenKind::RightCurly" ")"
); do { *((volatile int*)__null) = 12048; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
12048 "caller should have handled TokenKind::RightCurly")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(ltok != TokenKind::RightCurly)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(ltok != TokenKind::RightCurly
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"ltok != TokenKind::RightCurly" " (" "caller should have handled TokenKind::RightCurly"
")", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12048); AnnotateMozCrashReason("MOZ_ASSERT" "(" "ltok != TokenKind::RightCurly"
") (" "caller should have handled TokenKind::RightCurly" ")"
); do { *((volatile int*)__null) = 12048; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
12049
12050 // Accept `async` and/or `*`, indicating an async or generator method;
12051 // or `get` or `set` or `accessor`, indicating an accessor.
12052 bool isGenerator = false;
12053 bool isAsync = false;
12054 bool isGetter = false;
12055 bool isSetter = false;
12056#ifdef ENABLE_DECORATORS
12057 bool hasAccessor = false;
12058#endif
12059
12060 if (ltok == TokenKind::Async) {
12061 // `async` is also a PropertyName by itself (it's a conditional keyword),
12062 // so peek at the next token to see if we're really looking at a method.
12063 TokenKind tt = TokenKind::Eof;
12064 if (!tokenStream.peekTokenSameLine(&tt)) {
12065 return errorResult();
12066 }
12067 if (TokenKindCanStartPropertyName(tt)) {
12068 isAsync = true;
12069 tokenStream.consumeKnownToken(tt);
12070 ltok = tt;
12071 }
12072 }
12073
12074 if (ltok == TokenKind::Mul) {
12075 isGenerator = true;
12076 if (!tokenStream.getToken(&ltok)) {
12077 return errorResult();
12078 }
12079 }
12080
12081 if (!isAsync && !isGenerator &&
12082 (ltok == TokenKind::Get || ltok == TokenKind::Set)) {
12083 // We have parsed |get| or |set|. Look for an accessor property
12084 // name next.
12085 TokenKind tt;
12086 if (!tokenStream.peekToken(&tt)) {
12087 return errorResult();
12088 }
12089 if (TokenKindCanStartPropertyName(tt)) {
12090 tokenStream.consumeKnownToken(tt);
12091 isGetter = (ltok == TokenKind::Get);
12092 isSetter = (ltok == TokenKind::Set);
12093 }
12094 }
12095
12096#ifdef ENABLE_DECORATORS
12097 if (!isGenerator && !isAsync && propertyNameContext == PropertyNameInClass &&
12098 ltok == TokenKind::Accessor) {
12099 MOZ_ASSERT(!isGetter && !isSetter)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!isGetter && !isSetter)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!isGetter && !isSetter
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"!isGetter && !isSetter", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12099); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!isGetter && !isSetter"
")"); do { *((volatile int*)__null) = 12099; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12100 TokenKind tt;
12101 if (!tokenStream.peekTokenSameLine(&tt)) {
12102 return errorResult();
12103 }
12104
12105 // The target rule is `accessor [no LineTerminator here]
12106 // ClassElementName[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt`
12107 if (TokenKindCanStartPropertyName(tt)) {
12108 tokenStream.consumeKnownToken(tt);
12109 hasAccessor = true;
12110 }
12111 }
12112#endif
12113
12114 Node propName;
12115 MOZ_TRY_VAR(propName, propertyName(yieldHandling, propertyNameContext,do { auto mozTryVarTempResult_ = (propertyName(yieldHandling,
propertyNameContext, maybeDecl, propList, propAtomOut)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (propName) = mozTryVarTempResult_
.unwrap(); } while (0)
12116 maybeDecl, propList, propAtomOut))do { auto mozTryVarTempResult_ = (propertyName(yieldHandling,
propertyNameContext, maybeDecl, propList, propAtomOut)); if (
(__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0))) { return
mozTryVarTempResult_.propagateErr(); } (propName) = mozTryVarTempResult_
.unwrap(); } while (0)
;
12117
12118 // Grab the next token following the property/method name.
12119 // (If this isn't a colon, we're going to either put it back or throw.)
12120 TokenKind tt;
12121 if (!tokenStream.getToken(&tt)) {
12122 return errorResult();
12123 }
12124
12125 if (tt == TokenKind::Colon) {
12126 if (isGenerator || isAsync || isGetter || isSetter
12127#ifdef ENABLE_DECORATORS
12128 || hasAccessor
12129#endif
12130 ) {
12131 error(JSMSG_BAD_PROP_ID);
12132 return errorResult();
12133 }
12134 *propType = PropertyType::Normal;
12135 return propName;
12136 }
12137
12138 if (propertyNameContext != PropertyNameInClass &&
12139 TokenKindIsPossibleIdentifierName(ltok) &&
12140 (tt == TokenKind::Comma || tt == TokenKind::RightCurly ||
12141 tt == TokenKind::Assign)) {
12142#ifdef ENABLE_DECORATORS
12143 MOZ_ASSERT(!hasAccessor)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(!hasAccessor)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(!hasAccessor))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("!hasAccessor", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12143); AnnotateMozCrashReason("MOZ_ASSERT" "(" "!hasAccessor"
")"); do { *((volatile int*)__null) = 12143; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12144#endif
12145 if (isGenerator || isAsync || isGetter || isSetter) {
12146 error(JSMSG_BAD_PROP_ID);
12147 return errorResult();
12148 }
12149
12150 anyChars.ungetToken();
12151 *propType = tt == TokenKind::Assign ? PropertyType::CoverInitializedName
12152 : PropertyType::Shorthand;
12153 return propName;
12154 }
12155
12156 if (tt == TokenKind::LeftParen) {
12157 anyChars.ungetToken();
12158
12159#ifdef ENABLE_RECORD_TUPLE
12160 if (propertyNameContext == PropertyNameInRecord) {
12161 // Record & Tuple proposal, section 7.1.1:
12162 // RecordPropertyDefinition doesn't cover methods
12163 error(JSMSG_BAD_PROP_ID);
12164 return errorResult();
12165 }
12166#endif
12167
12168#ifdef ENABLE_DECORATORS
12169 if (hasAccessor) {
12170 error(JSMSG_BAD_PROP_ID);
12171 return errorResult();
12172 }
12173#endif
12174
12175 if (isGenerator && isAsync) {
12176 *propType = PropertyType::AsyncGeneratorMethod;
12177 } else if (isGenerator) {
12178 *propType = PropertyType::GeneratorMethod;
12179 } else if (isAsync) {
12180 *propType = PropertyType::AsyncMethod;
12181 } else if (isGetter) {
12182 *propType = PropertyType::Getter;
12183 } else if (isSetter) {
12184 *propType = PropertyType::Setter;
12185 } else {
12186 *propType = PropertyType::Method;
12187 }
12188 return propName;
12189 }
12190
12191 if (propertyNameContext == PropertyNameInClass) {
12192 if (isGenerator || isAsync || isGetter || isSetter) {
12193 error(JSMSG_BAD_PROP_ID);
12194 return errorResult();
12195 }
12196 anyChars.ungetToken();
12197#ifdef ENABLE_DECORATORS
12198 if (!hasAccessor) {
12199 *propType = PropertyType::Field;
12200 } else {
12201 *propType = PropertyType::FieldWithAccessor;
12202 }
12203#else
12204 *propType = PropertyType::Field;
12205#endif
12206 return propName;
12207 }
12208
12209 error(JSMSG_COLON_AFTER_ID);
12210 return errorResult();
12211}
12212
12213template <class ParseHandler, typename Unit>
12214typename ParseHandler::UnaryNodeResult
12215GeneralParser<ParseHandler, Unit>::computedPropertyName(
12216 YieldHandling yieldHandling, const Maybe<DeclarationKind>& maybeDecl,
12217 PropertyNameContext propertyNameContext, ListNodeType literal) {
12218 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftBracket))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftBracket))
>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftBracket))
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftBracket)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12218); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftBracket)"
")"); do { *((volatile int*)__null) = 12218; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12219
12220 uint32_t begin = pos().begin;
12221
12222 if (maybeDecl) {
12223 if (*maybeDecl == DeclarationKind::FormalParameter) {
12224 pc_->functionBox()->hasParameterExprs = true;
12225 }
12226 } else if (propertyNameContext ==
12227 PropertyNameContext::PropertyNameInLiteral) {
12228 handler_.setListHasNonConstInitializer(literal);
12229 }
12230
12231 Node assignNode;
12232 MOZ_TRY_VAR(assignNode,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (assignNode) = mozTryVarTempResult_.unwrap(); } while (0)
12233 assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (assignNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
12234
12235 if (!mustMatchToken(TokenKind::RightBracket, JSMSG_COMP_PROP_UNTERM_EXPR)) {
12236 return errorResult();
12237 }
12238 return handler_.newComputedName(assignNode, begin, pos().end);
12239}
12240
12241template <class ParseHandler, typename Unit>
12242typename ParseHandler::ListNodeResult
12243GeneralParser<ParseHandler, Unit>::objectLiteral(YieldHandling yieldHandling,
12244 PossibleError* possibleError) {
12245 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftCurly))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftCurly))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftCurly))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12245); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftCurly)"
")"); do { *((volatile int*)__null) = 12245; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12246
12247 uint32_t openedPos = pos().begin;
12248
12249 ListNodeType literal;
12250 MOZ_TRY_VAR(literal, handler_.newObjectLiteral(pos().begin))do { auto mozTryVarTempResult_ = (handler_.newObjectLiteral(pos
().begin)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (literal
) = mozTryVarTempResult_.unwrap(); } while (0)
;
12251
12252 bool seenPrototypeMutation = false;
12253 bool seenCoverInitializedName = false;
12254 Maybe<DeclarationKind> declKind = Nothing();
12255 TaggedParserAtomIndex propAtom;
12256 for (;;) {
12257 TokenKind tt;
12258 if (!tokenStream.peekToken(&tt)) {
12259 return errorResult();
12260 }
12261 if (tt == TokenKind::RightCurly) {
12262 break;
12263 }
12264
12265 if (tt == TokenKind::TripleDot) {
12266 tokenStream.consumeKnownToken(TokenKind::TripleDot);
12267 uint32_t begin = pos().begin;
12268
12269 TokenPos innerPos;
12270 if (!tokenStream.peekTokenPos(&innerPos, TokenStream::SlashIsRegExp)) {
12271 return errorResult();
12272 }
12273
12274 PossibleError possibleErrorInner(*this);
12275 Node inner;
12276 MOZ_TRY_VAR(inner, assignExpr(InAllowed, yieldHandling,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (inner) = mozTryVarTempResult_.unwrap(); }
while (0)
12277 TripledotProhibited, &possibleErrorInner))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (inner) = mozTryVarTempResult_.unwrap(); }
while (0)
;
12278 if (!checkDestructuringAssignmentTarget(
12279 inner, innerPos, &possibleErrorInner, possibleError,
12280 TargetBehavior::ForbidAssignmentPattern)) {
12281 return errorResult();
12282 }
12283 if (!handler_.addSpreadProperty(literal, begin, inner)) {
12284 return errorResult();
12285 }
12286 } else {
12287 TokenPos namePos = anyChars.nextToken().pos;
12288
12289 PropertyType propType;
12290 Node propName;
12291 MOZ_TRY_VAR(propName, propertyOrMethodName(do { auto mozTryVarTempResult_ = (propertyOrMethodName( yieldHandling
, PropertyNameInLiteral, declKind, literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
12292 yieldHandling, PropertyNameInLiteral, declKind,do { auto mozTryVarTempResult_ = (propertyOrMethodName( yieldHandling
, PropertyNameInLiteral, declKind, literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
12293 literal, &propType, &propAtom))do { auto mozTryVarTempResult_ = (propertyOrMethodName( yieldHandling
, PropertyNameInLiteral, declKind, literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
12294
12295 if (propType == PropertyType::Normal) {
12296 TokenPos exprPos;
12297 if (!tokenStream.peekTokenPos(&exprPos, TokenStream::SlashIsRegExp)) {
12298 return errorResult();
12299 }
12300
12301 PossibleError possibleErrorInner(*this);
12302 Node propExpr;
12303 MOZ_TRY_VAR(propExpr,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (propExpr) = mozTryVarTempResult_.unwrap()
; } while (0)
12304 assignExpr(InAllowed, yieldHandling, TripledotProhibited,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (propExpr) = mozTryVarTempResult_.unwrap()
; } while (0)
12305 &possibleErrorInner))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited, &possibleErrorInner)); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (propExpr) = mozTryVarTempResult_.unwrap()
; } while (0)
;
12306
12307 if (!checkDestructuringAssignmentElement(
12308 propExpr, exprPos, &possibleErrorInner, possibleError)) {
12309 return errorResult();
12310 }
12311
12312 if (propAtom == TaggedParserAtomIndex::WellKnown::proto_()) {
12313 if (seenPrototypeMutation) {
12314 // Directly report the error when we're definitely not
12315 // in a destructuring context.
12316 if (!possibleError) {
12317 errorAt(namePos.begin, JSMSG_DUPLICATE_PROTO_PROPERTY);
12318 return errorResult();
12319 }
12320
12321 // Otherwise delay error reporting until we've
12322 // determined whether or not we're destructuring.
12323 possibleError->setPendingExpressionErrorAt(
12324 namePos, JSMSG_DUPLICATE_PROTO_PROPERTY);
12325 }
12326 seenPrototypeMutation = true;
12327
12328 // This occurs *only* if we observe PropertyType::Normal!
12329 // Only |__proto__: v| mutates [[Prototype]]. Getters,
12330 // setters, method/generator definitions, computed
12331 // property name versions of all of these, and shorthands
12332 // do not.
12333 if (!handler_.addPrototypeMutation(literal, namePos.begin,
12334 propExpr)) {
12335 return errorResult();
12336 }
12337 } else {
12338 BinaryNodeType propDef;
12339 MOZ_TRY_VAR(propDef,do { auto mozTryVarTempResult_ = (handler_.newPropertyDefinition
(propName, propExpr)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propDef) = mozTryVarTempResult_.unwrap(); } while (0)
12340 handler_.newPropertyDefinition(propName, propExpr))do { auto mozTryVarTempResult_ = (handler_.newPropertyDefinition
(propName, propExpr)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propDef) = mozTryVarTempResult_.unwrap(); } while (0)
;
12341
12342 handler_.addPropertyDefinition(literal, propDef);
12343 }
12344 } else if (propType == PropertyType::Shorthand) {
12345 /*
12346 * Support, e.g., |({x, y} = o)| as destructuring shorthand
12347 * for |({x: x, y: y} = o)|, and |var o = {x, y}| as
12348 * initializer shorthand for |var o = {x: x, y: y}|.
12349 */
12350 TaggedParserAtomIndex name = identifierReference(yieldHandling);
12351 if (!name) {
12352 return errorResult();
12353 }
12354
12355 NameNodeType nameExpr;
12356 MOZ_TRY_VAR(nameExpr, identifierReference(name))do { auto mozTryVarTempResult_ = (identifierReference(name));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (nameExpr) =
mozTryVarTempResult_.unwrap(); } while (0)
;
12357
12358 if (possibleError) {
12359 checkDestructuringAssignmentName(nameExpr, namePos, possibleError);
12360 }
12361
12362 if (!handler_.addShorthand(literal, handler_.asNameNode(propName),
12363 nameExpr)) {
12364 return errorResult();
12365 }
12366 } else if (propType == PropertyType::CoverInitializedName) {
12367 /*
12368 * Support, e.g., |({x=1, y=2} = o)| as destructuring
12369 * shorthand with default values, as per ES6 12.14.5
12370 */
12371 TaggedParserAtomIndex name = identifierReference(yieldHandling);
12372 if (!name) {
12373 return errorResult();
12374 }
12375
12376 Node lhs;
12377 MOZ_TRY_VAR(lhs, identifierReference(name))do { auto mozTryVarTempResult_ = (identifierReference(name));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (lhs) = mozTryVarTempResult_
.unwrap(); } while (0)
;
12378
12379 tokenStream.consumeKnownToken(TokenKind::Assign);
12380
12381 if (!seenCoverInitializedName) {
12382 // "shorthand default" or "CoverInitializedName" syntax is
12383 // only valid in the case of destructuring.
12384 seenCoverInitializedName = true;
12385
12386 if (!possibleError) {
12387 // Destructuring defaults are definitely not allowed
12388 // in this object literal, because of something the
12389 // caller knows about the preceding code. For example,
12390 // maybe the preceding token is an operator:
12391 // |x + {y=z}|.
12392 error(JSMSG_COLON_AFTER_ID);
12393 return errorResult();
12394 }
12395
12396 // Here we set a pending error so that later in the parse,
12397 // once we've determined whether or not we're
12398 // destructuring, the error can be reported or ignored
12399 // appropriately.
12400 possibleError->setPendingExpressionErrorAt(pos(),
12401 JSMSG_COLON_AFTER_ID);
12402 }
12403
12404 if (const char* chars = nameIsArgumentsOrEval(lhs)) {
12405 // |chars| is "arguments" or "eval" here.
12406 if (!strictModeErrorAt(namePos.begin, JSMSG_BAD_STRICT_ASSIGN,
12407 chars)) {
12408 return errorResult();
12409 }
12410 }
12411
12412 if (handler_.isArgumentsLength(lhs)) {
12413 pc_->sc()->setIneligibleForArgumentsLength();
12414 }
12415
12416 Node rhs;
12417 MOZ_TRY_VAR(rhs,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (rhs) = mozTryVarTempResult_.unwrap(); } while (0)
12418 assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (rhs) = mozTryVarTempResult_.unwrap(); } while (0)
;
12419
12420 BinaryNodeType propExpr;
12421 MOZ_TRY_VAR(propExpr, handler_.newAssignment(ParseNodeKind::AssignExpr,do { auto mozTryVarTempResult_ = (handler_.newAssignment(ParseNodeKind
::AssignExpr, lhs, rhs)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propExpr) = mozTryVarTempResult_.unwrap(); } while (0)
12422 lhs, rhs))do { auto mozTryVarTempResult_ = (handler_.newAssignment(ParseNodeKind
::AssignExpr, lhs, rhs)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
12423
12424 if (!handler_.addPropertyDefinition(literal, propName, propExpr)) {
12425 return errorResult();
12426 }
12427 } else {
12428 TaggedParserAtomIndex funName;
12429 bool hasStaticName =
12430 !anyChars.isCurrentTokenType(TokenKind::RightBracket) && propAtom;
12431 if (hasStaticName) {
12432 funName = propAtom;
12433
12434 if (propType == PropertyType::Getter ||
12435 propType == PropertyType::Setter) {
12436 funName = prefixAccessorName(propType, propAtom);
12437 if (!funName) {
12438 return errorResult();
12439 }
12440 }
12441 }
12442
12443 FunctionNodeType funNode;
12444 MOZ_TRY_VAR(funNode,do { auto mozTryVarTempResult_ = (methodDefinition(namePos.begin
, propType, funName)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (funNode) = mozTryVarTempResult_.unwrap(); } while (0)
12445 methodDefinition(namePos.begin, propType, funName))do { auto mozTryVarTempResult_ = (methodDefinition(namePos.begin
, propType, funName)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (funNode) = mozTryVarTempResult_.unwrap(); } while (0)
;
12446
12447 AccessorType atype = ToAccessorType(propType);
12448 if (!handler_.addObjectMethodDefinition(literal, propName, funNode,
12449 atype)) {
12450 return errorResult();
12451 }
12452
12453 if (possibleError) {
12454 possibleError->setPendingDestructuringErrorAt(
12455 namePos, JSMSG_BAD_DESTRUCT_TARGET);
12456 }
12457 }
12458 }
12459
12460 bool matched;
12461 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
12462 TokenStream::SlashIsInvalid)) {
12463 return errorResult();
12464 }
12465 if (!matched) {
12466 break;
12467 }
12468 if (tt == TokenKind::TripleDot && possibleError) {
12469 possibleError->setPendingDestructuringErrorAt(pos(),
12470 JSMSG_REST_WITH_COMMA);
12471 }
12472 }
12473
12474 if (!mustMatchToken(
12475 TokenKind::RightCurly, [this, openedPos](TokenKind actual) {
12476 this->reportMissingClosing(JSMSG_CURLY_AFTER_LIST,
12477 JSMSG_CURLY_OPENED, openedPos);
12478 })) {
12479 return errorResult();
12480 }
12481
12482 handler_.setEndPosition(literal, pos().end);
12483 return literal;
12484}
12485
12486#ifdef ENABLE_RECORD_TUPLE
12487template <class ParseHandler, typename Unit>
12488typename ParseHandler::ListNodeResult
12489GeneralParser<ParseHandler, Unit>::recordLiteral(YieldHandling yieldHandling) {
12490 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::HashCurly))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::HashCurly))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::HashCurly))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::HashCurly)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12490); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::HashCurly)"
")"); do { *((volatile int*)__null) = 12490; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12491
12492 uint32_t openedPos = pos().begin;
12493
12494 ListNodeType literal;
12495 MOZ_TRY_VAR(literal, handler_.newRecordLiteral(pos().begin))do { auto mozTryVarTempResult_ = (handler_.newRecordLiteral(pos
().begin)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (literal
) = mozTryVarTempResult_.unwrap(); } while (0)
;
12496
12497 TaggedParserAtomIndex propAtom;
12498 for (;;) {
12499 TokenKind tt;
12500 if (!tokenStream.peekToken(&tt)) {
12501 return errorResult();
12502 }
12503 if (tt == TokenKind::RightCurly) {
12504 break;
12505 }
12506
12507 if (tt == TokenKind::TripleDot) {
12508 tokenStream.consumeKnownToken(TokenKind::TripleDot);
12509 uint32_t begin = pos().begin;
12510
12511 TokenPos innerPos;
12512 if (!tokenStream.peekTokenPos(&innerPos, TokenStream::SlashIsRegExp)) {
12513 return errorResult();
12514 }
12515
12516 Node inner;
12517 MOZ_TRY_VAR(inner,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (inner) = mozTryVarTempResult_.unwrap(); } while (0)
12518 assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (inner) = mozTryVarTempResult_.unwrap(); } while (0)
;
12519
12520 if (!handler_.addSpreadProperty(literal, begin, inner)) {
12521 return errorResult();
12522 }
12523 } else {
12524 TokenPos namePos = anyChars.nextToken().pos;
12525
12526 PropertyType propType;
12527 Node propName;
12528 MOZ_TRY_VAR(propName,do { auto mozTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInRecord, Nothing(), literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
12529 propertyOrMethodName(yieldHandling, PropertyNameInRecord,do { auto mozTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInRecord, Nothing(), literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
12530 /* maybeDecl */ Nothing(), literal,do { auto mozTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInRecord, Nothing(), literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
12531 &propType, &propAtom))do { auto mozTryVarTempResult_ = (propertyOrMethodName(yieldHandling
, PropertyNameInRecord, Nothing(), literal, &propType, &
propAtom)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (propName
) = mozTryVarTempResult_.unwrap(); } while (0)
;
12532
12533 if (propType == PropertyType::Normal) {
12534 TokenPos exprPos;
12535 if (!tokenStream.peekTokenPos(&exprPos, TokenStream::SlashIsRegExp)) {
12536 return errorResult();
12537 }
12538
12539 Node propExpr;
12540 MOZ_TRY_VAR(propExpr,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propExpr) = mozTryVarTempResult_.unwrap(); } while (0)
12541 assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propExpr) = mozTryVarTempResult_.unwrap(); } while (0)
;
12542
12543 if (propAtom == TaggedParserAtomIndex::WellKnown::proto_()) {
12544 errorAt(namePos.begin, JSMSG_RECORD_NO_PROTO);
12545 return errorResult();
12546 }
12547
12548 BinaryNodeType propDef;
12549 MOZ_TRY_VAR(propDef,do { auto mozTryVarTempResult_ = (handler_.newPropertyDefinition
(propName, propExpr)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propDef) = mozTryVarTempResult_.unwrap(); } while (0)
12550 handler_.newPropertyDefinition(propName, propExpr))do { auto mozTryVarTempResult_ = (handler_.newPropertyDefinition
(propName, propExpr)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (propDef) = mozTryVarTempResult_.unwrap(); } while (0)
;
12551
12552 handler_.addPropertyDefinition(literal, propDef);
12553 } else if (propType == PropertyType::Shorthand) {
12554 /*
12555 * Support |var o = #{x, y}| as initializer shorthand for
12556 * |var o = #{x: x, y: y}|.
12557 */
12558 TaggedParserAtomIndex name = identifierReference(yieldHandling);
12559 if (!name) {
12560 return errorResult();
12561 }
12562
12563 NameNodeType nameExpr;
12564 MOZ_TRY_VAR(nameExpr, identifierReference(name))do { auto mozTryVarTempResult_ = (identifierReference(name));
if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0)))
{ return mozTryVarTempResult_.propagateErr(); } (nameExpr) =
mozTryVarTempResult_.unwrap(); } while (0)
;
12565
12566 if (!handler_.addShorthand(literal, handler_.asNameNode(propName),
12567 nameExpr)) {
12568 return errorResult();
12569 }
12570 } else {
12571 error(JSMSG_BAD_PROP_ID);
12572 return errorResult();
12573 }
12574 }
12575
12576 bool matched;
12577 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
12578 TokenStream::SlashIsInvalid)) {
12579 return errorResult();
12580 }
12581 if (!matched) {
12582 break;
12583 }
12584 }
12585
12586 if (!mustMatchToken(
12587 TokenKind::RightCurly, [this, openedPos](TokenKind actual) {
12588 this->reportMissingClosing(JSMSG_CURLY_AFTER_LIST,
12589 JSMSG_CURLY_OPENED, openedPos);
12590 })) {
12591 return errorResult();
12592 }
12593
12594 handler_.setEndPosition(literal, pos().end);
12595 return literal;
12596}
12597
12598template <class ParseHandler, typename Unit>
12599typename ParseHandler::ListNodeResult
12600GeneralParser<ParseHandler, Unit>::tupleLiteral(YieldHandling yieldHandling) {
12601 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::HashBracket))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::HashBracket))
>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::HashBracket))
)), 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::HashBracket)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12601); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::HashBracket)"
")"); do { *((volatile int*)__null) = 12601; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12602
12603 uint32_t begin = pos().begin;
12604 ListNodeType literal;
12605 MOZ_TRY_VAR(literal, handler_.newTupleLiteral(begin))do { auto mozTryVarTempResult_ = (handler_.newTupleLiteral(begin
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (literal)
= mozTryVarTempResult_.unwrap(); } while (0)
;
12606
12607 for (uint32_t index = 0;; index++) {
12608 if (index >= NativeObject::MAX_DENSE_ELEMENTS_COUNT) {
12609 error(JSMSG_ARRAY_INIT_TOO_BIG);
12610 return errorResult();
12611 }
12612
12613 TokenKind tt;
12614 if (!tokenStream.peekToken(&tt, TokenStream::SlashIsRegExp)) {
12615 return errorResult();
12616 }
12617 if (tt == TokenKind::RightBracket) {
12618 break;
12619 }
12620
12621 if (tt == TokenKind::TripleDot) {
12622 tokenStream.consumeKnownToken(TokenKind::TripleDot,
12623 TokenStream::SlashIsRegExp);
12624 uint32_t begin = pos().begin;
12625
12626 TokenPos innerPos;
12627 if (!tokenStream.peekTokenPos(&innerPos, TokenStream::SlashIsRegExp)) {
12628 return errorResult();
12629 }
12630
12631 Node inner;
12632 MOZ_TRY_VAR(inner,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (inner) = mozTryVarTempResult_.unwrap(); } while (0)
12633 assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (inner) = mozTryVarTempResult_.unwrap(); } while (0)
;
12634
12635 if (!handler_.addSpreadElement(literal, begin, inner)) {
12636 return errorResult();
12637 }
12638 } else {
12639 TokenPos elementPos;
12640 if (!tokenStream.peekTokenPos(&elementPos, TokenStream::SlashIsRegExp)) {
12641 return errorResult();
12642 }
12643
12644 Node element;
12645 MOZ_TRY_VAR(element,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (element) = mozTryVarTempResult_.unwrap(); } while (0)
12646 assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (element) = mozTryVarTempResult_.unwrap(); } while (0)
;
12647 handler_.addArrayElement(literal, element);
12648 }
12649
12650 bool matched;
12651 if (!tokenStream.matchToken(&matched, TokenKind::Comma,
12652 TokenStream::SlashIsRegExp)) {
12653 return errorResult();
12654 }
12655 if (!matched) {
12656 break;
12657 }
12658 }
12659
12660 if (!mustMatchToken(TokenKind::RightBracket, [this, begin](TokenKind actual) {
12661 this->reportMissingClosing(JSMSG_BRACKET_AFTER_LIST,
12662 JSMSG_BRACKET_OPENED, begin);
12663 })) {
12664 return errorResult();
12665 }
12666
12667 handler_.setEndPosition(literal, pos().end);
12668 return literal;
12669}
12670#endif
12671
12672template <class ParseHandler, typename Unit>
12673typename ParseHandler::FunctionNodeResult
12674GeneralParser<ParseHandler, Unit>::methodDefinition(
12675 uint32_t toStringStart, PropertyType propType,
12676 TaggedParserAtomIndex funName) {
12677 FunctionSyntaxKind syntaxKind;
12678 switch (propType) {
12679 case PropertyType::Getter:
12680 syntaxKind = FunctionSyntaxKind::Getter;
12681 break;
12682
12683 case PropertyType::Setter:
12684 syntaxKind = FunctionSyntaxKind::Setter;
12685 break;
12686
12687 case PropertyType::Method:
12688 case PropertyType::GeneratorMethod:
12689 case PropertyType::AsyncMethod:
12690 case PropertyType::AsyncGeneratorMethod:
12691 syntaxKind = FunctionSyntaxKind::Method;
12692 break;
12693
12694 case PropertyType::Constructor:
12695 syntaxKind = FunctionSyntaxKind::ClassConstructor;
12696 break;
12697
12698 case PropertyType::DerivedConstructor:
12699 syntaxKind = FunctionSyntaxKind::DerivedClassConstructor;
12700 break;
12701
12702 default:
12703 MOZ_CRASH("unexpected property type")do { do { } while (false); MOZ_ReportCrash("" "unexpected property type"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12703); AnnotateMozCrashReason("MOZ_CRASH(" "unexpected property type"
")"); do { *((volatile int*)__null) = 12703; __attribute__((
nomerge)) ::abort(); } while (false); } while (false)
;
12704 }
12705
12706 GeneratorKind generatorKind = (propType == PropertyType::GeneratorMethod ||
12707 propType == PropertyType::AsyncGeneratorMethod)
12708 ? GeneratorKind::Generator
12709 : GeneratorKind::NotGenerator;
12710
12711 FunctionAsyncKind asyncKind = (propType == PropertyType::AsyncMethod ||
12712 propType == PropertyType::AsyncGeneratorMethod)
12713 ? FunctionAsyncKind::AsyncFunction
12714 : FunctionAsyncKind::SyncFunction;
12715
12716 YieldHandling yieldHandling = GetYieldHandling(generatorKind);
12717
12718 FunctionNodeType funNode;
12719 MOZ_TRY_VAR(funNode, handler_.newFunction(syntaxKind, pos()))do { auto mozTryVarTempResult_ = (handler_.newFunction(syntaxKind
, pos())); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr
()), 0))) { return mozTryVarTempResult_.propagateErr(); } (funNode
) = mozTryVarTempResult_.unwrap(); } while (0)
;
12720
12721 return functionDefinition(funNode, toStringStart, InAllowed, yieldHandling,
12722 funName, syntaxKind, generatorKind, asyncKind);
12723}
12724
12725template <class ParseHandler, typename Unit>
12726bool GeneralParser<ParseHandler, Unit>::tryNewTarget(
12727 NewTargetNodeType* newTarget) {
12728 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::New))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::New))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(anyChars.isCurrentTokenType(TokenKind::New)))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::New)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12728); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::New)"
")"); do { *((volatile int*)__null) = 12728; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12729
12730 *newTarget = null();
12731
12732 NullaryNodeType newHolder;
12733 MOZ_TRY_VAR_OR_RETURN(newHolder, handler_.newPosHolder(pos()), false)do { auto parserTryVarTempResult_ = (handler_.newPosHolder(pos
())); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr(
)), 0))) { return (false); } (newHolder) = parserTryVarTempResult_
.unwrap(); } while (0)
;
12734
12735 uint32_t begin = pos().begin;
12736
12737 // |new| expects to look for an operand, so we will honor that.
12738 TokenKind next;
12739 if (!tokenStream.getToken(&next, TokenStream::SlashIsRegExp)) {
12740 return false;
12741 }
12742
12743 // Don't unget the token, since lookahead cannot handle someone calling
12744 // getToken() with a different modifier. Callers should inspect
12745 // currentToken().
12746 if (next != TokenKind::Dot) {
12747 return true;
12748 }
12749
12750 if (!tokenStream.getToken(&next)) {
12751 return false;
12752 }
12753 if (next != TokenKind::Target) {
12754 error(JSMSG_UNEXPECTED_TOKEN, "target", TokenKindToDesc(next));
12755 return false;
12756 }
12757
12758 if (!pc_->sc()->allowNewTarget()) {
12759 errorAt(begin, JSMSG_BAD_NEWTARGET);
12760 return false;
12761 }
12762
12763 NullaryNodeType targetHolder;
12764 MOZ_TRY_VAR_OR_RETURN(targetHolder, handler_.newPosHolder(pos()), false)do { auto parserTryVarTempResult_ = (handler_.newPosHolder(pos
())); if ((__builtin_expect(!!(parserTryVarTempResult_.isErr(
)), 0))) { return (false); } (targetHolder) = parserTryVarTempResult_
.unwrap(); } while (0)
;
12765
12766 NameNodeType newTargetName;
12767 MOZ_TRY_VAR_OR_RETURN(newTargetName, newNewTargetName(), false)do { auto parserTryVarTempResult_ = (newNewTargetName()); if (
(__builtin_expect(!!(parserTryVarTempResult_.isErr()), 0))) {
return (false); } (newTargetName) = parserTryVarTempResult_.
unwrap(); } while (0)
;
12768
12769 MOZ_TRY_VAR_OR_RETURN(do { auto parserTryVarTempResult_ = (handler_.newNewTarget(newHolder
, targetHolder, newTargetName)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (*newTarget) = parserTryVarTempResult_
.unwrap(); } while (0)
12770 *newTarget, handler_.newNewTarget(newHolder, targetHolder, newTargetName),do { auto parserTryVarTempResult_ = (handler_.newNewTarget(newHolder
, targetHolder, newTargetName)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (*newTarget) = parserTryVarTempResult_
.unwrap(); } while (0)
12771 false)do { auto parserTryVarTempResult_ = (handler_.newNewTarget(newHolder
, targetHolder, newTargetName)); if ((__builtin_expect(!!(parserTryVarTempResult_
.isErr()), 0))) { return (false); } (*newTarget) = parserTryVarTempResult_
.unwrap(); } while (0)
;
12772
12773 return true;
12774}
12775
12776template <class ParseHandler, typename Unit>
12777typename ParseHandler::BinaryNodeResult
12778GeneralParser<ParseHandler, Unit>::importExpr(YieldHandling yieldHandling,
12779 bool allowCallSyntax) {
12780 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Import))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::Import))>::
isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::Import)))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::Import)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12780); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::Import)"
")"); do { *((volatile int*)__null) = 12780; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12781
12782 NullaryNodeType importHolder;
12783 MOZ_TRY_VAR(importHolder, handler_.newPosHolder(pos()))do { auto mozTryVarTempResult_ = (handler_.newPosHolder(pos()
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (importHolder
) = mozTryVarTempResult_.unwrap(); } while (0)
;
12784
12785 TokenKind next;
12786 if (!tokenStream.getToken(&next)) {
12787 return errorResult();
12788 }
12789
12790 if (next == TokenKind::Dot) {
12791 if (!tokenStream.getToken(&next)) {
12792 return errorResult();
12793 }
12794 if (next != TokenKind::Meta) {
12795 error(JSMSG_UNEXPECTED_TOKEN, "meta", TokenKindToDesc(next));
12796 return errorResult();
12797 }
12798
12799 if (parseGoal() != ParseGoal::Module) {
12800 errorAt(pos().begin, JSMSG_IMPORT_META_OUTSIDE_MODULE);
12801 return errorResult();
12802 }
12803
12804 NullaryNodeType metaHolder;
12805 MOZ_TRY_VAR(metaHolder, handler_.newPosHolder(pos()))do { auto mozTryVarTempResult_ = (handler_.newPosHolder(pos()
)); if ((__builtin_expect(!!(mozTryVarTempResult_.isErr()), 0
))) { return mozTryVarTempResult_.propagateErr(); } (metaHolder
) = mozTryVarTempResult_.unwrap(); } while (0)
;
12806
12807 return handler_.newImportMeta(importHolder, metaHolder);
12808 }
12809
12810 if (next == TokenKind::LeftParen && allowCallSyntax) {
12811 Node arg;
12812 MOZ_TRY_VAR(arg, assignExpr(InAllowed, yieldHandling, TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (arg) = mozTryVarTempResult_.unwrap(); } while (0)
;
12813
12814 if (!tokenStream.peekToken(&next, TokenStream::SlashIsRegExp)) {
12815 return errorResult();
12816 }
12817
12818 Node optionalArg;
12819 if (options().importAttributes()) {
12820 if (next == TokenKind::Comma) {
12821 tokenStream.consumeKnownToken(TokenKind::Comma,
12822 TokenStream::SlashIsRegExp);
12823
12824 if (!tokenStream.peekToken(&next, TokenStream::SlashIsRegExp)) {
12825 return errorResult();
12826 }
12827
12828 if (next != TokenKind::RightParen) {
12829 MOZ_TRY_VAR(optionalArg, assignExpr(InAllowed, yieldHandling,do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (optionalArg) = mozTryVarTempResult_.unwrap(); } while (0)
12830 TripledotProhibited))do { auto mozTryVarTempResult_ = (assignExpr(InAllowed, yieldHandling
, TripledotProhibited)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (optionalArg) = mozTryVarTempResult_.unwrap(); } while (0)
;
12831
12832 if (!tokenStream.peekToken(&next, TokenStream::SlashIsRegExp)) {
12833 return errorResult();
12834 }
12835
12836 if (next == TokenKind::Comma) {
12837 tokenStream.consumeKnownToken(TokenKind::Comma,
12838 TokenStream::SlashIsRegExp);
12839 }
12840 } else {
12841 MOZ_TRY_VAR(optionalArg,do { auto mozTryVarTempResult_ = (handler_.newPosHolder(TokenPos
(pos().end, pos().end))); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (optionalArg) = mozTryVarTempResult_.unwrap(); } while (0)
12842 handler_.newPosHolder(TokenPos(pos().end, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newPosHolder(TokenPos
(pos().end, pos().end))); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (optionalArg) = mozTryVarTempResult_.unwrap(); } while (0)
;
12843 }
12844 } else {
12845 MOZ_TRY_VAR(optionalArg,do { auto mozTryVarTempResult_ = (handler_.newPosHolder(TokenPos
(pos().end, pos().end))); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (optionalArg) = mozTryVarTempResult_.unwrap(); } while (0)
12846 handler_.newPosHolder(TokenPos(pos().end, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newPosHolder(TokenPos
(pos().end, pos().end))); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (optionalArg) = mozTryVarTempResult_.unwrap(); } while (0)
;
12847 }
12848 } else {
12849 MOZ_TRY_VAR(optionalArg,do { auto mozTryVarTempResult_ = (handler_.newPosHolder(TokenPos
(pos().end, pos().end))); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (optionalArg) = mozTryVarTempResult_.unwrap(); } while (0)
12850 handler_.newPosHolder(TokenPos(pos().end, pos().end)))do { auto mozTryVarTempResult_ = (handler_.newPosHolder(TokenPos
(pos().end, pos().end))); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (optionalArg) = mozTryVarTempResult_.unwrap(); } while (0)
;
12851 }
12852
12853 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_AFTER_ARGS)) {
12854 return errorResult();
12855 }
12856
12857 Node spec;
12858 MOZ_TRY_VAR(spec, handler_.newCallImportSpec(arg, optionalArg))do { auto mozTryVarTempResult_ = (handler_.newCallImportSpec(
arg, optionalArg)); if ((__builtin_expect(!!(mozTryVarTempResult_
.isErr()), 0))) { return mozTryVarTempResult_.propagateErr();
} (spec) = mozTryVarTempResult_.unwrap(); } while (0)
;
12859
12860 return handler_.newCallImport(importHolder, spec);
12861 }
12862
12863 error(JSMSG_UNEXPECTED_TOKEN_NO_EXPECT, TokenKindToDesc(next));
12864 return errorResult();
12865}
12866
12867template <class ParseHandler, typename Unit>
12868typename ParseHandler::NodeResult
12869GeneralParser<ParseHandler, Unit>::primaryExpr(
12870 YieldHandling yieldHandling, TripledotHandling tripledotHandling,
12871 TokenKind tt, PossibleError* possibleError, InvokedPrediction invoked) {
12872 MOZ_ASSERT(anyChars.isCurrentTokenType(tt))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(tt))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(anyChars.isCurrentTokenType(
tt)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("anyChars.isCurrentTokenType(tt)", "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 12872); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(tt)"
")"); do { *((volatile int*)__null) = 12872; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
12873 AutoCheckRecursionLimit recursion(this->fc_);
12874 if (!recursion.check(this->fc_)) {
12875 return errorResult();
12876 }
12877
12878 switch (tt) {
12879 case TokenKind::Function:
12880 return functionExpr(pos().begin, invoked,
12881 FunctionAsyncKind::SyncFunction);
12882
12883 case TokenKind::Class:
12884 return classDefinition(yieldHandling, ClassExpression, NameRequired);
12885
12886 case TokenKind::LeftBracket:
12887 return arrayInitializer(yieldHandling, possibleError);
12888
12889 case TokenKind::LeftCurly:
12890 return objectLiteral(yieldHandling, possibleError);
12891
12892#ifdef ENABLE_RECORD_TUPLE
12893 case TokenKind::HashCurly:
12894 return recordLiteral(yieldHandling);
12895
12896 case TokenKind::HashBracket:
12897 return tupleLiteral(yieldHandling);
12898#endif
12899
12900#ifdef ENABLE_DECORATORS
12901 case TokenKind::At:
12902 return classDefinition(yieldHandling, ClassExpression, NameRequired);
12903#endif
12904
12905 case TokenKind::LeftParen: {
12906 TokenKind next;
12907 if (!tokenStream.peekToken(&next, TokenStream::SlashIsRegExp)) {
12908 return errorResult();
12909 }
12910
12911 if (next == TokenKind::RightParen) {
12912 // Not valid expression syntax, but this is valid in an arrow function
12913 // with no params: `() => body`.
12914 tokenStream.consumeKnownToken(TokenKind::RightParen,
12915 TokenStream::SlashIsRegExp);
12916
12917 if (!tokenStream.peekToken(&next)) {
12918 return errorResult();
12919 }
12920 if (next != TokenKind::Arrow) {
12921 error(JSMSG_UNEXPECTED_TOKEN, "expression",
12922 TokenKindToDesc(TokenKind::RightParen));
12923 return errorResult();
12924 }
12925
12926 // Now just return something that will allow parsing to continue.
12927 // It doesn't matter what; when we reach the =>, we will rewind and
12928 // reparse the whole arrow function. See Parser::assignExpr.
12929 return handler_.newNullLiteral(pos());
12930 }
12931
12932 // Pass |possibleError| to support destructuring in arrow parameters.
12933 Node expr;
12934 MOZ_TRY_VAR(expr, exprInParens(InAllowed, yieldHandling, TripledotAllowed,do { auto mozTryVarTempResult_ = (exprInParens(InAllowed, yieldHandling
, TripledotAllowed, possibleError)); if ((__builtin_expect(!!
(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (expr) = mozTryVarTempResult_.unwrap(); } while
(0)
12935 possibleError))do { auto mozTryVarTempResult_ = (exprInParens(InAllowed, yieldHandling
, TripledotAllowed, possibleError)); if ((__builtin_expect(!!
(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (expr) = mozTryVarTempResult_.unwrap(); } while
(0)
;
12936 if (!mustMatchToken(TokenKind::RightParen, JSMSG_PAREN_IN_PAREN)) {
12937 return errorResult();
12938 }
12939 return handler_.parenthesize(expr);
12940 }
12941
12942 case TokenKind::TemplateHead:
12943 return templateLiteral(yieldHandling);
12944
12945 case TokenKind::NoSubsTemplate:
12946 return noSubstitutionUntaggedTemplate();
12947
12948 case TokenKind::String:
12949 return stringLiteral();
12950
12951 default: {
12952 if (!TokenKindIsPossibleIdentifier(tt)) {
12953 error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
12954 return errorResult();
12955 }
12956
12957 if (tt == TokenKind::Async) {
12958 TokenKind nextSameLine = TokenKind::Eof;
12959 if (!tokenStream.peekTokenSameLine(&nextSameLine)) {
12960 return errorResult();
12961 }
12962
12963 if (nextSameLine == TokenKind::Function) {
12964 uint32_t toStringStart = pos().begin;
12965 tokenStream.consumeKnownToken(TokenKind::Function);
12966 return functionExpr(toStringStart, PredictUninvoked,
12967 FunctionAsyncKind::AsyncFunction);
12968 }
12969 }
12970
12971 TaggedParserAtomIndex name = identifierReference(yieldHandling);
12972 if (!name) {
12973 return errorResult();
12974 }
12975
12976 return identifierReference(name);
12977 }
12978
12979 case TokenKind::RegExp:
12980 return newRegExp();
12981
12982 case TokenKind::Number:
12983 return newNumber(anyChars.currentToken());
12984
12985 case TokenKind::BigInt:
12986 return newBigInt();
12987
12988 case TokenKind::True:
12989 return handler_.newBooleanLiteral(true, pos());
12990 case TokenKind::False:
12991 return handler_.newBooleanLiteral(false, pos());
12992 case TokenKind::This: {
12993 NameNodeType thisName = null();
12994 if (pc_->sc()->hasFunctionThisBinding()) {
12995 MOZ_TRY_VAR(thisName, newThisName())do { auto mozTryVarTempResult_ = (newThisName()); if ((__builtin_expect
(!!(mozTryVarTempResult_.isErr()), 0))) { return mozTryVarTempResult_
.propagateErr(); } (thisName) = mozTryVarTempResult_.unwrap()
; } while (0)
;
12996 }
12997 return handler_.newThisLiteral(pos(), thisName);
12998 }
12999 case TokenKind::Null:
13000 return handler_.newNullLiteral(pos());
13001
13002 case TokenKind::TripleDot: {
13003 // This isn't valid expression syntax, but it's valid in an arrow
13004 // function as a trailing rest param: `(a, b, ...rest) => body`. Check
13005 // if it's directly under
13006 // CoverParenthesizedExpressionAndArrowParameterList, and check for a
13007 // name, closing parenthesis, and arrow, and allow it only if all are
13008 // present.
13009 if (tripledotHandling != TripledotAllowed) {
13010 error(JSMSG_UNEXPECTED_TOKEN, "expression", TokenKindToDesc(tt));
13011 return errorResult();
13012 }
13013
13014 TokenKind next;
13015 if (!tokenStream.getToken(&next)) {
13016 return errorResult();
13017 }
13018
13019 if (next == TokenKind::LeftBracket || next == TokenKind::LeftCurly) {
13020 // Validate, but don't store the pattern right now. The whole arrow
13021 // function is reparsed in functionFormalParametersAndBody().
13022 MOZ_TRY(destructuringDeclaration(DeclarationKind::CoverArrowParameter,do { auto mozTryTempResult_ = ::mozilla::ToResult(destructuringDeclaration
(DeclarationKind::CoverArrowParameter, yieldHandling, next));
if ((__builtin_expect(!!(mozTryTempResult_.isErr()), 0))) { return
mozTryTempResult_.propagateErr(); } } while (0)
13023 yieldHandling, next))do { auto mozTryTempResult_ = ::mozilla::ToResult(destructuringDeclaration
(DeclarationKind::CoverArrowParameter, yieldHandling, next));
if ((__builtin_expect(!!(mozTryTempResult_.isErr()), 0))) { return
mozTryTempResult_.propagateErr(); } } while (0)
;
13024 } else {
13025 // This doesn't check that the provided name is allowed, e.g. if
13026 // the enclosing code is strict mode code, any of "let", "yield",
13027 // or "arguments" should be prohibited. Argument-parsing code
13028 // handles that.
13029 if (!TokenKindIsPossibleIdentifier(next)) {
13030 error(JSMSG_UNEXPECTED_TOKEN, "rest argument name",
13031 TokenKindToDesc(next));
13032 return errorResult();
13033 }
13034 }
13035
13036 if (!tokenStream.getToken(&next)) {
13037 return errorResult();
13038 }
13039 if (next != TokenKind::RightParen) {
13040 error(JSMSG_UNEXPECTED_TOKEN, "closing parenthesis",
13041 TokenKindToDesc(next));
13042 return errorResult();
13043 }
13044
13045 if (!tokenStream.peekToken(&next)) {
13046 return errorResult();
13047 }
13048 if (next != TokenKind::Arrow) {
13049 // Advance the scanner for proper error location reporting.
13050 tokenStream.consumeKnownToken(next);
13051 error(JSMSG_UNEXPECTED_TOKEN, "'=>' after argument list",
13052 TokenKindToDesc(next));
13053 return errorResult();
13054 }
13055
13056 anyChars.ungetToken(); // put back right paren
13057
13058 // Return an arbitrary expression node. See case TokenKind::RightParen
13059 // above.
13060 return handler_.newNullLiteral(pos());
13061 }
13062 }
13063}
13064
13065template <class ParseHandler, typename Unit>
13066typename ParseHandler::NodeResult
13067GeneralParser<ParseHandler, Unit>::exprInParens(
13068 InHandling inHandling, YieldHandling yieldHandling,
13069 TripledotHandling tripledotHandling,
13070 PossibleError* possibleError /* = nullptr */) {
13071 MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftParen))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(anyChars.isCurrentTokenType(TokenKind::LeftParen))>
::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(anyChars.isCurrentTokenType(TokenKind::LeftParen))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("anyChars.isCurrentTokenType(TokenKind::LeftParen)"
, "/var/lib/jenkins/workspace/firefox-scan-build/js/src/frontend/Parser.cpp"
, 13071); AnnotateMozCrashReason("MOZ_ASSERT" "(" "anyChars.isCurrentTokenType(TokenKind::LeftParen)"
")"); do { *((volatile int*)__null) = 13071; __attribute__((
nomerge)) ::abort(); } while (false); } } while (false)
;
13072 return expr(inHandling, yieldHandling, tripledotHandling, possibleError,
13073 PredictInvoked);
13074}
13075
13076template class PerHandlerParser<FullParseHandler>;
13077template class PerHandlerParser<SyntaxParseHandler>;
13078template class GeneralParser<FullParseHandler, Utf8Unit>;
13079template class GeneralParser<SyntaxParseHandler, Utf8Unit>;
13080template class GeneralParser<FullParseHandler, char16_t>;
13081template class GeneralParser<SyntaxParseHandler, char16_t>;
13082template class Parser<FullParseHandler, Utf8Unit>;
13083template class Parser<SyntaxParseHandler, Utf8Unit>;
13084template class Parser<FullParseHandler, char16_t>;
13085template class Parser<SyntaxParseHandler, char16_t>;
13086
13087} // namespace js::frontend