NodeConstructors.h 33.3 KB
Newer Older
1
/*
2
 *  Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 *
 */

#ifndef NodeConstructors_h
#define NodeConstructors_h

#include "Nodes.h"
#include "Lexer.h"
26
#include "Parser.h"
27 28 29

namespace JSC {

ggaren@apple.com's avatar
ggaren@apple.com committed
30
    inline void* ParserArenaFreeable::operator new(size_t size, VM* vm)
31
    {
ggaren@apple.com's avatar
ggaren@apple.com committed
32
        return vm->parserArena->allocateFreeable(size);
33 34
    }

ggaren@apple.com's avatar
ggaren@apple.com committed
35
    inline void* ParserArenaDeletable::operator new(size_t size, VM* vm)
36
    {
ggaren@apple.com's avatar
ggaren@apple.com committed
37
        return vm->parserArena->allocateDeletable(size);
38 39
    }

ggaren@apple.com's avatar
ggaren@apple.com committed
40
    inline ParserArenaRefCounted::ParserArenaRefCounted(VM* vm)
41
    {
ggaren@apple.com's avatar
ggaren@apple.com committed
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 52
    inline ExpressionNode::ExpressionNode(const JSTokenLocation& location, ResultType resultType)
        : Node(location)
53 54 55 56
        , m_resultType(resultType)
    {
    }

57 58
    inline StatementNode::StatementNode(const JSTokenLocation& location)
        : Node(location)
59 60 61 62
        , m_lastLine(-1)
    {
    }

63 64 65 66 67
    inline ConstantNode::ConstantNode(const JSTokenLocation& location, ResultType resultType)
        : ExpressionNode(location, resultType)
    {
    }

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 76 77 78
        , m_value(value)
    {
    }

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 92
    inline RegExpNode::RegExpNode(const JSTokenLocation& location, const Identifier& pattern, const Identifier& flags)
        : ExpressionNode(location)
93 94 95 96 97
        , m_pattern(pattern)
        , m_flags(flags)
    {
    }

98 99
    inline ThisNode::ThisNode(const JSTokenLocation& location)
        : 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 114 115 116 117
        , m_elision(elision)
        , m_node(node)
    {
    }

118
    inline ElementNode::ElementNode(ElementNode* l, int elision, ExpressionNode* node)
119
        : m_next(0)
120 121 122 123 124 125
        , m_elision(elision)
        , m_node(node)
    {
        l->m_next = this;
    }

126 127
    inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision)
        : ExpressionNode(location)
128
        , m_element(0)
129 130 131 132 133
        , m_elision(elision)
        , m_optional(true)
    {
    }

134 135
    inline ArrayNode::ArrayNode(const JSTokenLocation& location, ElementNode* element)
        : ExpressionNode(location)
136 137 138 139 140 141
        , m_element(element)
        , m_elision(0)
        , m_optional(false)
    {
    }

142 143
    inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision, ElementNode* element)
        : ExpressionNode(location)
144 145 146 147 148 149
        , m_element(element)
        , m_elision(elision)
        , m_optional(true)
    {
    }

ggaren@apple.com's avatar
ggaren@apple.com committed
150
    inline PropertyNode::PropertyNode(VM*, const Identifier& name, ExpressionNode* assign, Type type)
151
        : m_name(&name)
152 153 154 155 156
        , m_assign(assign)
        , m_type(type)
    {
    }

ggaren@apple.com's avatar
ggaren@apple.com committed
157
    inline PropertyNode::PropertyNode(VM* vm, double name, ExpressionNode* assign, Type type)
158 159 160 161 162 163 164 165 166
        : m_name(&vm->parserArena->identifierArena().makeNumericIdentifier(vm, name))
        , m_assign(assign)
        , m_type(type)
    {
    }
    
    inline PropertyNode::PropertyNode(VM*, ExpressionNode* name, ExpressionNode* assign, Type type)
        : m_name(0)
        , m_expression(name)
167 168 169 170 171
        , m_assign(assign)
        , m_type(type)
    {
    }

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 185 186
    {
        list->m_next = this;
    }

187 188
    inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location)
        : ExpressionNode(location)
189
        , m_list(0)
190 191 192
    {
    }

193 194
    inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location, PropertyListNode* list)
        : ExpressionNode(location)
195 196 197 198
        , m_list(list)
    {
    }

199 200
    inline BracketAccessorNode::BracketAccessorNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments)
        : ExpressionNode(location)
201 202 203 204 205 206
        , m_base(base)
        , m_subscript(subscript)
        , m_subscriptHasAssignments(subscriptHasAssignments)
    {
    }

207 208
    inline DotAccessorNode::DotAccessorNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident)
        : ExpressionNode(location)
209 210 211 212
        , m_base(base)
        , m_ident(ident)
    {
    }
213 214 215 216 217 218 219
    
    
    inline SpreadExpressionNode::SpreadExpressionNode(const JSTokenLocation& location, ExpressionNode* expression)
        : ExpressionNode(location)
        , m_expression(expression)
    {
    }
220

221
    inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ExpressionNode* expr)
222
        : ExpressionNode(location)
223
        , m_next(0)
224 225 226 227
        , m_expr(expr)
    {
    }

228
    inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ArgumentListNode* listNode, ExpressionNode* expr)
229
        : ExpressionNode(location)
230
        , m_next(0)
231 232 233 234 235
        , m_expr(expr)
    {
        listNode->m_next = this;
    }

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 247
    inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr)
        : ExpressionNode(location)
248
        , m_expr(expr)
249
        , m_args(0)
250 251 252
    {
    }

253 254
    inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args)
        : ExpressionNode(location)
255 256 257 258 259
        , m_expr(expr)
        , m_args(args)
    {
    }

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 264 265 266
        , m_args(args)
    {
    }

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 271 272
        , m_expr(expr)
        , m_args(args)
    {
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 280 281 282 283
        , m_ident(ident)
        , m_args(args)
    {
    }

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 288 289 290 291 292
        , m_base(base)
        , m_subscript(subscript)
        , m_args(args)
    {
    }

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 297 298 299 300 301
        , m_base(base)
        , m_ident(ident)
        , m_args(args)
    {
    }

302 303
    inline CallFunctionCallDotNode::CallFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
        : FunctionCallDotNode(location, base, ident, args, divot, divotStart, divotEnd)
304 305 306
    {
    }

307 308
    inline ApplyFunctionCallDotNode::ApplyFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
        : FunctionCallDotNode(location, base, ident, args, divot, divotStart, divotEnd)
309 310 311
    {
    }

312 313
    inline PostfixNode::PostfixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd)
        : 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 321 322 323
        , m_ident(ident)
    {
    }

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 328 329 330 331
        , m_base(base)
        , m_subscript(subscript)
    {
    }

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 336 337 338 339
        , m_base(base)
        , m_ident(ident)
    {
    }

340 341
    inline DeleteValueNode::DeleteValueNode(const JSTokenLocation& location, ExpressionNode* expr)
        : ExpressionNode(location)
342 343 344 345
        , m_expr(expr)
    {
    }

346 347
    inline VoidNode::VoidNode(const JSTokenLocation& location, ExpressionNode* expr)
        : ExpressionNode(location)
348 349 350 351
        , m_expr(expr)
    {
    }

352 353
    inline TypeOfResolveNode::TypeOfResolveNode(const JSTokenLocation& location, const Identifier& ident)
        : ExpressionNode(location, ResultType::stringType())
354 355 356 357
        , m_ident(ident)
    {
    }

358 359
    inline TypeOfValueNode::TypeOfValueNode(const JSTokenLocation& location, ExpressionNode* expr)
        : ExpressionNode(location, ResultType::stringType())
360 361 362 363
        , m_expr(expr)
    {
    }

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 369 370 371
        , m_operator(oper)
    {
    }

372 373
    inline UnaryOpNode::UnaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr, OpcodeID opcodeID)
        : ExpressionNode(location, type)
374 375 376 377 378
        , m_expr(expr)
        , m_opcodeID(opcodeID)
    {
    }

379
    inline UnaryPlusNode::UnaryPlusNode(const JSTokenLocation& location, ExpressionNode* expr)
380
        : UnaryOpNode(location, ResultType::numberType(), expr, op_to_number)
381 382 383
    {
    }

384 385
    inline NegateNode::NegateNode(const JSTokenLocation& location, ExpressionNode* expr)
        : UnaryOpNode(location, ResultType::numberType(), expr, op_negate)
386 387 388
    {
    }

389 390
    inline BitwiseNotNode::BitwiseNotNode(const JSTokenLocation& location, ExpressionNode* expr)
        : ExpressionNode(location, ResultType::forBitOp())
391
        , m_expr(expr)
392 393 394
    {
    }

395 396
    inline LogicalNotNode::LogicalNotNode(const JSTokenLocation& location, ExpressionNode* expr)
        : UnaryOpNode(location, ResultType::booleanType(), expr, op_not)
397 398 399
    {
    }

400 401
    inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
        : ExpressionNode(location)
402 403 404 405 406 407 408
        , m_expr1(expr1)
        , m_expr2(expr2)
        , m_opcodeID(opcodeID)
        , m_rightHasAssignments(rightHasAssignments)
    {
    }

409 410
    inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
        : ExpressionNode(location, type)
411 412 413 414 415 416 417
        , m_expr1(expr1)
        , m_expr2(expr2)
        , m_opcodeID(opcodeID)
        , m_rightHasAssignments(rightHasAssignments)
    {
    }

418 419
    inline MultNode::MultNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mul, rightHasAssignments)
420 421 422
    {
    }

423 424
    inline DivNode::DivNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_div, rightHasAssignments)
425 426 427 428
    {
    }


429 430
    inline ModNode::ModNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mod, rightHasAssignments)
431 432 433
    {
    }

434 435
    inline AddNode::AddNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::forAdd(expr1->resultDescriptor(), expr2->resultDescriptor()), expr1, expr2, op_add, rightHasAssignments)
436 437 438
    {
    }

439 440
    inline SubNode::SubNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_sub, rightHasAssignments)
441 442 443
    {
    }

444 445
    inline LeftShiftNode::LeftShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_lshift, rightHasAssignments)
446 447 448
    {
    }

449 450
    inline RightShiftNode::RightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_rshift, rightHasAssignments)
451 452 453
    {
    }

454 455
    inline UnsignedRightShiftNode::UnsignedRightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_urshift, rightHasAssignments)
456 457 458
    {
    }

459 460
    inline LessNode::LessNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
461 462 463
    {
    }

464 465
    inline GreaterNode::GreaterNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greater, rightHasAssignments)
466 467 468
    {
    }

469 470
    inline LessEqNode::LessEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
471 472 473
    {
    }

474 475
    inline GreaterEqNode::GreaterEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greatereq, rightHasAssignments)
476 477 478
    {
    }

479 480
    inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
        : BinaryOpNode(location, type, expr1, expr2, opcodeID, rightHasAssignments)
481 482 483
    {
    }

484 485
    inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
        : BinaryOpNode(location, expr1, expr2, opcodeID, rightHasAssignments)
486 487 488
    {
    }

489 490
    inline InstanceOfNode::InstanceOfNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : ThrowableBinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_instanceof, rightHasAssignments)
491 492 493
    {
    }

494 495
    inline InNode::InNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : ThrowableBinaryOpNode(location, expr1, expr2, op_in, rightHasAssignments)
496 497 498
    {
    }

499 500
    inline EqualNode::EqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_eq, rightHasAssignments)
501 502 503
    {
    }

504 505
    inline NotEqualNode::NotEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_neq, rightHasAssignments)
506 507 508
    {
    }

509 510
    inline StrictEqualNode::StrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_stricteq, rightHasAssignments)
511 512 513
    {
    }

514 515
    inline NotStrictEqualNode::NotStrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_nstricteq, rightHasAssignments)
516 517 518
    {
    }

519 520
    inline BitAndNode::BitAndNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitand, rightHasAssignments)
521 522 523
    {
    }

524 525
    inline BitOrNode::BitOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitor, rightHasAssignments)
526 527 528
    {
    }

529 530
    inline BitXOrNode::BitXOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
        : 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 537 538 539 540 541
        , m_expr1(expr1)
        , m_expr2(expr2)
        , m_operator(oper)
    {
    }

542 543
    inline ConditionalNode::ConditionalNode(const JSTokenLocation& location, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2)
        : ExpressionNode(location)
544 545 546 547 548 549
        , m_logical(logical)
        , m_expr1(expr1)
        , m_expr2(expr2)
    {
    }

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 554 555 556 557 558 559
        , m_ident(ident)
        , m_right(right)
        , m_operator(oper)
        , m_rightHasAssignments(rightHasAssignments)
    {
    }

560 561
    inline AssignResolveNode::AssignResolveNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* right)
        : ExpressionNode(location)
562 563 564 565 566
        , m_ident(ident)
        , m_right(right)
    {
    }

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 572 573 574 575 576 577 578 579
        , m_base(base)
        , m_subscript(subscript)
        , m_right(right)
        , m_operator(oper)
        , m_subscriptHasAssignments(subscriptHasAssignments)
        , m_rightHasAssignments(rightHasAssignments)
    {
    }

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 584 585 586 587 588 589 590
        , m_base(base)
        , m_subscript(subscript)
        , m_right(right)
        , m_subscriptHasAssignments(subscriptHasAssignments)
        , m_rightHasAssignments(rightHasAssignments)
    {
    }

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 595 596 597 598 599 600
        , m_base(base)
        , m_ident(ident)
        , m_right(right)
        , m_rightHasAssignments(rightHasAssignments)
    {
    }

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 605 606 607 608 609 610 611
        , m_base(base)
        , m_ident(ident)
        , m_right(right)
        , m_operator(oper)
        , m_rightHasAssignments(rightHasAssignments)
    {
    }

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 619
    inline CommaNode::CommaNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2)
        : ExpressionNode(location)
620
    {
621 622
        ASSERT(expr1);
        ASSERT(expr2);
623 624
        m_expressions.append(expr1);
        m_expressions.append(expr2);
625 626
    }

627 628
    inline ConstStatementNode::ConstStatementNode(const JSTokenLocation& location, ConstDeclNode* next)
        : StatementNode(location)
629 630 631 632
        , m_next(next)
    {
    }

633
    inline SourceElements::SourceElements()
634 635 636
    {
    }

637 638
    inline EmptyStatementNode::EmptyStatementNode(const JSTokenLocation& location)
        : StatementNode(location)
639 640 641
    {
    }

642 643
    inline DebuggerStatementNode::DebuggerStatementNode(const JSTokenLocation& location)
        : StatementNode(location)
644 645 646
    {
    }
    
647 648
    inline ExprStatementNode::ExprStatementNode(const JSTokenLocation& location, ExpressionNode* expr)
        : StatementNode(location)
649 650 651 652
        , m_expr(expr)
    {
    }

653 654
    inline VarStatementNode::VarStatementNode(const JSTokenLocation& location, ExpressionNode* expr)
        : StatementNode(location)
655 656 657 658
        , m_expr(expr)
    {
    }
    
659
    inline IfElseNode::IfElseNode(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock)
660
        : StatementNode(location)
661 662 663 664 665 666
        , m_condition(condition)
        , m_ifBlock(ifBlock)
        , m_elseBlock(elseBlock)
    {
    }

667 668
    inline DoWhileNode::DoWhileNode(const JSTokenLocation& location, StatementNode* statement, ExpressionNode* expr)
        : StatementNode(location)
669 670 671 672 673
        , m_statement(statement)
        , m_expr(expr)
    {
    }

674 675
    inline WhileNode::WhileNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement)
        : StatementNode(location)
676 677 678 679 680
        , m_expr(expr)
        , m_statement(statement)
    {
    }

681 682
    inline ForNode::ForNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement)
        : StatementNode(location)
683 684 685 686 687 688 689 690
        , m_expr1(expr1)
        , m_expr2(expr2)
        , m_expr3(expr3)
        , m_statement(statement)
    {
        ASSERT(statement);
    }

ggaren@apple.com's avatar
ggaren@apple.com committed
691
    inline ContinueNode::ContinueNode(VM* vm, const JSTokenLocation& location)
692
        : StatementNode(location)
ggaren@apple.com's avatar
ggaren@apple.com committed
693
        , m_ident(vm->propertyNames->nullIdentifier)
694 695 696
    {
    }

697 698
    inline ContinueNode::ContinueNode(const JSTokenLocation& location, const Identifier& ident)
        : StatementNode(location)
699 700 701 702
        , m_ident(ident)
    {
    }
    
ggaren@apple.com's avatar
ggaren@apple.com committed
703
    inline BreakNode::BreakNode(VM* vm, const JSTokenLocation& location)
704
        : StatementNode(location)
ggaren@apple.com's avatar
ggaren@apple.com committed
705
        , m_ident(vm->propertyNames->nullIdentifier)
706 707 708
    {
    }

709 710
    inline BreakNode::BreakNode(const JSTokenLocation& location, const Identifier& ident)
        : StatementNode(location)
711 712 713 714
        , m_ident(ident)
    {
    }
    
715 716
    inline ReturnNode::ReturnNode(const JSTokenLocation& location, ExpressionNode* value)
        : StatementNode(location)
717 718 719 720
        , m_value(value)
    {
    }

721
    inline WithNode::WithNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement, const JSTextPosition& divot, uint32_t expressionLength)
722
        : StatementNode(location)
723 724 725 726 727 728 729
        , m_expr(expr)
        , m_statement(statement)
        , m_divot(divot)
        , m_expressionLength(expressionLength)
    {
    }

730 731
    inline LabelNode::LabelNode(const JSTokenLocation& location, const Identifier& name, StatementNode* statement)
        : StatementNode(location)
732 733 734 735 736
        , m_name(name)
        , m_statement(statement)
    {
    }

737 738
    inline ThrowNode::ThrowNode(const JSTokenLocation& location, ExpressionNode* expr)
        : StatementNode(location)
739 740 741 742
        , m_expr(expr)
    {
    }

743 744
    inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock)
        : StatementNode(location)
745 746 747 748 749 750 751
        , m_tryBlock(tryBlock)
        , m_exceptionIdent(exceptionIdent)
        , m_catchBlock(catchBlock)
        , m_finallyBlock(finallyBlock)
    {
    }

752 753
    inline ParameterNode::ParameterNode(PassRefPtr<DeconstructionPatternNode> pattern)
        : m_pattern(pattern)
754
        , m_next(0)
755
    {
756
        ASSERT(m_pattern);
757 758
    }

759 760
    inline ParameterNode::ParameterNode(ParameterNode* l, PassRefPtr<DeconstructionPatternNode> pattern)
        : m_pattern(pattern)
761
        , m_next(0)
762 763
    {
        l->m_next = this;
764 765
        ASSERT(m_pattern);
        ASSERT(l->m_pattern);
766 767
    }

768 769
    inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
        : ExpressionNode(location)
770 771
        , m_body(body)
    {
772
        m_body->finishParsing(source, parameter, ident, FunctionNameIsInScope);
773 774
    }

775 776
    inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
        : StatementNode(location)
777 778
        , m_body(body)
    {
779
        m_body->finishParsing(source, parameter, ident, FunctionNameIsNotInScope);
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 799 800
    {
        clauseList->m_next = this;
    }

801
    inline CaseBlockNode::CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2)
802
        : m_list1(list1)
803 804 805 806 807
        , m_defaultClause(defaultClause)
        , m_list2(list2)
    {
    }

808 809
    inline SwitchNode::SwitchNode(const JSTokenLocation& location, ExpressionNode* expr, CaseBlockNode* block)
        : StatementNode(location)
810 811 812 813 814
        , m_expr(expr)
        , m_block(block)
    {
    }

815 816
    inline ConstDeclNode::ConstDeclNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* init)
        : ExpressionNode(location)
817
        , m_ident(ident)
818
        , m_next(0)
819 820 821 822
        , m_init(init)
    {
    }

823 824
    inline BlockNode::BlockNode(const JSTokenLocation& location, SourceElements* statements)
        : StatementNode(location)
825
        , m_statements(statements)
826 827 828
    {
    }

oliver@apple.com's avatar
oliver@apple.com committed
829
    inline EnumerationNode::EnumerationNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
830
        : StatementNode(location)
831 832 833 834
        , m_lexpr(l)
        , m_expr(expr)
        , m_statement(statement)
    {
835
        ASSERT(l);
836
    }
837
    
oliver@apple.com's avatar
oliver@apple.com committed
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 842
        , m_expr(expr)
        , m_statement(statement)
843 844 845 846
    {
        ASSERT(pattern);
    }
    
oliver@apple.com's avatar
oliver@apple.com committed
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866
    inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
        : EnumerationNode(location, l, expr, statement)
    {
    }
    
    inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement)
        : EnumerationNode(vm, location, pattern, expr, statement)
    {
    }
    
    inline ForOfNode::ForOfNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
        : EnumerationNode(location, l, expr, statement)
    {
    }
    
    inline ForOfNode::ForOfNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement)
        : EnumerationNode(vm, location, pattern, expr, statement)
    {
    }
    
867
    inline DeconstructionPatternNode::DeconstructionPatternNode(VM*)
868 869 870
    {
    }

871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890
    inline ArrayPatternNode::ArrayPatternNode(VM* vm)
        : DeconstructionPatternNode(vm)
    {
    }
    
    inline PassRefPtr<ArrayPatternNode> ArrayPatternNode::create(VM* vm)
    {
        return adoptRef(new ArrayPatternNode(vm));
    }
    
    inline ObjectPatternNode::ObjectPatternNode(VM* vm)
        : DeconstructionPatternNode(vm)
    {
    }
    
    inline PassRefPtr<ObjectPatternNode> ObjectPatternNode::create(VM* vm)
    {
        return adoptRef(new ObjectPatternNode(vm));
    }

891
    inline PassRefPtr<BindingNode> BindingNode::create(VM* vm, const Identifier& boundProperty, const