]> git.saurik.com Git - apple/javascriptcore.git/blame - parser/NodeConstructors.h
JavaScriptCore-903.tar.gz
[apple/javascriptcore.git] / parser / NodeConstructors.h
CommitLineData
ba379fdc
A
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
f9bf01c6 30 inline void* ParserArenaFreeable::operator new(size_t size, JSGlobalData* globalData)
ba379fdc 31 {
f9bf01c6 32 return globalData->parser->arena().allocateFreeable(size);
ba379fdc
A
33 }
34
f9bf01c6 35 inline void* ParserArenaDeletable::operator new(size_t size, JSGlobalData* globalData)
ba379fdc 36 {
f9bf01c6 37 return globalData->parser->arena().allocateDeletable(size);
ba379fdc
A
38 }
39
40 inline ParserArenaRefCounted::ParserArenaRefCounted(JSGlobalData* globalData)
41 {
42 globalData->parser->arena().derefWithArena(adoptRef(this));
43 }
44
45 inline Node::Node(JSGlobalData* globalData)
14957cd0 46 : m_line(globalData->lexer->lastLineNumber())
ba379fdc
A
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
f9bf01c6 73 inline NumberNode::NumberNode(JSGlobalData* globalData, double value)
ba379fdc 74 : ExpressionNode(globalData, ResultType::numberType())
f9bf01c6 75 , m_value(value)
ba379fdc
A
76 {
77 }
78
f9bf01c6 79 inline StringNode::StringNode(JSGlobalData* globalData, const Identifier& value)
ba379fdc 80 : ExpressionNode(globalData, ResultType::stringType())
f9bf01c6 81 , m_value(value)
ba379fdc
A
82 {
83 }
84
f9bf01c6 85 inline RegExpNode::RegExpNode(JSGlobalData* globalData, const Identifier& pattern, const Identifier& flags)
ba379fdc
A
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
f9bf01c6
A
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
ba379fdc
A
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 ReverseBinaryOpNode::ReverseBinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
453 : BinaryOpNode(globalData, expr1, expr2, opcodeID, rightHasAssignments)
454 {
455 }
456
457 inline ReverseBinaryOpNode::ReverseBinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
458 : BinaryOpNode(globalData, type, expr1, expr2, opcodeID, rightHasAssignments)
459 {
460 }
461
462 inline MultNode::MultNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
463 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_mul, rightHasAssignments)
464 {
465 }
466
467 inline DivNode::DivNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
468 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_div, rightHasAssignments)
469 {
470 }
471
472
473 inline ModNode::ModNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
474 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_mod, rightHasAssignments)
475 {
476 }
477
478 inline AddNode::AddNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
479 : BinaryOpNode(globalData, ResultType::forAdd(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_add, rightHasAssignments)
480 {
481 }
482
483 inline SubNode::SubNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
484 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_sub, rightHasAssignments)
485 {
486 }
487
488 inline LeftShiftNode::LeftShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
489 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_lshift, rightHasAssignments)
490 {
491 }
492
493 inline RightShiftNode::RightShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
494 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_rshift, rightHasAssignments)
495 {
496 }
497
498 inline UnsignedRightShiftNode::UnsignedRightShiftNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
499 : BinaryOpNode(globalData, ResultType::numberTypeCanReuse(), expr1, expr2, op_urshift, rightHasAssignments)
500 {
501 }
502
503 inline LessNode::LessNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
504 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
505 {
506 }
507
508 inline GreaterNode::GreaterNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
509 : ReverseBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
510 {
511 }
512
513 inline LessEqNode::LessEqNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
514 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
515 {
516 }
517
518 inline GreaterEqNode::GreaterEqNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
519 : ReverseBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
520 {
521 }
522
523 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(JSGlobalData* globalData, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
524 : BinaryOpNode(globalData, type, expr1, expr2, opcodeID, rightHasAssignments)
525 {
526 }
527
528 inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
529 : BinaryOpNode(globalData, expr1, expr2, opcodeID, rightHasAssignments)
530 {
531 }
532
533 inline InstanceOfNode::InstanceOfNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
534 : ThrowableBinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_instanceof, rightHasAssignments)
535 {
536 }
537
538 inline InNode::InNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
539 : ThrowableBinaryOpNode(globalData, expr1, expr2, op_in, rightHasAssignments)
540 {
541 }
542
543 inline EqualNode::EqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
544 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_eq, rightHasAssignments)
545 {
546 }
547
548 inline NotEqualNode::NotEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
549 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_neq, rightHasAssignments)
550 {
551 }
552
553 inline StrictEqualNode::StrictEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
554 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_stricteq, rightHasAssignments)
555 {
556 }
557
558 inline NotStrictEqualNode::NotStrictEqualNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
559 : BinaryOpNode(globalData, ResultType::booleanType(), expr1, expr2, op_nstricteq, rightHasAssignments)
560 {
561 }
562
563 inline BitAndNode::BitAndNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
564 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_bitand, rightHasAssignments)
565 {
566 }
567
568 inline BitOrNode::BitOrNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
569 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_bitor, rightHasAssignments)
570 {
571 }
572
573 inline BitXOrNode::BitXOrNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
574 : BinaryOpNode(globalData, ResultType::forBitOp(), expr1, expr2, op_bitxor, rightHasAssignments)
575 {
576 }
577
578 inline LogicalOpNode::LogicalOpNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper)
579 : ExpressionNode(globalData, ResultType::booleanType())
580 , m_expr1(expr1)
581 , m_expr2(expr2)
582 , m_operator(oper)
583 {
584 }
585
586 inline ConditionalNode::ConditionalNode(JSGlobalData* globalData, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2)
587 : ExpressionNode(globalData)
588 , m_logical(logical)
589 , m_expr1(expr1)
590 , m_expr2(expr2)
591 {
592 }
593
594 inline ReadModifyResolveNode::ReadModifyResolveNode(JSGlobalData* globalData, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
595 : ExpressionNode(globalData)
596 , ThrowableExpressionData(divot, startOffset, endOffset)
597 , m_ident(ident)
598 , m_right(right)
599 , m_operator(oper)
600 , m_rightHasAssignments(rightHasAssignments)
601 {
602 }
603
604 inline AssignResolveNode::AssignResolveNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments)
605 : ExpressionNode(globalData)
606 , m_ident(ident)
607 , m_right(right)
608 , m_rightHasAssignments(rightHasAssignments)
609 {
610 }
611
612 inline ReadModifyBracketNode::ReadModifyBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
613 : ExpressionNode(globalData)
614 , ThrowableSubExpressionData(divot, startOffset, endOffset)
615 , m_base(base)
616 , m_subscript(subscript)
617 , m_right(right)
618 , m_operator(oper)
619 , m_subscriptHasAssignments(subscriptHasAssignments)
620 , m_rightHasAssignments(rightHasAssignments)
621 {
622 }
623
624 inline AssignBracketNode::AssignBracketNode(JSGlobalData* globalData, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
625 : ExpressionNode(globalData)
626 , ThrowableExpressionData(divot, startOffset, endOffset)
627 , m_base(base)
628 , m_subscript(subscript)
629 , m_right(right)
630 , m_subscriptHasAssignments(subscriptHasAssignments)
631 , m_rightHasAssignments(rightHasAssignments)
632 {
633 }
634
635 inline AssignDotNode::AssignDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
636 : ExpressionNode(globalData)
637 , ThrowableExpressionData(divot, startOffset, endOffset)
638 , m_base(base)
639 , m_ident(ident)
640 , m_right(right)
641 , m_rightHasAssignments(rightHasAssignments)
642 {
643 }
644
645 inline ReadModifyDotNode::ReadModifyDotNode(JSGlobalData* globalData, ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset)
646 : ExpressionNode(globalData)
647 , ThrowableSubExpressionData(divot, startOffset, endOffset)
648 , m_base(base)
649 , m_ident(ident)
650 , m_right(right)
651 , m_operator(oper)
652 , m_rightHasAssignments(rightHasAssignments)
653 {
654 }
655
656 inline AssignErrorNode::AssignErrorNode(JSGlobalData* globalData, ExpressionNode* left, Operator oper, ExpressionNode* right, unsigned divot, unsigned startOffset, unsigned endOffset)
657 : ExpressionNode(globalData)
658 , ThrowableExpressionData(divot, startOffset, endOffset)
659 , m_left(left)
660 , m_operator(oper)
661 , m_right(right)
662 {
663 }
664
665 inline CommaNode::CommaNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2)
666 : ExpressionNode(globalData)
667 {
668 m_expressions.append(expr1);
669 m_expressions.append(expr2);
670 }
671
672 inline ConstStatementNode::ConstStatementNode(JSGlobalData* globalData, ConstDeclNode* next)
673 : StatementNode(globalData)
674 , m_next(next)
675 {
676 }
677
678 inline SourceElements::SourceElements(JSGlobalData*)
679 {
680 }
681
682 inline EmptyStatementNode::EmptyStatementNode(JSGlobalData* globalData)
683 : StatementNode(globalData)
684 {
685 }
686
687 inline DebuggerStatementNode::DebuggerStatementNode(JSGlobalData* globalData)
688 : StatementNode(globalData)
689 {
690 }
691
692 inline ExprStatementNode::ExprStatementNode(JSGlobalData* globalData, ExpressionNode* expr)
693 : StatementNode(globalData)
694 , m_expr(expr)
695 {
696 }
697
698 inline VarStatementNode::VarStatementNode(JSGlobalData* globalData, ExpressionNode* expr)
699 : StatementNode(globalData)
700 , m_expr(expr)
701 {
702 }
703
704 inline IfNode::IfNode(JSGlobalData* globalData, ExpressionNode* condition, StatementNode* ifBlock)
705 : StatementNode(globalData)
706 , m_condition(condition)
707 , m_ifBlock(ifBlock)
708 {
709 }
710
711 inline IfElseNode::IfElseNode(JSGlobalData* globalData, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock)
712 : IfNode(globalData, condition, ifBlock)
713 , m_elseBlock(elseBlock)
714 {
715 }
716
717 inline DoWhileNode::DoWhileNode(JSGlobalData* globalData, StatementNode* statement, ExpressionNode* expr)
718 : StatementNode(globalData)
719 , m_statement(statement)
720 , m_expr(expr)
721 {
722 }
723
724 inline WhileNode::WhileNode(JSGlobalData* globalData, ExpressionNode* expr, StatementNode* statement)
725 : StatementNode(globalData)
726 , m_expr(expr)
727 , m_statement(statement)
728 {
729 }
730
731 inline ForNode::ForNode(JSGlobalData* globalData, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, bool expr1WasVarDecl)
732 : StatementNode(globalData)
733 , m_expr1(expr1)
734 , m_expr2(expr2)
735 , m_expr3(expr3)
736 , m_statement(statement)
737 , m_expr1WasVarDecl(expr1 && expr1WasVarDecl)
738 {
739 ASSERT(statement);
740 }
741
742 inline ContinueNode::ContinueNode(JSGlobalData* globalData)
743 : StatementNode(globalData)
f9bf01c6 744 , m_ident(globalData->propertyNames->nullIdentifier)
ba379fdc
A
745 {
746 }
747
748 inline ContinueNode::ContinueNode(JSGlobalData* globalData, const Identifier& ident)
749 : StatementNode(globalData)
750 , m_ident(ident)
751 {
752 }
753
754 inline BreakNode::BreakNode(JSGlobalData* globalData)
755 : StatementNode(globalData)
f9bf01c6 756 , m_ident(globalData->propertyNames->nullIdentifier)
ba379fdc
A
757 {
758 }
759
760 inline BreakNode::BreakNode(JSGlobalData* globalData, const Identifier& ident)
761 : StatementNode(globalData)
762 , m_ident(ident)
763 {
764 }
765
766 inline ReturnNode::ReturnNode(JSGlobalData* globalData, ExpressionNode* value)
767 : StatementNode(globalData)
768 , m_value(value)
769 {
770 }
771
772 inline WithNode::WithNode(JSGlobalData* globalData, ExpressionNode* expr, StatementNode* statement, uint32_t divot, uint32_t expressionLength)
773 : StatementNode(globalData)
774 , m_expr(expr)
775 , m_statement(statement)
776 , m_divot(divot)
777 , m_expressionLength(expressionLength)
778 {
779 }
780
781 inline LabelNode::LabelNode(JSGlobalData* globalData, const Identifier& name, StatementNode* statement)
782 : StatementNode(globalData)
783 , m_name(name)
784 , m_statement(statement)
785 {
786 }
787
788 inline ThrowNode::ThrowNode(JSGlobalData* globalData, ExpressionNode* expr)
789 : StatementNode(globalData)
790 , m_expr(expr)
791 {
792 }
793
794 inline TryNode::TryNode(JSGlobalData* globalData, StatementNode* tryBlock, const Identifier& exceptionIdent, bool catchHasEval, StatementNode* catchBlock, StatementNode* finallyBlock)
795 : StatementNode(globalData)
796 , m_tryBlock(tryBlock)
797 , m_exceptionIdent(exceptionIdent)
798 , m_catchBlock(catchBlock)
799 , m_finallyBlock(finallyBlock)
800 , m_catchHasEval(catchHasEval)
801 {
802 }
803
804 inline ParameterNode::ParameterNode(JSGlobalData*, const Identifier& ident)
805 : m_ident(ident)
806 , m_next(0)
807 {
808 }
809
810 inline ParameterNode::ParameterNode(JSGlobalData*, ParameterNode* l, const Identifier& ident)
811 : m_ident(ident)
812 , m_next(0)
813 {
814 l->m_next = this;
815 }
816
817 inline FuncExprNode::FuncExprNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
818 : ExpressionNode(globalData)
ba379fdc
A
819 , m_body(body)
820 {
f9bf01c6 821 m_body->finishParsing(source, parameter, ident);
ba379fdc
A
822 }
823
824 inline FuncDeclNode::FuncDeclNode(JSGlobalData* globalData, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
825 : StatementNode(globalData)
ba379fdc
A
826 , m_body(body)
827 {
f9bf01c6 828 m_body->finishParsing(source, parameter, ident);
ba379fdc
A
829 }
830
f9bf01c6 831 inline CaseClauseNode::CaseClauseNode(JSGlobalData*, ExpressionNode* expr, SourceElements* statements)
ba379fdc 832 : m_expr(expr)
f9bf01c6 833 , m_statements(statements)
ba379fdc 834 {
ba379fdc
A
835 }
836
837 inline ClauseListNode::ClauseListNode(JSGlobalData*, CaseClauseNode* clause)
838 : m_clause(clause)
839 , m_next(0)
840 {
841 }
842
843 inline ClauseListNode::ClauseListNode(JSGlobalData*, ClauseListNode* clauseList, CaseClauseNode* clause)
844 : m_clause(clause)
845 , m_next(0)
846 {
847 clauseList->m_next = this;
848 }
849
850 inline CaseBlockNode::CaseBlockNode(JSGlobalData*, ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2)
851 : m_list1(list1)
852 , m_defaultClause(defaultClause)
853 , m_list2(list2)
854 {
855 }
856
857 inline SwitchNode::SwitchNode(JSGlobalData* globalData, ExpressionNode* expr, CaseBlockNode* block)
858 : StatementNode(globalData)
859 , m_expr(expr)
860 , m_block(block)
861 {
862 }
863
864 inline ConstDeclNode::ConstDeclNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* init)
865 : ExpressionNode(globalData)
866 , m_ident(ident)
867 , m_next(0)
868 , m_init(init)
869 {
870 }
871
f9bf01c6 872 inline BlockNode::BlockNode(JSGlobalData* globalData, SourceElements* statements)
ba379fdc 873 : StatementNode(globalData)
f9bf01c6 874 , m_statements(statements)
ba379fdc 875 {
ba379fdc
A
876 }
877
878 inline ForInNode::ForInNode(JSGlobalData* globalData, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
879 : StatementNode(globalData)
f9bf01c6 880 , m_ident(globalData->propertyNames->nullIdentifier)
ba379fdc
A
881 , m_init(0)
882 , m_lexpr(l)
883 , m_expr(expr)
884 , m_statement(statement)
885 , m_identIsVarDecl(false)
886 {
887 }
888
889 inline ForInNode::ForInNode(JSGlobalData* globalData, const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement, int divot, int startOffset, int endOffset)
890 : StatementNode(globalData)
891 , m_ident(ident)
892 , m_init(0)
893 , m_lexpr(new (globalData) ResolveNode(globalData, ident, divot - startOffset))
894 , m_expr(expr)
895 , m_statement(statement)
896 , m_identIsVarDecl(true)
897 {
898 if (in) {
899 AssignResolveNode* node = new (globalData) AssignResolveNode(globalData, ident, in, true);
900 node->setExceptionSourceCode(divot, divot - startOffset, endOffset - divot);
901 m_init = node;
902 }
903 // for( var foo = bar in baz )
904 }
905
906} // namespace JSC
907
908#endif // NodeConstructors_h