initial import
[vuplus_webkit] / Source / JavaScriptCore / 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->parser->arena().allocateFreeable(size);
33     }
34
35     inline void* ParserArenaDeletable::operator new(size_t size, JSGlobalData* globalData)
36     {
37         return globalData->parser->arena().allocateDeletable(size);
38     }
39
40     inline ParserArenaRefCounted::ParserArenaRefCounted(JSGlobalData* globalData)
41     {
42         globalData->parser->arena().derefWithArena(adoptRef(this));
43     }
44
45     inline Node::Node(JSGlobalData* globalData)
46         : m_line(globalData->lexer->lastLineNumber())
47     {
48     }
49
50     inline ExpressionNode::ExpressionNode(JSGlobalData* globalData, ResultType resultType)
51         : Node(globalData)
52         , m_resultType(resultType)
53     {
54     }
55
56     inline StatementNode::StatementNode(JSGlobalData* globalData)
57         : Node(globalData)
58         , m_lastLine(-1)
59     {
60     }
61
62     inline NullNode::NullNode(JSGlobalData* globalData)
63         : ExpressionNode(globalData, ResultType::nullType())
64     {
65     }
66
67     inline BooleanNode::BooleanNode(JSGlobalData* globalData, bool value)
68         : ExpressionNode(globalData, ResultType::booleanType())
69         , m_value(value)
70     {
71     }
72
73     inline NumberNode::NumberNode(JSGlobalData* globalData, double value)
74         : ExpressionNode(globalData, ResultType::numberType())
75         , m_value(value)
76     {
77     }
78
79     inline StringNode::StringNode(JSGlobalData* globalData, const Identifier& value)
80         : ExpressionNode(globalData, ResultType::stringType())
81         , m_value(value)
82     {
83     }
84
85     inline RegExpNode::RegExpNode(JSGlobalData* globalData, const Identifier& pattern, const Identifier& flags)
86         : ExpressionNode(globalData)
87         , m_pattern(pattern)
88         , m_flags(flags)
89     {
90     }
91
92     inline ThisNode::ThisNode(JSGlobalData* globalData)
93         : ExpressionNode(globalData)
94     {
95     }
96
97     inline ResolveNode::ResolveNode(JSGlobalData* globalData, const Identifier& ident, int startOffset)
98         : ExpressionNode(globalData)
99         , m_ident(ident)
100         , m_startOffset(startOffset)
101     {
102     }
103
104     inline ElementNode::ElementNode(JSGlobalData*, int elision, ExpressionNode* node)
105         : m_next(0)
106         , m_elision(elision)
107         , m_node(node)
108     {
109     }
110
111     inline ElementNode::ElementNode(JSGlobalData*, 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(JSGlobalData* globalData, int elision)
120         : ExpressionNode(globalData)
121         , m_element(0)
122         , m_elision(elision)
123         , m_optional(true)
124     {
125     }
126
127     inline ArrayNode::ArrayNode(JSGlobalData* globalData, ElementNode* element)
128         : ExpressionNode(globalData)
129         , m_element(element)
130         , m_elision(0)
131         , m_optional(false)
132     {
133     }
134
135     inline ArrayNode::ArrayNode(JSGlobalData* globalData, int elision, ElementNode* element)
136         : ExpressionNode(globalData)
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->parser->arena().identifierArena().makeNumericIdentifier(globalData, name))
152         , m_assign(assign)
153         , m_type(type)
154     {
155     }
156
157     inline PropertyListNode::PropertyListNode(JSGlobalData* globalData, PropertyNode* node)
158         : Node(globalData)
159         , m_node(node)
160         , m_next(0)
161     {
162     }
163
164     inline PropertyListNode::PropertyListNode(JSGlobalData* globalData, PropertyNode* node, PropertyListNode* list)
165         : Node(globalData)
166         , m_node(node)
167         , m_next(0)
168     {
169         list->m_next = this;
170     }
171
172     inline ObjectLiteralNode::ObjectLiteralNode(JSGlobalData* globalData)
173         : ExpressionNode(globalData)
174         , m_list(0)
175     {
176     }
177
178     inline ObjectLiteralNode::ObjectLiteralNode(JSGlobalData* globalData, PropertyListNode* list)
179         : ExpressionNode(globalData)
180         , m_list(list)
181     {
182     }
183
184     inline BracketAccessorNode::BracketAccessorNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments)
185         : ExpressionNode(globalData)
186         , m_base(base)
187         , m_subscript(subscript)
188         , m_subscriptHasAssignments(subscriptHasAssignments)
189     {
190     }
191
192     inline DotAccessorNode::DotAccessorNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident)
193         : ExpressionNode(globalData)
194         , m_base(base)
195         , m_ident(ident)
196     {
197     }
198
199     inline ArgumentListNode::ArgumentListNode(JSGlobalData* globalData, ExpressionNode* expr)
200         : Node(globalData)
201         , m_next(0)
202         , m_expr(expr)
203     {
204     }
205
206     inline ArgumentListNode::ArgumentListNode(JSGlobalData* globalData, ArgumentListNode* listNode, ExpressionNode* expr)
207         : Node(globalData)
208         , m_next(0)
209         , m_expr(expr)
210     {
211         listNode->m_next = this;
212     }
213
214     inline ArgumentsNode::ArgumentsNode(JSGlobalData*)
215         : m_listNode(0)
216     {
217     }
218
219     inline ArgumentsNode::ArgumentsNode(JSGlobalData*, ArgumentListNode* listNode)
220         : m_listNode(listNode)
221     {
222     }
223
224     inline NewExprNode::NewExprNode(JSGlobalData* globalData, ExpressionNode* expr)
225         : ExpressionNode(globalData)
226         , m_expr(expr)
227         , m_args(0)
228     {
229     }
230
231     inline NewExprNode::NewExprNode(JSGlobalData* globalData, ExpressionNode* expr, ArgumentsNode* args)
232         : ExpressionNode(globalData)
233         , m_expr(expr)
234         , m_args(args)
235     {
236     }
237
238     inline EvalFunctionCallNode::EvalFunctionCallNode(JSGlobalData* globalData, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
239         : ExpressionNode(globalData)
240         , ThrowableExpressionData(divot, startOffset, endOffset)
241         , m_args(args)
242     {
243     }
244
245     inline FunctionCallValueNode::FunctionCallValueNode(JSGlobalData* globalData, ExpressionNode* expr, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
246         : ExpressionNode(globalData)
247         , ThrowableExpressionData(divot, startOffset, endOffset)
248         , m_expr(expr)
249         , m_args(args)
250     {
251     }
252
253     inline FunctionCallResolveNode::FunctionCallResolveNode(JSGlobalData* globalData, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
254         : ExpressionNode(globalData)
255         , ThrowableExpressionData(divot, startOffset, endOffset)
256         , m_ident(ident)
257         , m_args(args)
258     {
259     }
260
261     inline FunctionCallBracketNode::FunctionCallBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
262         : ExpressionNode(globalData)
263         , ThrowableSubExpressionData(divot, startOffset, endOffset)
264         , m_base(base)
265         , m_subscript(subscript)
266         , m_args(args)
267     {
268     }
269
270     inline FunctionCallDotNode::FunctionCallDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
271         : ExpressionNode(globalData)
272         , ThrowableSubExpressionData(divot, startOffset, endOffset)
273         , m_base(base)
274         , m_ident(ident)
275         , m_args(args)
276     {
277     }
278
279     inline CallFunctionCallDotNode::CallFunctionCallDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
280         : FunctionCallDotNode(globalData, base, ident, args, divot, startOffset, endOffset)
281     {
282     }
283
284     inline ApplyFunctionCallDotNode::ApplyFunctionCallDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset)
285         : FunctionCallDotNode(globalData, base, ident, args, divot, startOffset, endOffset)
286     {
287     }
288
289     inline PrePostResolveNode::PrePostResolveNode(JSGlobalData* globalData, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset)
290         : ExpressionNode(globalData, ResultType::numberType()) // could be reusable for pre?
291         , ThrowableExpressionData(divot, startOffset, endOffset)
292         , m_ident(ident)
293     {
294     }
295
296     inline PostfixResolveNode::PostfixResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
297         : PrePostResolveNode(globalData, ident, divot, startOffset, endOffset)
298         , m_operator(oper)
299     {
300     }
301
302     inline PostfixBracketNode::PostfixBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
303         : ExpressionNode(globalData)
304         , ThrowableSubExpressionData(divot, startOffset, endOffset)
305         , m_base(base)
306         , m_subscript(subscript)
307         , m_operator(oper)
308     {
309     }
310
311     inline PostfixDotNode::PostfixDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
312         : ExpressionNode(globalData)
313         , ThrowableSubExpressionData(divot, startOffset, endOffset)
314         , m_base(base)
315         , m_ident(ident)
316         , m_operator(oper)
317     {
318     }
319
320     inline PostfixErrorNode::PostfixErrorNode(JSGlobalData* globalData, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
321         : ExpressionNode(globalData)
322         , ThrowableSubExpressionData(divot, startOffset, endOffset)
323         , m_expr(expr)
324         , m_operator(oper)
325     {
326     }
327
328     inline DeleteResolveNode::DeleteResolveNode(JSGlobalData* globalData, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset)
329         : ExpressionNode(globalData)
330         , ThrowableExpressionData(divot, startOffset, endOffset)
331         , m_ident(ident)
332     {
333     }
334
335     inline DeleteBracketNode::DeleteBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, unsigned divot, unsigned startOffset, unsigned endOffset)
336         : ExpressionNode(globalData)
337         , ThrowableExpressionData(divot, startOffset, endOffset)
338         , m_base(base)
339         , m_subscript(subscript)
340     {
341     }
342
343     inline DeleteDotNode::DeleteDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset)
344         : ExpressionNode(globalData)
345         , ThrowableExpressionData(divot, startOffset, endOffset)
346         , m_base(base)
347         , m_ident(ident)
348     {
349     }
350
351     inline DeleteValueNode::DeleteValueNode(JSGlobalData* globalData, ExpressionNode* expr)
352         : ExpressionNode(globalData)
353         , m_expr(expr)
354     {
355     }
356
357     inline VoidNode::VoidNode(JSGlobalData* globalData, ExpressionNode* expr)
358         : ExpressionNode(globalData)
359         , m_expr(expr)
360     {
361     }
362
363     inline TypeOfResolveNode::TypeOfResolveNode(JSGlobalData* globalData, const Identifier& ident)
364         : ExpressionNode(globalData, ResultType::stringType())
365         , m_ident(ident)
366     {
367     }
368
369     inline TypeOfValueNode::TypeOfValueNode(JSGlobalData* globalData, ExpressionNode* expr)
370         : ExpressionNode(globalData, ResultType::stringType())
371         , m_expr(expr)
372     {
373     }
374
375     inline PrefixResolveNode::PrefixResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
376         : PrePostResolveNode(globalData, ident, divot, startOffset, endOffset)
377         , m_operator(oper)
378     {
379     }
380
381     inline PrefixBracketNode::PrefixBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
382         : ExpressionNode(globalData)
383         , ThrowablePrefixedSubExpressionData(divot, startOffset, endOffset)
384         , m_base(base)
385         , m_subscript(subscript)
386         , m_operator(oper)
387     {
388     }
389
390     inline PrefixDotNode::PrefixDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
391         : ExpressionNode(globalData)
392         , ThrowablePrefixedSubExpressionData(divot, startOffset, endOffset)
393         , m_base(base)
394         , m_ident(ident)
395         , m_operator(oper)
396     {
397     }
398
399     inline PrefixErrorNode::PrefixErrorNode(JSGlobalData* globalData, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset)
400         : ExpressionNode(globalData)
401         , ThrowableExpressionData(divot, startOffset, endOffset)
402         , m_expr(expr)
403         , m_operator(oper)
404     {
405     }
406
407     inline UnaryOpNode::UnaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr, OpcodeID opcodeID)
408         : ExpressionNode(globalData, type)
409         , m_expr(expr)
410         , m_opcodeID(opcodeID)
411     {
412     }
413
414     inline UnaryPlusNode::UnaryPlusNode(JSGlobalData* globalData, ExpressionNode* expr)
415         : UnaryOpNode(globalData, ResultType::numberType(), expr, op_to_jsnumber)
416     {
417     }
418
419     inline NegateNode::NegateNode(JSGlobalData* globalData, ExpressionNode* expr)
420         : UnaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr, op_negate)
421     {
422     }
423
424     inline BitwiseNotNode::BitwiseNotNode(JSGlobalData* globalData, ExpressionNode* expr)
425         : UnaryOpNode(globalData, ResultType::forBitOp(), expr, op_bitnot)
426     {
427     }
428
429     inline LogicalNotNode::LogicalNotNode(JSGlobalData* globalData, ExpressionNode* expr)
430         : UnaryOpNode(globalData, ResultType::booleanType(), expr, op_not)
431     {
432     }
433
434     inline BinaryOpNode::BinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
435         : ExpressionNode(globalData)
436         , m_expr1(expr1)
437         , m_expr2(expr2)
438         , m_opcodeID(opcodeID)
439         , m_rightHasAssignments(rightHasAssignments)
440     {
441     }
442
443     inline BinaryOpNode::BinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
444         : ExpressionNode(globalData, type)
445         , m_expr1(expr1)
446         , m_expr2(expr2)
447         , m_opcodeID(opcodeID)
448         , m_rightHasAssignments(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(expr1->resultDescriptor(), 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         : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_greater, 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         : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_greatereq, 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(expr1);
659         m_expressions.append(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, 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