/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#ifndef ASTBuilder_h
#define ASTBuilder_h
+#include "BuiltinNames.h"
#include "NodeConstructors.h"
#include "SyntaxChecker.h"
#include <utility>
class ASTBuilder {
struct BinaryOpInfo {
BinaryOpInfo() {}
- BinaryOpInfo(int s, int d, int e, bool r)
- : start(s)
- , divot(d)
- , end(e)
- , hasAssignment(r)
+ BinaryOpInfo(const JSTextPosition& otherStart, const JSTextPosition& otherDivot, const JSTextPosition& otherEnd, bool rhsHasAssignment)
+ : start(otherStart)
+ , divot(otherDivot)
+ , end(otherEnd)
+ , hasAssignment(rhsHasAssignment)
{
}
BinaryOpInfo(const BinaryOpInfo& lhs, const BinaryOpInfo& rhs)
, hasAssignment(lhs.hasAssignment || rhs.hasAssignment)
{
}
- int start;
- int divot;
- int end;
+ JSTextPosition start;
+ JSTextPosition divot;
+ JSTextPosition end;
bool hasAssignment;
};
struct AssignmentInfo {
AssignmentInfo() {}
- AssignmentInfo(ExpressionNode* node, int start, int divot, int initAssignments, Operator op)
+ AssignmentInfo(ExpressionNode* node, const JSTextPosition& start, const JSTextPosition& divot, int initAssignments, Operator op)
: m_node(node)
, m_start(start)
, m_divot(divot)
, m_initAssignments(initAssignments)
, m_op(op)
{
+ ASSERT(m_divot.offset >= m_divot.lineStartOffset);
+ ASSERT(m_start.offset >= m_start.lineStartOffset);
}
ExpressionNode* m_node;
- int m_start;
- int m_divot;
+ JSTextPosition m_start;
+ JSTextPosition m_divot;
int m_initAssignments;
Operator m_op;
};
public:
- ASTBuilder(JSGlobalData* globalData, SourceCode* sourceCode)
- : m_globalData(globalData)
+ ASTBuilder(VM* vm, SourceCode* sourceCode)
+ : m_vm(vm)
, m_sourceCode(sourceCode)
- , m_scope(globalData)
+ , m_scope(vm)
, m_evalCount(0)
{
}
UnaryExprContext(ASTBuilder&) {}
};
+
typedef SyntaxChecker FunctionBodyBuilder;
typedef ExpressionNode* Expression;
typedef CaseClauseNode* Clause;
typedef ConstDeclNode* ConstDeclList;
typedef std::pair<ExpressionNode*, BinaryOpInfo> BinaryOperand;
-
+ typedef RefPtr<DeconstructionPatternNode> DeconstructionPattern;
+ typedef RefPtr<ArrayPatternNode> ArrayPattern;
+ typedef RefPtr<ObjectPatternNode> ObjectPattern;
+ typedef RefPtr<BindingNode> BindingPattern;
static const bool CreatesAST = true;
static const bool NeedsFreeVariableInfo = true;
static const bool CanUseFunctionCache = true;
static const int DontBuildKeywords = 0;
static const int DontBuildStrings = 0;
- ExpressionNode* makeBinaryNode(int lineNumber, int token, std::pair<ExpressionNode*, BinaryOpInfo>, std::pair<ExpressionNode*, BinaryOpInfo>);
- ExpressionNode* makeFunctionCallNode(int lineNumber, ExpressionNode* func, ArgumentsNode* args, int start, int divot, int end);
+ ExpressionNode* makeBinaryNode(const JSTokenLocation&, int token, std::pair<ExpressionNode*, BinaryOpInfo>, std::pair<ExpressionNode*, BinaryOpInfo>);
+ ExpressionNode* makeFunctionCallNode(const JSTokenLocation&, ExpressionNode* func, ArgumentsNode* args, const JSTextPosition& divotStart, const JSTextPosition& divot, const JSTextPosition& divotEnd);
- JSC::SourceElements* createSourceElements() { return new (m_globalData) JSC::SourceElements(); }
+ JSC::SourceElements* createSourceElements() { return new (m_vm) JSC::SourceElements(); }
ParserArenaData<DeclarationStacks::VarStack>* varDeclarations() { return m_scope.m_varDeclarations; }
ParserArenaData<DeclarationStacks::FunctionStack>* funcDeclarations() { return m_scope.m_funcDeclarations; }
void appendToComma(CommaNode* commaNode, ExpressionNode* expr) { commaNode->append(expr); }
- CommaNode* createCommaExpr(int lineNumber, ExpressionNode* lhs, ExpressionNode* rhs) { return new (m_globalData) CommaNode(lineNumber, lhs, rhs); }
-
- ExpressionNode* makeAssignNode(int lineNumber, ExpressionNode* left, Operator, ExpressionNode* right, bool leftHasAssignments, bool rightHasAssignments, int start, int divot, int end);
- ExpressionNode* makePrefixNode(int lineNumber, ExpressionNode*, Operator, int start, int divot, int end);
- ExpressionNode* makePostfixNode(int lineNumber, ExpressionNode*, Operator, int start, int divot, int end);
- ExpressionNode* makeTypeOfNode(int lineNumber, ExpressionNode*);
- ExpressionNode* makeDeleteNode(int lineNumber, ExpressionNode*, int start, int divot, int end);
- ExpressionNode* makeNegateNode(int lineNumber, ExpressionNode*);
- ExpressionNode* makeBitwiseNotNode(int lineNumber, ExpressionNode*);
- ExpressionNode* makeMultNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeDivNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeModNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeAddNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeSubNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeBitXOrNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeBitAndNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeBitOrNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeLeftShiftNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeRightShiftNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
- ExpressionNode* makeURightShiftNode(int lineNumber, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
-
- ExpressionNode* createLogicalNot(int lineNumber, ExpressionNode* expr) { return new (m_globalData) LogicalNotNode(lineNumber, expr); }
- ExpressionNode* createUnaryPlus(int lineNumber, ExpressionNode* expr) { return new (m_globalData) UnaryPlusNode(lineNumber, expr); }
- ExpressionNode* createVoid(int lineNumber, ExpressionNode* expr)
+ CommaNode* createCommaExpr(const JSTokenLocation& location, ExpressionNode* lhs, ExpressionNode* rhs) { return new (m_vm) CommaNode(location, lhs, rhs); }
+
+ ExpressionNode* makeAssignNode(const JSTokenLocation&, ExpressionNode* left, Operator, ExpressionNode* right, bool leftHasAssignments, bool rightHasAssignments, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end);
+ ExpressionNode* makePrefixNode(const JSTokenLocation&, ExpressionNode*, Operator, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end);
+ ExpressionNode* makePostfixNode(const JSTokenLocation&, ExpressionNode*, Operator, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end);
+ ExpressionNode* makeTypeOfNode(const JSTokenLocation&, ExpressionNode*);
+ ExpressionNode* makeDeleteNode(const JSTokenLocation&, ExpressionNode*, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end);
+ ExpressionNode* makeNegateNode(const JSTokenLocation&, ExpressionNode*);
+ ExpressionNode* makeBitwiseNotNode(const JSTokenLocation&, ExpressionNode*);
+ ExpressionNode* makeMultNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeDivNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeModNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeAddNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeSubNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeBitXOrNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeBitAndNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeBitOrNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeLeftShiftNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeRightShiftNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+ ExpressionNode* makeURightShiftNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
+
+ ExpressionNode* createLogicalNot(const JSTokenLocation& location, ExpressionNode* expr)
+ {
+ if (expr->isNumber())
+ return createBoolean(location, isZeroOrUnordered(static_cast<NumberNode*>(expr)->value()));
+
+ return new (m_vm) LogicalNotNode(location, expr);
+ }
+ ExpressionNode* createUnaryPlus(const JSTokenLocation& location, ExpressionNode* expr) { return new (m_vm) UnaryPlusNode(location, expr); }
+ ExpressionNode* createVoid(const JSTokenLocation& location, ExpressionNode* expr)
{
incConstants();
- return new (m_globalData) VoidNode(lineNumber, expr);
+ return new (m_vm) VoidNode(location, expr);
}
- ExpressionNode* thisExpr(int lineNumber)
+ ExpressionNode* thisExpr(const JSTokenLocation& location)
{
usesThis();
- return new (m_globalData) ThisNode(lineNumber);
+ return new (m_vm) ThisNode(location);
}
- ExpressionNode* createResolve(int lineNumber, const Identifier* ident, int start)
+ ExpressionNode* createResolve(const JSTokenLocation& location, const Identifier* ident, const JSTextPosition& start)
{
- if (m_globalData->propertyNames->arguments == *ident)
+ if (m_vm->propertyNames->arguments == *ident)
usesArguments();
- return new (m_globalData) ResolveNode(lineNumber, *ident, start);
+ return new (m_vm) ResolveNode(location, *ident, start);
}
- ExpressionNode* createObjectLiteral(int lineNumber) { return new (m_globalData) ObjectLiteralNode(lineNumber); }
- ExpressionNode* createObjectLiteral(int lineNumber, PropertyListNode* properties) { return new (m_globalData) ObjectLiteralNode(lineNumber, properties); }
+ ExpressionNode* createObjectLiteral(const JSTokenLocation& location) { return new (m_vm) ObjectLiteralNode(location); }
+ ExpressionNode* createObjectLiteral(const JSTokenLocation& location, PropertyListNode* properties) { return new (m_vm) ObjectLiteralNode(location, properties); }
- ExpressionNode* createArray(int lineNumber, int elisions)
+ ExpressionNode* createArray(const JSTokenLocation& location, int elisions)
{
if (elisions)
incConstants();
- return new (m_globalData) ArrayNode(lineNumber, elisions);
+ return new (m_vm) ArrayNode(location, elisions);
}
- ExpressionNode* createArray(int lineNumber, ElementNode* elems) { return new (m_globalData) ArrayNode(lineNumber, elems); }
- ExpressionNode* createArray(int lineNumber, int elisions, ElementNode* elems)
+ ExpressionNode* createArray(const JSTokenLocation& location, ElementNode* elems) { return new (m_vm) ArrayNode(location, elems); }
+ ExpressionNode* createArray(const JSTokenLocation& location, int elisions, ElementNode* elems)
{
if (elisions)
incConstants();
- return new (m_globalData) ArrayNode(lineNumber, elisions, elems);
+ return new (m_vm) ArrayNode(location, elisions, elems);
}
- ExpressionNode* createNumberExpr(int lineNumber, double d)
+ ExpressionNode* createNumberExpr(const JSTokenLocation& location, double d)
{
incConstants();
- return new (m_globalData) NumberNode(lineNumber, d);
+ return new (m_vm) NumberNode(location, d);
}
- ExpressionNode* createString(int lineNumber, const Identifier* string)
+ ExpressionNode* createString(const JSTokenLocation& location, const Identifier* string)
{
incConstants();
- return new (m_globalData) StringNode(lineNumber, *string);
+ return new (m_vm) StringNode(location, *string);
}
- ExpressionNode* createBoolean(int lineNumber, bool b)
+ ExpressionNode* createBoolean(const JSTokenLocation& location, bool b)
{
incConstants();
- return new (m_globalData) BooleanNode(lineNumber, b);
+ return new (m_vm) BooleanNode(location, b);
}
- ExpressionNode* createNull(int lineNumber)
+ ExpressionNode* createNull(const JSTokenLocation& location)
{
incConstants();
- return new (m_globalData) NullNode(lineNumber);
+ return new (m_vm) NullNode(location);
+ }
+
+ ExpressionNode* createBracketAccess(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* property, bool propertyHasAssignments, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
+ {
+ BracketAccessorNode* node = new (m_vm) BracketAccessorNode(location, base, property, propertyHasAssignments);
+ setExceptionLocation(node, start, divot, end);
+ return node;
}
- ExpressionNode* createBracketAccess(int lineNumber, ExpressionNode* base, ExpressionNode* property, bool propertyHasAssignments, int start, int divot, int end)
+ ExpressionNode* createDotAccess(const JSTokenLocation& location, ExpressionNode* base, const Identifier* property, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
{
- BracketAccessorNode* node = new (m_globalData) BracketAccessorNode(lineNumber, base, property, propertyHasAssignments);
+ DotAccessorNode* node = new (m_vm) DotAccessorNode(location, base, *property);
setExceptionLocation(node, start, divot, end);
return node;
}
- ExpressionNode* createDotAccess(int lineNumber, ExpressionNode* base, const Identifier* property, int start, int divot, int end)
+ ExpressionNode* createSpreadExpression(const JSTokenLocation& location, ExpressionNode* expression, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
{
- DotAccessorNode* node = new (m_globalData) DotAccessorNode(lineNumber, base, *property);
+ auto node = new (m_vm) SpreadExpressionNode(location, expression);
setExceptionLocation(node, start, divot, end);
return node;
}
- ExpressionNode* createRegExp(int lineNumber, const Identifier& pattern, const Identifier& flags, int start)
+ ExpressionNode* createRegExp(const JSTokenLocation& location, const Identifier& pattern, const Identifier& flags, const JSTextPosition& start)
{
- if (Yarr::checkSyntax(pattern.ustring()))
+ if (Yarr::checkSyntax(pattern.string()))
return 0;
- RegExpNode* node = new (m_globalData) RegExpNode(lineNumber, pattern, flags);
+ RegExpNode* node = new (m_vm) RegExpNode(location, pattern, flags);
int size = pattern.length() + 2; // + 2 for the two /'s
- setExceptionLocation(node, start, start + size, start + size);
+ JSTextPosition end = start + size;
+ setExceptionLocation(node, start, end, end);
return node;
}
- ExpressionNode* createNewExpr(int lineNumber, ExpressionNode* expr, ArgumentsNode* arguments, int start, int divot, int end)
+ ExpressionNode* createNewExpr(const JSTokenLocation& location, ExpressionNode* expr, ArgumentsNode* arguments, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
{
- NewExprNode* node = new (m_globalData) NewExprNode(lineNumber, expr, arguments);
+ NewExprNode* node = new (m_vm) NewExprNode(location, expr, arguments);
setExceptionLocation(node, start, divot, end);
return node;
}
- ExpressionNode* createNewExpr(int lineNumber, ExpressionNode* expr, int start, int end)
+ ExpressionNode* createNewExpr(const JSTokenLocation& location, ExpressionNode* expr, const JSTextPosition& start, const JSTextPosition& end)
{
- NewExprNode* node = new (m_globalData) NewExprNode(lineNumber, expr);
+ NewExprNode* node = new (m_vm) NewExprNode(location, expr);
setExceptionLocation(node, start, end, end);
return node;
}
- ExpressionNode* createConditionalExpr(int lineNumber, ExpressionNode* condition, ExpressionNode* lhs, ExpressionNode* rhs)
+ ExpressionNode* createConditionalExpr(const JSTokenLocation& location, ExpressionNode* condition, ExpressionNode* lhs, ExpressionNode* rhs)
{
- return new (m_globalData) ConditionalNode(lineNumber, condition, lhs, rhs);
+ return new (m_vm) ConditionalNode(location, condition, lhs, rhs);
}
- ExpressionNode* createAssignResolve(int lineNumber, const Identifier& ident, ExpressionNode* rhs, bool rhsHasAssignment, int start, int divot, int end)
+ ExpressionNode* createAssignResolve(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* rhs, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
{
if (rhs->isFuncExprNode())
static_cast<FuncExprNode*>(rhs)->body()->setInferredName(ident);
- AssignResolveNode* node = new (m_globalData) AssignResolveNode(lineNumber, ident, rhs, rhsHasAssignment);
+ AssignResolveNode* node = new (m_vm) AssignResolveNode(location, ident, rhs);
setExceptionLocation(node, start, divot, end);
return node;
}
- ExpressionNode* createFunctionExpr(int lineNumber, const Identifier* name, FunctionBodyNode* body, ParameterNode* parameters, int openBracePos, int closeBracePos, int bodyStartLine, int bodyEndLine)
+ ExpressionNode* createFunctionExpr(const JSTokenLocation& location, const Identifier* name, FunctionBodyNode* body, ParameterNode* parameters, unsigned openBraceOffset, unsigned closeBraceOffset, int bodyStartLine, int bodyEndLine, unsigned startColumn)
{
- FuncExprNode* result = new (m_globalData) FuncExprNode(lineNumber, *name, body, m_sourceCode->subExpression(openBracePos, closeBracePos, bodyStartLine), parameters);
- body->setLoc(bodyStartLine, bodyEndLine);
+ FuncExprNode* result = new (m_vm) FuncExprNode(location, *name, body, m_sourceCode->subExpression(openBraceOffset, closeBraceOffset, bodyStartLine, startColumn), parameters);
+ body->setLoc(bodyStartLine, bodyEndLine, location.startOffset, location.lineStartOffset);
return result;
}
- FunctionBodyNode* createFunctionBody(int lineNumber, bool inStrictContext)
+ FunctionBodyNode* createFunctionBody(const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, bool inStrictContext)
{
- return FunctionBodyNode::create(m_globalData, lineNumber, inStrictContext);
+ return FunctionBodyNode::create(m_vm, startLocation, endLocation, startColumn, endColumn, inStrictContext);
+ }
+
+ void setFunctionNameStart(FunctionBodyNode* body, int functionNameStart)
+ {
+ body->setFunctionNameStart(functionNameStart);
}
- template <bool> PropertyNode* createGetterOrSetterProperty(int lineNumber, PropertyNode::Type type, const Identifier* name, ParameterNode* params, FunctionBodyNode* body, int openBracePos, int closeBracePos, int bodyStartLine, int bodyEndLine)
+ NEVER_INLINE PropertyNode* createGetterOrSetterProperty(const JSTokenLocation& location, PropertyNode::Type type, bool, const Identifier* name, ParameterNode* params, FunctionBodyNode* body, unsigned openBraceOffset, unsigned closeBraceOffset, int bodyStartLine, int bodyEndLine, unsigned bodyStartColumn)
{
ASSERT(name);
- body->setLoc(bodyStartLine, bodyEndLine);
+ body->setLoc(bodyStartLine, bodyEndLine, location.startOffset, location.lineStartOffset);
body->setInferredName(*name);
- return new (m_globalData) PropertyNode(m_globalData, *name, new (m_globalData) FuncExprNode(lineNumber, m_globalData->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBracePos, closeBracePos, bodyStartLine), params), type);
+ return new (m_vm) PropertyNode(m_vm, *name, new (m_vm) FuncExprNode(location, m_vm->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBraceOffset, closeBraceOffset, bodyStartLine, bodyStartColumn), params), type);
}
- template <bool> PropertyNode* createGetterOrSetterProperty(JSGlobalData*, int lineNumber, PropertyNode::Type type, double name, ParameterNode* params, FunctionBodyNode* body, int openBracePos, int closeBracePos, int bodyStartLine, int bodyEndLine)
+ NEVER_INLINE PropertyNode* createGetterOrSetterProperty(VM*, const JSTokenLocation& location, PropertyNode::Type type, bool, double name, ParameterNode* params, FunctionBodyNode* body, unsigned openBraceOffset, unsigned closeBraceOffset, int bodyStartLine, int bodyEndLine, unsigned bodyStartColumn)
{
- body->setLoc(bodyStartLine, bodyEndLine);
- return new (m_globalData) PropertyNode(m_globalData, name, new (m_globalData) FuncExprNode(lineNumber, m_globalData->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBracePos, closeBracePos, bodyStartLine), params), type);
+ body->setLoc(bodyStartLine, bodyEndLine, location.startOffset, location.lineStartOffset);
+ return new (m_vm) PropertyNode(m_vm, name, new (m_vm) FuncExprNode(location, m_vm->propertyNames->nullIdentifier, body, m_sourceCode->subExpression(openBraceOffset, closeBraceOffset, bodyStartLine, bodyStartColumn), params), type);
}
- ArgumentsNode* createArguments() { return new (m_globalData) ArgumentsNode(); }
- ArgumentsNode* createArguments(ArgumentListNode* args) { return new (m_globalData) ArgumentsNode(args); }
- ArgumentListNode* createArgumentsList(int lineNumber, ExpressionNode* arg) { return new (m_globalData) ArgumentListNode(lineNumber, arg); }
- ArgumentListNode* createArgumentsList(int lineNumber, ArgumentListNode* args, ExpressionNode* arg) { return new (m_globalData) ArgumentListNode(lineNumber, args, arg); }
+ ArgumentsNode* createArguments() { return new (m_vm) ArgumentsNode(); }
+ ArgumentsNode* createArguments(ArgumentListNode* args) { return new (m_vm) ArgumentsNode(args); }
+ ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ExpressionNode* arg) { return new (m_vm) ArgumentListNode(location, arg); }
+ ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ArgumentListNode* args, ExpressionNode* arg) { return new (m_vm) ArgumentListNode(location, args, arg); }
- template <bool> PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type)
+ PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type, bool)
{
if (node->isFuncExprNode())
static_cast<FuncExprNode*>(node)->body()->setInferredName(*propertyName);
- return new (m_globalData) PropertyNode(m_globalData, *propertyName, node, type);
+ return new (m_vm) PropertyNode(m_vm, *propertyName, node, type);
}
- template <bool> PropertyNode* createProperty(JSGlobalData*, double propertyName, ExpressionNode* node, PropertyNode::Type type) { return new (m_globalData) PropertyNode(m_globalData, propertyName, node, type); }
- PropertyListNode* createPropertyList(int lineNumber, PropertyNode* property) { return new (m_globalData) PropertyListNode(lineNumber, property); }
- PropertyListNode* createPropertyList(int lineNumber, PropertyNode* property, PropertyListNode* tail) { return new (m_globalData) PropertyListNode(lineNumber, property, tail); }
+ PropertyNode* createProperty(VM*, double propertyName, ExpressionNode* node, PropertyNode::Type type, bool) { return new (m_vm) PropertyNode(m_vm, propertyName, node, type); }
+ PropertyNode* createProperty(VM*, ExpressionNode* propertyName, ExpressionNode* node, PropertyNode::Type type, bool) { return new (m_vm) PropertyNode(m_vm, propertyName, node, type); }
+ PropertyListNode* createPropertyList(const JSTokenLocation& location, PropertyNode* property) { return new (m_vm) PropertyListNode(location, property); }
+ PropertyListNode* createPropertyList(const JSTokenLocation& location, PropertyNode* property, PropertyListNode* tail) { return new (m_vm) PropertyListNode(location, property, tail); }
- ElementNode* createElementList(int elisions, ExpressionNode* expr) { return new (m_globalData) ElementNode(elisions, expr); }
- ElementNode* createElementList(ElementNode* elems, int elisions, ExpressionNode* expr) { return new (m_globalData) ElementNode(elems, elisions, expr); }
+ ElementNode* createElementList(int elisions, ExpressionNode* expr) { return new (m_vm) ElementNode(elisions, expr); }
+ ElementNode* createElementList(ElementNode* elems, int elisions, ExpressionNode* expr) { return new (m_vm) ElementNode(elems, elisions, expr); }
- ParameterNode* createFormalParameterList(const Identifier& ident) { return new (m_globalData) ParameterNode(ident); }
- ParameterNode* createFormalParameterList(ParameterNode* list, const Identifier& ident) { return new (m_globalData) ParameterNode(list, ident); }
+ ParameterNode* createFormalParameterList(DeconstructionPattern pattern) { return new (m_vm) ParameterNode(pattern); }
+ ParameterNode* createFormalParameterList(ParameterNode* list, DeconstructionPattern pattern) { return new (m_vm) ParameterNode(list, pattern); }
- CaseClauseNode* createClause(ExpressionNode* expr, JSC::SourceElements* statements) { return new (m_globalData) CaseClauseNode(expr, statements); }
- ClauseListNode* createClauseList(CaseClauseNode* clause) { return new (m_globalData) ClauseListNode(clause); }
- ClauseListNode* createClauseList(ClauseListNode* tail, CaseClauseNode* clause) { return new (m_globalData) ClauseListNode(tail, clause); }
+ CaseClauseNode* createClause(ExpressionNode* expr, JSC::SourceElements* statements) { return new (m_vm) CaseClauseNode(expr, statements); }
+ ClauseListNode* createClauseList(CaseClauseNode* clause) { return new (m_vm) ClauseListNode(clause); }
+ ClauseListNode* createClauseList(ClauseListNode* tail, CaseClauseNode* clause) { return new (m_vm) ClauseListNode(tail, clause); }
void setUsesArguments(FunctionBodyNode* node) { node->setUsesArguments(); }
- StatementNode* createFuncDeclStatement(int lineNumber, const Identifier* name, FunctionBodyNode* body, ParameterNode* parameters, int openBracePos, int closeBracePos, int bodyStartLine, int bodyEndLine)
+ StatementNode* createFuncDeclStatement(const JSTokenLocation& location, const Identifier* name, FunctionBodyNode* body, ParameterNode* parameters, unsigned openBraceOffset, unsigned closeBraceOffset, int bodyStartLine, int bodyEndLine, unsigned bodyStartColumn)
{
- FuncDeclNode* decl = new (m_globalData) FuncDeclNode(lineNumber, *name, body, m_sourceCode->subExpression(openBracePos, closeBracePos, bodyStartLine), parameters);
- if (*name == m_globalData->propertyNames->arguments)
+ FuncDeclNode* decl = new (m_vm) FuncDeclNode(location, *name, body, m_sourceCode->subExpression(openBraceOffset, closeBraceOffset, bodyStartLine, bodyStartColumn), parameters);
+ if (*name == m_vm->propertyNames->arguments)
usesArguments();
m_scope.m_funcDeclarations->data.append(decl->body());
- body->setLoc(bodyStartLine, bodyEndLine);
+ body->setLoc(bodyStartLine, bodyEndLine, location.startOffset, location.lineStartOffset);
return decl;
}
- StatementNode* createBlockStatement(int lineNumber, JSC::SourceElements* elements, int startLine, int endLine)
+ StatementNode* createBlockStatement(const JSTokenLocation& location, JSC::SourceElements* elements, int startLine, int endLine)
{
- BlockNode* block = new (m_globalData) BlockNode(lineNumber, elements);
- block->setLoc(startLine, endLine);
+ BlockNode* block = new (m_vm) BlockNode(location, elements);
+ block->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
return block;
}
- StatementNode* createExprStatement(int lineNumber, ExpressionNode* expr, int start, int end)
+ StatementNode* createExprStatement(const JSTokenLocation& location, ExpressionNode* expr, const JSTextPosition& start, int end)
{
- ExprStatementNode* result = new (m_globalData) ExprStatementNode(lineNumber, expr);
- result->setLoc(start, end);
+ ExprStatementNode* result = new (m_vm) ExprStatementNode(location, expr);
+ result->setLoc(start.line, end, start.offset, start.lineStartOffset);
return result;
}
- StatementNode* createIfStatement(int lineNumber, ExpressionNode* condition, StatementNode* trueBlock, int start, int end)
+ StatementNode* createIfStatement(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* trueBlock, StatementNode* falseBlock, int start, int end)
{
- IfNode* result = new (m_globalData) IfNode(lineNumber, condition, trueBlock);
- result->setLoc(start, end);
+ IfElseNode* result = new (m_vm) IfElseNode(location, condition, trueBlock, falseBlock);
+ result->setLoc(start, end, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createIfStatement(int lineNumber, ExpressionNode* condition, StatementNode* trueBlock, StatementNode* falseBlock, int start, int end)
+ StatementNode* createForLoop(const JSTokenLocation& location, ExpressionNode* initializer, ExpressionNode* condition, ExpressionNode* iter, StatementNode* statements, int start, int end)
{
- IfNode* result = new (m_globalData) IfElseNode(lineNumber, condition, trueBlock, falseBlock);
- result->setLoc(start, end);
+ ForNode* result = new (m_vm) ForNode(location, initializer, condition, iter, statements);
+ result->setLoc(start, end, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createForLoop(int lineNumber, ExpressionNode* initializer, ExpressionNode* condition, ExpressionNode* iter, StatementNode* statements, bool b, int start, int end)
+ StatementNode* createForInLoop(const JSTokenLocation& location, ExpressionNode* lhs, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
{
- ForNode* result = new (m_globalData) ForNode(lineNumber, initializer, condition, iter, statements, b);
- result->setLoc(start, end);
+ ForInNode* result = new (m_vm) ForInNode(location, lhs, iter, statements);
+ result->setLoc(start, end, location.startOffset, location.lineStartOffset);
+ setExceptionLocation(result, eStart, eDivot, eEnd);
return result;
}
-
- StatementNode* createForInLoop(int lineNumber, const Identifier* ident, ExpressionNode* initializer, ExpressionNode* iter, StatementNode* statements, int start, int divot, int end, int initStart, int initEnd, int startLine, int endLine)
+
+ StatementNode* createForInLoop(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> pattern, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
{
- ForInNode* result = new (m_globalData) ForInNode(m_globalData, lineNumber, *ident, initializer, iter, statements, initStart, initStart - start, initEnd - initStart);
- result->setLoc(startLine, endLine);
- setExceptionLocation(result, start, divot + 1, end);
+ ForInNode* result = new (m_vm) ForInNode(m_vm, location, pattern.get(), iter, statements);
+ result->setLoc(start, end, location.startOffset, location.lineStartOffset);
+ setExceptionLocation(result, eStart, eDivot, eEnd);
return result;
}
-
- StatementNode* createForInLoop(int lineNumber, ExpressionNode* lhs, ExpressionNode* iter, StatementNode* statements, int eStart, int eDivot, int eEnd, int start, int end)
+
+ StatementNode* createForOfLoop(const JSTokenLocation& location, ExpressionNode* lhs, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
+ {
+ ForOfNode* result = new (m_vm) ForOfNode(location, lhs, iter, statements);
+ result->setLoc(start, end, location.startOffset, location.lineStartOffset);
+ setExceptionLocation(result, eStart, eDivot, eEnd);
+ return result;
+ }
+
+ StatementNode* createForOfLoop(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> pattern, ExpressionNode* iter, StatementNode* statements, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end)
{
- ForInNode* result = new (m_globalData) ForInNode(m_globalData, lineNumber, lhs, iter, statements);
- result->setLoc(start, end);
+ ForOfNode* result = new (m_vm) ForOfNode(m_vm, location, pattern.get(), iter, statements);
+ result->setLoc(start, end, location.startOffset, location.lineStartOffset);
setExceptionLocation(result, eStart, eDivot, eEnd);
return result;
}
- StatementNode* createEmptyStatement(int lineNumber) { return new (m_globalData) EmptyStatementNode(lineNumber); }
+ bool isBindingNode(const DeconstructionPattern& pattern)
+ {
+ return pattern->isBindingNode();
+ }
+
+ StatementNode* createEmptyStatement(const JSTokenLocation& location) { return new (m_vm) EmptyStatementNode(location); }
- StatementNode* createVarStatement(int lineNumber, ExpressionNode* expr, int start, int end)
+ StatementNode* createVarStatement(const JSTokenLocation& location, ExpressionNode* expr, int start, int end)
{
StatementNode* result;
if (!expr)
- result = new (m_globalData) EmptyStatementNode(lineNumber);
+ result = new (m_vm) EmptyStatementNode(location);
else
- result = new (m_globalData) VarStatementNode(lineNumber, expr);
- result->setLoc(start, end);
+ result = new (m_vm) VarStatementNode(location, expr);
+ result->setLoc(start, end, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createReturnStatement(int lineNumber, ExpressionNode* expression, int eStart, int eEnd, int startLine, int endLine)
+ StatementNode* createReturnStatement(const JSTokenLocation& location, ExpressionNode* expression, const JSTextPosition& start, const JSTextPosition& end)
{
- ReturnNode* result = new (m_globalData) ReturnNode(lineNumber, expression);
- setExceptionLocation(result, eStart, eEnd, eEnd);
- result->setLoc(startLine, endLine);
+ ReturnNode* result = new (m_vm) ReturnNode(location, expression);
+ setExceptionLocation(result, start, end, end);
+ result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);
return result;
}
- StatementNode* createBreakStatement(int lineNumber, int eStart, int eEnd, int startLine, int endLine)
+ StatementNode* createBreakStatement(const JSTokenLocation& location, const JSTextPosition& start, const JSTextPosition& end)
{
- BreakNode* result = new (m_globalData) BreakNode(m_globalData, lineNumber);
- setExceptionLocation(result, eStart, eEnd, eEnd);
- result->setLoc(startLine, endLine);
+ BreakNode* result = new (m_vm) BreakNode(m_vm, location);
+ setExceptionLocation(result, start, end, end);
+ result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);
return result;
}
- StatementNode* createBreakStatement(int lineNumber, const Identifier* ident, int eStart, int eEnd, int startLine, int endLine)
+ StatementNode* createBreakStatement(const JSTokenLocation& location, const Identifier* ident, const JSTextPosition& start, const JSTextPosition& end)
{
- BreakNode* result = new (m_globalData) BreakNode(lineNumber, *ident);
- setExceptionLocation(result, eStart, eEnd, eEnd);
- result->setLoc(startLine, endLine);
+ BreakNode* result = new (m_vm) BreakNode(location, *ident);
+ setExceptionLocation(result, start, end, end);
+ result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);
return result;
}
- StatementNode* createContinueStatement(int lineNumber, int eStart, int eEnd, int startLine, int endLine)
+ StatementNode* createContinueStatement(const JSTokenLocation& location, const JSTextPosition& start, const JSTextPosition& end)
{
- ContinueNode* result = new (m_globalData) ContinueNode(m_globalData, lineNumber);
- setExceptionLocation(result, eStart, eEnd, eEnd);
- result->setLoc(startLine, endLine);
+ ContinueNode* result = new (m_vm) ContinueNode(m_vm, location);
+ setExceptionLocation(result, start, end, end);
+ result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);
return result;
}
- StatementNode* createContinueStatement(int lineNumber, const Identifier* ident, int eStart, int eEnd, int startLine, int endLine)
+ StatementNode* createContinueStatement(const JSTokenLocation& location, const Identifier* ident, const JSTextPosition& start, const JSTextPosition& end)
{
- ContinueNode* result = new (m_globalData) ContinueNode(lineNumber, *ident);
- setExceptionLocation(result, eStart, eEnd, eEnd);
- result->setLoc(startLine, endLine);
+ ContinueNode* result = new (m_vm) ContinueNode(location, *ident);
+ setExceptionLocation(result, start, end, end);
+ result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);
return result;
}
- StatementNode* createTryStatement(int lineNumber, StatementNode* tryBlock, const Identifier* ident, StatementNode* catchBlock, StatementNode* finallyBlock, int startLine, int endLine)
+ StatementNode* createTryStatement(const JSTokenLocation& location, StatementNode* tryBlock, const Identifier* ident, StatementNode* catchBlock, StatementNode* finallyBlock, int startLine, int endLine)
{
- TryNode* result = new (m_globalData) TryNode(lineNumber, tryBlock, *ident, catchBlock, finallyBlock);
+ TryNode* result = new (m_vm) TryNode(location, tryBlock, *ident, catchBlock, finallyBlock);
if (catchBlock)
usesCatch();
- result->setLoc(startLine, endLine);
+ result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createSwitchStatement(int lineNumber, ExpressionNode* expr, ClauseListNode* firstClauses, CaseClauseNode* defaultClause, ClauseListNode* secondClauses, int startLine, int endLine)
+ StatementNode* createSwitchStatement(const JSTokenLocation& location, ExpressionNode* expr, ClauseListNode* firstClauses, CaseClauseNode* defaultClause, ClauseListNode* secondClauses, int startLine, int endLine)
{
- CaseBlockNode* cases = new (m_globalData) CaseBlockNode(firstClauses, defaultClause, secondClauses);
- SwitchNode* result = new (m_globalData) SwitchNode(lineNumber, expr, cases);
- result->setLoc(startLine, endLine);
+ CaseBlockNode* cases = new (m_vm) CaseBlockNode(firstClauses, defaultClause, secondClauses);
+ SwitchNode* result = new (m_vm) SwitchNode(location, expr, cases);
+ result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createWhileStatement(int lineNumber, ExpressionNode* expr, StatementNode* statement, int startLine, int endLine)
+ StatementNode* createWhileStatement(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement, int startLine, int endLine)
{
- WhileNode* result = new (m_globalData) WhileNode(lineNumber, expr, statement);
- result->setLoc(startLine, endLine);
+ WhileNode* result = new (m_vm) WhileNode(location, expr, statement);
+ result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createDoWhileStatement(int lineNumber, StatementNode* statement, ExpressionNode* expr, int startLine, int endLine)
+ StatementNode* createDoWhileStatement(const JSTokenLocation& location, StatementNode* statement, ExpressionNode* expr, int startLine, int endLine)
{
- DoWhileNode* result = new (m_globalData) DoWhileNode(lineNumber, statement, expr);
- result->setLoc(startLine, endLine);
+ DoWhileNode* result = new (m_vm) DoWhileNode(location, statement, expr);
+ result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createLabelStatement(int lineNumber, const Identifier* ident, StatementNode* statement, int start, int end)
+ StatementNode* createLabelStatement(const JSTokenLocation& location, const Identifier* ident, StatementNode* statement, const JSTextPosition& start, const JSTextPosition& end)
{
- LabelNode* result = new (m_globalData) LabelNode(lineNumber, *ident, statement);
+ LabelNode* result = new (m_vm) LabelNode(location, *ident, statement);
setExceptionLocation(result, start, end, end);
return result;
}
- StatementNode* createWithStatement(int lineNumber, ExpressionNode* expr, StatementNode* statement, int start, int end, int startLine, int endLine)
+ StatementNode* createWithStatement(const JSTokenLocation& location, ExpressionNode* expr, StatementNode* statement, unsigned start, const JSTextPosition& end, unsigned startLine, unsigned endLine)
{
usesWith();
- WithNode* result = new (m_globalData) WithNode(lineNumber, expr, statement, end, end - start);
- result->setLoc(startLine, endLine);
+ WithNode* result = new (m_vm) WithNode(location, expr, statement, end, end - start);
+ result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createThrowStatement(int lineNumber, ExpressionNode* expr, int start, int end, int startLine, int endLine)
+ StatementNode* createThrowStatement(const JSTokenLocation& location, ExpressionNode* expr, const JSTextPosition& start, const JSTextPosition& end)
{
- ThrowNode* result = new (m_globalData) ThrowNode(lineNumber, expr);
- result->setLoc(startLine, endLine);
+ ThrowNode* result = new (m_vm) ThrowNode(location, expr);
+ result->setLoc(start.line, end.line, start.offset, start.lineStartOffset);
setExceptionLocation(result, start, end, end);
return result;
}
- StatementNode* createDebugger(int lineNumber, int startLine, int endLine)
+ StatementNode* createDebugger(const JSTokenLocation& location, int startLine, int endLine)
{
- DebuggerStatementNode* result = new (m_globalData) DebuggerStatementNode(lineNumber);
- result->setLoc(startLine, endLine);
+ DebuggerStatementNode* result = new (m_vm) DebuggerStatementNode(location);
+ result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
return result;
}
- StatementNode* createConstStatement(int lineNumber, ConstDeclNode* decls, int startLine, int endLine)
+ StatementNode* createConstStatement(const JSTokenLocation& location, ConstDeclNode* decls, int startLine, int endLine)
{
- ConstStatementNode* result = new (m_globalData) ConstStatementNode(lineNumber, decls);
- result->setLoc(startLine, endLine);
+ ConstStatementNode* result = new (m_vm) ConstStatementNode(location, decls);
+ result->setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
return result;
}
- ConstDeclNode* appendConstDecl(int lineNumber, ConstDeclNode* tail, const Identifier* name, ExpressionNode* initializer)
+ ConstDeclNode* appendConstDecl(const JSTokenLocation& location, ConstDeclNode* tail, const Identifier* name, ExpressionNode* initializer)
{
- ConstDeclNode* result = new (m_globalData) ConstDeclNode(lineNumber, *name, initializer);
+ ConstDeclNode* result = new (m_vm) ConstDeclNode(location, *name, initializer);
if (tail)
tail->m_next = result;
return result;
void addVar(const Identifier* ident, int attrs)
{
- if (m_globalData->propertyNames->arguments == *ident)
+ if (m_vm->propertyNames->arguments == *ident)
usesArguments();
- m_scope.m_varDeclarations->data.append(std::make_pair(ident, attrs));
+ ASSERT(ident->impl()->isAtomic());
+ m_scope.m_varDeclarations->data.append(std::make_pair(*ident, attrs));
}
- ExpressionNode* combineCommaNodes(int lineNumber, ExpressionNode* list, ExpressionNode* init)
+ ExpressionNode* combineCommaNodes(const JSTokenLocation& location, ExpressionNode* list, ExpressionNode* init)
{
if (!list)
return init;
static_cast<CommaNode*>(list)->append(init);
return list;
}
- return new (m_globalData) CommaNode(lineNumber, list, init);
+ return new (m_vm) CommaNode(location, list, init);
}
int evalCount() const { return m_evalCount; }
- void appendBinaryExpressionInfo(int& operandStackDepth, ExpressionNode* current, int exprStart, int lhs, int rhs, bool hasAssignments)
+ void appendBinaryExpressionInfo(int& operandStackDepth, ExpressionNode* current, const JSTextPosition& exprStart, const JSTextPosition& lhs, const JSTextPosition& rhs, bool hasAssignments)
{
operandStackDepth++;
m_binaryOperandStack.append(std::make_pair(current, BinaryOpInfo(exprStart, lhs, rhs, hasAssignments)));
ASSERT(operandStackDepth >= 0);
m_binaryOperandStack.resize(m_binaryOperandStack.size() - amount);
}
- void appendBinaryOperation(int lineNumber, int& operandStackDepth, int&, const BinaryOperand& lhs, const BinaryOperand& rhs)
+ void appendBinaryOperation(const JSTokenLocation& location, int& operandStackDepth, int&, const BinaryOperand& lhs, const BinaryOperand& rhs)
{
operandStackDepth++;
- m_binaryOperandStack.append(std::make_pair(makeBinaryNode(lineNumber, m_binaryOperatorStack.last().first, lhs, rhs), BinaryOpInfo(lhs.second, rhs.second)));
+ m_binaryOperandStack.append(std::make_pair(makeBinaryNode(location, m_binaryOperatorStack.last().first, lhs, rhs), BinaryOpInfo(lhs.second, rhs.second)));
}
void operatorStackAppend(int& operatorStackDepth, int op, int precedence)
{
return result;
}
- void appendUnaryToken(int& tokenStackDepth, int type, int start)
+ void appendUnaryToken(int& tokenStackDepth, int type, const JSTextPosition& start)
{
tokenStackDepth++;
m_unaryTokenStack.append(std::make_pair(type, start));
return m_unaryTokenStack.last().first;
}
- int unaryTokenStackLastStart(int&)
+ const JSTextPosition& unaryTokenStackLastStart(int&)
{
return m_unaryTokenStack.last().second;
}
m_unaryTokenStack.removeLast();
}
- void assignmentStackAppend(int& assignmentStackDepth, ExpressionNode* node, int start, int divot, int assignmentCount, Operator op)
+ void assignmentStackAppend(int& assignmentStackDepth, ExpressionNode* node, const JSTextPosition& start, const JSTextPosition& divot, int assignmentCount, Operator op)
{
assignmentStackDepth++;
+ ASSERT(start.offset >= start.lineStartOffset);
+ ASSERT(divot.offset >= divot.lineStartOffset);
m_assignmentInfoStack.append(AssignmentInfo(node, start, divot, assignmentCount, op));
}
- ExpressionNode* createAssignment(int lineNumber, int& assignmentStackDepth, ExpressionNode* rhs, int initialAssignmentCount, int currentAssignmentCount, int lastTokenEnd)
+ ExpressionNode* createAssignment(const JSTokenLocation& location, int& assignmentStackDepth, ExpressionNode* rhs, int initialAssignmentCount, int currentAssignmentCount, const JSTextPosition& lastTokenEnd)
{
- ExpressionNode* result = makeAssignNode(lineNumber, m_assignmentInfoStack.last().m_node, m_assignmentInfoStack.last().m_op, rhs, m_assignmentInfoStack.last().m_initAssignments != initialAssignmentCount, m_assignmentInfoStack.last().m_initAssignments != currentAssignmentCount, m_assignmentInfoStack.last().m_start, m_assignmentInfoStack.last().m_divot + 1, lastTokenEnd);
+ AssignmentInfo& info = m_assignmentInfoStack.last();
+ ExpressionNode* result = makeAssignNode(location, info.m_node, info.m_op, rhs, info.m_initAssignments != initialAssignmentCount, info.m_initAssignments != currentAssignmentCount, info.m_start, info.m_divot + 1, lastTokenEnd);
m_assignmentInfoStack.removeLast();
assignmentStackDepth--;
return result;
}
- const Identifier& getName(Property property) const { return property->name(); }
+ const Identifier* getName(Property property) const { return property->name(); }
PropertyNode::Type getType(Property property) const { return property->type(); }
bool isResolve(ExpressionNode* expr) const { return expr->isResolveNode(); }
+ ExpressionNode* createDeconstructingAssignment(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> pattern, ExpressionNode* initializer)
+ {
+ return new (m_vm) DeconstructingAssignmentNode(location, pattern.get(), initializer);
+ }
+
+ ArrayPattern createArrayPattern(const JSTokenLocation&)
+ {
+ return ArrayPatternNode::create(m_vm);
+ }
+
+ void appendArrayPatternSkipEntry(ArrayPattern node, const JSTokenLocation& location)
+ {
+ node->appendIndex(location, 0);
+ }
+
+ void appendArrayPatternEntry(ArrayPattern node, const JSTokenLocation& location, DeconstructionPattern pattern)
+ {
+ node->appendIndex(location, pattern.get());
+ }
+
+ ObjectPattern createObjectPattern(const JSTokenLocation&)
+ {
+ return ObjectPatternNode::create(m_vm);
+ }
+
+ void appendObjectPatternEntry(ObjectPattern node, const JSTokenLocation& location, bool wasString, const Identifier& identifier, DeconstructionPattern pattern)
+ {
+ node->appendEntry(location, identifier, wasString, pattern.get());
+ }
+
+ BindingPattern createBindingLocation(const JSTokenLocation&, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end)
+ {
+ return BindingNode::create(m_vm, boundProperty, start, end);
+ }
+
private:
struct Scope {
- Scope(JSGlobalData* globalData)
- : m_varDeclarations(new (globalData) ParserArenaData<DeclarationStacks::VarStack>)
- , m_funcDeclarations(new (globalData) ParserArenaData<DeclarationStacks::FunctionStack>)
+ Scope(VM* vm)
+ : m_varDeclarations(new (vm) ParserArenaData<DeclarationStacks::VarStack>)
+ , m_funcDeclarations(new (vm) ParserArenaData<DeclarationStacks::FunctionStack>)
, m_features(0)
, m_numConstants(0)
{
int m_numConstants;
};
- static void setExceptionLocation(ThrowableExpressionData* node, unsigned start, unsigned divot, unsigned end)
+ static void setExceptionLocation(ThrowableExpressionData* node, const JSTextPosition& divotStart, const JSTextPosition& divot, const JSTextPosition& divotEnd)
{
- node->setExceptionSourceCode(divot, divot - start, end - divot);
+ ASSERT(divot.offset >= divot.lineStartOffset);
+ node->setExceptionSourceCode(divot, divotStart, divotEnd);
}
void incConstants() { m_scope.m_numConstants++; }
m_evalCount++;
m_scope.m_features |= EvalFeature;
}
- ExpressionNode* createNumber(int lineNumber, double d)
+ ExpressionNode* createNumber(const JSTokenLocation& location, double d)
{
- return new (m_globalData) NumberNode(lineNumber, d);
+ return new (m_vm) NumberNode(location, d);
}
- JSGlobalData* m_globalData;
+ VM* m_vm;
SourceCode* m_sourceCode;
Scope m_scope;
- Vector<BinaryOperand, 10> m_binaryOperandStack;
- Vector<AssignmentInfo, 10> m_assignmentInfoStack;
- Vector<pair<int, int>, 10> m_binaryOperatorStack;
- Vector<pair<int, int>, 10> m_unaryTokenStack;
+ Vector<BinaryOperand, 10, UnsafeVectorOverflow> m_binaryOperandStack;
+ Vector<AssignmentInfo, 10, UnsafeVectorOverflow> m_assignmentInfoStack;
+ Vector<std::pair<int, int>, 10, UnsafeVectorOverflow> m_binaryOperatorStack;
+ Vector<std::pair<int, JSTextPosition>, 10, UnsafeVectorOverflow> m_unaryTokenStack;
int m_evalCount;
};
-ExpressionNode* ASTBuilder::makeTypeOfNode(int lineNumber, ExpressionNode* expr)
+ExpressionNode* ASTBuilder::makeTypeOfNode(const JSTokenLocation& location, ExpressionNode* expr)
{
if (expr->isResolveNode()) {
ResolveNode* resolve = static_cast<ResolveNode*>(expr);
- return new (m_globalData) TypeOfResolveNode(lineNumber, resolve->identifier());
+ return new (m_vm) TypeOfResolveNode(location, resolve->identifier());
}
- return new (m_globalData) TypeOfValueNode(lineNumber, expr);
+ return new (m_vm) TypeOfValueNode(location, expr);
}
-ExpressionNode* ASTBuilder::makeDeleteNode(int lineNumber, ExpressionNode* expr, int start, int divot, int end)
+ExpressionNode* ASTBuilder::makeDeleteNode(const JSTokenLocation& location, ExpressionNode* expr, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
{
if (!expr->isLocation())
- return new (m_globalData) DeleteValueNode(lineNumber, expr);
+ return new (m_vm) DeleteValueNode(location, expr);
if (expr->isResolveNode()) {
ResolveNode* resolve = static_cast<ResolveNode*>(expr);
- return new (m_globalData) DeleteResolveNode(lineNumber, resolve->identifier(), divot, divot - start, end - divot);
+ return new (m_vm) DeleteResolveNode(location, resolve->identifier(), divot, start, end);
}
if (expr->isBracketAccessorNode()) {
BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
- return new (m_globalData) DeleteBracketNode(lineNumber, bracket->base(), bracket->subscript(), divot, divot - start, end - divot);
+ return new (m_vm) DeleteBracketNode(location, bracket->base(), bracket->subscript(), divot, start, end);
}
ASSERT(expr->isDotAccessorNode());
DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
- return new (m_globalData) DeleteDotNode(lineNumber, dot->base(), dot->identifier(), divot, divot - start, end - divot);
+ return new (m_vm) DeleteDotNode(location, dot->base(), dot->identifier(), divot, start, end);
}
-ExpressionNode* ASTBuilder::makeNegateNode(int lineNumber, ExpressionNode* n)
+ExpressionNode* ASTBuilder::makeNegateNode(const JSTokenLocation& location, ExpressionNode* n)
{
if (n->isNumber()) {
NumberNode* numberNode = static_cast<NumberNode*>(n);
return numberNode;
}
- return new (m_globalData) NegateNode(lineNumber, n);
+ return new (m_vm) NegateNode(location, n);
}
-ExpressionNode* ASTBuilder::makeBitwiseNotNode(int lineNumber, ExpressionNode* expr)
+ExpressionNode* ASTBuilder::makeBitwiseNotNode(const JSTokenLocation& location, ExpressionNode* expr)
{
if (expr->isNumber())
- return createNumber(lineNumber, ~toInt32(static_cast<NumberNode*>(expr)->value()));
- return new (m_globalData) BitwiseNotNode(lineNumber, expr);
+ return createNumber(location, ~toInt32(static_cast<NumberNode*>(expr)->value()));
+ return new (m_vm) BitwiseNotNode(location, expr);
}
-ExpressionNode* ASTBuilder::makeMultNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeMultNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
expr1 = expr1->stripUnaryPlus();
expr2 = expr2->stripUnaryPlus();
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, static_cast<NumberNode*>(expr1)->value() * static_cast<NumberNode*>(expr2)->value());
+ return createNumber(location, static_cast<NumberNode*>(expr1)->value() * static_cast<NumberNode*>(expr2)->value());
if (expr1->isNumber() && static_cast<NumberNode*>(expr1)->value() == 1)
- return new (m_globalData) UnaryPlusNode(lineNumber, expr2);
+ return new (m_vm) UnaryPlusNode(location, expr2);
if (expr2->isNumber() && static_cast<NumberNode*>(expr2)->value() == 1)
- return new (m_globalData) UnaryPlusNode(lineNumber, expr1);
+ return new (m_vm) UnaryPlusNode(location, expr1);
- return new (m_globalData) MultNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return new (m_vm) MultNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeDivNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeDivNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
expr1 = expr1->stripUnaryPlus();
expr2 = expr2->stripUnaryPlus();
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, static_cast<NumberNode*>(expr1)->value() / static_cast<NumberNode*>(expr2)->value());
- return new (m_globalData) DivNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, static_cast<NumberNode*>(expr1)->value() / static_cast<NumberNode*>(expr2)->value());
+ return new (m_vm) DivNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeModNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeModNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
expr1 = expr1->stripUnaryPlus();
expr2 = expr2->stripUnaryPlus();
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, fmod(static_cast<NumberNode*>(expr1)->value(), static_cast<NumberNode*>(expr2)->value()));
- return new (m_globalData) ModNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, fmod(static_cast<NumberNode*>(expr1)->value(), static_cast<NumberNode*>(expr2)->value()));
+ return new (m_vm) ModNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeAddNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeAddNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, static_cast<NumberNode*>(expr1)->value() + static_cast<NumberNode*>(expr2)->value());
- return new (m_globalData) AddNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, static_cast<NumberNode*>(expr1)->value() + static_cast<NumberNode*>(expr2)->value());
+ return new (m_vm) AddNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeSubNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeSubNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
expr1 = expr1->stripUnaryPlus();
expr2 = expr2->stripUnaryPlus();
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, static_cast<NumberNode*>(expr1)->value() - static_cast<NumberNode*>(expr2)->value());
- return new (m_globalData) SubNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, static_cast<NumberNode*>(expr1)->value() - static_cast<NumberNode*>(expr2)->value());
+ return new (m_vm) SubNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeLeftShiftNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeLeftShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, toInt32(static_cast<NumberNode*>(expr1)->value()) << (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
- return new (m_globalData) LeftShiftNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, toInt32(static_cast<NumberNode*>(expr1)->value()) << (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
+ return new (m_vm) LeftShiftNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeRightShiftNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeRightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, toInt32(static_cast<NumberNode*>(expr1)->value()) >> (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
- return new (m_globalData) RightShiftNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, toInt32(static_cast<NumberNode*>(expr1)->value()) >> (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
+ return new (m_vm) RightShiftNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeURightShiftNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeURightShiftNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, toUInt32(static_cast<NumberNode*>(expr1)->value()) >> (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
- return new (m_globalData) UnsignedRightShiftNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, toUInt32(static_cast<NumberNode*>(expr1)->value()) >> (toUInt32(static_cast<NumberNode*>(expr2)->value()) & 0x1f));
+ return new (m_vm) UnsignedRightShiftNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeBitOrNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeBitOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, toInt32(static_cast<NumberNode*>(expr1)->value()) | toInt32(static_cast<NumberNode*>(expr2)->value()));
- return new (m_globalData) BitOrNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, toInt32(static_cast<NumberNode*>(expr1)->value()) | toInt32(static_cast<NumberNode*>(expr2)->value()));
+ return new (m_vm) BitOrNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeBitAndNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeBitAndNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, toInt32(static_cast<NumberNode*>(expr1)->value()) & toInt32(static_cast<NumberNode*>(expr2)->value()));
- return new (m_globalData) BitAndNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, toInt32(static_cast<NumberNode*>(expr1)->value()) & toInt32(static_cast<NumberNode*>(expr2)->value()));
+ return new (m_vm) BitAndNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeBitXOrNode(int lineNumber, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
+ExpressionNode* ASTBuilder::makeBitXOrNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments)
{
if (expr1->isNumber() && expr2->isNumber())
- return createNumber(lineNumber, toInt32(static_cast<NumberNode*>(expr1)->value()) ^ toInt32(static_cast<NumberNode*>(expr2)->value()));
- return new (m_globalData) BitXOrNode(lineNumber, expr1, expr2, rightHasAssignments);
+ return createNumber(location, toInt32(static_cast<NumberNode*>(expr1)->value()) ^ toInt32(static_cast<NumberNode*>(expr2)->value()));
+ return new (m_vm) BitXOrNode(location, expr1, expr2, rightHasAssignments);
}
-ExpressionNode* ASTBuilder::makeFunctionCallNode(int lineNumber, ExpressionNode* func, ArgumentsNode* args, int start, int divot, int end)
+ExpressionNode* ASTBuilder::makeFunctionCallNode(const JSTokenLocation& location, ExpressionNode* func, ArgumentsNode* args, const JSTextPosition& divotStart, const JSTextPosition& divot, const JSTextPosition& divotEnd)
{
+ ASSERT(divot.offset >= divot.lineStartOffset);
if (!func->isLocation())
- return new (m_globalData) FunctionCallValueNode(lineNumber, func, args, divot, divot - start, end - divot);
+ return new (m_vm) FunctionCallValueNode(location, func, args, divot, divotStart, divotEnd);
if (func->isResolveNode()) {
ResolveNode* resolve = static_cast<ResolveNode*>(func);
const Identifier& identifier = resolve->identifier();
- if (identifier == m_globalData->propertyNames->eval) {
+ if (identifier == m_vm->propertyNames->eval) {
usesEval();
- return new (m_globalData) EvalFunctionCallNode(lineNumber, args, divot, divot - start, end - divot);
+ return new (m_vm) EvalFunctionCallNode(location, args, divot, divotStart, divotEnd);
}
- return new (m_globalData) FunctionCallResolveNode(lineNumber, identifier, args, divot, divot - start, end - divot);
+ return new (m_vm) FunctionCallResolveNode(location, identifier, args, divot, divotStart, divotEnd);
}
if (func->isBracketAccessorNode()) {
BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(func);
- FunctionCallBracketNode* node = new (m_globalData) FunctionCallBracketNode(lineNumber, bracket->base(), bracket->subscript(), args, divot, divot - start, end - divot);
- node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
+ FunctionCallBracketNode* node = new (m_vm) FunctionCallBracketNode(location, bracket->base(), bracket->subscript(), args, divot, divotStart, divotEnd);
+ node->setSubexpressionInfo(bracket->divot(), bracket->divotEnd().offset);
return node;
}
ASSERT(func->isDotAccessorNode());
DotAccessorNode* dot = static_cast<DotAccessorNode*>(func);
FunctionCallDotNode* node;
- if (dot->identifier() == m_globalData->propertyNames->call)
- node = new (m_globalData) CallFunctionCallDotNode(lineNumber, dot->base(), dot->identifier(), args, divot, divot - start, end - divot);
- else if (dot->identifier() == m_globalData->propertyNames->apply)
- node = new (m_globalData) ApplyFunctionCallDotNode(lineNumber, dot->base(), dot->identifier(), args, divot, divot - start, end - divot);
+ if (dot->identifier() == m_vm->propertyNames->builtinNames().callPublicName() || dot->identifier() == m_vm->propertyNames->builtinNames().callPrivateName())
+ node = new (m_vm) CallFunctionCallDotNode(location, dot->base(), dot->identifier(), args, divot, divotStart, divotEnd);
+ else if (dot->identifier() == m_vm->propertyNames->builtinNames().applyPublicName() || dot->identifier() == m_vm->propertyNames->builtinNames().applyPrivateName())
+ node = new (m_vm) ApplyFunctionCallDotNode(location, dot->base(), dot->identifier(), args, divot, divotStart, divotEnd);
else
- node = new (m_globalData) FunctionCallDotNode(lineNumber, dot->base(), dot->identifier(), args, divot, divot - start, end - divot);
- node->setSubexpressionInfo(dot->divot(), dot->endOffset());
+ node = new (m_vm) FunctionCallDotNode(location, dot->base(), dot->identifier(), args, divot, divotStart, divotEnd);
+ node->setSubexpressionInfo(dot->divot(), dot->divotEnd().offset);
return node;
}
-ExpressionNode* ASTBuilder::makeBinaryNode(int lineNumber, int token, pair<ExpressionNode*, BinaryOpInfo> lhs, pair<ExpressionNode*, BinaryOpInfo> rhs)
+ExpressionNode* ASTBuilder::makeBinaryNode(const JSTokenLocation& location, int token, std::pair<ExpressionNode*, BinaryOpInfo> lhs, std::pair<ExpressionNode*, BinaryOpInfo> rhs)
{
switch (token) {
case OR:
- return new (m_globalData) LogicalOpNode(lineNumber, lhs.first, rhs.first, OpLogicalOr);
+ return new (m_vm) LogicalOpNode(location, lhs.first, rhs.first, OpLogicalOr);
case AND:
- return new (m_globalData) LogicalOpNode(lineNumber, lhs.first, rhs.first, OpLogicalAnd);
+ return new (m_vm) LogicalOpNode(location, lhs.first, rhs.first, OpLogicalAnd);
case BITOR:
- return makeBitOrNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeBitOrNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case BITXOR:
- return makeBitXOrNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeBitXOrNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case BITAND:
- return makeBitAndNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeBitAndNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case EQEQ:
- return new (m_globalData) EqualNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return new (m_vm) EqualNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case NE:
- return new (m_globalData) NotEqualNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return new (m_vm) NotEqualNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case STREQ:
- return new (m_globalData) StrictEqualNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return new (m_vm) StrictEqualNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case STRNEQ:
- return new (m_globalData) NotStrictEqualNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return new (m_vm) NotStrictEqualNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case LT:
- return new (m_globalData) LessNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return new (m_vm) LessNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case GT:
- return new (m_globalData) GreaterNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return new (m_vm) GreaterNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case LE:
- return new (m_globalData) LessEqNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return new (m_vm) LessEqNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case GE:
- return new (m_globalData) GreaterEqNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return new (m_vm) GreaterEqNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case INSTANCEOF: {
- InstanceOfNode* node = new (m_globalData) InstanceOfNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ InstanceOfNode* node = new (m_vm) InstanceOfNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
setExceptionLocation(node, lhs.second.start, rhs.second.start, rhs.second.end);
return node;
}
case INTOKEN: {
- InNode* node = new (m_globalData) InNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ InNode* node = new (m_vm) InNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
setExceptionLocation(node, lhs.second.start, rhs.second.start, rhs.second.end);
return node;
}
case LSHIFT:
- return makeLeftShiftNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeLeftShiftNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case RSHIFT:
- return makeRightShiftNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeRightShiftNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case URSHIFT:
- return makeURightShiftNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeURightShiftNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case PLUS:
- return makeAddNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeAddNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case MINUS:
- return makeSubNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeSubNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case TIMES:
- return makeMultNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeMultNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case DIVIDE:
- return makeDivNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeDivNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
case MOD:
- return makeModNode(lineNumber, lhs.first, rhs.first, rhs.second.hasAssignment);
+ return makeModNode(location, lhs.first, rhs.first, rhs.second.hasAssignment);
}
CRASH();
return 0;
}
-ExpressionNode* ASTBuilder::makeAssignNode(int lineNumber, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, int start, int divot, int end)
+ExpressionNode* ASTBuilder::makeAssignNode(const JSTokenLocation& location, ExpressionNode* loc, Operator op, ExpressionNode* expr, bool locHasAssignments, bool exprHasAssignments, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
{
if (!loc->isLocation())
- return new (m_globalData) AssignErrorNode(lineNumber, loc, op, expr, divot, divot - start, end - divot);
+ return new (m_vm) AssignErrorNode(location, divot, start, end);
if (loc->isResolveNode()) {
ResolveNode* resolve = static_cast<ResolveNode*>(loc);
if (op == OpEqual) {
if (expr->isFuncExprNode())
static_cast<FuncExprNode*>(expr)->body()->setInferredName(resolve->identifier());
- AssignResolveNode* node = new (m_globalData) AssignResolveNode(lineNumber, resolve->identifier(), expr, exprHasAssignments);
+ AssignResolveNode* node = new (m_vm) AssignResolveNode(location, resolve->identifier(), expr);
setExceptionLocation(node, start, divot, end);
return node;
}
- return new (m_globalData) ReadModifyResolveNode(lineNumber, resolve->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
+ return new (m_vm) ReadModifyResolveNode(location, resolve->identifier(), op, expr, exprHasAssignments, divot, start, end);
}
if (loc->isBracketAccessorNode()) {
BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(loc);
if (op == OpEqual)
- return new (m_globalData) AssignBracketNode(lineNumber, bracket->base(), bracket->subscript(), expr, locHasAssignments, exprHasAssignments, bracket->divot(), bracket->divot() - start, end - bracket->divot());
- ReadModifyBracketNode* node = new (m_globalData) ReadModifyBracketNode(lineNumber, bracket->base(), bracket->subscript(), op, expr, locHasAssignments, exprHasAssignments, divot, divot - start, end - divot);
- node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
+ return new (m_vm) AssignBracketNode(location, bracket->base(), bracket->subscript(), expr, locHasAssignments, exprHasAssignments, bracket->divot(), start, end);
+ ReadModifyBracketNode* node = new (m_vm) ReadModifyBracketNode(location, bracket->base(), bracket->subscript(), op, expr, locHasAssignments, exprHasAssignments, divot, start, end);
+ node->setSubexpressionInfo(bracket->divot(), bracket->divotEnd().offset);
return node;
}
ASSERT(loc->isDotAccessorNode());
if (op == OpEqual) {
if (expr->isFuncExprNode())
static_cast<FuncExprNode*>(expr)->body()->setInferredName(dot->identifier());
- return new (m_globalData) AssignDotNode(lineNumber, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), dot->divot() - start, end - dot->divot());
+ return new (m_vm) AssignDotNode(location, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), start, end);
}
- ReadModifyDotNode* node = new (m_globalData) ReadModifyDotNode(lineNumber, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, divot - start, end - divot);
- node->setSubexpressionInfo(dot->divot(), dot->endOffset());
+ ReadModifyDotNode* node = new (m_vm) ReadModifyDotNode(location, dot->base(), dot->identifier(), op, expr, exprHasAssignments, divot, start, end);
+ node->setSubexpressionInfo(dot->divot(), dot->divotEnd().offset);
return node;
}
-ExpressionNode* ASTBuilder::makePrefixNode(int lineNumber, ExpressionNode* expr, Operator op, int start, int divot, int end)
+ExpressionNode* ASTBuilder::makePrefixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator op, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
{
- if (!expr->isLocation())
- return new (m_globalData) PrefixErrorNode(lineNumber, expr, op, divot, divot - start, end - divot);
-
- if (expr->isResolveNode()) {
- ResolveNode* resolve = static_cast<ResolveNode*>(expr);
- return new (m_globalData) PrefixResolveNode(lineNumber, resolve->identifier(), op, divot, divot - start, end - divot);
- }
- if (expr->isBracketAccessorNode()) {
- BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
- PrefixBracketNode* node = new (m_globalData) PrefixBracketNode(lineNumber, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
- node->setSubexpressionInfo(bracket->divot(), bracket->startOffset());
- return node;
- }
- ASSERT(expr->isDotAccessorNode());
- DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
- PrefixDotNode* node = new (m_globalData) PrefixDotNode(lineNumber, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
- node->setSubexpressionInfo(dot->divot(), dot->startOffset());
- return node;
+ return new (m_vm) PrefixNode(location, expr, op, divot, start, end);
}
-ExpressionNode* ASTBuilder::makePostfixNode(int lineNumber, ExpressionNode* expr, Operator op, int start, int divot, int end)
+ExpressionNode* ASTBuilder::makePostfixNode(const JSTokenLocation& location, ExpressionNode* expr, Operator op, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
{
- if (!expr->isLocation())
- return new (m_globalData) PostfixErrorNode(lineNumber, expr, op, divot, divot - start, end - divot);
-
- if (expr->isResolveNode()) {
- ResolveNode* resolve = static_cast<ResolveNode*>(expr);
- return new (m_globalData) PostfixResolveNode(lineNumber, resolve->identifier(), op, divot, divot - start, end - divot);
- }
- if (expr->isBracketAccessorNode()) {
- BracketAccessorNode* bracket = static_cast<BracketAccessorNode*>(expr);
- PostfixBracketNode* node = new (m_globalData) PostfixBracketNode(lineNumber, bracket->base(), bracket->subscript(), op, divot, divot - start, end - divot);
- node->setSubexpressionInfo(bracket->divot(), bracket->endOffset());
- return node;
-
- }
- ASSERT(expr->isDotAccessorNode());
- DotAccessorNode* dot = static_cast<DotAccessorNode*>(expr);
- PostfixDotNode* node = new (m_globalData) PostfixDotNode(lineNumber, dot->base(), dot->identifier(), op, divot, divot - start, end - divot);
- node->setSubexpressionInfo(dot->divot(), dot->endOffset());
- return node;
+ return new (m_vm) PostfixNode(location, expr, op, divot, start, end);
}
}