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