]> git.saurik.com Git - apple/javascriptcore.git/blob - parser/NodeConstructors.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / parser / NodeConstructors.h
1 /*
2 * Copyright (C) 2009, 2013 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 #ifndef NodeConstructors_h
22 #define NodeConstructors_h
23
24 #include "Nodes.h"
25 #include "Lexer.h"
26 #include "Parser.h"
27
28 namespace JSC {
29
30 inline void* ParserArenaFreeable::operator new(size_t size, ParserArena& parserArena)
31 {
32 return parserArena.allocateFreeable(size);
33 }
34
35 inline void* ParserArenaDeletable::operator new(size_t size, ParserArena& parserArena)
36 {
37 return parserArena.allocateDeletable(size);
38 }
39
40 inline ParserArenaRoot::ParserArenaRoot(ParserArena& parserArena)
41 {
42 m_arena.swap(parserArena);
43 }
44
45 inline Node::Node(const JSTokenLocation& location)
46 : m_position(location.line, location.startOffset, location.lineStartOffset)
47 , m_endOffset(-1)
48 {
49 ASSERT(location.startOffset >= location.lineStartOffset);
50 }
51
52 inline ExpressionNode::ExpressionNode(const JSTokenLocation& location, ResultType resultType)
53 : Node(location)
54 , m_resultType(resultType)
55 {
56 }
57
58 inline StatementNode::StatementNode(const JSTokenLocation& location)
59 : Node(location)
60 , m_next(nullptr)
61 , m_lastLine(-1)
62 {
63 }
64
65 inline ConstantNode::ConstantNode(const JSTokenLocation& location, ResultType resultType)
66 : ExpressionNode(location, resultType)
67 {
68 }
69
70 inline NullNode::NullNode(const JSTokenLocation& location)
71 : ConstantNode(location, ResultType::nullType())
72 {
73 }
74
75 inline BooleanNode::BooleanNode(const JSTokenLocation& location, bool value)
76 : ConstantNode(location, ResultType::booleanType())
77 , m_value(value)
78 {
79 }
80
81 inline NumberNode::NumberNode(const JSTokenLocation& location, double value)
82 : ConstantNode(location, JSValue(value).isInt32() ? ResultType::numberTypeIsInt32() : ResultType::numberType())
83 , m_value(value)
84 {
85 }
86
87 inline DoubleNode::DoubleNode(const JSTokenLocation& location, double value)
88 : NumberNode(location, value)
89 {
90 }
91
92 inline IntegerNode::IntegerNode(const JSTokenLocation& location, double value)
93 : DoubleNode(location, value)
94 {
95 }
96
97 inline StringNode::StringNode(const JSTokenLocation& location, const Identifier& value)
98 : ConstantNode(location, ResultType::stringType())
99 , m_value(value)
100 {
101 }
102
103 #if ENABLE(ES6_TEMPLATE_LITERAL_SYNTAX)
104 inline TemplateExpressionListNode::TemplateExpressionListNode(ExpressionNode* node)
105 : m_node(node)
106 {
107 }
108
109 inline TemplateExpressionListNode::TemplateExpressionListNode(TemplateExpressionListNode* previous, ExpressionNode* node)
110 : m_node(node)
111 {
112 previous->m_next = this;
113 }
114
115 inline TemplateStringNode::TemplateStringNode(const JSTokenLocation& location, const Identifier& cooked, const Identifier& raw)
116 : ExpressionNode(location)
117 , m_cooked(cooked)
118 , m_raw(raw)
119 {
120 }
121
122 inline TemplateStringListNode::TemplateStringListNode(TemplateStringNode* node)
123 : m_node(node)
124 {
125 }
126
127 inline TemplateStringListNode::TemplateStringListNode(TemplateStringListNode* previous, TemplateStringNode* node)
128 : m_node(node)
129 {
130 previous->m_next = this;
131 }
132
133 inline TemplateLiteralNode::TemplateLiteralNode(const JSTokenLocation& location, TemplateStringListNode* templateStrings)
134 : ExpressionNode(location)
135 , m_templateStrings(templateStrings)
136 , m_templateExpressions(nullptr)
137 {
138 }
139
140 inline TemplateLiteralNode::TemplateLiteralNode(const JSTokenLocation& location, TemplateStringListNode* templateStrings, TemplateExpressionListNode* templateExpressions)
141 : ExpressionNode(location)
142 , m_templateStrings(templateStrings)
143 , m_templateExpressions(templateExpressions)
144 {
145 }
146
147 inline TaggedTemplateNode::TaggedTemplateNode(const JSTokenLocation& location, ExpressionNode* tag, TemplateLiteralNode* templateLiteral)
148 : ExpressionNode(location)
149 , m_tag(tag)
150 , m_templateLiteral(templateLiteral)
151 {
152 }
153 #endif
154
155 inline RegExpNode::RegExpNode(const JSTokenLocation& location, const Identifier& pattern, const Identifier& flags)
156 : ExpressionNode(location)
157 , m_pattern(pattern)
158 , m_flags(flags)
159 {
160 }
161
162 inline ThisNode::ThisNode(const JSTokenLocation& location, ThisTDZMode thisTDZMode)
163 : ExpressionNode(location)
164 , m_shouldAlwaysEmitTDZCheck(thisTDZMode == ThisTDZMode::AlwaysCheck)
165 {
166 }
167
168 inline SuperNode::SuperNode(const JSTokenLocation& location)
169 : ExpressionNode(location)
170 {
171 }
172
173 inline ResolveNode::ResolveNode(const JSTokenLocation& location, const Identifier& ident, const JSTextPosition& start)
174 : ExpressionNode(location)
175 , m_ident(ident)
176 , m_start(start)
177 {
178 ASSERT(m_start.offset >= m_start.lineStartOffset);
179 }
180
181 inline ElementNode::ElementNode(int elision, ExpressionNode* node)
182 : m_next(0)
183 , m_elision(elision)
184 , m_node(node)
185 {
186 }
187
188 inline ElementNode::ElementNode(ElementNode* l, int elision, ExpressionNode* node)
189 : m_next(0)
190 , m_elision(elision)
191 , m_node(node)
192 {
193 l->m_next = this;
194 }
195
196 inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision)
197 : ExpressionNode(location)
198 , m_element(0)
199 , m_elision(elision)
200 , m_optional(true)
201 {
202 }
203
204 inline ArrayNode::ArrayNode(const JSTokenLocation& location, ElementNode* element)
205 : ExpressionNode(location)
206 , m_element(element)
207 , m_elision(0)
208 , m_optional(false)
209 {
210 }
211
212 inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision, ElementNode* element)
213 : ExpressionNode(location)
214 , m_element(element)
215 , m_elision(elision)
216 , m_optional(true)
217 {
218 }
219
220 inline PropertyNode::PropertyNode(const Identifier& name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding = SuperBinding::NotNeeded)
221 : m_name(&name)
222 , m_assign(assign)
223 , m_type(type)
224 , m_needsSuperBinding(superBinding == SuperBinding::Needed)
225 , m_putType(putType)
226 {
227 }
228
229 inline PropertyNode::PropertyNode(ExpressionNode* name, ExpressionNode* assign, Type type, PutType putType)
230 : m_name(0)
231 , m_expression(name)
232 , m_assign(assign)
233 , m_type(type)
234 , m_needsSuperBinding(false)
235 , m_putType(putType)
236 {
237 }
238
239 inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node)
240 : ExpressionNode(location)
241 , m_node(node)
242 , m_next(0)
243 {
244 }
245
246 inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node, PropertyListNode* list)
247 : ExpressionNode(location)
248 , m_node(node)
249 , m_next(0)
250 {
251 list->m_next = this;
252 }
253
254 inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location)
255 : ExpressionNode(location)
256 , m_list(0)
257 {
258 }
259
260 inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location, PropertyListNode* list)
261 : ExpressionNode(location)
262 , m_list(list)
263 {
264 }
265
266 inline BracketAccessorNode::BracketAccessorNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments)
267 : ExpressionNode(location)
268 , m_base(base)
269 , m_subscript(subscript)
270 , m_subscriptHasAssignments(subscriptHasAssignments)
271 {
272 }
273
274 inline DotAccessorNode::DotAccessorNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident)
275 : ExpressionNode(location)
276 , m_base(base)
277 , m_ident(ident)
278 {
279 }
280
281
282 inline SpreadExpressionNode::SpreadExpressionNode(const JSTokenLocation& location, ExpressionNode* expression)
283 : ExpressionNode(location)
284 , m_expression(expression)
285 {
286 }
287
288 inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ExpressionNode* expr)
289 : ExpressionNode(location)
290 , m_next(0)
291 , m_expr(expr)
292 {
293 }
294
295 inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ArgumentListNode* listNode, ExpressionNode* expr)
296 : ExpressionNode(location)
297 , m_next(0)
298 , m_expr(expr)
299 {
300 listNode->m_next = this;
301 }
302
303 inline ArgumentsNode::ArgumentsNode()
304 : m_listNode(0)
305 {
306 }
307
308 inline ArgumentsNode::ArgumentsNode(ArgumentListNode* listNode)
309 : m_listNode(listNode)
310 {
311 }
312
313 inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr)
314 : ExpressionNode(location)
315 , m_expr(expr)
316 , m_args(0)
317 {
318 }
319
320 inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args)
321 : ExpressionNode(location)
322 , m_expr(expr)
323 , m_args(args)
324 {
325 }
326
327 inline EvalFunctionCallNode::EvalFunctionCallNode(const JSTokenLocation& location, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
328 : ExpressionNode(location)
329 , ThrowableExpressionData(divot, divotStart, divotEnd)
330 , m_args(args)
331 {
332 }
333
334 inline FunctionCallValueNode::FunctionCallValueNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
335 : ExpressionNode(location)
336 , ThrowableExpressionData(divot, divotStart, divotEnd)
337 , m_expr(expr)
338 , m_args(args)
339 {
340 ASSERT(divot.offset >= divotStart.offset);
341 }
342
343 inline FunctionCallResolveNode::FunctionCallResolveNode(const JSTokenLocation& location, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
344 : ExpressionNode(location)
345 , ThrowableExpressionData(divot, divotStart, divotEnd)
346 , m_ident(ident)
347 , m_args(args)
348 {
349 }
350
351 inline FunctionCallBracketNode::FunctionCallBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
352 : ExpressionNode(location)
353 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
354 , m_base(base)
355 , m_subscript(subscript)
356 , m_args(args)
357 , m_subscriptHasAssignments(subscriptHasAssignments)
358 {
359 }
360
361 inline FunctionCallDotNode::FunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
362 : ExpressionNode(location)
363 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
364 , m_base(base)
365 , m_ident(ident)
366 , m_args(args)
367 {
368 }
369
370 inline BytecodeIntrinsicNode::BytecodeIntrinsicNode(const JSTokenLocation& location, EmitterType emitter, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
371 : ExpressionNode(location)
372 , ThrowableExpressionData(divot, divotStart, divotEnd)
373 , m_emitter(emitter)
374 , m_ident(ident)
375 , m_args(args)
376 {
377 }
378
379 inline CallFunctionCallDotNode::CallFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
380 : FunctionCallDotNode(location, base, ident, args, divot, divotStart, divotEnd)
381 {
382 }
383
384 inline ApplyFunctionCallDotNode::ApplyFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
385 : FunctionCallDotNode(location, base, ident, args, divot, divotStart, divotEnd)
386 {
387 }
388
389 inline PostfixNode::PostfixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
390 : PrefixNode(location, expr, oper, divot, divotStart, divotEnd)
391 {
392 }
393
394 inline DeleteResolveNode::DeleteResolveNode(const JSTokenLocation& location, const Identifier& ident, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
395 : ExpressionNode(location)
396 , ThrowableExpressionData(divot, divotStart, divotEnd)
397 , m_ident(ident)
398 {
399 }
400
401 inline DeleteBracketNode::DeleteBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
402 : ExpressionNode(location)
403 , ThrowableExpressionData(divot, divotStart, divotEnd)
404 , m_base(base)
405 , m_subscript(subscript)
406 {
407 }
408
409 inline DeleteDotNode::DeleteDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
410 : ExpressionNode(location)
411 , ThrowableExpressionData(divot, divotStart, divotEnd)
412 , m_base(base)
413 , m_ident(ident)
414 {
415 }
416
417 inline DeleteValueNode::DeleteValueNode(const JSTokenLocation& location, ExpressionNode* expr)
418 : ExpressionNode(location)
419 , m_expr(expr)
420 {
421 }
422
423 inline VoidNode::VoidNode(const JSTokenLocation& location, ExpressionNode* expr)
424 : ExpressionNode(location)
425 , m_expr(expr)
426 {
427 }
428
429 inline TypeOfResolveNode::TypeOfResolveNode(const JSTokenLocation& location, const Identifier& ident)
430 : ExpressionNode(location, ResultType::stringType())
431 , m_ident(ident)
432 {
433 }
434
435 inline TypeOfValueNode::TypeOfValueNode(const JSTokenLocation& location, ExpressionNode* expr)
436 : ExpressionNode(location, ResultType::stringType())
437 , m_expr(expr)
438 {
439 }
440
441 inline PrefixNode::PrefixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
442 : ExpressionNode(location)
443 , ThrowablePrefixedSubExpressionData(divot, divotStart, divotEnd)
444 , m_expr(expr)
445 , m_operator(oper)
446 {
447 }
448
449 inline UnaryOpNode::UnaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr, OpcodeID opcodeID)
450 : ExpressionNode(location, type)
451 , m_expr(expr)
452 , m_opcodeID(opcodeID)
453 {
454 }
455
456 inline UnaryPlusNode::UnaryPlusNode(const JSTokenLocation& location, ExpressionNode* expr)
457 : UnaryOpNode(location, ResultType::numberType(), expr, op_to_number)
458 {
459 }
460
461 inline NegateNode::NegateNode(const JSTokenLocation& location, ExpressionNode* expr)
462 : UnaryOpNode(location, ResultType::numberType(), expr, op_negate)
463 {
464 }
465
466 inline BitwiseNotNode::BitwiseNotNode(const JSTokenLocation& location, ExpressionNode* expr)
467 : ExpressionNode(location, ResultType::forBitOp())
468 , m_expr(expr)
469 {
470 }
471
472 inline LogicalNotNode::LogicalNotNode(const JSTokenLocation& location, ExpressionNode* expr)
473 : UnaryOpNode(location, ResultType::booleanType(), expr, op_not)
474 {
475 }
476
477 inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
478 : ExpressionNode(location)
479 , m_expr1(expr1)
480 , m_expr2(expr2)
481 , m_opcodeID(opcodeID)
482 , m_rightHasAssignments(rightHasAssignments)
483 {
484 }
485
486 inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
487 : ExpressionNode(location, type)
488 , m_expr1(expr1)
489 , m_expr2(expr2)
490 , m_opcodeID(opcodeID)
491 , m_rightHasAssignments(rightHasAssignments)
492 {
493 }
494
495 inline MultNode::MultNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
496 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mul, rightHasAssignments)
497 {
498 }
499
500 inline DivNode::DivNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
501 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_div, rightHasAssignments)
502 {
503 }
504
505
506 inline ModNode::ModNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
507 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mod, rightHasAssignments)
508 {
509 }
510
511 inline AddNode::AddNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
512 : BinaryOpNode(location, ResultType::forAdd(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_add, rightHasAssignments)
513 {
514 }
515
516 inline SubNode::SubNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
517 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_sub, rightHasAssignments)
518 {
519 }
520
521 inline LeftShiftNode::LeftShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
522 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_lshift, rightHasAssignments)
523 {
524 }
525
526 inline RightShiftNode::RightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
527 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_rshift, rightHasAssignments)
528 {
529 }
530
531 inline UnsignedRightShiftNode::UnsignedRightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
532 : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_urshift, rightHasAssignments)
533 {
534 }
535
536 inline LessNode::LessNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
537 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
538 {
539 }
540
541 inline GreaterNode::GreaterNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
542 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greater, rightHasAssignments)
543 {
544 }
545
546 inline LessEqNode::LessEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
547 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
548 {
549 }
550
551 inline GreaterEqNode::GreaterEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
552 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greatereq, rightHasAssignments)
553 {
554 }
555
556 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
557 : BinaryOpNode(location, type, expr1, expr2, opcodeID, rightHasAssignments)
558 {
559 }
560
561 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
562 : BinaryOpNode(location, expr1, expr2, opcodeID, rightHasAssignments)
563 {
564 }
565
566 inline InstanceOfNode::InstanceOfNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
567 : ThrowableBinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_instanceof, rightHasAssignments)
568 {
569 }
570
571 inline InNode::InNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
572 : ThrowableBinaryOpNode(location, expr1, expr2, op_in, rightHasAssignments)
573 {
574 }
575
576 inline EqualNode::EqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
577 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_eq, rightHasAssignments)
578 {
579 }
580
581 inline NotEqualNode::NotEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
582 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_neq, rightHasAssignments)
583 {
584 }
585
586 inline StrictEqualNode::StrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
587 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_stricteq, rightHasAssignments)
588 {
589 }
590
591 inline NotStrictEqualNode::NotStrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
592 : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_nstricteq, rightHasAssignments)
593 {
594 }
595
596 inline BitAndNode::BitAndNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
597 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitand, rightHasAssignments)
598 {
599 }
600
601 inline BitOrNode::BitOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
602 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitor, rightHasAssignments)
603 {
604 }
605
606 inline BitXOrNode::BitXOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
607 : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitxor, rightHasAssignments)
608 {
609 }
610
611 inline LogicalOpNode::LogicalOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper)
612 : ExpressionNode(location, ResultType::forLogicalOp(expr1->resultDescriptor(), expr2->resultDescriptor()))
613 , m_expr1(expr1)
614 , m_expr2(expr2)
615 , m_operator(oper)
616 {
617 }
618
619 inline ConditionalNode::ConditionalNode(const JSTokenLocation& location, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2)
620 : ExpressionNode(location)
621 , m_logical(logical)
622 , m_expr1(expr1)
623 , m_expr2(expr2)
624 {
625 }
626
627 inline ReadModifyResolveNode::ReadModifyResolveNode(const JSTokenLocation& location, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
628 : ExpressionNode(location)
629 , ThrowableExpressionData(divot, divotStart, divotEnd)
630 , m_ident(ident)
631 , m_right(right)
632 , m_operator(oper)
633 , m_rightHasAssignments(rightHasAssignments)
634 {
635 }
636
637 inline AssignResolveNode::AssignResolveNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* right)
638 : ExpressionNode(location)
639 , m_ident(ident)
640 , m_right(right)
641 {
642 }
643
644
645 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)
646 : ExpressionNode(location)
647 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
648 , m_base(base)
649 , m_subscript(subscript)
650 , m_right(right)
651 , m_operator(oper)
652 , m_subscriptHasAssignments(subscriptHasAssignments)
653 , m_rightHasAssignments(rightHasAssignments)
654 {
655 }
656
657 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)
658 : ExpressionNode(location)
659 , ThrowableExpressionData(divot, divotStart, divotEnd)
660 , m_base(base)
661 , m_subscript(subscript)
662 , m_right(right)
663 , m_subscriptHasAssignments(subscriptHasAssignments)
664 , m_rightHasAssignments(rightHasAssignments)
665 {
666 }
667
668 inline AssignDotNode::AssignDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
669 : ExpressionNode(location)
670 , ThrowableExpressionData(divot, divotStart, divotEnd)
671 , m_base(base)
672 , m_ident(ident)
673 , m_right(right)
674 , m_rightHasAssignments(rightHasAssignments)
675 {
676 }
677
678 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)
679 : ExpressionNode(location)
680 , ThrowableSubExpressionData(divot, divotStart, divotEnd)
681 , m_base(base)
682 , m_ident(ident)
683 , m_right(right)
684 , m_operator(oper)
685 , m_rightHasAssignments(rightHasAssignments)
686 {
687 }
688
689 inline AssignErrorNode::AssignErrorNode(const JSTokenLocation& location, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
690 : ExpressionNode(location)
691 , ThrowableExpressionData(divot, divotStart, divotEnd)
692 {
693 }
694
695 inline CommaNode::CommaNode(const JSTokenLocation& location, ExpressionNode* expr)
696 : ExpressionNode(location)
697 , m_expr(expr)
698 , m_next(nullptr)
699 {
700 }
701
702 inline ConstStatementNode::ConstStatementNode(const JSTokenLocation& location, ConstDeclNode* next)
703 : StatementNode(location)
704 , m_next(next)
705 {
706 }
707
708 inline SourceElements::SourceElements()
709 : m_head(nullptr)
710 , m_tail(nullptr)
711 {
712 }
713
714 inline EmptyStatementNode::EmptyStatementNode(const JSTokenLocation& location)
715 : StatementNode(location)
716 {
717 }
718
719 inline DebuggerStatementNode::DebuggerStatementNode(const JSTokenLocation& location)
720 : StatementNode(location)
721 {
722 }
723
724 inline ExprStatementNode::ExprStatementNode(const JSTokenLocation& location, ExpressionNode* expr)
725 : StatementNode(location)
726 , m_expr(expr)
727 {
728 }
729
730 inline VarStatementNode::VarStatementNode(const JSTokenLocation& location, ExpressionNode* expr)
731 : StatementNode(location)
732 , m_expr(expr)
733 {
734 }
735
736 inline EmptyVarExpression::EmptyVarExpression(const JSTokenLocation& location, const Identifier& ident)
737 : ExpressionNode(location)
738 , m_ident(ident)
739 {
740 }
741
742 inline IfElseNode::IfElseNode(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock)
743 : StatementNode(location)
744 , m_condition(condition)
745 , m_ifBlock(ifBlock)
746 , m_elseBlock(elseBlock)
747 {
748 }
749
750 inline DoWhileNode::DoWhileNode(const JSTokenLocation& location, StatementNode* statement, ExpressionNode* expr)
751 : StatementNode(location)
752 , m_statement(statement)
753 , m_expr(expr)
754 {
755 }
756
757 inline WhileNode::WhileNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement)
758 : StatementNode(location)
759 , m_expr(expr)
760 , m_statement(statement)
761 {
762 }
763
764 inline ForNode::ForNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement)
765 : StatementNode(location)
766 , m_expr1(expr1)
767 , m_expr2(expr2)
768 , m_expr3(expr3)
769 , m_statement(statement)
770 {
771 ASSERT(statement);
772 }
773
774 inline ContinueNode::ContinueNode(const JSTokenLocation& location, const Identifier& ident)
775 : StatementNode(location)
776 , m_ident(ident)
777 {
778 }
779
780 inline BreakNode::BreakNode(const JSTokenLocation& location, const Identifier& ident)
781 : StatementNode(location)
782 , m_ident(ident)
783 {
784 }
785
786 inline ReturnNode::ReturnNode(const JSTokenLocation& location, ExpressionNode* value)
787 : StatementNode(location)
788 , m_value(value)
789 {
790 }
791
792 inline WithNode::WithNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement, const JSTextPosition& divot, uint32_t expressionLength)
793 : StatementNode(location)
794 , m_expr(expr)
795 , m_statement(statement)
796 , m_divot(divot)
797 , m_expressionLength(expressionLength)
798 {
799 }
800
801 inline LabelNode::LabelNode(const JSTokenLocation& location, const Identifier& name, StatementNode* statement)
802 : StatementNode(location)
803 , m_name(name)
804 , m_statement(statement)
805 {
806 }
807
808 inline ThrowNode::ThrowNode(const JSTokenLocation& location, ExpressionNode* expr)
809 : StatementNode(location)
810 , m_expr(expr)
811 {
812 }
813
814 inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, const Identifier& thrownValueIdent, StatementNode* catchBlock, StatementNode* finallyBlock)
815 : StatementNode(location)
816 , m_tryBlock(tryBlock)
817 , m_thrownValueIdent(thrownValueIdent)
818 , m_catchBlock(catchBlock)
819 , m_finallyBlock(finallyBlock)
820 {
821 }
822
823 inline ParameterNode::ParameterNode(PassRefPtr<DestructuringPatternNode> pattern)
824 : m_pattern(pattern)
825 , m_next(0)
826 {
827 ASSERT(m_pattern);
828 }
829
830 inline ParameterNode::ParameterNode(ParameterNode* previous, PassRefPtr<DestructuringPatternNode> pattern)
831 : m_pattern(pattern)
832 , m_next(0)
833 {
834 previous->m_next = this;
835 ASSERT(m_pattern);
836 ASSERT(previous->m_pattern);
837 }
838
839 inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
840 : ExpressionNode(location)
841 , m_body(body)
842 {
843 m_body->finishParsing(source, parameter, ident, FunctionExpression);
844 }
845
846 inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
847 : StatementNode(location)
848 , m_body(body)
849 {
850 m_body->finishParsing(source, parameter, ident, FunctionDeclaration);
851 }
852
853 #if ENABLE(ES6_CLASS_SYNTAX)
854 inline ClassDeclNode::ClassDeclNode(const JSTokenLocation& location, ExpressionNode* classDeclaration)
855 : StatementNode(location)
856 , m_classDeclaration(classDeclaration)
857 {
858 }
859
860 inline ClassExprNode::ClassExprNode(const JSTokenLocation& location, const Identifier& name, ExpressionNode* constructorExpression, ExpressionNode* classHeritage, PropertyListNode* instanceMethods, PropertyListNode* staticMethods)
861 : ExpressionNode(location)
862 , m_name(name)
863 , m_constructorExpression(constructorExpression)
864 , m_classHeritage(classHeritage)
865 , m_instanceMethods(instanceMethods)
866 , m_staticMethods(staticMethods)
867 {
868 }
869 #endif
870
871 inline CaseClauseNode::CaseClauseNode(ExpressionNode* expr, SourceElements* statements)
872 : m_expr(expr)
873 , m_statements(statements)
874 {
875 }
876
877 inline ClauseListNode::ClauseListNode(CaseClauseNode* clause)
878 : m_clause(clause)
879 , m_next(0)
880 {
881 }
882
883 inline ClauseListNode::ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause)
884 : m_clause(clause)
885 , m_next(0)
886 {
887 clauseList->m_next = this;
888 }
889
890 inline CaseBlockNode::CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2)
891 : m_list1(list1)
892 , m_defaultClause(defaultClause)
893 , m_list2(list2)
894 {
895 }
896
897 inline SwitchNode::SwitchNode(const JSTokenLocation& location, ExpressionNode* expr, CaseBlockNode* block)
898 : StatementNode(location)
899 , m_expr(expr)
900 , m_block(block)
901 {
902 }
903
904 inline ConstDeclNode::ConstDeclNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* init)
905 : ExpressionNode(location)
906 , m_ident(ident)
907 , m_next(0)
908 , m_init(init)
909 {
910 }
911
912 inline BlockNode::BlockNode(const JSTokenLocation& location, SourceElements* statements)
913 : StatementNode(location)
914 , m_statements(statements)
915 {
916 }
917
918 inline EnumerationNode::EnumerationNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
919 : StatementNode(location)
920 , m_lexpr(l)
921 , m_expr(expr)
922 , m_statement(statement)
923 {
924 ASSERT(l);
925 }
926
927 inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
928 : EnumerationNode(location, l, expr, statement)
929 {
930 }
931
932 inline ForOfNode::ForOfNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
933 : EnumerationNode(location, l, expr, statement)
934 {
935 }
936
937 inline DestructuringPatternNode::DestructuringPatternNode()
938 {
939 }
940
941 inline ArrayPatternNode::ArrayPatternNode()
942 : DestructuringPatternNode()
943 {
944 }
945
946 inline Ref<ArrayPatternNode> ArrayPatternNode::create()
947 {
948 return adoptRef(*new ArrayPatternNode);
949 }
950
951 inline ObjectPatternNode::ObjectPatternNode()
952 : DestructuringPatternNode()
953 {
954 }
955
956 inline Ref<ObjectPatternNode> ObjectPatternNode::create()
957 {
958 return adoptRef(*new ObjectPatternNode);
959 }
960
961 inline Ref<BindingNode> BindingNode::create(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end)
962 {
963 return adoptRef(*new BindingNode(boundProperty, start, end));
964 }
965
966 inline BindingNode::BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end)
967 : DestructuringPatternNode()
968 , m_divotStart(start)
969 , m_divotEnd(end)
970 , m_boundProperty(boundProperty)
971 {
972 }
973
974 inline DestructuringAssignmentNode::DestructuringAssignmentNode(const JSTokenLocation& location, PassRefPtr<DestructuringPatternNode> bindings, ExpressionNode* initializer)
975 : ExpressionNode(location)
976 , m_bindings(bindings)
977 , m_initializer(initializer)
978 {
979 }
980
981 } // namespace JSC
982
983 #endif // NodeConstructors_h