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