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)
183 : ExpressionNode(location)
184 , m_expr(expr)
185 {
186 }
187
188 inline MetaPropertyNode::MetaPropertyNode(const JSTokenLocation& location)
189 : ExpressionNode(location)
190 {
191 }
192
193 inline NewTargetNode::NewTargetNode(const JSTokenLocation& location)
194 : MetaPropertyNode(location)
195 {
196 }
197
198 inline ImportMetaNode::ImportMetaNode(const JSTokenLocation& location, ExpressionNode* expr)
199 : MetaPropertyNode(location)
200 , m_expr(expr)
201 {
202 }
203
204 inline ResolveNode::ResolveNode(const JSTokenLocation& location, const Identifier& ident, const JSTextPosition& start)
205 : ExpressionNode(location)
206 , m_ident(ident)
207 , m_start(start)
208 {
209 ASSERT(m_start.offset >= m_start.lineStartOffset);
210 }
211
212 inline ElementNode::ElementNode(int elision, ExpressionNode* node)
213 : m_node(node)
214 , m_elision(elision)
215 {
216 }
217
218 inline ElementNode::ElementNode(ElementNode* l, int elision, ExpressionNode* node)
219 : m_node(node)
220 , m_elision(elision)
221 {
222 l->m_next = this;
223 }
224
225 inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision)
226 : ExpressionNode(location)
227 , m_element(nullptr)
228 , m_elision(elision)
229 , m_optional(true)
230 {
231 }
232
233 inline ArrayNode::ArrayNode(const JSTokenLocation& location, ElementNode* element)
234 : ExpressionNode(location)
235 , m_element(element)
236 , m_elision(0)
237 , m_optional(false)
238 {
239 }
240
241 inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision, ElementNode* element)
242 : ExpressionNode(location)
243 , m_element(element)
244 , m_elision(elision)
245 , m_optional(true)
246 {
247 }
248
249 inline PropertyNode::PropertyNode(const Identifier& name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding, ClassElementTag tag)
250 : m_name(&name)
251 , m_assign(assign)
252 , m_type(type)
253 , m_needsSuperBinding(superBinding == SuperBinding::Needed)
254 , m_putType(putType)
255 , m_classElementTag(static_cast<unsigned>(tag))
256 , m_isOverriddenByDuplicate(false)
257 {
258 }
259
260 inline PropertyNode::PropertyNode(ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding, ClassElementTag tag)
261 : m_name(nullptr)
262 , m_assign(assign)
263 , m_type(type)
264 , m_needsSuperBinding(superBinding == SuperBinding::Needed)
265 , m_putType(putType)
266 , m_classElementTag(static_cast<unsigned>(tag))
267 , m_isOverriddenByDuplicate(false)
268 {
269 }
270
271 inline PropertyNode::PropertyNode(ExpressionNode* name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding, ClassElementTag tag)
272 : m_name(nullptr)
273 , m_expression(name)
274 , m_assign(assign)
275 , m_type(type)
276 , m_needsSuperBinding(superBinding == SuperBinding::Needed)
277 , m_putType(putType)
278 , m_classElementTag(static_cast<unsigned>(tag))
279 , m_isOverriddenByDuplicate(false)
280 {
281 }
282
283 inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node)
284 : ExpressionNode(location)
285 , m_node(node)
286 {
287 }
288
289 inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node, PropertyListNode* list)
290 : ExpressionNode(location)
291 , m_node(node)
292 {
293 list->m_next = this;
294 }
295
296 inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location)
297 : ExpressionNode(location)
298 , m_list(nullptr)
299 {
300 }
301
302 inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location, PropertyListNode* list)
303 : ExpressionNode(location)
304 , m_list(list)
305 {
306 }
307
308 inline BracketAccessorNode::BracketAccessorNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments)
309 : ExpressionNode(location)
310 , m_base(base)
311 , m_subscript(subscript)
312 , m_subscriptHasAssignments(subscriptHasAssignments)
313 {
314 }
315
316 inline DotAccessorNode::DotAccessorNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident)
317 : ExpressionNode(location)
318 , m_base(base)
319 , m_ident(ident)
320 {
321 }
322
323
324 inline SpreadExpressionNode::SpreadExpressionNode(const JSTokenLocation& location, ExpressionNode* expression)
325 : ExpressionNode(location)
326 , m_expression(expression)
327 {
328 }
329
330 inline ObjectSpreadExpressionNode::ObjectSpreadExpressionNode(const JSTokenLocation& location, ExpressionNode* expression)
331 : ExpressionNode(location)
332 , m_expression(expression)
333 {
334 }
335
336 inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ExpressionNode* expr)
337 : ExpressionNode(location)
338 , m_expr(expr)
339 {
340 }
341
342 inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ArgumentListNode* listNode, ExpressionNode* expr)
343 : ExpressionNode(location)
344 , m_expr(expr)
345 {
346 listNode->m_next = this;
347 }
348
349 inline ArgumentsNode::ArgumentsNode()
350 : m_listNode(nullptr)
351 {
352 }
353
354 inline ArgumentsNode::ArgumentsNode(ArgumentListNode* listNode)
355 : m_listNode(listNode)
356 {
357 }
358
359 inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr)
360 : ExpressionNode(location)
361 , m_expr(expr)
362 , m_args(nullptr)
363 {
364 }
365
366 inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args)
367 : ExpressionNode(location)
368 , m_expr(expr)
369 , m_args(args)
370 {
371 }
372
373 inline EvalFunctionCallNode::EvalFunctionCallNode(const JSTokenLocation& location, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
374 : ExpressionNode(location)
375 , ThrowableExpressionData(divot, divotStart, divotEnd)
376 , m_args(args)
377 {
378 }
379
380 inline FunctionCallValueNode::FunctionCallValueNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
381 : ExpressionNode(location)
382 , ThrowableExpressionData(divot, divotStart, divotEnd)
383 , m_expr(expr)
384 , m_args(args)
385 {
386 ASSERT(divot.offset >= divotStart.offset);
387 }
388
389 inline FunctionCallResolveNode::FunctionCallResolveNode(const JSTokenLocation& location, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
390 : ExpressionNode(location)
391 , ThrowableExpressionData(divot, divotStart, divotEnd)
392 , m_ident(ident)
393 , m_args(args)
394 {
395 }
396
397 inline FunctionCallBracketNode::FunctionCallBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
398 : ExpressionNode(location)
399 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
400 , m_base(base)
401 , m_subscript(subscript)
402 , m_args(args)
403 , m_subscriptHasAssignments(subscriptHasAssignments)
404 {
405 }
406
407 inline FunctionCallDotNode::FunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
408 : ExpressionNode(location)
409 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
410 , m_base(base)
411 , m_ident(ident)
412 , m_args(args)
413 {
414 }
415
416 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)
417 : ExpressionNode(location)
418 , ThrowableExpressionData(divot, divotStart, divotEnd)
419 , m_entry(entry)
420 , m_ident(ident)
421 , m_args(args)
422 , m_type(type)
423 {
424 }
425
426 inline CallFunctionCallDotNode::CallFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd, size_t distanceToInnermostCallOrApply)
427 : FunctionCallDotNode(location, base, ident, args, divot, divotStart, divotEnd)
428 , m_distanceToInnermostCallOrApply(distanceToInnermostCallOrApply)
429 {
430 }
431
432 inline ApplyFunctionCallDotNode::ApplyFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd, size_t distanceToInnermostCallOrApply)
433 : FunctionCallDotNode(location, base, ident, args, divot, divotStart, divotEnd)
434 , m_distanceToInnermostCallOrApply(distanceToInnermostCallOrApply)
435 {
436 }
437
438 inline PostfixNode::PostfixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
439 : PrefixNode(location, expr, oper, divot, divotStart, divotEnd)
440 {
441 }
442
443 inline DeleteResolveNode::DeleteResolveNode(const JSTokenLocation& location, const Identifier& ident, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
444 : ExpressionNode(location)
445 , ThrowableExpressionData(divot, divotStart, divotEnd)
446 , m_ident(ident)
447 {
448 }
449
450 inline DeleteBracketNode::DeleteBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
451 : ExpressionNode(location)
452 , ThrowableExpressionData(divot, divotStart, divotEnd)
453 , m_base(base)
454 , m_subscript(subscript)
455 {
456 }
457
458 inline DeleteDotNode::DeleteDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
459 : ExpressionNode(location)
460 , ThrowableExpressionData(divot, divotStart, divotEnd)
461 , m_base(base)
462 , m_ident(ident)
463 {
464 }
465
466 inline DeleteValueNode::DeleteValueNode(const JSTokenLocation& location, ExpressionNode* expr)
467 : ExpressionNode(location)
468 , m_expr(expr)
469 {
470 }
471
472 inline VoidNode::VoidNode(const JSTokenLocation& location, ExpressionNode* expr)
473 : ExpressionNode(location)
474 , m_expr(expr)
475 {
476 }
477
478 inline TypeOfResolveNode::TypeOfResolveNode(const JSTokenLocation& location, const Identifier& ident)
479 : ExpressionNode(location, ResultType::stringType())
480 , m_ident(ident)
481 {
482 }
483
484 inline TypeOfValueNode::TypeOfValueNode(const JSTokenLocation& location, ExpressionNode* expr)
485 : ExpressionNode(location, ResultType::stringType())
486 , m_expr(expr)
487 {
488 }
489
490 inline PrefixNode::PrefixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
491 : ExpressionNode(location)
492 , ThrowablePrefixedSubExpressionData(divot, divotStart, divotEnd)
493 , m_expr(expr)
494 , m_operator(oper)
495 {
496 }
497
498 inline UnaryOpNode::UnaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr, OpcodeID opcodeID)
499 : ExpressionNode(location, type)
500 , m_expr(expr)
501 , m_opcodeID(opcodeID)
502 {
503 }
504
505 inline UnaryPlusNode::UnaryPlusNode(const JSTokenLocation& location, ExpressionNode* expr)
506 : UnaryOpNode(location, ResultType::numberType(), expr, op_to_number)
507 {
508 }
509
510 inline NegateNode::NegateNode(const JSTokenLocation& location, ExpressionNode* expr)
511 : UnaryOpNode(location, ResultType::numberType(), expr, op_negate)
512 {
513 }
514
515 inline BitwiseNotNode::BitwiseNotNode(const JSTokenLocation& location, ExpressionNode* expr)
516 : UnaryOpNode(location, ResultType::forBitOp(), expr, op_bitnot)
517 {
518 }
519
520 inline LogicalNotNode::LogicalNotNode(const JSTokenLocation& location, ExpressionNode* expr)
521 : UnaryOpNode(location, ResultType::booleanType(), expr, op_not)
522 {
523 }
524
525 inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
526 : ExpressionNode(location)
527 , m_rightHasAssignments(rightHasAssignments)
528 , m_opcodeID(opcodeID)
529 , m_expr1(expr1)
530 , m_expr2(expr2)
531 {
532 }
533
534 inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
535 : ExpressionNode(location, type)
536 , m_rightHasAssignments(rightHasAssignments)
537 , m_opcodeID(opcodeID)
538 , m_expr1(expr1)
539 , m_expr2(expr2)
540 {
541 }
542
543 inline PowNode::PowNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
544 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_pow, rightHasAssignments)
545 {
546 }
547
548 inline MultNode::MultNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
549 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mul, rightHasAssignments)
550 {
551 }
552
553 inline DivNode::DivNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
554 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_div, rightHasAssignments)
555 {
556 }
557
558
559 inline ModNode::ModNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
560 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mod, rightHasAssignments)
561 {
562 }
563
564 inline AddNode::AddNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
565 : BinaryOpNode(location, ResultType::forAdd(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_add, rightHasAssignments)
566 {
567 }
568
569 inline SubNode::SubNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
570 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_sub, rightHasAssignments)
571 {
572 }
573
574 inline LeftShiftNode::LeftShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
575 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_lshift, rightHasAssignments)
576 {
577 }
578
579 inline RightShiftNode::RightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
580 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_rshift, rightHasAssignments)
581 {
582 }
583
584 inline UnsignedRightShiftNode::UnsignedRightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
585 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_urshift, rightHasAssignments)
586 {
587 }
588
589 inline LessNode::LessNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
590 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
591 {
592 }
593
594 inline GreaterNode::GreaterNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
595 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greater, rightHasAssignments)
596 {
597 }
598
599 inline LessEqNode::LessEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
600 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
601 {
602 }
603
604 inline GreaterEqNode::GreaterEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
605 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greatereq, rightHasAssignments)
606 {
607 }
608
609 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
610 : BinaryOpNode(location, type, expr1, expr2, opcodeID, rightHasAssignments)
611 {
612 }
613
614 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
615 : BinaryOpNode(location, expr1, expr2, opcodeID, rightHasAssignments)
616 {
617 }
618
619 inline InstanceOfNode::InstanceOfNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
620 : ThrowableBinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_instanceof, rightHasAssignments)
621 {
622 }
623
624 inline InNode::InNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
625 : ThrowableBinaryOpNode(location, expr1, expr2, op_in_by_val, rightHasAssignments)
626 {
627 }
628
629 inline EqualNode::EqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
630 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_eq, rightHasAssignments)
631 {
632 }
633
634 inline NotEqualNode::NotEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
635 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_neq, rightHasAssignments)
636 {
637 }
638
639 inline StrictEqualNode::StrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
640 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_stricteq, rightHasAssignments)
641 {
642 }
643
644 inline NotStrictEqualNode::NotStrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
645 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_nstricteq, rightHasAssignments)
646 {
647 }
648
649 inline BitAndNode::BitAndNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
650 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitand, rightHasAssignments)
651 {
652 }
653
654 inline BitOrNode::BitOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
655 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitor, rightHasAssignments)
656 {
657 }
658
659 inline BitXOrNode::BitXOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
660 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitxor, rightHasAssignments)
661 {
662 }
663
664 inline LogicalOpNode::LogicalOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper)
665 : ExpressionNode(location, ResultType::forLogicalOp(expr1->resultDescriptor(), expr2->resultDescriptor()))
666 , m_operator(oper)
667 , m_expr1(expr1)
668 , m_expr2(expr2)
669 {
670 }
671
672 inline CoalesceNode::CoalesceNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool hasAbsorbedOptionalChain)
673 : ExpressionNode(location, ResultType::forCoalesce(expr1->resultDescriptor(), expr2->resultDescriptor()))
674 , m_expr1(expr1)
675 , m_expr2(expr2)
676 , m_hasAbsorbedOptionalChain(hasAbsorbedOptionalChain)
677 {
678 }
679
680 inline OptionalChainNode::OptionalChainNode(const JSTokenLocation& location, ExpressionNode* expr, bool isOutermost)
681 : ExpressionNode(location)
682 , m_expr(expr)
683 , m_isOutermost(isOutermost)
684 {
685 }
686
687 inline ConditionalNode::ConditionalNode(const JSTokenLocation& location, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2)
688 : ExpressionNode(location)
689 , m_logical(logical)
690 , m_expr1(expr1)
691 , m_expr2(expr2)
692 {
693 }
694
695 inline ReadModifyResolveNode::ReadModifyResolveNode(const JSTokenLocation& location, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
696 : ExpressionNode(location)
697 , ThrowableExpressionData(divot, divotStart, divotEnd)
698 , m_ident(ident)
699 , m_right(right)
700 , m_operator(oper)
701 , m_rightHasAssignments(rightHasAssignments)
702 {
703 }
704
705 inline AssignResolveNode::AssignResolveNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* right, AssignmentContext assignmentContext)
706 : ExpressionNode(location)
707 , m_ident(ident)
708 , m_right(right)
709 , m_assignmentContext(assignmentContext)
710 {
711 }
712
713
714 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)
715 : ExpressionNode(location)
716 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
717 , m_base(base)
718 , m_subscript(subscript)
719 , m_right(right)
720 , m_operator(oper)
721 , m_subscriptHasAssignments(subscriptHasAssignments)
722 , m_rightHasAssignments(rightHasAssignments)
723 {
724 }
725
726 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)
727 : ExpressionNode(location)
728 , ThrowableExpressionData(divot, divotStart, divotEnd)
729 , m_base(base)
730 , m_subscript(subscript)
731 , m_right(right)
732 , m_subscriptHasAssignments(subscriptHasAssignments)
733 , m_rightHasAssignments(rightHasAssignments)
734 {
735 }
736
737 inline AssignDotNode::AssignDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
738 : ExpressionNode(location)
739 , ThrowableExpressionData(divot, divotStart, divotEnd)
740 , m_base(base)
741 , m_ident(ident)
742 , m_right(right)
743 , m_rightHasAssignments(rightHasAssignments)
744 {
745 }
746
747 inline ReadModifyDotNode::ReadModifyDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
748 : ExpressionNode(location)
749 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
750 , m_base(base)
751 , m_ident(ident)
752 , m_right(right)
753 , m_operator(oper)
754 , m_rightHasAssignments(rightHasAssignments)
755 {
756 }
757
758 inline AssignErrorNode::AssignErrorNode(const JSTokenLocation& location, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
759 : ExpressionNode(location)
760 , ThrowableExpressionData(divot, divotStart, divotEnd)
761 {
762 }
763
764 inline CommaNode::CommaNode(const JSTokenLocation& location, ExpressionNode* expr)
765 : ExpressionNode(location)
766 , m_expr(expr)
767 {
768 }
769
770 inline SourceElements::SourceElements()
771 {
772 }
773
774 inline EmptyStatementNode::EmptyStatementNode(const JSTokenLocation& location)
775 : StatementNode(location)
776 {
777 }
778
779 inline DebuggerStatementNode::DebuggerStatementNode(const JSTokenLocation& location)
780 : StatementNode(location)
781 {
782 }
783
784 inline ExprStatementNode::ExprStatementNode(const JSTokenLocation& location, ExpressionNode* expr)
785 : StatementNode(location)
786 , m_expr(expr)
787 {
788 }
789
790 inline DeclarationStatement::DeclarationStatement(const JSTokenLocation& location, ExpressionNode* expr)
791 : StatementNode(location)
792 , m_expr(expr)
793 {
794 }
795
796 inline ModuleDeclarationNode::ModuleDeclarationNode(const JSTokenLocation& location)
797 : StatementNode(location)
798 {
799 }
800
801 inline ModuleNameNode::ModuleNameNode(const JSTokenLocation& location, const Identifier& moduleName)
802 : Node(location)
803 , m_moduleName(moduleName)
804 {
805 }
806
807 inline ImportSpecifierNode::ImportSpecifierNode(const JSTokenLocation& location, const Identifier& importedName, const Identifier& localName)
808 : Node(location)
809 , m_importedName(importedName)
810 , m_localName(localName)
811 {
812 }
813
814 inline ImportDeclarationNode::ImportDeclarationNode(const JSTokenLocation& location, ImportSpecifierListNode* importSpecifierList, ModuleNameNode* moduleName)
815 : ModuleDeclarationNode(location)
816 , m_specifierList(importSpecifierList)
817 , m_moduleName(moduleName)
818 {
819 }
820
821 inline ExportAllDeclarationNode::ExportAllDeclarationNode(const JSTokenLocation& location, ModuleNameNode* moduleName)
822 : ModuleDeclarationNode(location)
823 , m_moduleName(moduleName)
824 {
825 }
826
827 inline ExportDefaultDeclarationNode::ExportDefaultDeclarationNode(const JSTokenLocation& location, StatementNode* declaration, const Identifier& localName)
828 : ModuleDeclarationNode(location)
829 , m_declaration(declaration)
830 , m_localName(localName)
831 {
832 }
833
834 inline ExportLocalDeclarationNode::ExportLocalDeclarationNode(const JSTokenLocation& location, StatementNode* declaration)
835 : ModuleDeclarationNode(location)
836 , m_declaration(declaration)
837 {
838 }
839
840 inline ExportNamedDeclarationNode::ExportNamedDeclarationNode(const JSTokenLocation& location, ExportSpecifierListNode* exportSpecifierList, ModuleNameNode* moduleName)
841 : ModuleDeclarationNode(location)
842 , m_specifierList(exportSpecifierList)
843 , m_moduleName(moduleName)
844 {
845 }
846
847 inline ExportSpecifierNode::ExportSpecifierNode(const JSTokenLocation& location, const Identifier& localName, const Identifier& exportedName)
848 : Node(location)
849 , m_localName(localName)
850 , m_exportedName(exportedName)
851 {
852 }
853
854 inline EmptyVarExpression::EmptyVarExpression(const JSTokenLocation& location, const Identifier& ident)
855 : ExpressionNode(location)
856 , m_ident(ident)
857 {
858 }
859
860 inline EmptyLetExpression::EmptyLetExpression(const JSTokenLocation& location, const Identifier& ident)
861 : ExpressionNode(location)
862 , m_ident(ident)
863 {
864 }
865
866 inline IfElseNode::IfElseNode(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock)
867 : StatementNode(location)
868 , m_condition(condition)
869 , m_ifBlock(ifBlock)
870 , m_elseBlock(elseBlock)
871 {
872 }
873
874 inline DoWhileNode::DoWhileNode(const JSTokenLocation& location, StatementNode* statement, ExpressionNode* expr)
875 : StatementNode(location)
876 , m_statement(statement)
877 , m_expr(expr)
878 {
879 }
880
881 inline WhileNode::WhileNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement)
882 : StatementNode(location)
883 , m_expr(expr)
884 , m_statement(statement)
885 {
886 }
887
888 inline ForNode::ForNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, VariableEnvironment& lexicalVariables)
889 : StatementNode(location)
890 , VariableEnvironmentNode(lexicalVariables)
891 , m_expr1(expr1)
892 , m_expr2(expr2)
893 , m_expr3(expr3)
894 , m_statement(statement)
895 {
896 ASSERT(statement);
897 }
898
899 inline ContinueNode::ContinueNode(const JSTokenLocation& location, const Identifier& ident)
900 : StatementNode(location)
901 , m_ident(ident)
902 {
903 }
904
905 inline BreakNode::BreakNode(const JSTokenLocation& location, const Identifier& ident)
906 : StatementNode(location)
907 , m_ident(ident)
908 {
909 }
910
911 inline ReturnNode::ReturnNode(const JSTokenLocation& location, ExpressionNode* value)
912 : StatementNode(location)
913 , m_value(value)
914 {
915 }
916
917 inline WithNode::WithNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement, const JSTextPosition& divot, uint32_t expressionLength)
918 : StatementNode(location)
919 , m_expr(expr)
920 , m_statement(statement)
921 , m_divot(divot)
922 , m_expressionLength(expressionLength)
923 {
924 }
925
926 inline LabelNode::LabelNode(const JSTokenLocation& location, const Identifier& name, StatementNode* statement)
927 : StatementNode(location)
928 , m_name(name)
929 , m_statement(statement)
930 {
931 }
932
933 inline ThrowNode::ThrowNode(const JSTokenLocation& location, ExpressionNode* expr)
934 : StatementNode(location)
935 , m_expr(expr)
936 {
937 }
938
939 inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, DestructuringPatternNode* catchPattern, StatementNode* catchBlock, VariableEnvironment& catchEnvironment, StatementNode* finallyBlock)
940 : StatementNode(location)
941 , VariableEnvironmentNode(catchEnvironment)
942 , m_tryBlock(tryBlock)
943 , m_catchPattern(catchPattern)
944 , m_catchBlock(catchBlock)
945 , m_finallyBlock(finallyBlock)
946 {
947 }
948
949 inline FunctionParameters::FunctionParameters()
950 {
951 }
952
953
954 inline BaseFuncExprNode::BaseFuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source, FunctionMode functionMode)
955 : ExpressionNode(location)
956 , m_metadata(metadata)
957 {
958 m_metadata->finishParsing(source, ident, functionMode);
959 }
960
961 inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source)
962 : BaseFuncExprNode(location, ident, metadata, source, FunctionMode::FunctionExpression)
963 {
964 }
965
966 inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source, FunctionMode functionMode)
967 : BaseFuncExprNode(location, ident, metadata, source, functionMode)
968 {
969 }
970
971 inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source)
972 : StatementNode(location)
973 , m_metadata(metadata)
974 {
975 m_metadata->finishParsing(source, ident, FunctionMode::FunctionDeclaration);
976 }
977
978 inline ArrowFuncExprNode::ArrowFuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source)
979 : BaseFuncExprNode(location, ident, metadata, source, FunctionMode::FunctionExpression)
980 {
981 }
982
983 inline MethodDefinitionNode::MethodDefinitionNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* metadata, const SourceCode& source)
984 : FuncExprNode(location, ident, metadata, source, FunctionMode::MethodDefinition)
985 {
986 }
987
988 inline YieldExprNode::YieldExprNode(const JSTokenLocation& location, ExpressionNode* argument, bool delegate)
989 : ExpressionNode(location)
990 , m_argument(argument)
991 , m_delegate(delegate)
992 {
993 }
994
995 inline AwaitExprNode::AwaitExprNode(const JSTokenLocation& location, ExpressionNode* argument)
996 : ExpressionNode(location)
997 , m_argument(argument)
998 {
999 }
1000
1001 inline ClassDeclNode::ClassDeclNode(const JSTokenLocation& location, ExpressionNode* classDeclaration)
1002 : StatementNode(location)
1003 , m_classDeclaration(classDeclaration)
1004 {
1005 }
1006
1007 inline ClassExprNode::ClassExprNode(const JSTokenLocation& location, const Identifier& name, const SourceCode& classSource, VariableEnvironment& classEnvironment, ExpressionNode* constructorExpression, ExpressionNode* classHeritage, PropertyListNode* classElements)
1008 : ExpressionNode(location)
1009 , VariableEnvironmentNode(classEnvironment)
1010 , m_classSource(classSource)
1011 , m_name(name)
1012 , m_ecmaName(&name)
1013 , m_constructorExpression(constructorExpression)
1014 , m_classHeritage(classHeritage)
1015 , m_classElements(classElements)
1016 {
1017 }
1018
1019 inline CaseClauseNode::CaseClauseNode(ExpressionNode* expr, SourceElements* statements)
1020 : m_expr(expr)
1021 , m_statements(statements)
1022 {
1023 }
1024
1025 inline ClauseListNode::ClauseListNode(CaseClauseNode* clause)
1026 : m_clause(clause)
1027 {
1028 }
1029
1030 inline ClauseListNode::ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause)
1031 : m_clause(clause)
1032 {
1033 clauseList->m_next = this;
1034 }
1035
1036 inline CaseBlockNode::CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2)
1037 : m_list1(list1)
1038 , m_defaultClause(defaultClause)
1039 , m_list2(list2)
1040 {
1041 }
1042
1043 inline SwitchNode::SwitchNode(const JSTokenLocation& location, ExpressionNode* expr, CaseBlockNode* block, VariableEnvironment& lexicalVariables, FunctionStack&& functionStack)
1044 : StatementNode(location)
1045 , VariableEnvironmentNode(lexicalVariables, WTFMove(functionStack))
1046 , m_expr(expr)
1047 , m_block(block)
1048 {
1049 }
1050
1051 inline BlockNode::BlockNode(const JSTokenLocation& location, SourceElements* statements, VariableEnvironment& lexicalVariables, FunctionStack&& functionStack)
1052 : StatementNode(location)
1053 , VariableEnvironmentNode(lexicalVariables, WTFMove(functionStack))
1054 , m_statements(statements)
1055 {
1056 }
1057
1058 inline EnumerationNode::EnumerationNode(const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment& lexicalVariables)
1059 : StatementNode(location)
1060 , VariableEnvironmentNode(lexicalVariables)
1061 , m_lexpr(lexpr)
1062 , m_expr(expr)
1063 , m_statement(statement)
1064 {
1065 ASSERT(lexpr);
1066 }
1067
1068 inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment& lexicalVariables)
1069 : EnumerationNode(location, lexpr, expr, statement, lexicalVariables)
1070 {
1071 }
1072
1073 inline ForOfNode::ForOfNode(bool isForAwait, const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment& lexicalVariables)
1074 : EnumerationNode(location, lexpr, expr, statement, lexicalVariables)
1075 , m_isForAwait(isForAwait)
1076 {
1077 }
1078
1079 inline DestructuringPatternNode::DestructuringPatternNode()
1080 {
1081 }
1082
1083 inline ArrayPatternNode::ArrayPatternNode()
1084 : DestructuringPatternNode()
1085 {
1086 }
1087
1088 inline ObjectPatternNode::ObjectPatternNode()
1089 : DestructuringPatternNode()
1090 {
1091 }
1092
1093 inline BindingNode::BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end, AssignmentContext context)
1094 : DestructuringPatternNode()
1095 , m_divotStart(start)
1096 , m_divotEnd(end)
1097 , m_boundProperty(boundProperty)
1098 , m_bindingContext(context)
1099 {
1100 }
1101
1102 inline AssignmentElementNode::AssignmentElementNode(ExpressionNode* assignmentTarget, const JSTextPosition& start, const JSTextPosition& end)
1103 : DestructuringPatternNode()
1104 , m_divotStart(start)
1105 , m_divotEnd(end)
1106 , m_assignmentTarget(assignmentTarget)
1107 {
1108 }
1109
1110 inline RestParameterNode::RestParameterNode(DestructuringPatternNode* pattern, unsigned numParametersToSkip)
1111 : DestructuringPatternNode()
1112 , m_pattern(pattern)
1113 , m_numParametersToSkip(numParametersToSkip)
1114 {
1115 ASSERT(!pattern->isRestParameter());
1116 }
1117
1118 inline DestructuringAssignmentNode::DestructuringAssignmentNode(const JSTokenLocation& location, DestructuringPatternNode* bindings, ExpressionNode* initializer)
1119 : ExpressionNode(location)
1120 , m_bindings(bindings)
1121 , m_initializer(initializer)
1122 {
1123 }
1124
1125} // namespace JSC
1126