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