OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PARSING_PARSER_H_ | 5 #ifndef V8_PARSING_PARSER_H_ |
6 #define V8_PARSING_PARSER_H_ | 6 #define V8_PARSING_PARSER_H_ |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/parsing/parser-base.h" | 10 #include "src/parsing/parser-base.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 typedef ParserBase<Parser> Base; | 143 typedef ParserBase<Parser> Base; |
144 typedef Parser Impl; | 144 typedef Parser Impl; |
145 | 145 |
146 typedef Variable GeneratorVariable; | 146 typedef Variable GeneratorVariable; |
147 | 147 |
148 // Return types for traversing functions. | 148 // Return types for traversing functions. |
149 typedef const AstRawString* Identifier; | 149 typedef const AstRawString* Identifier; |
150 typedef v8::internal::Expression* Expression; | 150 typedef v8::internal::Expression* Expression; |
151 typedef v8::internal::FunctionLiteral* FunctionLiteral; | 151 typedef v8::internal::FunctionLiteral* FunctionLiteral; |
152 typedef ObjectLiteral::Property* ObjectLiteralProperty; | 152 typedef ObjectLiteral::Property* ObjectLiteralProperty; |
| 153 typedef ClassLiteral::Property* ClassLiteralProperty; |
153 typedef ZoneList<v8::internal::Expression*>* ExpressionList; | 154 typedef ZoneList<v8::internal::Expression*>* ExpressionList; |
154 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; | 155 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; |
155 typedef ParserFormalParameters FormalParameters; | 156 typedef ParserFormalParameters FormalParameters; |
156 typedef v8::internal::Statement* Statement; | 157 typedef v8::internal::Statement* Statement; |
157 typedef ZoneList<v8::internal::Statement*>* StatementList; | 158 typedef ZoneList<v8::internal::Statement*>* StatementList; |
158 typedef v8::internal::Block* Block; | 159 typedef v8::internal::Block* Block; |
159 | 160 |
160 // For constructing objects returned by the traversing functions. | 161 // For constructing objects returned by the traversing functions. |
161 typedef AstNodeFactory Factory; | 162 typedef AstNodeFactory Factory; |
162 | 163 |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 // is also compared with it and the result is true only if they are equal. | 707 // is also compared with it and the result is true only if they are equal. |
707 V8_INLINE bool IsStringLiteral(Statement* statement, | 708 V8_INLINE bool IsStringLiteral(Statement* statement, |
708 const AstRawString* arg = nullptr) const { | 709 const AstRawString* arg = nullptr) const { |
709 ExpressionStatement* e_stat = statement->AsExpressionStatement(); | 710 ExpressionStatement* e_stat = statement->AsExpressionStatement(); |
710 if (e_stat == nullptr) return false; | 711 if (e_stat == nullptr) return false; |
711 Literal* literal = e_stat->expression()->AsLiteral(); | 712 Literal* literal = e_stat->expression()->AsLiteral(); |
712 if (literal == nullptr || !literal->raw_value()->IsString()) return false; | 713 if (literal == nullptr || !literal->raw_value()->IsString()) return false; |
713 return arg == nullptr || literal->raw_value()->AsString() == arg; | 714 return arg == nullptr || literal->raw_value()->AsString() == arg; |
714 } | 715 } |
715 | 716 |
716 V8_INLINE static Expression* GetPropertyValue( | 717 V8_INLINE static Expression* GetPropertyValue(LiteralProperty* property) { |
717 ObjectLiteral::Property* property) { | |
718 return property->value(); | 718 return property->value(); |
719 } | 719 } |
720 | 720 |
721 // Functions for encapsulating the differences between parsing and preparsing; | 721 // Functions for encapsulating the differences between parsing and preparsing; |
722 // operations interleaved with the recursive descent. | 722 // operations interleaved with the recursive descent. |
723 V8_INLINE void PushLiteralName(const AstRawString* id) { | 723 V8_INLINE void PushLiteralName(const AstRawString* id) { |
724 DCHECK_NOT_NULL(fni_); | 724 DCHECK_NOT_NULL(fni_); |
725 fni_->PushLiteralName(id); | 725 fni_->PushLiteralName(id); |
726 } | 726 } |
727 | 727 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 arg, error_type); | 840 arg, error_type); |
841 } | 841 } |
842 | 842 |
843 // "null" return type creators. | 843 // "null" return type creators. |
844 V8_INLINE static const AstRawString* EmptyIdentifier() { return nullptr; } | 844 V8_INLINE static const AstRawString* EmptyIdentifier() { return nullptr; } |
845 V8_INLINE static Expression* EmptyExpression() { return nullptr; } | 845 V8_INLINE static Expression* EmptyExpression() { return nullptr; } |
846 V8_INLINE static Literal* EmptyLiteral() { return nullptr; } | 846 V8_INLINE static Literal* EmptyLiteral() { return nullptr; } |
847 V8_INLINE static ObjectLiteralProperty* EmptyObjectLiteralProperty() { | 847 V8_INLINE static ObjectLiteralProperty* EmptyObjectLiteralProperty() { |
848 return nullptr; | 848 return nullptr; |
849 } | 849 } |
| 850 V8_INLINE static ClassLiteralProperty* EmptyClassLiteralProperty() { |
| 851 return nullptr; |
| 852 } |
850 V8_INLINE static FunctionLiteral* EmptyFunctionLiteral() { return nullptr; } | 853 V8_INLINE static FunctionLiteral* EmptyFunctionLiteral() { return nullptr; } |
851 V8_INLINE static Block* NullBlock() { return nullptr; } | 854 V8_INLINE static Block* NullBlock() { return nullptr; } |
852 | 855 |
853 V8_INLINE static bool IsEmptyExpression(Expression* expr) { | 856 V8_INLINE static bool IsEmptyExpression(Expression* expr) { |
854 return expr == nullptr; | 857 return expr == nullptr; |
855 } | 858 } |
856 | 859 |
857 // Used in error return values. | 860 // Used in error return values. |
858 V8_INLINE static ZoneList<Expression*>* NullExpressionList() { | 861 V8_INLINE static ZoneList<Expression*>* NullExpressionList() { |
859 return nullptr; | 862 return nullptr; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 return factory()->NewStringLiteral(symbol, pos); | 928 return factory()->NewStringLiteral(symbol, pos); |
926 } | 929 } |
927 | 930 |
928 V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const { | 931 V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const { |
929 return new (zone()) ZoneList<Expression*>(size, zone()); | 932 return new (zone()) ZoneList<Expression*>(size, zone()); |
930 } | 933 } |
931 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewPropertyList( | 934 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewPropertyList( |
932 int size) const { | 935 int size) const { |
933 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone()); | 936 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone()); |
934 } | 937 } |
| 938 V8_INLINE ZoneList<ClassLiteral::Property*>* NewClassPropertyList( |
| 939 int size) const { |
| 940 return new (zone()) ZoneList<ClassLiteral::Property*>(size, zone()); |
| 941 } |
935 V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const { | 942 V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const { |
936 return new (zone()) ZoneList<Statement*>(size, zone()); | 943 return new (zone()) ZoneList<Statement*>(size, zone()); |
937 } | 944 } |
938 | 945 |
939 V8_INLINE Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, | 946 V8_INLINE Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, |
940 bool ignore_completion_value, int pos) { | 947 bool ignore_completion_value, int pos) { |
941 return factory()->NewBlock(labels, capacity, ignore_completion_value, pos); | 948 return factory()->NewBlock(labels, capacity, ignore_completion_value, pos); |
942 } | 949 } |
943 | 950 |
944 V8_INLINE void AddParameterInitializationBlock( | 951 V8_INLINE void AddParameterInitializationBlock( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 V8_INLINE static bool IsTaggedTemplate(const Expression* tag) { | 1012 V8_INLINE static bool IsTaggedTemplate(const Expression* tag) { |
1006 return tag != NULL; | 1013 return tag != NULL; |
1007 } | 1014 } |
1008 | 1015 |
1009 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} | 1016 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} |
1010 | 1017 |
1011 Expression* ExpressionListToExpression(ZoneList<Expression*>* args); | 1018 Expression* ExpressionListToExpression(ZoneList<Expression*>* args); |
1012 | 1019 |
1013 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, | 1020 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, |
1014 const AstRawString* name); | 1021 const AstRawString* name); |
| 1022 void SetFunctionNameFromPropertyName(ClassLiteralProperty* property, |
| 1023 const AstRawString* name); |
1015 | 1024 |
1016 void SetFunctionNameFromIdentifierRef(Expression* value, | 1025 void SetFunctionNameFromIdentifierRef(Expression* value, |
1017 Expression* identifier); | 1026 Expression* identifier); |
1018 | 1027 |
1019 V8_INLINE ZoneList<typename ExpressionClassifier::Error>* | 1028 V8_INLINE ZoneList<typename ExpressionClassifier::Error>* |
1020 GetReportedErrorList() const { | 1029 GetReportedErrorList() const { |
1021 return function_state_->GetReportedErrorList(); | 1030 return function_state_->GetReportedErrorList(); |
1022 } | 1031 } |
1023 | 1032 |
1024 V8_INLINE ZoneList<Expression*>* GetNonPatternList() const { | 1033 V8_INLINE ZoneList<Expression*>* GetNonPatternList() const { |
(...skipping 25 matching lines...) Expand all Loading... |
1050 | 1059 |
1051 #ifdef DEBUG | 1060 #ifdef DEBUG |
1052 void Print(AstNode* node); | 1061 void Print(AstNode* node); |
1053 #endif // DEBUG | 1062 #endif // DEBUG |
1054 }; | 1063 }; |
1055 | 1064 |
1056 } // namespace internal | 1065 } // namespace internal |
1057 } // namespace v8 | 1066 } // namespace v8 |
1058 | 1067 |
1059 #endif // V8_PARSING_PARSER_H_ | 1068 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |