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/parsing/parser-base.h" | 9 #include "src/parsing/parser-base.h" |
10 | 10 |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 } | 880 } |
881 | 881 |
882 // Parses a single function literal, from the opening parentheses before | 882 // Parses a single function literal, from the opening parentheses before |
883 // parameters to the closing brace after the body. | 883 // parameters to the closing brace after the body. |
884 // Returns a FunctionEntry describing the body of the function in enough | 884 // Returns a FunctionEntry describing the body of the function in enough |
885 // detail that it can be lazily compiled. | 885 // detail that it can be lazily compiled. |
886 // The scanner is expected to have matched the "function" or "function*" | 886 // The scanner is expected to have matched the "function" or "function*" |
887 // keyword and parameters, and have consumed the initial '{'. | 887 // keyword and parameters, and have consumed the initial '{'. |
888 // At return, unless an error occurred, the scanner is positioned before the | 888 // At return, unless an error occurred, the scanner is positioned before the |
889 // the final '}'. | 889 // the final '}'. |
890 PreParseResult PreParseFunction(DeclarationScope* function_scope, | 890 PreParseResult PreParseFunction(FunctionKind kind, |
| 891 DeclarationScope* function_scope, |
891 bool parsing_module, SingletonLogger* log, | 892 bool parsing_module, SingletonLogger* log, |
892 bool track_unresolved_variables, | 893 bool track_unresolved_variables, |
893 bool may_abort, int* use_counts); | 894 bool may_abort, int* use_counts); |
894 | 895 |
895 private: | 896 private: |
896 // These types form an algebra over syntactic categories that is just | 897 // These types form an algebra over syntactic categories that is just |
897 // rich enough to let us recognize and propagate the constructs that | 898 // rich enough to let us recognize and propagate the constructs that |
898 // are either being counted in the preparser data, or is important | 899 // are either being counted in the preparser data, or is important |
899 // to throw the correct syntax error exceptions. | 900 // to throw the correct syntax error exceptions. |
900 | 901 |
901 // All ParseXXX functions take as the last argument an *ok parameter | 902 // All ParseXXX functions take as the last argument an *ok parameter |
902 // which is set to false if parsing failed; it is unchanged otherwise. | 903 // which is set to false if parsing failed; it is unchanged otherwise. |
903 // By making the 'exception handling' explicit, we are forced to check | 904 // By making the 'exception handling' explicit, we are forced to check |
904 // for failure at the call sites. | 905 // for failure at the call sites. |
905 | 906 |
906 V8_INLINE PreParserStatementList ParseEagerFunctionBody( | 907 V8_INLINE PreParserStatementList ParseEagerFunctionBody( |
907 PreParserIdentifier function_name, int pos, | 908 PreParserIdentifier function_name, int pos, |
908 const PreParserFormalParameters& parameters, FunctionKind kind, | 909 const PreParserFormalParameters& parameters, FunctionKind kind, |
909 FunctionLiteral::FunctionType function_type, bool* ok); | 910 FunctionLiteral::FunctionType function_type, bool* ok); |
910 | 911 |
911 bool AllowsLazyParsingWithoutUnresolvedVariables() const { return false; } | 912 bool AllowsLazyParsingWithoutUnresolvedVariables() const { return false; } |
912 | 913 |
913 V8_INLINE LazyParsingResult SkipLazyFunctionBody( | 914 V8_INLINE LazyParsingResult SkipLazyFunction( |
| 915 FunctionKind kind, DeclarationScope* function_scope, int* num_parameters, |
| 916 int* function_length, bool* has_duplicate_parameters, |
914 int* materialized_literal_count, int* expected_property_count, | 917 int* materialized_literal_count, int* expected_property_count, |
915 bool track_unresolved_variables, bool may_abort, bool* ok) { | 918 bool is_inner_function, bool may_abort, bool* ok) { |
916 UNREACHABLE(); | 919 UNREACHABLE(); |
917 return kLazyParsingComplete; | 920 return kLazyParsingComplete; |
918 } | 921 } |
919 Expression ParseFunctionLiteral( | 922 Expression ParseFunctionLiteral( |
920 Identifier name, Scanner::Location function_name_location, | 923 Identifier name, Scanner::Location function_name_location, |
921 FunctionNameValidity function_name_validity, FunctionKind kind, | 924 FunctionNameValidity function_name_validity, FunctionKind kind, |
922 int function_token_pos, FunctionLiteral::FunctionType function_type, | 925 int function_token_pos, FunctionLiteral::FunctionType function_type, |
923 LanguageMode language_mode, bool* ok); | 926 LanguageMode language_mode, bool* ok); |
924 LazyParsingResult ParseStatementListAndLogFunction(bool may_abort, bool* ok); | 927 LazyParsingResult ParseStatementListAndLogFunction( |
| 928 int position_before_formals, PreParserFormalParameters* formals, |
| 929 bool has_duplicate_parameters, bool maybe_abort, bool* ok); |
925 | 930 |
926 struct TemplateLiteralState {}; | 931 struct TemplateLiteralState {}; |
927 | 932 |
928 V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos) { | 933 V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos) { |
929 return TemplateLiteralState(); | 934 return TemplateLiteralState(); |
930 } | 935 } |
931 V8_INLINE void AddTemplateExpression(TemplateLiteralState* state, | 936 V8_INLINE void AddTemplateExpression(TemplateLiteralState* state, |
932 PreParserExpression expression) {} | 937 PreParserExpression expression) {} |
933 V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool tail) {} | 938 V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool tail) {} |
934 V8_INLINE PreParserExpression CloseTemplateLiteral( | 939 V8_INLINE PreParserExpression CloseTemplateLiteral( |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 function_state_->NextMaterializedLiteralIndex(); | 1545 function_state_->NextMaterializedLiteralIndex(); |
1541 function_state_->NextMaterializedLiteralIndex(); | 1546 function_state_->NextMaterializedLiteralIndex(); |
1542 } | 1547 } |
1543 return EmptyExpression(); | 1548 return EmptyExpression(); |
1544 } | 1549 } |
1545 | 1550 |
1546 } // namespace internal | 1551 } // namespace internal |
1547 } // namespace v8 | 1552 } // namespace v8 |
1548 | 1553 |
1549 #endif // V8_PARSING_PREPARSER_H | 1554 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |