source: webkit/trunk/Source/JavaScriptCore/parser/NodeConstructors.h

Last change on this file was 288473, checked in by [email protected], 3 years ago

[JSC] Support import assertion syntax
https://bugs.webkit.org/show_bug.cgi?id=235312

Reviewed by Ross Kirsling.

JSTests:

  • modules/import-meta-syntax.js:

(shouldThrow):

  • stress/import-syntax.js:
  • stress/modules-syntax-error.js:
  • stress/modules-syntax-import-assertion-error.js: Added.

(shouldThrow):

  • stress/modules-syntax-import-assertion.js: Added.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt:
  • web-platform-tests/service-workers/service-worker/dedicated-worker-service-worker-interception.https-expected.txt:
  • web-platform-tests/workers/dedicated-worker-parse-error-failure-expected.txt:
  • web-platform-tests/workers/modules/dedicated-worker-options-credentials-expected.txt:

Source/JavaScriptCore:

This patch adds syntax support for import assertion[1].
This does not add the actual feature propagating import assertion
to the module request yet.

[1]: https://github.com/tc39/proposal-import-assertions

  • bytecompiler/NodesCodegen.cpp:

(JSC::ImportNode::emitBytecode):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createImportExpr):
(JSC::ASTBuilder::createImportAssertionList):
(JSC::ASTBuilder::appendImportAssertion):
(JSC::ASTBuilder::createImportDeclaration):
(JSC::ASTBuilder::createExportAllDeclaration):
(JSC::ASTBuilder::createExportNamedDeclaration):

  • parser/NodeConstructors.h:

(JSC::ImportNode::ImportNode):
(JSC::ImportDeclarationNode::ImportDeclarationNode):
(JSC::ExportAllDeclarationNode::ExportAllDeclarationNode):
(JSC::ExportNamedDeclarationNode::ExportNamedDeclarationNode):

  • parser/Nodes.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseImportAssertions):
(JSC::Parser<LexerType>::parseImportDeclaration):
(JSC::Parser<LexerType>::parseExportDeclaration):
(JSC::Parser<LexerType>::parseMemberExpression):

  • parser/Parser.h:
  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createImportExpr):
(JSC::SyntaxChecker::createImportAssertionList):
(JSC::SyntaxChecker::appendImportAssertion):
(JSC::SyntaxChecker::createImportDeclaration):
(JSC::SyntaxChecker::createExportAllDeclaration):
(JSC::SyntaxChecker::createExportNamedDeclaration):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/OptionsList.h:
  • Property svn:eol-style set to native
File size: 46.7 KB
Line 
1/*
2 * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#pragma once
22
23#include "Nodes.h"
24#include "Opcode.h"
25
26namespace JSC {
27
28 inline void* ParserArenaFreeable::operator new(size_t size, ParserArena& parserArena)
29 {
30 return parserArena.allocateFreeable(size);
31 }
32
33 template<typename T>
34 inline void* ParserArenaDeletable::operator new(size_t size, ParserArena& parserArena)
35 {
36 return parserArena.allocateDeletable<T>(size);
37 }
38
39 inline ParserArenaRoot::ParserArenaRoot(ParserArena& parserArena)
40 {
41 m_arena.swap(parserArena);
42 }
43
44 inline Node::Node(const JSTokenLocation& location)
45 : m_position(location.line, location.startOffset, location.lineStartOffset)
46 {
47 ASSERT(location.startOffset >= location.lineStartOffset);
48 }
49
50 inline ExpressionNode::ExpressionNode(const JSTokenLocation& location, ResultType resultType)
51 : Node(location)
52 , m_resultType(resultType)
53 {
54 }
55
56 inline StatementNode::StatementNode(const JSTokenLocation& location)
57 : Node(location)
58 {
59 }
60
61 inline ConstantNode::ConstantNode(const JSTokenLocation& location, ResultType resultType)
62 : ExpressionNode(location, resultType)
63 {
64 }
65
66 inline NullNode::NullNode(const JSTokenLocation& location)
67 : ConstantNode(location, ResultType::nullType())
68 {
69 }
70
71 inline BooleanNode::BooleanNode(const JSTokenLocation& location, bool value)
72 : ConstantNode(location, ResultType::booleanType())
73 , m_value(value)
74 {
75 }
76
77 inline NumberNode::NumberNode(const JSTokenLocation& location, double value)
78 : ConstantNode(location, JSValue(value).isInt32() ? ResultType::numberTypeIsInt32() : ResultType::numberType())
79 , m_value(value)
80 {
81 }
82
83 inline DoubleNode::DoubleNode(const JSTokenLocation& location, double value)
84 : NumberNode(location, value)
85 {
86 }
87
88 inline IntegerNode::IntegerNode(const JSTokenLocation& location, double value)
89 : DoubleNode(location, value)
90 {
91 }
92
93 inline BigIntNode::BigIntNode(const JSTokenLocation& location, const Identifier& value, uint8_t radix)
94 : ConstantNode(location, ResultType::bigIntType())
95 , m_value(value)
96 , m_radix(radix)
97 , m_sign(false)
98 {
99 }
100
101 inline BigIntNode::BigIntNode(const JSTokenLocation& location, const Identifier& value, uint8_t radix, bool sign)
102 : ConstantNode(location, ResultType::bigIntType())
103 , m_value(value)
104 , m_radix(radix)
105 , m_sign(sign)
106 {
107 }
108
109 inline StringNode::StringNode(const JSTokenLocation& location, const Identifier& value)
110 : ConstantNode(location, ResultType::stringType())
111 , m_value(value)
112 {
113 }
114
115 inline TemplateExpressionListNode::TemplateExpressionListNode(ExpressionNode* node)
116 : m_node(node)
117 {
118 }
119
120 inline TemplateExpressionListNode::TemplateExpressionListNode(TemplateExpressionListNode* previous, ExpressionNode* node)
121 : m_node(node)
122 {
123 previous->m_next = this;
124 }
125
126 inline TemplateStringNode::TemplateStringNode(const JSTokenLocation& location, const Identifier* cooked, const Identifier* raw)
127 : ExpressionNode(location)
128 , m_cooked(cooked)
129 , m_raw(raw)
130 {
131 }
132
133 inline TemplateStringListNode::TemplateStringListNode(TemplateStringNode* node)
134 : m_node(node)
135 {
136 }
137
138 inline TemplateStringListNode::TemplateStringListNode(TemplateStringListNode* previous, TemplateStringNode* node)
139 : m_node(node)
140 {
141 previous->m_next = this;
142 }
143
144 inline TemplateLiteralNode::TemplateLiteralNode(const JSTokenLocation& location, TemplateStringListNode* templateStrings)
145 : ExpressionNode(location)
146 , m_templateStrings(templateStrings)
147 , m_templateExpressions(nullptr)
148 {
149 }
150
151 inline TemplateLiteralNode::TemplateLiteralNode(const JSTokenLocation& location, TemplateStringListNode* templateStrings, TemplateExpressionListNode* templateExpressions)
152 : ExpressionNode(location)
153 , m_templateStrings(templateStrings)
154 , m_templateExpressions(templateExpressions)
155 {
156 }
157
158 inline TaggedTemplateNode::TaggedTemplateNode(const JSTokenLocation& location, ExpressionNode* tag, TemplateLiteralNode* templateLiteral)
159 : ExpressionNode(location)
160 , m_tag(tag)
161 , m_templateLiteral(templateLiteral)
162 {
163 }
164
165 inline RegExpNode::RegExpNode(const JSTokenLocation& location, const Identifier& pattern, const Identifier& flags)
166 : ExpressionNode(location)
167 , m_pattern(pattern)
168 , m_flags(flags)
169 {
170 }
171
172 inline ThisNode::ThisNode(const JSTokenLocation& location)
173 : ExpressionNode(location)
174 {
175 }
176
177 inline SuperNode::SuperNode(const JSTokenLocation& location)
178 : ExpressionNode(location)
179 {
180 }
181
182 inline ImportNode::ImportNode(const JSTokenLocation& location, ExpressionNode* expr, ExpressionNode* option)
183 : ExpressionNode(location)
184 , m_expr(expr)
185 , m_option(option)
186 {
187 }
188
189 inline MetaPropertyNode::MetaPropertyNode(const JSTokenLocation& location)
190 : ExpressionNode(location)
191 {
192 }
193
194 inline NewTargetNode::NewTargetNode(const JSTokenLocation& location)
195 : MetaPropertyNode(location)
196 {
197 }
198
199 inline ImportMetaNode::ImportMetaNode(const JSTokenLocation& location, ExpressionNode* expr)
200 : MetaPropertyNode(location)
201 , m_expr(expr)
202 {
203 }
204
205 inline ResolveNode::ResolveNode(const JSTokenLocation& location, const Identifier& ident, const JSTextPosition& start)
206 : ExpressionNode(location)
207 , m_ident(ident)
208 , m_start(start)
209 {
210 ASSERT(m_start.offset >= m_start.lineStartOffset);
211 }
212
213 inline PrivateIdentifierNode::PrivateIdentifierNode(const JSTokenLocation& location, const Identifier& ident)
214 : ExpressionNode(location)
215 , m_ident(ident)
216 {
217 }
218
219 inline ElementNode::ElementNode(int elision, ExpressionNode* node)
220 : m_node(node)
221 , m_elision(elision)
222 {
223 }
224
225 inline ElementNode::ElementNode(ElementNode* l, int elision, ExpressionNode* node)
226 : m_node(node)
227 , m_elision(elision)
228 {
229 l->m_next = this;
230 }
231
232 inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision)
233 : ExpressionNode(location)
234 , m_element(nullptr)
235 , m_elision(elision)
236 {
237 }
238
239 inline ArrayNode::ArrayNode(const JSTokenLocation& location, ElementNode* element)
240 : ExpressionNode(location)
241 , m_element(element)
242 , m_elision(0)
243 {
244 }
245
246 inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision, ElementNode* element)
247 : ExpressionNode(location)
248 , m_element(element)
249 , m_elision(elision)
250 {
251 }
252
253 inline PropertyNode::PropertyNode(const Identifier& name, ExpressionNode* assign, Type type, SuperBinding superBinding, ClassElementTag tag)
254 : m_name(&name)
255 , m_expression(nullptr)
256 , m_assign(assign)
257 , m_type(type)
258 , m_needsSuperBinding(superBinding == SuperBinding::Needed)
259 , m_classElementTag(static_cast<unsigned>(tag))
260 , m_isOverriddenByDuplicate(false)
261 {
262 }
263
264 inline PropertyNode::PropertyNode(ExpressionNode* assign, Type type, SuperBinding superBinding, ClassElementTag tag)
265 : m_name(nullptr)
266 , m_expression(nullptr)
267 , m_assign(assign)
268 , m_type(type)
269 , m_needsSuperBinding(superBinding == SuperBinding::Needed)
270 , m_classElementTag(static_cast<unsigned>(tag))
271 , m_isOverriddenByDuplicate(false)
272 {
273 }
274
275 inline PropertyNode::PropertyNode(ExpressionNode* name, ExpressionNode* assign, Type type, SuperBinding superBinding, ClassElementTag tag)
276 : m_name(nullptr)
277 , m_expression(name)
278 , m_assign(assign)
279 , m_type(type)
280 , m_needsSuperBinding(superBinding == SuperBinding::Needed)
281 , m_classElementTag(static_cast<unsigned>(tag))
282 , m_isOverriddenByDuplicate(false)
283 {
284 }
285
286 inline PropertyNode::PropertyNode(const Identifier& ident, ExpressionNode* name, ExpressionNode* assign, Type type, SuperBinding superBinding, ClassElementTag tag)
287 : m_name(&ident)
288 , m_expression(name)
289 , m_assign(assign)
290 , m_type(type)
291 , m_needsSuperBinding(superBinding == SuperBinding::Needed)
292 , m_classElementTag(static_cast<unsigned>(tag))
293 , m_isOverriddenByDuplicate(false)
294 {
295 }
296
297 inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node)
298 : ExpressionNode(location)
299 , m_node(node)
300 {
301 }
302
303 inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node, PropertyListNode* list)
304 : ExpressionNode(location)
305 , m_node(node)
306 {
307 list->m_next = this;
308 }
309
310 inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location)
311 : ExpressionNode(location)
312 , m_list(nullptr)
313 {
314 }
315
316 inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location, PropertyListNode* list)
317 : ExpressionNode(location)
318 , m_list(list)
319 {
320 }
321
322 inline BracketAccessorNode::BracketAccessorNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments)
323 : ExpressionNode(location)
324 , m_base(base)
325 , m_subscript(subscript)
326 , m_subscriptHasAssignments(subscriptHasAssignments)
327 {
328 }
329
330 inline BaseDotNode::BaseDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type)
331 : ExpressionNode(location)
332 , m_base(base)
333 , m_ident(ident)
334 , m_type(type)
335 {
336 }
337
338 inline DotAccessorNode::DotAccessorNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type)
339 : BaseDotNode(location, base, ident, type)
340 {
341 }
342
343
344 inline SpreadExpressionNode::SpreadExpressionNode(const JSTokenLocation& location, ExpressionNode* expression)
345 : ExpressionNode(location)
346 , m_expression(expression)
347 {
348 }
349
350 inline ObjectSpreadExpressionNode::ObjectSpreadExpressionNode(const JSTokenLocation& location, ExpressionNode* expression)
351 : ExpressionNode(location)
352 , m_expression(expression)
353 {
354 }
355
356 inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ExpressionNode* expr)
357 : ExpressionNode(location)
358 , m_expr(expr)
359 {
360 }
361
362 inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ArgumentListNode* listNode, ExpressionNode* expr)
363 : ExpressionNode(location)
364 , m_expr(expr)
365 {
366 listNode->m_next = this;
367 }
368
369 inline ArgumentsNode::ArgumentsNode()
370 : m_listNode(nullptr)
371 {
372 }
373
374 inline ArgumentsNode::ArgumentsNode(ArgumentListNode* listNode, bool hasAssignments)
375 : m_listNode(listNode)
376 , m_hasAssignments(hasAssignments)
377 {
378 }
379
380 inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr)
381 : ExpressionNode(location)
382 , m_expr(expr)
383 , m_args(nullptr)
384 {
385 }
386
387 inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args)
388 : ExpressionNode(location)
389 , m_expr(expr)
390 , m_args(args)
391 {
392 }
393
394 inline EvalFunctionCallNode::EvalFunctionCallNode(const JSTokenLocation& location, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
395 : ExpressionNode(location)
396 , ThrowableExpressionData(divot, divotStart, divotEnd)
397 , m_args(args)
398 {
399 }
400
401 inline FunctionCallValueNode::FunctionCallValueNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
402 : ExpressionNode(location)
403 , ThrowableExpressionData(divot, divotStart, divotEnd)
404 , m_expr(expr)
405 , m_args(args)
406 {
407 ASSERT(divot.offset >= divotStart.offset);
408 }
409
410 inline FunctionCallResolveNode::FunctionCallResolveNode(const JSTokenLocation& location, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
411 : ExpressionNode(location)
412 , ThrowableExpressionData(divot, divotStart, divotEnd)
413 , m_ident(ident)
414 , m_args(args)
415 {
416 }
417
418 inline FunctionCallBracketNode::FunctionCallBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
419 : ExpressionNode(location)
420 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
421 , m_base(base)
422 , m_subscript(subscript)
423 , m_args(args)
424 , m_subscriptHasAssignments(subscriptHasAssignments)
425 {
426 }
427
428 inline FunctionCallDotNode::FunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
429 : BaseDotNode(location, base, ident, type)
430 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
431 , m_args(args)
432 {
433 }
434
435 inline BytecodeIntrinsicNode::BytecodeIntrinsicNode(Type type, const JSTokenLocation& location, BytecodeIntrinsicRegistry::Entry entry, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
436 : ExpressionNode(location)
437 , ThrowableExpressionData(divot, divotStart, divotEnd)
438 , m_entry(entry)
439 , m_ident(ident)
440 , m_args(args)
441 , m_type(type)
442 {
443 }
444
445 inline CallFunctionCallDotNode::CallFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd, size_t distanceToInnermostCallOrApply)
446 : FunctionCallDotNode(location, base, ident, type, args, divot, divotStart, divotEnd)
447 , m_distanceToInnermostCallOrApply(distanceToInnermostCallOrApply)
448 {
449 }
450
451 inline ApplyFunctionCallDotNode::ApplyFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd, size_t distanceToInnermostCallOrApply)
452 : FunctionCallDotNode(location, base, ident, type, args, divot, divotStart, divotEnd)
453 , m_distanceToInnermostCallOrApply(distanceToInnermostCallOrApply)
454 {
455 }
456
457 inline HasOwnPropertyFunctionCallDotNode::HasOwnPropertyFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
458 : FunctionCallDotNode(location, base, ident, type, args, divot, divotStart, divotEnd)
459 {
460 }
461
462 inline PostfixNode::PostfixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
463 : PrefixNode(location, expr, oper, divot, divotStart, divotEnd)
464 {
465 }
466
467 inline DeleteResolveNode::DeleteResolveNode(const JSTokenLocation& location, const Identifier& ident, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
468 : ExpressionNode(location)
469 , ThrowableExpressionData(divot, divotStart, divotEnd)
470 , m_ident(ident)
471 {
472 }
473
474 inline DeleteBracketNode::DeleteBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
475 : ExpressionNode(location)
476 , ThrowableExpressionData(divot, divotStart, divotEnd)
477 , m_base(base)
478 , m_subscript(subscript)
479 {
480 }
481
482 inline DeleteDotNode::DeleteDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
483 : ExpressionNode(location)
484 , ThrowableExpressionData(divot, divotStart, divotEnd)
485 , m_base(base)
486 , m_ident(ident)
487 {
488 }
489
490 inline DeleteValueNode::DeleteValueNode(const JSTokenLocation& location, ExpressionNode* expr)
491 : ExpressionNode(location)
492 , m_expr(expr)
493 {
494 }
495
496 inline VoidNode::VoidNode(const JSTokenLocation& location, ExpressionNode* expr)
497 : ExpressionNode(location)
498 , m_expr(expr)
499 {
500 }
501
502 inline TypeOfResolveNode::TypeOfResolveNode(const JSTokenLocation& location, const Identifier& ident)
503 : ExpressionNode(location, ResultType::stringType())
504 , m_ident(ident)
505 {
506 }
507
508 inline TypeOfValueNode::TypeOfValueNode(const JSTokenLocation& location, ExpressionNode* expr)
509 : ExpressionNode(location, ResultType::stringType())
510 , m_expr(expr)
511 {
512 }
513
514 inline PrefixNode::PrefixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
515 : ExpressionNode(location)
516 , ThrowablePrefixedSubExpressionData(divot, divotStart, divotEnd)
517 , m_expr(expr)
518 , m_operator(oper)
519 {
520 }
521
522 inline UnaryOpNode::UnaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr, OpcodeID opcodeID)
523 : ExpressionNode(location, type)
524 , m_expr(expr)
525 , m_opcodeID(opcodeID)
526 {
527 }
528
529 // UnaryPlus is guaranteed to always return a number, never a BigInt.
530 // See https://tc39.es/ecma262/#sec-unary-plus-operator-runtime-semantics-evaluation
531 inline UnaryPlusNode::UnaryPlusNode(const JSTokenLocation& location, ExpressionNode* expr)
532 : UnaryOpNode(location, ResultType::numberType(), expr, op_to_number)
533 {
534 }
535
536 inline NegateNode::NegateNode(const JSTokenLocation& location, ExpressionNode* expr)
537 : UnaryOpNode(location, ResultType::forUnaryArith(expr->resultDescriptor()), expr, op_negate)
538 {
539 }
540
541 inline BitwiseNotNode::BitwiseNotNode(const JSTokenLocation& location, ExpressionNode* expr)
542 : UnaryOpNode(location, ResultType::forBitOp(), expr, op_bitnot)
543 {
544 }
545
546 inline LogicalNotNode::LogicalNotNode(const JSTokenLocation& location, ExpressionNode* expr)
547 : UnaryOpNode(location, ResultType::booleanType(), expr, op_not)
548 {
549 }
550
551 inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
552 : ExpressionNode(location)
553 , m_rightHasAssignments(rightHasAssignments)
554 , m_opcodeID(opcodeID)
555 , m_expr1(expr1)
556 , m_expr2(expr2)
557 {
558 }
559
560 inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
561 : ExpressionNode(location, type)
562 , m_rightHasAssignments(rightHasAssignments)
563 , m_opcodeID(opcodeID)
564 , m_expr1(expr1)
565 , m_expr2(expr2)
566 {
567 }
568
569 inline PowNode::PowNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
570 : BinaryOpNode(location, ResultType::forNonAddArith(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_pow, rightHasAssignments)
571 {
572 }
573
574 inline MultNode::MultNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
575 : BinaryOpNode(location, ResultType::forNonAddArith(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_mul, rightHasAssignments)
576 {
577 }
578
579 inline DivNode::DivNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
580 : BinaryOpNode(location, ResultType::forNonAddArith(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_div, rightHasAssignments)
581 {
582 }
583
584
585 inline ModNode::ModNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
586 : BinaryOpNode(location, ResultType::forNonAddArith(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_mod, rightHasAssignments)
587 {
588 }
589
590 inline AddNode::AddNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
591 : BinaryOpNode(location, ResultType::forAdd(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_add, rightHasAssignments)
592 {
593 }
594
595 inline SubNode::SubNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
596 : BinaryOpNode(location, ResultType::forNonAddArith(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_sub, rightHasAssignments)
597 {
598 }
599
600 inline LeftShiftNode::LeftShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
601 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_lshift, rightHasAssignments)
602 {
603 }
604
605 inline RightShiftNode::RightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
606 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_rshift, rightHasAssignments)
607 {
608 }
609
610 inline UnsignedRightShiftNode::UnsignedRightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
611 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_urshift, rightHasAssignments)
612 {
613 }
614
615 inline LessNode::LessNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
616 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
617 {
618 }
619
620 inline GreaterNode::GreaterNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
621 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greater, rightHasAssignments)
622 {
623 }
624
625 inline LessEqNode::LessEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
626 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
627 {
628 }
629
630 inline GreaterEqNode::GreaterEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
631 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greatereq, rightHasAssignments)
632 {
633 }
634
635 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
636 : BinaryOpNode(location, type, expr1, expr2, opcodeID, rightHasAssignments)
637 {
638 }
639
640 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
641 : BinaryOpNode(location, expr1, expr2, opcodeID, rightHasAssignments)
642 {
643 }
644
645 inline InstanceOfNode::InstanceOfNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
646 : ThrowableBinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_instanceof, rightHasAssignments)
647 {
648 }
649
650 inline InNode::InNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
651 : ThrowableBinaryOpNode(location, expr1, expr2, op_in_by_val, rightHasAssignments)
652 {
653 }
654
655 inline EqualNode::EqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
656 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_eq, rightHasAssignments)
657 {
658 }
659
660 inline NotEqualNode::NotEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
661 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_neq, rightHasAssignments)
662 {
663 }
664
665 inline StrictEqualNode::StrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
666 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_stricteq, rightHasAssignments)
667 {
668 }
669
670 inline NotStrictEqualNode::NotStrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
671 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_nstricteq, rightHasAssignments)
672 {
673 }
674
675 inline BitAndNode::BitAndNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
676 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitand, rightHasAssignments)
677 {
678 }
679
680 inline BitOrNode::BitOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
681 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitor, rightHasAssignments)
682 {
683 }
684
685 inline BitXOrNode::BitXOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
686 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitxor, rightHasAssignments)
687 {
688 }
689
690 inline LogicalOpNode::LogicalOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper)
691 : ExpressionNode(location, ResultType::forLogicalOp(expr1->resultDescriptor(), expr2->resultDescriptor()))
692 , m_operator(oper)
693 , m_expr1(expr1)
694 , m_expr2(expr2)
695 {
696 }
697
698 inline CoalesceNode::CoalesceNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool hasAbsorbedOptionalChain)
699 : ExpressionNode(location, ResultType::forCoalesce(expr1->resultDescriptor(), expr2->resultDescriptor()))
700 , m_expr1(expr1)
701 , m_expr2(expr2)
702 , m_hasAbsorbedOptionalChain(hasAbsorbedOptionalChain)
703 {
704 }
705
706 inline OptionalChainNode::OptionalChainNode(const JSTokenLocation& location, ExpressionNode* expr, bool isOutermost)
707 : ExpressionNode(location)
708 , m_expr(expr)
709 , m_isOutermost(isOutermost)
710 {
711 }
712
713 inline ConditionalNode::ConditionalNode(const JSTokenLocation& location, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2)
714 : ExpressionNode(location)
715 , m_logical(logical)
716 , m_expr1(expr1)
717 , m_expr2(expr2)
718 {
719 }
720
721 inline ReadModifyResolveNode::ReadModifyResolveNode(const JSTokenLocation& location, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
722 : ExpressionNode(location)
723 , ThrowableExpressionData(divot, divotStart, divotEnd)
724 , m_ident(ident)
725 , m_right(right)
726 , m_operator(oper)
727 , m_rightHasAssignments(rightHasAssignments)
728 {
729 }
730
731 inline ShortCircuitReadModifyResolveNode::ShortCircuitReadModifyResolveNode(const JSTokenLocation& location, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
732 : ExpressionNode(location)
733 , ThrowableExpressionData(divot, divotStart, divotEnd)
734 , m_ident(ident)
735 , m_right(right)
736 , m_operator(oper)
737 , m_rightHasAssignments(rightHasAssignments)
738 {
739 }
740
741 inline AssignResolveNode::AssignResolveNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* right, AssignmentContext assignmentContext)
742 : ExpressionNode(location)
743 , m_ident(ident)
744 , m_right(right)
745 , m_assignmentContext(assignmentContext)
746 {
747 }
748
749
750 inline ReadModifyBracketNode::ReadModifyBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
751 : ExpressionNode(location)
752 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
753 , m_base(base)
754 , m_subscript(subscript)
755 , m_right(right)
756 , m_operator(oper)
757 , m_subscriptHasAssignments(subscriptHasAssignments)
758 , m_rightHasAssignments(rightHasAssignments)
759 {
760 }
761
762 inline ShortCircuitReadModifyBracketNode::ShortCircuitReadModifyBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
763 : ExpressionNode(location)
764 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
765 , m_base(base)
766 , m_subscript(subscript)
767 , m_right(right)
768 , m_operator(oper)
769 , m_subscriptHasAssignments(subscriptHasAssignments)
770 , m_rightHasAssignments(rightHasAssignments)
771 {
772 }
773
774 inline AssignBracketNode::AssignBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
775 : ExpressionNode(location)
776 , ThrowableExpressionData(divot, divotStart, divotEnd)
777 , m_base(base)
778 , m_subscript(subscript)
779 , m_right(right)
780 , m_subscriptHasAssignments(subscriptHasAssignments)
781 , m_rightHasAssignments(rightHasAssignments)
782 {
783 }
784
785 inline AssignDotNode::AssignDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
786 : BaseDotNode(location, base, ident, type)
787 , ThrowableExpressionData(divot, divotStart, divotEnd)
788 , m_right(right)
789 , m_rightHasAssignments(rightHasAssignments)
790 {
791 }
792
793 inline ReadModifyDotNode::ReadModifyDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type, Operator oper, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
794 : BaseDotNode(location, base, ident, type)
795 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
796 , m_right(right)
797 , m_operator(oper)
798 , m_rightHasAssignments(rightHasAssignments)
799 {
800 }
801
802 inline ShortCircuitReadModifyDotNode::ShortCircuitReadModifyDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, DotType type, Operator oper, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
803 : BaseDotNode(location, base, ident, type)
804 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
805 , m_right(right)
806 , m_operator(oper)
807 , m_rightHasAssignments(rightHasAssignments)
808 {
809 }
810
811 inline AssignErrorNode::AssignErrorNode(const JSTokenLocation& location, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
812 : ExpressionNode(location)
813 , ThrowableExpressionData(divot, divotStart, divotEnd)
814 {
815 }
816
817 inline CommaNode::CommaNode(const JSTokenLocation& location, ExpressionNode* expr)
818 : ExpressionNode(location)
819 , m_expr(expr)
820 {
821 }
822
823 inline SourceElements::SourceElements()
824 {
825 }
826
827 inline EmptyStatementNode::EmptyStatementNode(const JSTokenLocation& location)
828 : StatementNode(location)
829 {
830 }
831
832 inline DebuggerStatementNode::DebuggerStatementNode(const JSTokenLocation& location)
833 : StatementNode(location)
834 {
835 }
836
837 inline ExprStatementNode::ExprStatementNode(const JSTokenLocation& location, ExpressionNode* expr)
838 : StatementNode(location)
839 , m_expr(expr)
840 {
841 m_expr->setIsOnlyChildOfStatement();
842 }
843
844 inline DeclarationStatement::DeclarationStatement(const JSTokenLocation& location, ExpressionNode* expr)
845 : StatementNode(location)
846 , m_expr(expr)
847 {
848 m_expr->setIsOnlyChildOfStatement();
849 }
850
851 inline ModuleDeclarationNode::ModuleDeclarationNode(const JSTokenLocation& location)
852 : StatementNode(location)
853 {
854 }
855
856 inline ModuleNameNode::ModuleNameNode(const JSTokenLocation& location, const Identifier& moduleName)
857 : Node(location)
858 , m_moduleName(moduleName)
859 {
860 }
861
862 inline ImportSpecifierNode::ImportSpecifierNode(const JSTokenLocation& location, const Identifier& importedName, const Identifier& localName)
863 : Node(location)
864 , m_importedName(importedName)
865 , m_localName(localName)
866 {
867 }
868
869 inline ImportDeclarationNode::ImportDeclarationNode(const JSTokenLocation& location, ImportSpecifierListNode* importSpecifierList, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
870 : ModuleDeclarationNode(location)
871 , m_specifierList(importSpecifierList)
872 , m_moduleName(moduleName)
873 , m_assertionList(importAssertionList)
874 {
875 }
876
877 inline ExportAllDeclarationNode::ExportAllDeclarationNode(const JSTokenLocation& location, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
878 : ModuleDeclarationNode(location)
879 , m_moduleName(moduleName)
880 , m_assertionList(importAssertionList)
881 {
882 }
883
884 inline ExportDefaultDeclarationNode::ExportDefaultDeclarationNode(const JSTokenLocation& location, StatementNode* declaration, const Identifier& localName)
885 : ModuleDeclarationNode(location)
886 , m_declaration(declaration)
887 , m_localName(localName)
888 {
889 }
890
891 inline ExportLocalDeclarationNode::ExportLocalDeclarationNode(const JSTokenLocation& location, StatementNode* declaration)
892 : ModuleDeclarationNode(location)
893 , m_declaration(declaration)
894 {
895 }
896
897 inline ExportNamedDeclarationNode::ExportNamedDeclarationNode(const JSTokenLocation& location, ExportSpecifierListNode* exportSpecifierList, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
898 : ModuleDeclarationNode(location)
899 , m_specifierList(exportSpecifierList)
900 , m_moduleName(moduleName)
901 , m_assertionList(importAssertionList)
902 {
903 }
904
905 inline ExportSpecifierNode::ExportSpecifierNode(const JSTokenLocation& location, const Identifier& localName, const Identifier& exportedName)
906 : Node(location)
907 , m_localName(localName)
908 , m_exportedName(exportedName)
909 {
910 }
911
912 inline EmptyVarExpression::EmptyVarExpression(const JSTokenLocation& location, const Identifier& ident)
913 : ExpressionNode(location)
914 , m_ident(ident)
915 {
916 }
917
918 inline EmptyLetExpression::EmptyLetExpression(const JSTokenLocation& location, const Identifier& ident)
919 : ExpressionNode(location)
920 , m_ident(ident)
921 {
922 }
923
924 inline IfElseNode::IfElseNode(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock)
925 : StatementNode(location)
926 , m_condition(condition)
927 , m_ifBlock(ifBlock)
928 , m_elseBlock(elseBlock)
929 {
930 }
931
932 inline DoWhileNode::DoWhileNode(const JSTokenLocation& location, StatementNode* statement, ExpressionNode* expr)
933 : StatementNode(location)
934 , m_statement(statement)
935 , m_expr(expr)
936 {
937 }
938
939 inline WhileNode::WhileNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement)
940 : StatementNode(location)
941 , m_expr(expr)
942 , m_statement(statement)
943 {
944 }
945
946 inline ForNode::ForNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, VariableEnvironment&& lexicalVariables)
947 : StatementNode(location)
948 , VariableEnvironmentNode(WTFMove(lexicalVariables))
949 , m_expr1(expr1)
950 , m_expr2(expr2)
951 , m_expr3(expr3)
952 , m_statement(statement)
953 {
954 ASSERT(statement);
955 }
956
957 inline ContinueNode::ContinueNode(const JSTokenLocation& location, const Identifier& ident)
958 : StatementNode(location)
959 , m_ident(ident)
960 {
961 }
962
963 inline BreakNode::BreakNode(const JSTokenLocation& location, const Identifier& ident)
964 : StatementNode(location)
965 , m_ident(ident)
966 {
967 }
968
969 inline ReturnNode::ReturnNode(const JSTokenLocation& location, ExpressionNode* value)
970 : StatementNode(location)
971 , m_value(value)
972 {
973 if (m_value)
974 m_value->setIsOnlyChildOfStatement();
975 }
976
977 inline WithNode::WithNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement, const JSTextPosition& divot, uint32_t expressionLength)
978 : StatementNode(location)
979 , m_expr(expr)
980 , m_statement(statement)
981 , m_divot(divot)
982 , m_expressionLength(expressionLength)
983 {
984 }
985
986 inline LabelNode::LabelNode(const JSTokenLocation& location, const Identifier& name, StatementNode* statement)
987 : StatementNode(location)
988 , m_name(name)
989 , m_statement(statement)
990 {
991 }
992
993 inline ThrowNode::ThrowNode(const JSTokenLocation& location, ExpressionNode* expr)
994 : StatementNode(location)
995 , m_expr(expr)
996 {
997 m_expr->setIsOnlyChildOfStatement();
998 }
999
1000 inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, DestructuringPatternNode* catchPattern, StatementNode* catchBlock, VariableEnvironment&& catchEnvironment, StatementNode* finallyBlock)
1001 : StatementNode(location)
1002 , VariableEnvironmentNode(WTFMove(catchEnvironment))
1003 , m_tryBlock(tryBlock)
1004 , m_catchPattern(catchPattern)
1005 , m_catchBlock(catchBlock)
1006 , m_finallyBlock(finallyBlock)
1007 {
1008 }
1009
1010 inline FunctionParameters::FunctionParameters()
1011 {
1012 }
1013
1014
1015 inline BaseFuncExprNode::BaseFuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source, FunctionMode functionMode)
1016 : ExpressionNode(location)
1017 , m_metadata(metadata)
1018 {
1019 m_metadata->finishParsing(source, ident, functionMode);
1020 }
1021
1022 inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source)
1023 : BaseFuncExprNode(location, ident, metadata, source, FunctionMode::FunctionExpression)
1024 {
1025 }
1026
1027 inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source, FunctionMode functionMode)
1028 : BaseFuncExprNode(location, ident, metadata, source, functionMode)
1029 {
1030 }
1031
1032 inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source)
1033 : StatementNode(location)
1034 , m_metadata(metadata)
1035 {
1036 m_metadata->finishParsing(source, ident, FunctionMode::FunctionDeclaration);
1037 }
1038
1039 inline ArrowFuncExprNode::ArrowFuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source)
1040 : BaseFuncExprNode(location, ident, metadata, source, FunctionMode::FunctionExpression)
1041 {
1042 }
1043
1044 inline MethodDefinitionNode::MethodDefinitionNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source)
1045 : FuncExprNode(location, ident, metadata, source, FunctionMode::MethodDefinition)
1046 {
1047 }
1048
1049 inline YieldExprNode::YieldExprNode(const JSTokenLocation& location, ExpressionNode* argument, bool delegate)
1050 : ExpressionNode(location)
1051 , m_argument(argument)
1052 , m_delegate(delegate)
1053 {
1054 }
1055
1056 inline AwaitExprNode::AwaitExprNode(const JSTokenLocation& location, ExpressionNode* argument)
1057 : ExpressionNode(location)
1058 , m_argument(argument)
1059 {
1060 }
1061
1062 inline DefineFieldNode::DefineFieldNode(const JSTokenLocation& location, const Identifier* ident, ExpressionNode* assign, Type type)
1063 : StatementNode(location)
1064 , m_ident(ident)
1065 , m_assign(assign)
1066 , m_type(type)
1067 {
1068 }
1069
1070 inline ClassDeclNode::ClassDeclNode(const JSTokenLocation& location, ExpressionNode* classDeclaration)
1071 : StatementNode(location)
1072 , m_classDeclaration(classDeclaration)
1073 {
1074 }
1075
1076 inline ClassExprNode::ClassExprNode(const JSTokenLocation& location, const Identifier& name, const SourceCode& classSource, VariableEnvironment&& classHeadEnvironment, VariableEnvironment&& classEnvironment, ExpressionNode* constructorExpression, ExpressionNode* classHeritage, PropertyListNode* classElements)
1077 : ExpressionNode(location)
1078 , VariableEnvironmentNode(WTFMove(classEnvironment))
1079 , m_classHeadEnvironment(WTFMove(classHeadEnvironment))
1080 , m_classSource(classSource)
1081 , m_name(name)
1082 , m_ecmaName(&name)
1083 , m_constructorExpression(constructorExpression)
1084 , m_classHeritage(classHeritage)
1085 , m_classElements(classElements)
1086 , m_needsLexicalScope(PropertyListNode::shouldCreateLexicalScopeForClass(classElements))
1087 {
1088 }
1089
1090 inline CaseClauseNode::CaseClauseNode(ExpressionNode* expr, SourceElements* statements)
1091 : m_expr(expr)
1092 , m_statements(statements)
1093 {
1094 }
1095
1096 inline ClauseListNode::ClauseListNode(CaseClauseNode* clause)
1097 : m_clause(clause)
1098 {
1099 }
1100
1101 inline ClauseListNode::ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause)
1102 : m_clause(clause)
1103 {
1104 clauseList->m_next = this;
1105 }
1106
1107 inline CaseBlockNode::CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2)
1108 : m_list1(list1)
1109 , m_defaultClause(defaultClause)
1110 , m_list2(list2)
1111 {
1112 }
1113
1114 inline SwitchNode::SwitchNode(const JSTokenLocation& location, ExpressionNode* expr, CaseBlockNode* block, VariableEnvironment&& lexicalVariables, FunctionStack&& functionStack)
1115 : StatementNode(location)
1116 , VariableEnvironmentNode(WTFMove(lexicalVariables), WTFMove(functionStack))
1117 , m_expr(expr)
1118 , m_block(block)
1119 {
1120 }
1121
1122 inline BlockNode::BlockNode(const JSTokenLocation& location, SourceElements* statements, VariableEnvironment&& lexicalVariables, FunctionStack&& functionStack)
1123 : StatementNode(location)
1124 , VariableEnvironmentNode(WTFMove(lexicalVariables), WTFMove(functionStack))
1125 , m_statements(statements)
1126 {
1127 }
1128
1129 inline EnumerationNode::EnumerationNode(const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment&& lexicalVariables)
1130 : StatementNode(location)
1131 , VariableEnvironmentNode(WTFMove(lexicalVariables))
1132 , m_lexpr(lexpr)
1133 , m_expr(expr)
1134 , m_statement(statement)
1135 {
1136 ASSERT(lexpr);
1137 }
1138
1139 inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment&& lexicalVariables)
1140 : EnumerationNode(location, lexpr, expr, statement, WTFMove(lexicalVariables))
1141 {
1142 }
1143
1144 inline ForOfNode::ForOfNode(bool isForAwait, const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment&& lexicalVariables)
1145 : EnumerationNode(location, lexpr, expr, statement, WTFMove(lexicalVariables))
1146 , m_isForAwait(isForAwait)
1147 {
1148 }
1149
1150 inline DestructuringPatternNode::DestructuringPatternNode()
1151 {
1152 }
1153
1154 inline ArrayPatternNode::ArrayPatternNode()
1155 : DestructuringPatternNode()
1156 {
1157 }
1158
1159 inline ObjectPatternNode::ObjectPatternNode()
1160 : DestructuringPatternNode()
1161 {
1162 }
1163
1164 inline BindingNode::BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end, AssignmentContext context)
1165 : DestructuringPatternNode()
1166 , m_divotStart(start)
1167 , m_divotEnd(end)
1168 , m_boundProperty(boundProperty)
1169 , m_bindingContext(context)
1170 {
1171 }
1172
1173 inline AssignmentElementNode::AssignmentElementNode(ExpressionNode* assignmentTarget, const JSTextPosition& start, const JSTextPosition& end)
1174 : DestructuringPatternNode()
1175 , m_divotStart(start)
1176 , m_divotEnd(end)
1177 , m_assignmentTarget(assignmentTarget)
1178 {
1179 }
1180
1181 inline RestParameterNode::RestParameterNode(DestructuringPatternNode* pattern, unsigned numParametersToSkip)
1182 : DestructuringPatternNode()
1183 , m_pattern(pattern)
1184 , m_numParametersToSkip(numParametersToSkip)
1185 {
1186 ASSERT(!pattern->isRestParameter());
1187 }
1188
1189 inline DestructuringAssignmentNode::DestructuringAssignmentNode(const JSTokenLocation& location, DestructuringPatternNode* bindings, ExpressionNode* initializer)
1190 : ExpressionNode(location)
1191 , m_bindings(bindings)
1192 , m_initializer(initializer)
1193 {
1194 }
1195
1196} // namespace JSC
Note: See TracBrowser for help on using the repository browser.