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