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_PREPARSER_H | 5 #ifndef V8_PARSING_PREPARSER_H |
6 #define V8_PARSING_PREPARSER_H | 6 #define V8_PARSING_PREPARSER_H |
7 | 7 |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // These functions make list->Add(some_expression) work (and do nothing). | 334 // These functions make list->Add(some_expression) work (and do nothing). |
335 explicit PreParserList(int length = 0) : length_(length) {} | 335 explicit PreParserList(int length = 0) : length_(length) {} |
336 PreParserList* operator->() { return this; } | 336 PreParserList* operator->() { return this; } |
337 void Add(T, void*) { ++length_; } | 337 void Add(T, void*) { ++length_; } |
338 int length() const { return length_; } | 338 int length() const { return length_; } |
339 private: | 339 private: |
340 int length_; | 340 int length_; |
341 }; | 341 }; |
342 | 342 |
343 | 343 |
| 344 typedef PreParserList<PreParserIdentifier> PreParserIdentifierList; |
344 typedef PreParserList<PreParserExpression> PreParserExpressionList; | 345 typedef PreParserList<PreParserExpression> PreParserExpressionList; |
345 | 346 |
346 | 347 |
347 class PreParserStatement { | 348 class PreParserStatement { |
348 public: | 349 public: |
349 static PreParserStatement Default() { | 350 static PreParserStatement Default() { |
350 return PreParserStatement(kUnknownStatement); | 351 return PreParserStatement(kUnknownStatement); |
351 } | 352 } |
352 | 353 |
353 static PreParserStatement Jump() { | 354 static PreParserStatement Jump() { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 const PreParserIdentifier& string, int pos) { | 710 const PreParserIdentifier& string, int pos) { |
710 return typesystem::PreParserType::StringLiteral(); | 711 return typesystem::PreParserType::StringLiteral(); |
711 } | 712 } |
712 | 713 |
713 typesystem::PreParserType NewTypeReference( | 714 typesystem::PreParserType NewTypeReference( |
714 const PreParserIdentifier& name, | 715 const PreParserIdentifier& name, |
715 const typesystem::PreParserTypeArguments& type_arguments, int pos) { | 716 const typesystem::PreParserTypeArguments& type_arguments, int pos) { |
716 return typesystem::PreParserType::Reference(type_arguments.length() == 0); | 717 return typesystem::PreParserType::Reference(type_arguments.length() == 0); |
717 } | 718 } |
718 | 719 |
| 720 typesystem::PreParserType NewQueryType( |
| 721 const PreParserIdentifier& name, |
| 722 const PreParserIdentifierList& property_names, int pos) { |
| 723 return typesystem::PreParserType::Default(); |
| 724 } |
| 725 |
719 typesystem::PreParserFormalParameter NewFormalParameter( | 726 typesystem::PreParserFormalParameter NewFormalParameter( |
720 const PreParserIdentifier& name, bool optional, bool spread, | 727 const PreParserIdentifier& name, bool optional, bool spread, |
721 const typesystem::PreParserType& type, int pos) { | 728 const typesystem::PreParserType& type, int pos) { |
722 return typesystem::PreParserFormalParameter::Named(); | 729 return typesystem::PreParserFormalParameter::Named(); |
723 } | 730 } |
724 | 731 |
725 typesystem::PreParserFormalParameter NewFormalParameter( | 732 typesystem::PreParserFormalParameter NewFormalParameter( |
726 const typesystem::PreParserType& type, int pos) { | 733 const typesystem::PreParserType& type, int pos) { |
727 return typesystem::PreParserFormalParameter::Unnamed(type); | 734 return typesystem::PreParserFormalParameter::Unnamed(type); |
728 } | 735 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 // PreParser doesn't need to store generator variables. | 778 // PreParser doesn't need to store generator variables. |
772 typedef void GeneratorVariable; | 779 typedef void GeneratorVariable; |
773 | 780 |
774 typedef int AstProperties; | 781 typedef int AstProperties; |
775 | 782 |
776 typedef v8::internal::ExpressionClassifier<PreParserTraits> | 783 typedef v8::internal::ExpressionClassifier<PreParserTraits> |
777 ExpressionClassifier; | 784 ExpressionClassifier; |
778 | 785 |
779 // Return types for traversing functions. | 786 // Return types for traversing functions. |
780 typedef PreParserIdentifier Identifier; | 787 typedef PreParserIdentifier Identifier; |
| 788 typedef PreParserIdentifierList IdentifierList; |
781 typedef PreParserExpression Expression; | 789 typedef PreParserExpression Expression; |
782 typedef PreParserExpression YieldExpression; | 790 typedef PreParserExpression YieldExpression; |
783 typedef PreParserExpression FunctionLiteral; | 791 typedef PreParserExpression FunctionLiteral; |
784 typedef PreParserExpression ClassLiteral; | 792 typedef PreParserExpression ClassLiteral; |
785 typedef PreParserExpression ObjectLiteralProperty; | 793 typedef PreParserExpression ObjectLiteralProperty; |
786 typedef PreParserExpression Literal; | 794 typedef PreParserExpression Literal; |
787 typedef PreParserExpressionList ExpressionList; | 795 typedef PreParserExpressionList ExpressionList; |
788 typedef PreParserExpressionList PropertyList; | 796 typedef PreParserExpressionList PropertyList; |
789 typedef PreParserIdentifier FormalParameter; | 797 typedef PreParserIdentifier FormalParameter; |
790 typedef PreParserFormalParameters FormalParameters; | 798 typedef PreParserFormalParameters FormalParameters; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 } | 975 } |
968 static typesystem::PreParserTypeArguments EmptyTypeArguments() { | 976 static typesystem::PreParserTypeArguments EmptyTypeArguments() { |
969 return typesystem::PreParserTypeArguments(); | 977 return typesystem::PreParserTypeArguments(); |
970 } | 978 } |
971 static typesystem::PreParserTypeParameters EmptyTypeParameters() { | 979 static typesystem::PreParserTypeParameters EmptyTypeParameters() { |
972 return typesystem::PreParserTypeParameters(); | 980 return typesystem::PreParserTypeParameters(); |
973 } | 981 } |
974 static typesystem::PreParserFormalParameters EmptyFormalParameters() { | 982 static typesystem::PreParserFormalParameters EmptyFormalParameters() { |
975 return typesystem::PreParserFormalParameters(); | 983 return typesystem::PreParserFormalParameters(); |
976 } | 984 } |
| 985 static PreParserIdentifierList NullIdentifierList() { |
| 986 return PreParserIdentifierList(); |
| 987 } |
| 988 static PreParserIdentifierList EmptyIdentifierList() { |
| 989 return PreParserIdentifierList(); |
| 990 } |
977 | 991 |
978 // Odd-ball literal creators. | 992 // Odd-ball literal creators. |
979 static PreParserExpression GetLiteralTheHole(int position, | 993 static PreParserExpression GetLiteralTheHole(int position, |
980 PreParserFactory* factory) { | 994 PreParserFactory* factory) { |
981 return PreParserExpression::Default(); | 995 return PreParserExpression::Default(); |
982 } | 996 } |
983 | 997 |
984 // Producing data during the recursive descent. | 998 // Producing data during the recursive descent. |
985 PreParserIdentifier GetSymbol(Scanner* scanner); | 999 PreParserIdentifier GetSymbol(Scanner* scanner); |
986 PreParserIdentifier GetNumberAsSymbol(Scanner* scanner); | 1000 PreParserIdentifier GetNumberAsSymbol(Scanner* scanner); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 const PreParserFormalParameters& parameters, FunctionKind kind, | 1402 const PreParserFormalParameters& parameters, FunctionKind kind, |
1389 FunctionLiteral::FunctionType function_type, bool* ok) { | 1403 FunctionLiteral::FunctionType function_type, bool* ok) { |
1390 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1404 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
1391 kind, function_type, ok); | 1405 kind, function_type, ok); |
1392 } | 1406 } |
1393 | 1407 |
1394 } // namespace internal | 1408 } // namespace internal |
1395 } // namespace v8 | 1409 } // namespace v8 |
1396 | 1410 |
1397 #endif // V8_PARSING_PREPARSER_H | 1411 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |