Chromium Code Reviews| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 const AstRawString* local_name; | 259 const AstRawString* local_name; |
| 260 const Scanner::Location location; | 260 const Scanner::Location location; |
| 261 NamedImport(const AstRawString* import_name, const AstRawString* local_name, | 261 NamedImport(const AstRawString* import_name, const AstRawString* local_name, |
| 262 Scanner::Location location) | 262 Scanner::Location location) |
| 263 : import_name(import_name), | 263 : import_name(import_name), |
| 264 local_name(local_name), | 264 local_name(local_name), |
| 265 location(location) {} | 265 location(location) {} |
| 266 }; | 266 }; |
| 267 ZoneList<const NamedImport*>* ParseNamedImports(int pos, bool* ok); | 267 ZoneList<const NamedImport*>* ParseNamedImports(int pos, bool* ok); |
| 268 Statement* ParseFunctionDeclaration(bool* ok); | 268 Statement* ParseFunctionDeclaration(bool* ok); |
| 269 Statement* ParseHoistableDeclaration(ZoneList<const AstRawString*>* names, | |
| 270 bool default_export, bool* ok); | |
| 271 Statement* ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, | |
| 272 ZoneList<const AstRawString*>* names, | |
| 273 bool default_export, bool* ok); | |
| 274 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, | 269 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, |
| 275 bool default_export, bool* ok); | 270 bool default_export, bool* ok); |
| 276 Expression* ParseAsyncFunctionExpression(bool* ok); | 271 Expression* ParseAsyncFunctionExpression(bool* ok); |
| 277 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, | 272 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
| 278 bool default_export, bool* ok); | 273 bool default_export, bool* ok); |
| 279 Statement* ParseNativeDeclaration(bool* ok); | 274 Statement* ParseNativeDeclaration(bool* ok); |
| 280 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); | 275 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); |
| 281 Block* BuildInitializationBlock(DeclarationParsingResult* parsing_result, | 276 Block* BuildInitializationBlock(DeclarationParsingResult* parsing_result, |
| 282 ZoneList<const AstRawString*>* names, | 277 ZoneList<const AstRawString*>* names, |
| 283 bool* ok); | 278 bool* ok); |
| 284 void DeclareAndInitializeVariables( | 279 void DeclareAndInitializeVariables( |
| 285 Block* block, const DeclarationDescriptor* declaration_descriptor, | 280 Block* block, const DeclarationDescriptor* declaration_descriptor, |
| 286 const DeclarationParsingResult::Declaration* declaration, | 281 const DeclarationParsingResult::Declaration* declaration, |
| 287 ZoneList<const AstRawString*>* names, bool* ok); | 282 ZoneList<const AstRawString*>* names, bool* ok); |
| 288 | 283 |
| 284 Statement* DeclareFunction(const AstRawString* variable_name, | |
| 285 FunctionLiteral* function, int pos, | |
| 286 bool is_generator, bool is_async, | |
| 287 ZoneList<const AstRawString*>* names, bool* ok); | |
| 288 | |
| 289 Block* ParseVariableStatement(VariableDeclarationContext var_context, | 289 Block* ParseVariableStatement(VariableDeclarationContext var_context, |
| 290 ZoneList<const AstRawString*>* names, | 290 ZoneList<const AstRawString*>* names, |
| 291 bool* ok); | 291 bool* ok); |
| 292 DoExpression* ParseDoExpression(bool* ok); | 292 DoExpression* ParseDoExpression(bool* ok); |
| 293 Expression* ParseYieldStarExpression(bool* ok); | 293 Expression* ParseYieldStarExpression(bool* ok); |
| 294 | 294 |
| 295 class PatternRewriter final : public AstVisitor<PatternRewriter> { | 295 class PatternRewriter final : public AstVisitor<PatternRewriter> { |
| 296 public: | 296 public: |
| 297 static void DeclareAndInitializeVariables( | 297 static void DeclareAndInitializeVariables( |
| 298 Parser* parser, Block* block, | 298 Parser* parser, Block* block, |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 Literal* literal = e_stat->expression()->AsLiteral(); | 709 Literal* literal = e_stat->expression()->AsLiteral(); |
| 710 if (literal == nullptr || !literal->raw_value()->IsString()) return false; | 710 if (literal == nullptr || !literal->raw_value()->IsString()) return false; |
| 711 return arg == nullptr || literal->raw_value()->AsString() == arg; | 711 return arg == nullptr || literal->raw_value()->AsString() == arg; |
| 712 } | 712 } |
| 713 | 713 |
| 714 V8_INLINE static Expression* GetPropertyValue( | 714 V8_INLINE static Expression* GetPropertyValue( |
| 715 ObjectLiteral::Property* property) { | 715 ObjectLiteral::Property* property) { |
| 716 return property->value(); | 716 return property->value(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 V8_INLINE void GetDefaultStrings( | |
| 720 const AstRawString** default_string, | |
| 721 const AstRawString** star_default_star_string) { | |
| 722 *default_string = ast_value_factory()->default_string(); | |
| 723 *star_default_star_string = ast_value_factory()->star_default_star_string(); | |
| 724 } | |
| 725 | |
| 719 // Functions for encapsulating the differences between parsing and preparsing; | 726 // Functions for encapsulating the differences between parsing and preparsing; |
| 720 // operations interleaved with the recursive descent. | 727 // operations interleaved with the recursive descent. |
| 721 V8_INLINE void PushLiteralName(const AstRawString* id) { | 728 V8_INLINE void PushLiteralName(const AstRawString* id) { |
| 722 DCHECK_NOT_NULL(fni_); | 729 DCHECK_NOT_NULL(fni_); |
| 723 fni_->PushLiteralName(id); | 730 fni_->PushLiteralName(id); |
| 724 } | 731 } |
| 725 | 732 |
| 726 V8_INLINE void PushVariableName(const AstRawString* id) { | 733 V8_INLINE void PushVariableName(const AstRawString* id) { |
| 727 DCHECK_NOT_NULL(fni_); | 734 DCHECK_NOT_NULL(fni_); |
| 728 fni_->PushVariableName(id); | 735 fni_->PushVariableName(id); |
| 729 } | 736 } |
| 730 | 737 |
| 731 V8_INLINE void PushPropertyName(Expression* expression) { | 738 V8_INLINE void PushPropertyName(Expression* expression) { |
| 732 DCHECK_NOT_NULL(fni_); | 739 DCHECK_NOT_NULL(fni_); |
| 733 if (expression->IsPropertyName()) { | 740 if (expression->IsPropertyName()) { |
| 734 fni_->PushLiteralName(expression->AsLiteral()->AsRawPropertyName()); | 741 fni_->PushLiteralName(expression->AsLiteral()->AsRawPropertyName()); |
| 735 } else { | 742 } else { |
| 736 fni_->PushLiteralName(ast_value_factory()->anonymous_function_string()); | 743 fni_->PushLiteralName(ast_value_factory()->anonymous_function_string()); |
| 737 } | 744 } |
| 738 } | 745 } |
| 739 | 746 |
| 747 V8_INLINE void PushEnclosingName(const AstRawString* name) { | |
| 748 DCHECK_NOT_NULL(fni_); | |
| 749 fni_->PushEnclosingName(name); | |
| 750 } | |
| 751 | |
| 740 V8_INLINE void InferFunctionName(FunctionLiteral* func_to_infer) { | 752 V8_INLINE void InferFunctionName(FunctionLiteral* func_to_infer) { |
| 741 fni_->AddFunction(func_to_infer); | 753 fni_->AddFunction(func_to_infer); |
| 742 } | 754 } |
| 743 | 755 |
| 744 // If we assign a function literal to a property we pretenure the | 756 // If we assign a function literal to a property we pretenure the |
| 745 // literal so it can be added as a constant function property. | 757 // literal so it can be added as a constant function property. |
| 746 V8_INLINE static void CheckAssigningFunctionLiteralToProperty( | 758 V8_INLINE static void CheckAssigningFunctionLiteralToProperty( |
| 747 Expression* left, Expression* right) { | 759 Expression* left, Expression* right) { |
| 748 DCHECK(left != NULL); | 760 DCHECK(left != NULL); |
| 749 if (left->IsProperty() && right->IsFunctionLiteral()) { | 761 if (left->IsProperty() && right->IsFunctionLiteral()) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 } | 851 } |
| 840 | 852 |
| 841 // "null" return type creators. | 853 // "null" return type creators. |
| 842 V8_INLINE static const AstRawString* EmptyIdentifier() { return nullptr; } | 854 V8_INLINE static const AstRawString* EmptyIdentifier() { return nullptr; } |
| 843 V8_INLINE static Expression* EmptyExpression() { return nullptr; } | 855 V8_INLINE static Expression* EmptyExpression() { return nullptr; } |
| 844 V8_INLINE static Literal* EmptyLiteral() { return nullptr; } | 856 V8_INLINE static Literal* EmptyLiteral() { return nullptr; } |
| 845 V8_INLINE static ObjectLiteralProperty* EmptyObjectLiteralProperty() { | 857 V8_INLINE static ObjectLiteralProperty* EmptyObjectLiteralProperty() { |
| 846 return nullptr; | 858 return nullptr; |
| 847 } | 859 } |
| 848 V8_INLINE static FunctionLiteral* EmptyFunctionLiteral() { return nullptr; } | 860 V8_INLINE static FunctionLiteral* EmptyFunctionLiteral() { return nullptr; } |
| 861 // Using GetEmptyStatement instead of EmptyStatement because EmptyStatement is | |
| 862 // already in use. | |
| 863 V8_INLINE static Statement* GetEmptyStatement() { return nullptr; } | |
|
nickie
2016/09/06 17:29:57
There's a NullStatement on line 881. I suppose th
marja
2016/09/08 11:15:58
Ah true; confused about Null / Empty!
| |
| 849 V8_INLINE static Block* NullBlock() { return nullptr; } | 864 V8_INLINE static Block* NullBlock() { return nullptr; } |
| 850 | 865 |
| 851 V8_INLINE static bool IsEmptyExpression(Expression* expr) { | 866 V8_INLINE static bool IsEmptyExpression(Expression* expr) { |
| 852 return expr == nullptr; | 867 return expr == nullptr; |
| 853 } | 868 } |
| 854 | 869 |
| 855 // Used in error return values. | 870 // Used in error return values. |
| 856 V8_INLINE static ZoneList<Expression*>* NullExpressionList() { | 871 V8_INLINE static ZoneList<Expression*>* NullExpressionList() { |
| 857 return nullptr; | 872 return nullptr; |
| 858 } | 873 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1048 | 1063 |
| 1049 #ifdef DEBUG | 1064 #ifdef DEBUG |
| 1050 void Print(AstNode* node); | 1065 void Print(AstNode* node); |
| 1051 #endif // DEBUG | 1066 #endif // DEBUG |
| 1052 }; | 1067 }; |
| 1053 | 1068 |
| 1054 } // namespace internal | 1069 } // namespace internal |
| 1055 } // namespace v8 | 1070 } // namespace v8 |
| 1056 | 1071 |
| 1057 #endif // V8_PARSING_PARSER_H_ | 1072 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |