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