123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844 |
- /*
- * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
- *
- * 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"
- #include "Parser.h"
- namespace JSC {
- inline void* ParserArenaFreeable::operator new(size_t size, VM* vm)
- {
- return vm->parserArena->allocateFreeable(size);
- }
- inline void* ParserArenaDeletable::operator new(size_t size, VM* vm)
- {
- return vm->parserArena->allocateDeletable(size);
- }
- inline ParserArenaRefCounted::ParserArenaRefCounted(VM* vm)
- {
- vm->parserArena->derefWithArena(adoptRef(this));
- }
- inline Node::Node(const JSTokenLocation& location)
- : m_lineNumber(location.line)
- , m_startOffset(location.startOffset)
- , m_lineStartOffset(location.lineStartOffset)
- {
- ASSERT(location.startOffset >= location.lineStartOffset);
- }
- inline ExpressionNode::ExpressionNode(const JSTokenLocation& location, ResultType resultType)
- : Node(location)
- , m_resultType(resultType)
- {
- }
- inline StatementNode::StatementNode(const JSTokenLocation& location)
- : Node(location)
- , m_lastLine(-1)
- {
- }
- inline ConstantNode::ConstantNode(const JSTokenLocation& location, ResultType resultType)
- : ExpressionNode(location, resultType)
- {
- }
- inline NullNode::NullNode(const JSTokenLocation& location)
- : ConstantNode(location, ResultType::nullType())
- {
- }
- inline BooleanNode::BooleanNode(const JSTokenLocation& location, bool value)
- : ConstantNode(location, ResultType::booleanType())
- , m_value(value)
- {
- }
- inline NumberNode::NumberNode(const JSTokenLocation& location, double value)
- : ConstantNode(location, JSValue(value).isInt32() ? ResultType::numberTypeIsInt32() : ResultType::numberType())
- , m_value(value)
- {
- }
- inline StringNode::StringNode(const JSTokenLocation& location, const Identifier& value)
- : ConstantNode(location, ResultType::stringType())
- , m_value(value)
- {
- }
- inline RegExpNode::RegExpNode(const JSTokenLocation& location, const Identifier& pattern, const Identifier& flags)
- : ExpressionNode(location)
- , m_pattern(pattern)
- , m_flags(flags)
- {
- }
- inline ThisNode::ThisNode(const JSTokenLocation& location)
- : ExpressionNode(location)
- {
- }
- inline ResolveNode::ResolveNode(const JSTokenLocation& location, const Identifier& ident, unsigned startOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , m_ident(ident)
- , m_startOffset(startOffset)
- , m_divotLine(divotLine)
- , m_divotLineStart(divotLineStart)
- {
- ASSERT(m_startOffset >= m_divotLineStart);
- }
- inline ElementNode::ElementNode(int elision, ExpressionNode* node)
- : m_next(0)
- , m_elision(elision)
- , m_node(node)
- {
- }
- inline ElementNode::ElementNode(ElementNode* l, int elision, ExpressionNode* node)
- : m_next(0)
- , m_elision(elision)
- , m_node(node)
- {
- l->m_next = this;
- }
- inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision)
- : ExpressionNode(location)
- , m_element(0)
- , m_elision(elision)
- , m_optional(true)
- {
- }
- inline ArrayNode::ArrayNode(const JSTokenLocation& location, ElementNode* element)
- : ExpressionNode(location)
- , m_element(element)
- , m_elision(0)
- , m_optional(false)
- {
- }
- inline ArrayNode::ArrayNode(const JSTokenLocation& location, int elision, ElementNode* element)
- : ExpressionNode(location)
- , m_element(element)
- , m_elision(elision)
- , m_optional(true)
- {
- }
- inline PropertyNode::PropertyNode(VM*, const Identifier& name, ExpressionNode* assign, Type type)
- : m_name(name)
- , m_assign(assign)
- , m_type(type)
- {
- }
- inline PropertyNode::PropertyNode(VM* vm, double name, ExpressionNode* assign, Type type)
- : m_name(vm->parserArena->identifierArena().makeNumericIdentifier(vm, name))
- , m_assign(assign)
- , m_type(type)
- {
- }
- inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node)
- : ExpressionNode(location)
- , m_node(node)
- , m_next(0)
- {
- }
- inline PropertyListNode::PropertyListNode(const JSTokenLocation& location, PropertyNode* node, PropertyListNode* list)
- : ExpressionNode(location)
- , m_node(node)
- , m_next(0)
- {
- list->m_next = this;
- }
- inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location)
- : ExpressionNode(location)
- , m_list(0)
- {
- }
- inline ObjectLiteralNode::ObjectLiteralNode(const JSTokenLocation& location, PropertyListNode* list)
- : ExpressionNode(location)
- , m_list(list)
- {
- }
- inline BracketAccessorNode::BracketAccessorNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments)
- : ExpressionNode(location)
- , m_base(base)
- , m_subscript(subscript)
- , m_subscriptHasAssignments(subscriptHasAssignments)
- {
- }
- inline DotAccessorNode::DotAccessorNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident)
- : ExpressionNode(location)
- , m_base(base)
- , m_ident(ident)
- {
- }
- inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ExpressionNode* expr)
- : ExpressionNode(location)
- , m_next(0)
- , m_expr(expr)
- {
- }
- inline ArgumentListNode::ArgumentListNode(const JSTokenLocation& location, ArgumentListNode* listNode, ExpressionNode* expr)
- : ExpressionNode(location)
- , m_next(0)
- , m_expr(expr)
- {
- listNode->m_next = this;
- }
- inline ArgumentsNode::ArgumentsNode()
- : m_listNode(0)
- {
- }
- inline ArgumentsNode::ArgumentsNode(ArgumentListNode* listNode)
- : m_listNode(listNode)
- {
- }
- inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr)
- : ExpressionNode(location)
- , m_expr(expr)
- , m_args(0)
- {
- }
- inline NewExprNode::NewExprNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args)
- : ExpressionNode(location)
- , m_expr(expr)
- , m_args(args)
- {
- }
- inline EvalFunctionCallNode::EvalFunctionCallNode(const JSTokenLocation& location, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_args(args)
- {
- ASSERT(divot >= divotLineStart);
- }
- inline FunctionCallValueNode::FunctionCallValueNode(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_expr(expr)
- , m_args(args)
- {
- }
- inline FunctionCallResolveNode::FunctionCallResolveNode(const JSTokenLocation& location, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_ident(ident)
- , m_args(args)
- {
- }
- inline FunctionCallBracketNode::FunctionCallBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_base(base)
- , m_subscript(subscript)
- , m_args(args)
- {
- }
- inline FunctionCallDotNode::FunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_base(base)
- , m_ident(ident)
- , m_args(args)
- {
- }
- inline CallFunctionCallDotNode::CallFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : FunctionCallDotNode(location, base, ident, args, divot, startOffset, endOffset, divotLine, divotLineStart)
- {
- }
- inline ApplyFunctionCallDotNode::ApplyFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : FunctionCallDotNode(location, base, ident, args, divot, startOffset, endOffset, divotLine, divotLineStart)
- {
- }
- inline PostfixNode::PostfixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : PrefixNode(location, expr, oper, divot, startOffset, endOffset, divotLine, divotLineStart)
- {
- }
- inline DeleteResolveNode::DeleteResolveNode(const JSTokenLocation& location, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_ident(ident)
- {
- }
- inline DeleteBracketNode::DeleteBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_base(base)
- , m_subscript(subscript)
- {
- }
- inline DeleteDotNode::DeleteDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_base(base)
- , m_ident(ident)
- {
- }
- inline DeleteValueNode::DeleteValueNode(const JSTokenLocation& location, ExpressionNode* expr)
- : ExpressionNode(location)
- , m_expr(expr)
- {
- }
- inline VoidNode::VoidNode(const JSTokenLocation& location, ExpressionNode* expr)
- : ExpressionNode(location)
- , m_expr(expr)
- {
- }
- inline TypeOfResolveNode::TypeOfResolveNode(const JSTokenLocation& location, const Identifier& ident)
- : ExpressionNode(location, ResultType::stringType())
- , m_ident(ident)
- {
- }
- inline TypeOfValueNode::TypeOfValueNode(const JSTokenLocation& location, ExpressionNode* expr)
- : ExpressionNode(location, ResultType::stringType())
- , m_expr(expr)
- {
- }
- inline PrefixNode::PrefixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator oper, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowablePrefixedSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_expr(expr)
- , m_operator(oper)
- {
- }
- inline UnaryOpNode::UnaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr, OpcodeID opcodeID)
- : ExpressionNode(location, type)
- , m_expr(expr)
- , m_opcodeID(opcodeID)
- {
- }
- inline UnaryPlusNode::UnaryPlusNode(const JSTokenLocation& location, ExpressionNode* expr)
- : UnaryOpNode(location, ResultType::numberType(), expr, op_to_number)
- {
- }
- inline NegateNode::NegateNode(const JSTokenLocation& location, ExpressionNode* expr)
- : UnaryOpNode(location, ResultType::numberType(), expr, op_negate)
- {
- }
- inline BitwiseNotNode::BitwiseNotNode(const JSTokenLocation& location, ExpressionNode* expr)
- : ExpressionNode(location, ResultType::forBitOp())
- , m_expr(expr)
- {
- }
- inline LogicalNotNode::LogicalNotNode(const JSTokenLocation& location, ExpressionNode* expr)
- : UnaryOpNode(location, ResultType::booleanType(), expr, op_not)
- {
- }
- inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
- : ExpressionNode(location)
- , m_expr1(expr1)
- , m_expr2(expr2)
- , m_opcodeID(opcodeID)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
- inline BinaryOpNode::BinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
- : ExpressionNode(location, type)
- , m_expr1(expr1)
- , m_expr2(expr2)
- , m_opcodeID(opcodeID)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
- inline MultNode::MultNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mul, rightHasAssignments)
- {
- }
- inline DivNode::DivNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_div, rightHasAssignments)
- {
- }
- inline ModNode::ModNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_mod, rightHasAssignments)
- {
- }
- 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)
- {
- }
- inline SubNode::SubNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_sub, rightHasAssignments)
- {
- }
- inline LeftShiftNode::LeftShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_lshift, rightHasAssignments)
- {
- }
- inline RightShiftNode::RightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_rshift, rightHasAssignments)
- {
- }
- inline UnsignedRightShiftNode::UnsignedRightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::numberType(), expr1, expr2, op_urshift, rightHasAssignments)
- {
- }
- inline LessNode::LessNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_less, rightHasAssignments)
- {
- }
- inline GreaterNode::GreaterNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greater, rightHasAssignments)
- {
- }
- inline LessEqNode::LessEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_lesseq, rightHasAssignments)
- {
- }
- inline GreaterEqNode::GreaterEqNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_greatereq, rightHasAssignments)
- {
- }
- inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ResultType type, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
- : BinaryOpNode(location, type, expr1, expr2, opcodeID, rightHasAssignments)
- {
- }
- inline ThrowableBinaryOpNode::ThrowableBinaryOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID opcodeID, bool rightHasAssignments)
- : BinaryOpNode(location, expr1, expr2, opcodeID, rightHasAssignments)
- {
- }
- inline InstanceOfNode::InstanceOfNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : ThrowableBinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_instanceof, rightHasAssignments)
- {
- }
- inline InNode::InNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : ThrowableBinaryOpNode(location, expr1, expr2, op_in, rightHasAssignments)
- {
- }
- inline EqualNode::EqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_eq, rightHasAssignments)
- {
- }
- inline NotEqualNode::NotEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_neq, rightHasAssignments)
- {
- }
- inline StrictEqualNode::StrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_stricteq, rightHasAssignments)
- {
- }
- inline NotStrictEqualNode::NotStrictEqualNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::booleanType(), expr1, expr2, op_nstricteq, rightHasAssignments)
- {
- }
- inline BitAndNode::BitAndNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitand, rightHasAssignments)
- {
- }
- inline BitOrNode::BitOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitor, rightHasAssignments)
- {
- }
- inline BitXOrNode::BitXOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
- : BinaryOpNode(location, ResultType::forBitOp(), expr1, expr2, op_bitxor, rightHasAssignments)
- {
- }
- inline LogicalOpNode::LogicalOpNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, LogicalOperator oper)
- : ExpressionNode(location, ResultType::booleanType())
- , m_expr1(expr1)
- , m_expr2(expr2)
- , m_operator(oper)
- {
- }
- inline ConditionalNode::ConditionalNode(const JSTokenLocation& location, ExpressionNode* logical, ExpressionNode* expr1, ExpressionNode* expr2)
- : ExpressionNode(location)
- , m_logical(logical)
- , m_expr1(expr1)
- , m_expr2(expr2)
- {
- }
- inline ReadModifyResolveNode::ReadModifyResolveNode(const JSTokenLocation& location, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_ident(ident)
- , m_right(right)
- , m_operator(oper)
- , m_rightHasAssignments(rightHasAssignments)
- {
- ASSERT(divot >= divotLineStart);
- ASSERT(divot - startOffset >= divotLineStart);
- }
- inline AssignResolveNode::AssignResolveNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* right)
- : ExpressionNode(location)
- , m_ident(ident)
- , m_right(right)
- {
- }
- inline ReadModifyBracketNode::ReadModifyBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_base(base)
- , m_subscript(subscript)
- , m_right(right)
- , m_operator(oper)
- , m_subscriptHasAssignments(subscriptHasAssignments)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
- inline AssignBracketNode::AssignBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right, bool subscriptHasAssignments, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_base(base)
- , m_subscript(subscript)
- , m_right(right)
- , m_subscriptHasAssignments(subscriptHasAssignments)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
- inline AssignDotNode::AssignDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_base(base)
- , m_ident(ident)
- , m_right(right)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
- inline ReadModifyDotNode::ReadModifyDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right, bool rightHasAssignments, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableSubExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- , m_base(base)
- , m_ident(ident)
- , m_right(right)
- , m_operator(oper)
- , m_rightHasAssignments(rightHasAssignments)
- {
- }
- inline AssignErrorNode::AssignErrorNode(const JSTokenLocation& location, unsigned divot, unsigned startOffset, unsigned endOffset, unsigned divotLine, unsigned divotLineStart)
- : ExpressionNode(location)
- , ThrowableExpressionData(divot, startOffset, endOffset, divotLine, divotLineStart)
- {
- }
- inline CommaNode::CommaNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2)
- : ExpressionNode(location)
- {
- m_expressions.append(expr1);
- m_expressions.append(expr2);
- }
- inline ConstStatementNode::ConstStatementNode(const JSTokenLocation& location, ConstDeclNode* next)
- : StatementNode(location)
- , m_next(next)
- {
- }
- inline SourceElements::SourceElements()
- {
- }
- inline EmptyStatementNode::EmptyStatementNode(const JSTokenLocation& location)
- : StatementNode(location)
- {
- }
- inline DebuggerStatementNode::DebuggerStatementNode(const JSTokenLocation& location)
- : StatementNode(location)
- {
- }
-
- inline ExprStatementNode::ExprStatementNode(const JSTokenLocation& location, ExpressionNode* expr)
- : StatementNode(location)
- , m_expr(expr)
- {
- }
- inline VarStatementNode::VarStatementNode(const JSTokenLocation& location, ExpressionNode* expr)
- : StatementNode(location)
- , m_expr(expr)
- {
- }
-
- inline IfElseNode::IfElseNode(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock)
- : StatementNode(location)
- , m_condition(condition)
- , m_ifBlock(ifBlock)
- , m_elseBlock(elseBlock)
- {
- }
- inline DoWhileNode::DoWhileNode(const JSTokenLocation& location, StatementNode* statement, ExpressionNode* expr)
- : StatementNode(location)
- , m_statement(statement)
- , m_expr(expr)
- {
- }
- inline WhileNode::WhileNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement)
- : StatementNode(location)
- , m_expr(expr)
- , m_statement(statement)
- {
- }
- inline ForNode::ForNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement)
- : StatementNode(location)
- , m_expr1(expr1)
- , m_expr2(expr2)
- , m_expr3(expr3)
- , m_statement(statement)
- {
- ASSERT(statement);
- }
- inline ContinueNode::ContinueNode(VM* vm, const JSTokenLocation& location)
- : StatementNode(location)
- , m_ident(vm->propertyNames->nullIdentifier)
- {
- }
- inline ContinueNode::ContinueNode(const JSTokenLocation& location, const Identifier& ident)
- : StatementNode(location)
- , m_ident(ident)
- {
- }
-
- inline BreakNode::BreakNode(VM* vm, const JSTokenLocation& location)
- : StatementNode(location)
- , m_ident(vm->propertyNames->nullIdentifier)
- {
- }
- inline BreakNode::BreakNode(const JSTokenLocation& location, const Identifier& ident)
- : StatementNode(location)
- , m_ident(ident)
- {
- }
-
- inline ReturnNode::ReturnNode(const JSTokenLocation& location, ExpressionNode* value)
- : StatementNode(location)
- , m_value(value)
- {
- }
- inline WithNode::WithNode(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement, uint32_t divot, unsigned divotLine, unsigned divotLineStart, uint32_t expressionLength)
- : StatementNode(location)
- , m_expr(expr)
- , m_statement(statement)
- , m_divot(divot)
- , m_divotLine(divotLine)
- , m_divotLineStart(divotLineStart)
- , m_expressionLength(expressionLength)
- {
- }
- inline LabelNode::LabelNode(const JSTokenLocation& location, const Identifier& name, StatementNode* statement)
- : StatementNode(location)
- , m_name(name)
- , m_statement(statement)
- {
- }
- inline ThrowNode::ThrowNode(const JSTokenLocation& location, ExpressionNode* expr)
- : StatementNode(location)
- , m_expr(expr)
- {
- }
- inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock)
- : StatementNode(location)
- , m_tryBlock(tryBlock)
- , m_exceptionIdent(exceptionIdent)
- , m_catchBlock(catchBlock)
- , m_finallyBlock(finallyBlock)
- {
- }
- inline ParameterNode::ParameterNode(const Identifier& ident)
- : m_ident(ident)
- , m_next(0)
- {
- }
- inline ParameterNode::ParameterNode(ParameterNode* l, const Identifier& ident)
- : m_ident(ident)
- , m_next(0)
- {
- l->m_next = this;
- }
- inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
- : ExpressionNode(location)
- , m_body(body)
- {
- m_body->finishParsing(source, parameter, ident, FunctionNameIsInScope);
- }
- inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter)
- : StatementNode(location)
- , m_body(body)
- {
- m_body->finishParsing(source, parameter, ident, FunctionNameIsNotInScope);
- }
- inline CaseClauseNode::CaseClauseNode(ExpressionNode* expr, SourceElements* statements)
- : m_expr(expr)
- , m_statements(statements)
- {
- }
- inline ClauseListNode::ClauseListNode(CaseClauseNode* clause)
- : m_clause(clause)
- , m_next(0)
- {
- }
- inline ClauseListNode::ClauseListNode(ClauseListNode* clauseList, CaseClauseNode* clause)
- : m_clause(clause)
- , m_next(0)
- {
- clauseList->m_next = this;
- }
- inline CaseBlockNode::CaseBlockNode(ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2)
- : m_list1(list1)
- , m_defaultClause(defaultClause)
- , m_list2(list2)
- {
- }
- inline SwitchNode::SwitchNode(const JSTokenLocation& location, ExpressionNode* expr, CaseBlockNode* block)
- : StatementNode(location)
- , m_expr(expr)
- , m_block(block)
- {
- }
- inline ConstDeclNode::ConstDeclNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* init)
- : ExpressionNode(location)
- , m_ident(ident)
- , m_next(0)
- , m_init(init)
- {
- }
- inline BlockNode::BlockNode(const JSTokenLocation& location, SourceElements* statements)
- : StatementNode(location)
- , m_statements(statements)
- {
- }
- inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement)
- : StatementNode(location)
- , m_init(0)
- , m_lexpr(l)
- , m_expr(expr)
- , m_statement(statement)
- {
- }
- inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, const Identifier& ident, ExpressionNode* in, ExpressionNode* expr, StatementNode* statement, unsigned divot, int startOffset, int endOffset, unsigned divotLine, unsigned divotLineStart)
- : StatementNode(location)
- , m_init(0)
- , m_lexpr(new (vm) ResolveNode(location, ident, divot - startOffset, divotLine, divotLineStart))
- , m_expr(expr)
- , m_statement(statement)
- {
- if (in) {
- AssignResolveNode* node = new (vm) AssignResolveNode(location, ident, in);
- ASSERT(divot >= divotLineStart);
- node->setExceptionSourceCode(divot, divot - startOffset, endOffset - divot, divotLine, divotLineStart);
- m_init = node;
- }
- // for( var foo = bar in baz )
- }
- } // namespace JSC
- #endif // NodeConstructors_h
|