1/*
2 * Copyright (C) 2009 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
28namespace JSC {
29
30 inline ParserArenaRefCounted::ParserArenaRefCounted(JSGlobalData* globalData)
31 {
32 globalData->parser->arena().derefWithArena(adoptRef(p: this));
33 }
34
35 inline Node::Node(JSGlobalData* globalData)
36 : m_line(globalData->lexer->lineNumber())
37 {
38 }
39
40 inline ExpressionNode::ExpressionNode(JSGlobalData* globalData, ResultType resultType)
41 : Node(globalData)
42 , m_resultType(resultType)
43 {
44 }
45
46 inline StatementNode::StatementNode(JSGlobalData* globalData)
47 : Node(globalData)
48 , m_lastLine(-1)
49 {
50 }
51
52 inline NullNode::NullNode(JSGlobalData* globalData)
53 : ExpressionNode(globalData, ResultType::nullType())
54 {
55 }
56
57 inline BooleanNode::BooleanNode(JSGlobalData* globalData, bool value)
58 : ExpressionNode(globalData, ResultType::booleanType())
59 , m_value(value)
60 {
61 }
62
63 inline NumberNode::NumberNode(JSGlobalData* globalData, double value)
64 : ExpressionNode(globalData, ResultType::numberType())
65 , m_value(value)
66 {
67 }
68
69 inline StringNode::StringNode(JSGlobalData* globalData, const Identifier& value)
70 : ExpressionNode(globalData, ResultType::stringType())
71 , m_value(value)
72 {
73 }
74
75 inline RegExpNode::RegExpNode(JSGlobalData* globalData, const Identifier& pattern, const Identifier& flags)
76 : ExpressionNode(globalData)
77 , m_pattern(pattern)
78 , m_flags(flags)
79 {
80 }
81
82 inline ThisNode::ThisNode(JSGlobalData* globalData)
83 : ExpressionNode(globalData)
84 {
85 }
86
87 inline ResolveNode::ResolveNode(JSGlobalData* globalData, const Identifier& ident, int startOffset)
88 : ExpressionNode(globalData)
89 , m_ident(ident)
90 , m_startOffset(startOffset)
91 {
92 }
93
94 inline ElementNode::ElementNode(JSGlobalData*, int elision, ExpressionNode* node)
95 : m_next(0)
96 , m_elision(elision)
97 , m_node(node)
98 {
99 }
100
101 inline ElementNode::ElementNode(JSGlobalData*, ElementNode* l, int elision, ExpressionNode* node)
102 : m_next(0)
103 , m_elision(elision)
104 , m_node(node)
105 {
106 l->m_next = this;
107 }
108
109 inline ArrayNode::ArrayNode(JSGlobalData* globalData, int elision)
110 : ExpressionNode(globalData)
111 , m_element(0)
112 , m_elision(elision)
113 , m_optional(true)
114 {
115 }
116
117 inline ArrayNode::ArrayNode(JSGlobalData* globalData, ElementNode* element)
118 : ExpressionNode(globalData)
119 , m_element(element)
120 , m_elision(0)
121 , m_optional(false)
122 {
123 }
124
125 inline ArrayNode::ArrayNode(JSGlobalData* globalData, int elision, ElementNode* element)
126 : ExpressionNode(globalData)
127 , m_element(element)
128 , m_elision(elision)
129 , m_optional(true)
130 {
131 }
132
133 inline PropertyNode::PropertyNode(JSGlobalData*, const Identifier& name, ExpressionNode* assign, Type type)
134 : m_name(name)
135 , m_assign(assign)
136 , m_type(type)
137 {
138 }
139
140 inline PropertyNode::PropertyNode(JSGlobalData* globalData, double name, ExpressionNode* assign, Type type)
141 : m_name(globalData->parser->arena().identifierArena().makeNumericIdentifier(globalData, number: name))
142 , m_assign(assign)
143 , m_type(type)
144 {
145 }
146
147 inline PropertyListNode::PropertyListNode(JSGlobalData* globalData, PropertyNode* node)
148 : Node(globalData)
149 , m_node(node)
150 , m_next(0)
151 {
152 }
153
154 inline PropertyListNode::PropertyListNode(JSGlobalData* globalData, PropertyNode* node, PropertyListNode* list)
155 : Node(globalData)
156 , m_node(node)
157 , m_next(0)
158 {
159 list->m_next = this;
160 }
161
162 inline ObjectLiteralNode::ObjectLiteralNode(JSGlobalData* globalData)
163 : ExpressionNode(globalData)
164 , m_list(0)
165 {
166 }
167
168 inline ObjectLiteralNode::ObjectLiteralNode(JSGlobalData* globalData, PropertyListNode* list)
169 : ExpressionNode(globalData)
170 , m_list(list)
171 {
172 }
173
174 inline BracketAccessorNode::BracketAccessorNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments)
175 : ExpressionNode(globalData)
176 , m_base(base)
177 , m_subscript(subscript)
178 , m_subscriptHasAssignments(subscriptHasAssignments)
179 {
180 }
181
182 inline DotAccessorNode::DotAccessorNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident)
183 : ExpressionNode(globalData)
184 , m_base(base)
185 , m_ident(ident)
186 {
187 }
188
189 inline ArgumentListNode::ArgumentListNode(JSGlobalData* globalData, ExpressionNode* expr)
190 : Node(globalData)
191 , m_next(0)
192 , m_expr(expr)
193 {
194 }
195
196 inline ArgumentListNode::ArgumentListNode(JSGlobalData* globalData, ArgumentListNode* listNode, ExpressionNode* expr)
197 : Node(globalData)
198 , m_next(0)
199 , m_expr(expr)
200 {
201 listNode->m_next = this;
202 }
203
204 inline ArgumentsNode::ArgumentsNode(JSGlobalData*)
205 : m_listNode(0)
206 {
207 }
208
209 inline ArgumentsNode::ArgumentsNode(JSGlobalData*, ArgumentListNode* listNode)
210 : m_listNode(listNode)
211 {
212 }
213
214 inline NewExprNode::NewExprNode(JSGlobalData* globalData, ExpressionNode* expr)
215 : ExpressionNode(globalData)
216 , m_expr(expr)
217 , m_args(0)
218 {
219 }
220
221 inline NewExprNode::NewExprNode(JSGlobalData* globalData, ExpressionNode* expr, ArgumentsNode* args)
222 : ExpressionNode(globalData)
223 , m_expr(expr)
224 , m_args(args)
225 {
226 }
227
228 inline EvalFunctionCallNode::EvalFunctionCallNode(JSGlobalData* globalData, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
229 : ExpressionNode(globalData)
230 , ThrowableExpressionData(divot, startOffset, endOffset)
231 , m_args(args)
232 {
233 }
234
235 inline FunctionCallValueNode::FunctionCallValueNode(JSGlobalData* globalData, ExpressionNode* expr, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
236 : ExpressionNode(globalData)
237 , ThrowableExpressionData(divot, startOffset, endOffset)
238 , m_expr(expr)
239 , m_args(args)
240 {
241 }
242
243 inline FunctionCallResolveNode::FunctionCallResolveNode(JSGlobalData* globalData, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
244 : ExpressionNode(globalData)
245 , ThrowableExpressionData(divot, startOffset, endOffset)
246 , m_ident(ident)
247 , m_args(args)
248 {
249 }
250
251 inline FunctionCallBracketNode::FunctionCallBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
252 : ExpressionNode(globalData)
253 , ThrowableSubExpressionData(divot, startOffset, endOffset)
254 , m_base(base)
255 , m_subscript(subscript)
256 , m_args(args)
257 {
258 }
259
260 inline FunctionCallDotNode::FunctionCallDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
261 : ExpressionNode(globalData)
262 , ThrowableSubExpressionData(divot, startOffset, endOffset)
263 , m_base(base)
264 , m_ident(ident)
265 , m_args(args)
266 {
267 }
268
269 inline CallFunctionCallDotNode::CallFunctionCallDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
270 : FunctionCallDotNode(globalData, base, ident, args, divot, startOffset, endOffset)
271 {
272 }
273
274 inline ApplyFunctionCallDotNode::ApplyFunctionCallDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
275 : FunctionCallDotNode(globalData, base, ident, args, divot, startOffset, endOffset)
276 {
277 }
278
279 inline PrePostResolveNode::PrePostResolveNode(JSGlobalData* globalData, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset)
280 : ExpressionNode(globalData, ResultType::numberType()) // could be reusable for pre?
281 , ThrowableExpressionData(divot, startOffset, endOffset)
282 , m_ident(ident)
283 {
284 }
285
286 inline PostfixResolveNode::PostfixResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
287 : PrePostResolveNode(globalData, ident, divot, startOffset, endOffset)
288 , m_operator(oper)
289 {
290 }
291
292 inline PostfixBracketNode::PostfixBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
293 : ExpressionNode(globalData)
294 , ThrowableSubExpressionData(divot, startOffset, endOffset)
295 , m_base(base)
296 , m_subscript(subscript)
297 , m_operator(oper)
298 {
299 }
300
301 inline PostfixDotNode::PostfixDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
302 : ExpressionNode(globalData)
303 , ThrowableSubExpressionData(divot, startOffset, endOffset)
304 , m_base(base)
305 , m_ident(ident)
306 , m_operator(oper)
307 {
308 }
309
310 inline PostfixErrorNode::PostfixErrorNode(JSGlobalData* globalData, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
311 : ExpressionNode(globalData)
312 , ThrowableSubExpressionData(divot, startOffset, endOffset)
313 , m_expr(expr)
314 , m_operator(oper)
315 {
316 }
317
318 inline DeleteResolveNode::DeleteResolveNode(JSGlobalData* globalData, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset)
319 : ExpressionNode(globalData)
320 , ThrowableExpressionData(divot, startOffset, endOffset)
321 , m_ident(ident)
322 {
323 }
324
325 inline DeleteBracketNode::DeleteBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, unsigned divot, unsigned startOffset, unsigned endOffset)
326 : ExpressionNode(globalData)
327 , ThrowableExpressionData(divot, startOffset, endOffset)
328 , m_base(base)
329 , m_subscript(subscript)
330 {
331 }
332
333 inline DeleteDotNode::DeleteDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset)
334 : ExpressionNode(globalData)
335 , ThrowableExpressionData(divot, startOffset, endOffset)
336 , m_base(base)
337 , m_ident(ident)
338 {
339 }
340
341 inline DeleteValueNode::DeleteValueNode(JSGlobalData* globalData, ExpressionNode* expr)
342 : ExpressionNode(globalData)
343 , m_expr(expr)
344 {
345 }
346
347 inline VoidNode::VoidNode(JSGlobalData* globalData, ExpressionNode* expr)
348 : ExpressionNode(globalData)
349 , m_expr(expr)
350 {
351 }
352
353 inline TypeOfResolveNode::TypeOfResolveNode(JSGlobalData* globalData, const Identifier& ident)
354 : ExpressionNode(globalData, ResultType::stringType())
355 , m_ident(ident)
356 {
357 }
358
359 inline TypeOfValueNode::TypeOfValueNode(JSGlobalData* globalData, ExpressionNode* expr)
360 : ExpressionNode(globalData, ResultType::stringType())
361 , m_expr(expr)
362 {
363 }
364
365 inline PrefixResolveNode::PrefixResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
366 : PrePostResolveNode(globalData, ident, divot, startOffset, endOffset)
367 , m_operator(oper)
368 {
369 }
370
371 inline PrefixBracketNode::PrefixBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
372 : ExpressionNode(globalData)
373 , ThrowablePrefixedSubExpressionData(divot, startOffset, endOffset)
374 , m_base(base)
375 , m_subscript(subscript)
376 , m_operator(oper)
377 {
378 }
379
380 inline PrefixDotNode::PrefixDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
381 : ExpressionNode(globalData)
382 , ThrowablePrefixedSubExpressionData(divot, startOffset, endOffset)
383 , m_base(base)
384 , m_ident(ident)
385 , m_operator(oper)
386 {
387 }
388
389 inline PrefixErrorNode::PrefixErrorNode(JSGlobalData* globalData, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
390 : ExpressionNode(globalData)
391 , ThrowableExpressionData(divot, startOffset, endOffset)
392 , m_expr(expr)
393 , m_operator(oper)
394 {
395 }
396
397 inline UnaryOpNode::UnaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr, OpcodeID opcodeID)
398 : ExpressionNode(globalData, type)
399 , m_expr(expr)
400 , m_opcodeID(opcodeID)
401 {
402 }
403
404 inline UnaryPlusNode::UnaryPlusNode(JSGlobalData* globalData, ExpressionNode* expr)
405 : UnaryOpNode(globalData, ResultType::numberType(), expr, op_to_jsnumber)
406 {
407 }
408
409 inline NegateNode::NegateNode(JSGlobalData* globalData, ExpressionNode* expr)
410 : UnaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr, op_negate)
411 {
412 }
413
414 inline BitwiseNotNode::BitwiseNotNode(JSGlobalData* globalData, ExpressionNode* expr)
415 : UnaryOpNode(globalData, ResultType::forBitOp(), expr, op_bitnot)
416 {
417 }
418
419 inline LogicalNotNode::LogicalNotNode(JSGlobalData* globalData, ExpressionNode* expr)
420 : UnaryOpNode(globalData, ResultType::booleanType(), expr, op_not)
421 {
422 }
423
424 inline BinaryOpNode::BinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
425 : ExpressionNode(globalData)
426 , m_expr1(expr1)
427 , m_expr2(expr2)
428 , m_opcodeID(opcodeID)
429 , m_rightHasAssignments(rightHasAssignments)
430 {
431 }
432
433 inline BinaryOpNode::BinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
434 : ExpressionNode(globalData, type)
435 , m_expr1(expr1)
436 , m_expr2(expr2)
437 , m_opcodeID(opcodeID)
438 , m_rightHasAssignments(rightHasAssignments)
439 {
440 }
441
442 inline ReverseBinaryOpNode::ReverseBinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
443 : BinaryOpNode(globalData, expr1, expr2, opcodeID, rightHasAssignments)
444 {
445 }
446
447 inline ReverseBinaryOpNode::ReverseBinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
448 : BinaryOpNode(globalData, type, expr1, expr2, opcodeID, rightHasAssignments)
449 {
450 }
451
452 inline MultNode::MultNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
453 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_mul, rightHasAssignments)
454 {
455 }
456
457 inline DivNode::DivNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
458 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_div, rightHasAssignments)
459 {
460 }
461
462
463 inline ModNode::ModNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
464 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_mod, rightHasAssignments)
465 {
466 }
467
468 inline AddNode::AddNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
469 : BinaryOpNode(globalData, ResultType::forAdd(op1: expr1->resultDescriptor(), op2: expr2->resultDescriptor()), expr1, expr2, op_add, rightHasAssignments)
470 {
471 }
472
473 inline SubNode::SubNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
474 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_sub, rightHasAssignments)
475 {
476 }
477
478 inline LeftShiftNode::LeftShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
479 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_lshift, rightHasAssignments)
480 {
481 }
482
483 inline RightShiftNode::RightShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
484 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_rshift, rightHasAssignments)
485 {
486 }
487
488 inline UnsignedRightShiftNode::UnsignedRightShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
489 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_urshift, rightHasAssignments)
490 {
491 }
492
493 inline LessNode::LessNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
494 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
495 {
496 }
497
498 inline GreaterNode::GreaterNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
499 : ReverseBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
500 {
501 }
502
503 inline LessEqNode::LessEqNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
504 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
505 {
506 }
507
508 inline GreaterEqNode::GreaterEqNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
509 : ReverseBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
510 {
511 }
512
513 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
514 : BinaryOpNode(globalData, type, expr1, expr2, opcodeID, rightHasAssignments)
515 {
516 }
517
518 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
519 : BinaryOpNode(globalData, expr1, expr2, opcodeID, rightHasAssignments)
520 {
521 }
522
523 inline InstanceOfNode::InstanceOfNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
524 : ThrowableBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_instanceof, rightHasAssignments)
525 {
526 }
527
528 inline InNode::InNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
529 : ThrowableBinaryOpNode(globalData, expr1, expr2, op_in, rightHasAssignments)
530 {
531 }
532
533 inline EqualNode::EqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
534 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_eq, rightHasAssignments)
535 {
536 }
537
538 inline NotEqualNode::NotEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
539 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_neq, rightHasAssignments)
540 {
541 }
542
543 inline StrictEqualNode::StrictEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
544 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_stricteq, rightHasAssignments)
545 {
546 }
547
548 inline NotStrictEqualNode::NotStrictEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
549 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_nstricteq, rightHasAssignments)
550 {
551 }
552
553 inline BitAndNode::BitAndNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
554 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_bitand, rightHasAssignments)
555 {
556 }
557
558 inline BitOrNode::BitOrNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
559 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_bitor, rightHasAssignments)
560 {
561 }
562
563 inline BitXOrNode::BitXOrNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
564 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_bitxor, rightHasAssignments)
565 {
566 }
567
568 inline LogicalOpNode::LogicalOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper)
569 : ExpressionNode(globalData, ResultType::booleanType())
570 , m_expr1(expr1)
571 , m_expr2(expr2)
572 , m_operator(oper)
573 {
574 }
575
576 inline ConditionalNode::ConditionalNode(JSGlobalData* globalData, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2)
577 : ExpressionNode(globalData)
578 , m_logical(logical)
579 , m_expr1(expr1)
580 , m_expr2(expr2)
581 {
582 }
583
584 inline ReadModifyResolveNode::ReadModifyResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
585 : ExpressionNode(globalData)
586 , ThrowableExpressionData(divot, startOffset, endOffset)
587 , m_ident(ident)
588 , m_right(right)
589 , m_operator(oper)
590 , m_rightHasAssignments(rightHasAssignments)
591 {
592 }
593
594 inline AssignResolveNode::AssignResolveNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments)
595 : ExpressionNode(globalData)
596 , m_ident(ident)
597 , m_right(right)
598 , m_rightHasAssignments(rightHasAssignments)
599 {
600 }
601
602 inline ReadModifyBracketNode::ReadModifyBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
603 : ExpressionNode(globalData)
604 , ThrowableSubExpressionData(divot, startOffset, endOffset)
605 , m_base(base)
606 , m_subscript(subscript)
607 , m_right(right)
608 , m_operator(oper)
609 , m_subscriptHasAssignments(subscriptHasAssignments)
610 , m_rightHasAssignments(rightHasAssignments)
611 {
612 }
613
614 inline AssignBracketNode::AssignBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
615 : ExpressionNode(globalData)
616 , ThrowableExpressionData(divot, startOffset, endOffset)
617 , m_base(base)
618 , m_subscript(subscript)
619 , m_right(right)
620 , m_subscriptHasAssignments(subscriptHasAssignments)
621 , m_rightHasAssignments(rightHasAssignments)
622 {
623 }
624
625 inline AssignDotNode::AssignDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
626 : ExpressionNode(globalData)
627 , ThrowableExpressionData(divot, startOffset, endOffset)
628 , m_base(base)
629 , m_ident(ident)
630 , m_right(right)
631 , m_rightHasAssignments(rightHasAssignments)
632 {
633 }
634
635 inline ReadModifyDotNode::ReadModifyDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
636 : ExpressionNode(globalData)
637 , ThrowableSubExpressionData(divot, startOffset, endOffset)
638 , m_base(base)
639 , m_ident(ident)
640 , m_right(right)
641 , m_operator(oper)
642 , m_rightHasAssignments(rightHasAssignments)
643 {
644 }
645
646 inline AssignErrorNode::AssignErrorNode(JSGlobalData* globalData, ExpressionNode* left, Operator oper, ExpressionNode* right, unsigned divot, unsigned startOffset, unsigned endOffset)
647 : ExpressionNode(globalData)
648 , ThrowableExpressionData(divot, startOffset, endOffset)
649 , m_left(left)
650 , m_operator(oper)
651 , m_right(right)
652 {
653 }
654
655 inline CommaNode::CommaNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2)
656 : ExpressionNode(globalData)
657 {
658 m_expressions.append(val: expr1);
659 m_expressions.append(val: expr2);
660 }
661
662 inline ConstStatementNode::ConstStatementNode(JSGlobalData* globalData, ConstDeclNode* next)
663 : StatementNode(globalData)
664 , m_next(next)
665 {
666 }
667
668 inline SourceElements::SourceElements(JSGlobalData*)
669 {
670 }
671
672 inline EmptyStatementNode::EmptyStatementNode(JSGlobalData* globalData)
673 : StatementNode(globalData)
674 {
675 }
676
677 inline DebuggerStatementNode::DebuggerStatementNode(JSGlobalData* globalData)
678 : StatementNode(globalData)
679 {
680 }
681
682 inline ExprStatementNode::ExprStatementNode(JSGlobalData* globalData, ExpressionNode* expr)
683 : StatementNode(globalData)
684 , m_expr(expr)
685 {
686 }
687
688 inline VarStatementNode::VarStatementNode(JSGlobalData* globalData, ExpressionNode* expr)
689 : StatementNode(globalData)
690 , m_expr(expr)
691 {
692 }
693
694 inline IfNode::IfNode(JSGlobalData* globalData, ExpressionNode* condition, StatementNode* ifBlock)
695 : StatementNode(globalData)
696 , m_condition(condition)
697 , m_ifBlock(ifBlock)
698 {
699 }
700
701 inline IfElseNode::IfElseNode(JSGlobalData* globalData, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock)
702 : IfNode(globalData, condition, ifBlock)
703 , m_elseBlock(elseBlock)
704 {
705 }
706
707 inline DoWhileNode::DoWhileNode(JSGlobalData* globalData, StatementNode* statement, ExpressionNode* expr)
708 : StatementNode(globalData)
709 , m_statement(statement)
710 , m_expr(expr)
711 {
712 }
713
714 inline WhileNode::WhileNode(JSGlobalData* globalData, ExpressionNode* expr, StatementNode* statement)
715 : StatementNode(globalData)
716 , m_expr(expr)
717 , m_statement(statement)
718 {
719 }
720
721 inline ForNode::ForNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl)
722 : StatementNode(globalData)
723 , m_expr1(expr1)
724 , m_expr2(expr2)
725 , m_expr3(expr3)
726 , m_statement(statement)
727 , m_expr1WasVarDecl(expr1 && expr1WasVarDecl)
728 {
729 ASSERT(statement);
730 }
731
732 inline ContinueNode::ContinueNode(JSGlobalData* globalData)
733 : StatementNode(globalData)
734 , m_ident(globalData->propertyNames->nullIdentifier)
735 {
736 }
737
738 inline ContinueNode::ContinueNode(JSGlobalData* globalData, const Identifier& ident)
739 : StatementNode(globalData)
740 , m_ident(ident)
741 {
742 }
743
744 inline BreakNode::BreakNode(JSGlobalData* globalData)
745 : StatementNode(globalData)
746 , m_ident(globalData->propertyNames->nullIdentifier)
747 {
748 }
749
750 inline BreakNode::BreakNode(JSGlobalData* globalData, const Identifier& ident)
751 : StatementNode(globalData)
752 , m_ident(ident)
753 {
754 }
755
756 inline ReturnNode::ReturnNode(JSGlobalData* globalData, ExpressionNode* value)
757 : StatementNode(globalData)
758 , m_value(value)
759 {
760 }
761
762 inline WithNode::WithNode(JSGlobalData* globalData, ExpressionNode* expr, StatementNode* statement, uint32_t divot, uint32_t expressionLength)
763 : StatementNode(globalData)
764 , m_expr(expr)
765 , m_statement(statement)
766 , m_divot(divot)
767 , m_expressionLength(expressionLength)
768 {
769 }
770
771 inline LabelNode::LabelNode(JSGlobalData* globalData, const Identifier& name, StatementNode* statement)
772 : StatementNode(globalData)
773 , m_name(name)
774 , m_statement(statement)
775 {
776 }
777
778 inline ThrowNode::ThrowNode(JSGlobalData* globalData, ExpressionNode* expr)
779 : StatementNode(globalData)
780 , m_expr(expr)
781 {
782 }
783
784 inline TryNode::TryNode(JSGlobalData* globalData, StatementNode* tryBlock, const Identifier& exceptionIdent, bool catchHasEval, StatementNode* catchBlock, StatementNode* finallyBlock)
785 : StatementNode(globalData)
786 , m_tryBlock(tryBlock)
787 , m_exceptionIdent(exceptionIdent)
788 , m_catchBlock(catchBlock)
789 , m_finallyBlock(finallyBlock)
790 , m_catchHasEval(catchHasEval)
791 {
792 }
793
794 inline ParameterNode::ParameterNode(JSGlobalData*, const Identifier& ident)
795 : m_ident(ident)
796 , m_next(0)
797 {
798 }
799
800 inline ParameterNode::ParameterNode(JSGlobalData*, ParameterNode* l, const Identifier& ident)
801 : m_ident(ident)
802 , m_next(0)
803 {
804 l->m_next = this;
805 }
806
807 inline FuncExprNode::FuncExprNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
808 : ExpressionNode(globalData)
809 , m_body(body)
810 {
811 m_body->finishParsing(source, parameter, ident);
812 }
813
814 inline FuncDeclNode::FuncDeclNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
815 : StatementNode(globalData)
816 , m_body(body)
817 {
818 m_body->finishParsing(source, parameter, ident);
819 }
820
821 inline CaseClauseNode::CaseClauseNode(JSGlobalData*, ExpressionNode* expr, SourceElements* statements)
822 : m_expr(expr)
823 , m_statements(statements)
824 {
825 }
826
827 inline ClauseListNode::ClauseListNode(JSGlobalData*, CaseClauseNode* clause)
828 : m_clause(clause)
829 , m_next(0)
830 {
831 }
832
833 inline ClauseListNode::ClauseListNode(JSGlobalData*, ClauseListNode* clauseList, CaseClauseNode* clause)
834 : m_clause(clause)
835 , m_next(0)
836 {
837 clauseList->m_next = this;
838 }
839
840 inline CaseBlockNode::CaseBlockNode(JSGlobalData*, ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2)
841 : m_list1(list1)
842 , m_defaultClause(defaultClause)
843 , m_list2(list2)
844 {
845 }
846
847 inline SwitchNode::SwitchNode(JSGlobalData* globalData, ExpressionNode* expr, CaseBlockNode* block)
848 : StatementNode(globalData)
849 , m_expr(expr)
850 , m_block(block)
851 {
852 }
853
854 inline ConstDeclNode::ConstDeclNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* init)
855 : ExpressionNode(globalData)
856 , m_ident(ident)
857 , m_next(0)
858 , m_init(init)
859 {
860 }
861
862 inline BlockNode::BlockNode(JSGlobalData* globalData, SourceElements* statements)
863 : StatementNode(globalData)
864 , m_statements(statements)
865 {
866 }
867
868 inline ForInNode::ForInNode(JSGlobalData* globalData, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
869 : StatementNode(globalData)
870 , m_ident(globalData->propertyNames->nullIdentifier)
871 , m_init(0)
872 , m_lexpr(l)
873 , m_expr(expr)
874 , m_statement(statement)
875 , m_identIsVarDecl(false)
876 {
877 }
878
879 inline ForInNode::ForInNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement, int divot, int startOffset, int endOffset)
880 : StatementNode(globalData)
881 , m_ident(ident)
882 , m_init(0)
883 , m_lexpr(new (globalData) ResolveNode(globalData, ident, divot - startOffset))
884 , m_expr(expr)
885 , m_statement(statement)
886 , m_identIsVarDecl(true)
887 {
888 if (in) {
889 AssignResolveNode* node = new (globalData) AssignResolveNode(globalData, ident, in, true);
890 node->setExceptionSourceCode(divot, startOffset: divot - startOffset, endOffset: endOffset - divot);
891 m_init = node;
892 }
893 // for( var foo = bar in baz )
894 }
895
896} // namespace JSC
897
898#endif // NodeConstructors_h
899

source code of qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/NodeConstructors.h