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