diff options
Diffstat (limited to 'Source/JavaScriptCore/parser/NodeConstructors.h')
-rw-r--r-- | Source/JavaScriptCore/parser/NodeConstructors.h | 374 |
1 files changed, 118 insertions, 256 deletions
diff --git a/Source/JavaScriptCore/parser/NodeConstructors.h b/Source/JavaScriptCore/parser/NodeConstructors.h index 1de31687d..917126975 100644 --- a/Source/JavaScriptCore/parser/NodeConstructors.h +++ b/Source/JavaScriptCore/parser/NodeConstructors.h @@ -27,24 +27,23 @@ namespace JSC { - inline void* ParserArenaFreeable::operator new(size_t size, ParserArena& parserArena) + inline void* ParserArenaFreeable::operator new(size_t size, VM* vm) { - return parserArena.allocateFreeable(size); + return vm->parserArena->allocateFreeable(size); } - inline void* ParserArenaDeletable::operator new(size_t size, ParserArena& parserArena) + inline void* ParserArenaDeletable::operator new(size_t size, VM* vm) { - return parserArena.allocateDeletable(size); + return vm->parserArena->allocateDeletable(size); } - inline ParserArenaRoot::ParserArenaRoot(ParserArena& parserArena) + inline ParserArenaRefCounted::ParserArenaRefCounted(VM* vm) { - m_arena.swap(parserArena); + vm->parserArena->derefWithArena(adoptRef(this)); } inline Node::Node(const JSTokenLocation& location) : m_position(location.line, location.startOffset, location.lineStartOffset) - , m_endOffset(-1) { ASSERT(location.startOffset >= location.lineStartOffset); } @@ -57,7 +56,6 @@ namespace JSC { inline StatementNode::StatementNode(const JSTokenLocation& location) : Node(location) - , m_next(nullptr) , m_lastLine(-1) { } @@ -84,72 +82,12 @@ namespace JSC { { } - inline DoubleNode::DoubleNode(const JSTokenLocation& location, double value) - : NumberNode(location, value) - { - } - - inline IntegerNode::IntegerNode(const JSTokenLocation& location, double value) - : DoubleNode(location, value) - { - } - inline StringNode::StringNode(const JSTokenLocation& location, const Identifier& value) : ConstantNode(location, ResultType::stringType()) , m_value(value) { } - inline TemplateExpressionListNode::TemplateExpressionListNode(ExpressionNode* node) - : m_node(node) - { - } - - inline TemplateExpressionListNode::TemplateExpressionListNode(TemplateExpressionListNode* previous, ExpressionNode* node) - : m_node(node) - { - previous->m_next = this; - } - - inline TemplateStringNode::TemplateStringNode(const JSTokenLocation& location, const Identifier& cooked, const Identifier& raw) - : ExpressionNode(location) - , m_cooked(cooked) - , m_raw(raw) - { - } - - inline TemplateStringListNode::TemplateStringListNode(TemplateStringNode* node) - : m_node(node) - { - } - - inline TemplateStringListNode::TemplateStringListNode(TemplateStringListNode* previous, TemplateStringNode* node) - : m_node(node) - { - previous->m_next = this; - } - - inline TemplateLiteralNode::TemplateLiteralNode(const JSTokenLocation& location, TemplateStringListNode* templateStrings) - : ExpressionNode(location) - , m_templateStrings(templateStrings) - , m_templateExpressions(nullptr) - { - } - - inline TemplateLiteralNode::TemplateLiteralNode(const JSTokenLocation& location, TemplateStringListNode* templateStrings, TemplateExpressionListNode* templateExpressions) - : ExpressionNode(location) - , m_templateStrings(templateStrings) - , m_templateExpressions(templateExpressions) - { - } - - inline TaggedTemplateNode::TaggedTemplateNode(const JSTokenLocation& location, ExpressionNode* tag, TemplateLiteralNode* templateLiteral) - : ExpressionNode(location) - , m_tag(tag) - , m_templateLiteral(templateLiteral) - { - } - inline RegExpNode::RegExpNode(const JSTokenLocation& location, const Identifier& pattern, const Identifier& flags) : ExpressionNode(location) , m_pattern(pattern) @@ -157,23 +95,12 @@ namespace JSC { { } - inline ThisNode::ThisNode(const JSTokenLocation& location, ThisTDZMode thisTDZMode) - : ExpressionNode(location) - , m_shouldAlwaysEmitTDZCheck(thisTDZMode == ThisTDZMode::AlwaysCheck) - { - } - - inline SuperNode::SuperNode(const JSTokenLocation& location) + inline ThisNode::ThisNode(const JSTokenLocation& location) : ExpressionNode(location) { } - inline NewTargetNode::NewTargetNode(const JSTokenLocation& location) - : ExpressionNode(location) - { - } - - inline ResolveNode::ResolveNode(const JSTokenLocation& location, const Identifier& ident, const JSTextPosition& start) +inline ResolveNode::ResolveNode(const JSTokenLocation& location, const Identifier& ident, const JSTextPosition& start) : ExpressionNode(location) , m_ident(ident) , m_start(start) @@ -220,22 +147,25 @@ namespace JSC { { } - inline PropertyNode::PropertyNode(const Identifier& name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding = SuperBinding::NotNeeded) + inline PropertyNode::PropertyNode(VM*, const Identifier& name, ExpressionNode* assign, Type type) : m_name(&name) , m_assign(assign) , m_type(type) - , m_needsSuperBinding(superBinding == SuperBinding::Needed) - , m_putType(putType) { } - inline PropertyNode::PropertyNode(ExpressionNode* name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding = SuperBinding::NotNeeded) + 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 PropertyNode::PropertyNode(VM*, ExpressionNode* name, ExpressionNode* assign, Type type) : m_name(0) , m_expression(name) , m_assign(assign) , m_type(type) - , m_needsSuperBinding(superBinding == SuperBinding::Needed) - , m_putType(putType) { } @@ -351,13 +281,12 @@ namespace JSC { { } - inline FunctionCallBracketNode::FunctionCallBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, bool subscriptHasAssignments, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd) + inline FunctionCallBracketNode::FunctionCallBracketNode(const JSTokenLocation& location, ExpressionNode* base, ExpressionNode* subscript, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd) : ExpressionNode(location) , ThrowableSubExpressionData(divot, divotStart, divotEnd) , m_base(base) , m_subscript(subscript) , m_args(args) - , m_subscriptHasAssignments(subscriptHasAssignments) { } @@ -370,16 +299,6 @@ namespace JSC { { } - inline BytecodeIntrinsicNode::BytecodeIntrinsicNode(Type type, const JSTokenLocation& location, EmitterType emitter, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd) - : ExpressionNode(location) - , ThrowableExpressionData(divot, divotStart, divotEnd) - , m_type(type) - , m_emitter(emitter) - , m_ident(ident) - , m_args(args) - { - } - inline CallFunctionCallDotNode::CallFunctionCallDotNode(const JSTokenLocation& location, ExpressionNode* base, const Identifier& ident, ArgumentsNode* args, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd) : FunctionCallDotNode(location, base, ident, args, divot, divotStart, divotEnd) { @@ -638,11 +557,10 @@ namespace JSC { { } - inline AssignResolveNode::AssignResolveNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* right, AssignmentContext assignmentContext) + inline AssignResolveNode::AssignResolveNode(const JSTokenLocation& location, const Identifier& ident, ExpressionNode* right) : ExpressionNode(location) , m_ident(ident) , m_right(right) - , m_assignmentContext(assignmentContext) { } @@ -697,16 +615,22 @@ namespace JSC { { } - inline CommaNode::CommaNode(const JSTokenLocation& location, ExpressionNode* expr) + inline CommaNode::CommaNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2) : ExpressionNode(location) - , m_expr(expr) - , m_next(nullptr) + { + ASSERT(expr1); + ASSERT(expr2); + m_expressions.append(expr1); + m_expressions.append(expr2); + } + + inline ConstStatementNode::ConstStatementNode(const JSTokenLocation& location, ConstDeclNode* next) + : StatementNode(location) + , m_next(next) { } inline SourceElements::SourceElements() - : m_head(nullptr) - , m_tail(nullptr) { } @@ -726,81 +650,11 @@ namespace JSC { { } - inline DeclarationStatement::DeclarationStatement(const JSTokenLocation& location, ExpressionNode* expr) + inline VarStatementNode::VarStatementNode(const JSTokenLocation& location, ExpressionNode* expr) : StatementNode(location) , m_expr(expr) { } - - inline ModuleDeclarationNode::ModuleDeclarationNode(const JSTokenLocation& location) - : StatementNode(location) - { - } - - inline ModuleNameNode::ModuleNameNode(const JSTokenLocation& location, const Identifier& moduleName) - : Node(location) - , m_moduleName(moduleName) - { - } - - inline ImportSpecifierNode::ImportSpecifierNode(const JSTokenLocation& location, const Identifier& importedName, const Identifier& localName) - : Node(location) - , m_importedName(importedName) - , m_localName(localName) - { - } - - inline ImportDeclarationNode::ImportDeclarationNode(const JSTokenLocation& location, ImportSpecifierListNode* importSpecifierList, ModuleNameNode* moduleName) - : ModuleDeclarationNode(location) - , m_specifierList(importSpecifierList) - , m_moduleName(moduleName) - { - } - - inline ExportAllDeclarationNode::ExportAllDeclarationNode(const JSTokenLocation& location, ModuleNameNode* moduleName) - : ModuleDeclarationNode(location) - , m_moduleName(moduleName) - { - } - - inline ExportDefaultDeclarationNode::ExportDefaultDeclarationNode(const JSTokenLocation& location, StatementNode* declaration, const Identifier& localName) - : ModuleDeclarationNode(location) - , m_declaration(declaration) - , m_localName(localName) - { - } - - inline ExportLocalDeclarationNode::ExportLocalDeclarationNode(const JSTokenLocation& location, StatementNode* declaration) - : ModuleDeclarationNode(location) - , m_declaration(declaration) - { - } - - inline ExportNamedDeclarationNode::ExportNamedDeclarationNode(const JSTokenLocation& location, ExportSpecifierListNode* exportSpecifierList, ModuleNameNode* moduleName) - : ModuleDeclarationNode(location) - , m_specifierList(exportSpecifierList) - , m_moduleName(moduleName) - { - } - - inline ExportSpecifierNode::ExportSpecifierNode(const JSTokenLocation& location, const Identifier& localName, const Identifier& exportedName) - : Node(location) - , m_localName(localName) - , m_exportedName(exportedName) - { - } - - inline EmptyVarExpression::EmptyVarExpression(const JSTokenLocation& location, const Identifier& ident) - : ExpressionNode(location) - , m_ident(ident) - { - } - - inline EmptyLetExpression::EmptyLetExpression(const JSTokenLocation& location, const Identifier& ident) - : ExpressionNode(location) - , m_ident(ident) - { - } inline IfElseNode::IfElseNode(const JSTokenLocation& location, ExpressionNode* condition, StatementNode* ifBlock, StatementNode* elseBlock) : StatementNode(location) @@ -824,9 +678,8 @@ namespace JSC { { } - inline ForNode::ForNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement, VariableEnvironment& lexicalVariables) + inline ForNode::ForNode(const JSTokenLocation& location, ExpressionNode* expr1, ExpressionNode* expr2, ExpressionNode* expr3, StatementNode* statement) : StatementNode(location) - , VariableEnvironmentNode(lexicalVariables) , m_expr1(expr1) , m_expr2(expr2) , m_expr3(expr3) @@ -835,12 +688,24 @@ namespace JSC { 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) @@ -875,67 +740,43 @@ namespace JSC { { } - inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, DestructuringPatternNode* catchPattern, StatementNode* catchBlock, VariableEnvironment& catchEnvironment, StatementNode* finallyBlock) + inline TryNode::TryNode(const JSTokenLocation& location, StatementNode* tryBlock, const Identifier& exceptionIdent, StatementNode* catchBlock, StatementNode* finallyBlock) : StatementNode(location) - , VariableEnvironmentNode(catchEnvironment) , m_tryBlock(tryBlock) - , m_catchPattern(catchPattern) + , m_exceptionIdent(exceptionIdent) , m_catchBlock(catchBlock) , m_finallyBlock(finallyBlock) { } - inline FunctionParameters::FunctionParameters() - { - } - - - inline BaseFuncExprNode::BaseFuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* m_metadata, const SourceCode& source) - : ExpressionNode(location) - , m_metadata(m_metadata) - { - m_metadata->finishParsing(source, ident, FunctionExpression); - } - - inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* m_metadata, const SourceCode& source) - : BaseFuncExprNode(location, ident, m_metadata, source) - { - } - - inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* m_metadata, const SourceCode& source) - : StatementNode(location) - , m_metadata(m_metadata) + inline ParameterNode::ParameterNode(PassRefPtr<DeconstructionPatternNode> pattern) + : m_pattern(pattern) + , m_next(0) { - m_metadata->finishParsing(source, ident, FunctionDeclaration); + ASSERT(m_pattern); } - inline ArrowFuncExprNode::ArrowFuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionMetadataNode* m_metadata, const SourceCode& source) - : BaseFuncExprNode(location, ident, m_metadata, source) + inline ParameterNode::ParameterNode(ParameterNode* l, PassRefPtr<DeconstructionPatternNode> pattern) + : m_pattern(pattern) + , m_next(0) { + l->m_next = this; + ASSERT(m_pattern); + ASSERT(l->m_pattern); } - inline YieldExprNode::YieldExprNode(const JSTokenLocation& location, ExpressionNode* argument, bool delegate) + inline FuncExprNode::FuncExprNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter) : ExpressionNode(location) - , m_argument(argument) - , m_delegate(delegate) + , m_body(body) { + m_body->finishParsing(source, parameter, ident, FunctionNameIsInScope); } - inline ClassDeclNode::ClassDeclNode(const JSTokenLocation& location, ExpressionNode* classDeclaration) + inline FuncDeclNode::FuncDeclNode(const JSTokenLocation& location, const Identifier& ident, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter) : StatementNode(location) - , m_classDeclaration(classDeclaration) - { - } - - inline ClassExprNode::ClassExprNode(const JSTokenLocation& location, const Identifier& name, VariableEnvironment& classEnvironment, ExpressionNode* constructorExpression, ExpressionNode* classHeritage, PropertyListNode* instanceMethods, PropertyListNode* staticMethods) - : ExpressionNode(location) - , VariableEnvironmentNode(classEnvironment) - , m_name(name) - , m_constructorExpression(constructorExpression) - , m_classHeritage(classHeritage) - , m_instanceMethods(instanceMethods) - , m_staticMethods(staticMethods) + , m_body(body) { + m_body->finishParsing(source, parameter, ident, FunctionNameIsNotInScope); } inline CaseClauseNode::CaseClauseNode(ExpressionNode* expr, SourceElements* statements) @@ -964,82 +805,103 @@ namespace JSC { { } - inline SwitchNode::SwitchNode(const JSTokenLocation& location, ExpressionNode* expr, CaseBlockNode* block, VariableEnvironment& lexicalVariables) + inline SwitchNode::SwitchNode(const JSTokenLocation& location, ExpressionNode* expr, CaseBlockNode* block) : StatementNode(location) - , VariableEnvironmentNode(lexicalVariables) , m_expr(expr) , m_block(block) { } - inline BlockNode::BlockNode(const JSTokenLocation& location, SourceElements* statements, VariableEnvironment& lexicalVariables) + 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) - , VariableEnvironmentNode(lexicalVariables) , m_statements(statements) { } - inline EnumerationNode::EnumerationNode(const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment& lexicalVariables) + inline EnumerationNode::EnumerationNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) : StatementNode(location) - , VariableEnvironmentNode(lexicalVariables) - , m_lexpr(lexpr) + , m_lexpr(l) , m_expr(expr) , m_statement(statement) { - ASSERT(lexpr); + ASSERT(l); } - inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment& lexicalVariables) - : EnumerationNode(location, lexpr, expr, statement, lexicalVariables) + inline EnumerationNode::EnumerationNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement) + : StatementNode(location) + , m_lexpr(new (vm) DeconstructingAssignmentNode(location, pattern, 0)) + , m_expr(expr) + , m_statement(statement) { + ASSERT(pattern); } - inline ForOfNode::ForOfNode(const JSTokenLocation& location, ExpressionNode* lexpr, ExpressionNode* expr, StatementNode* statement, VariableEnvironment& lexicalVariables) - : EnumerationNode(location, lexpr, expr, statement, lexicalVariables) + inline ForInNode::ForInNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) + : EnumerationNode(location, l, expr, statement) { } - inline DestructuringPatternNode::DestructuringPatternNode() + inline ForInNode::ForInNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement) + : EnumerationNode(vm, location, pattern, expr, statement) { } - - inline ArrayPatternNode::ArrayPatternNode() - : DestructuringPatternNode() + + inline ForOfNode::ForOfNode(const JSTokenLocation& location, ExpressionNode* l, ExpressionNode* expr, StatementNode* statement) + : EnumerationNode(location, l, expr, statement) { } - inline ObjectPatternNode::ObjectPatternNode() - : DestructuringPatternNode() + inline ForOfNode::ForOfNode(VM* vm, const JSTokenLocation& location, DeconstructionPatternNode* pattern, ExpressionNode* expr, StatementNode* statement) + : EnumerationNode(vm, location, pattern, expr, statement) { } - inline BindingNode::BindingNode(const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end, AssignmentContext context) - : DestructuringPatternNode() - , m_divotStart(start) - , m_divotEnd(end) - , m_boundProperty(boundProperty) - , m_bindingContext(context) + inline DeconstructionPatternNode::DeconstructionPatternNode(VM*) { } - inline AssignmentElementNode::AssignmentElementNode(ExpressionNode* assignmentTarget, const JSTextPosition& start, const JSTextPosition& end) - : DestructuringPatternNode() - , m_divotStart(start) - , m_divotEnd(end) - , m_assignmentTarget(assignmentTarget) + inline ArrayPatternNode::ArrayPatternNode(VM* vm) + : DeconstructionPatternNode(vm) + { + } + + inline PassRefPtr<ArrayPatternNode> ArrayPatternNode::create(VM* vm) + { + return adoptRef(new ArrayPatternNode(vm)); + } + + inline ObjectPatternNode::ObjectPatternNode(VM* vm) + : DeconstructionPatternNode(vm) { } + + inline PassRefPtr<ObjectPatternNode> ObjectPatternNode::create(VM* vm) + { + return adoptRef(new ObjectPatternNode(vm)); + } - inline RestParameterNode::RestParameterNode(const Identifier& name, unsigned numParametersToSkip, const JSTextPosition& start, const JSTextPosition& end) - : DestructuringPatternNode() - , m_name(name) - , m_numParametersToSkip(numParametersToSkip) + inline PassRefPtr<BindingNode> BindingNode::create(VM* vm, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end) + { + return adoptRef(new BindingNode(vm, boundProperty, start, end)); + } + + inline BindingNode::BindingNode(VM* vm, const Identifier& boundProperty, const JSTextPosition& start, const JSTextPosition& end) + : DeconstructionPatternNode(vm) , m_divotStart(start) , m_divotEnd(end) + , m_boundProperty(boundProperty) { } - - inline DestructuringAssignmentNode::DestructuringAssignmentNode(const JSTokenLocation& location, DestructuringPatternNode* bindings, ExpressionNode* initializer) + + inline DeconstructingAssignmentNode::DeconstructingAssignmentNode(const JSTokenLocation& location, PassRefPtr<DeconstructionPatternNode> bindings, ExpressionNode* initializer) : ExpressionNode(location) , m_bindings(bindings) , m_initializer(initializer) |