Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: src/parsing/preparser.h

Issue 1913203002: Widen --harmony-for-in flag to throw errors in PreParser (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 typedef PreParserStatement Statement; 956 typedef PreParserStatement Statement;
957 957
958 enum PreParseResult { 958 enum PreParseResult {
959 kPreParseStackOverflow, 959 kPreParseStackOverflow,
960 kPreParseSuccess 960 kPreParseSuccess
961 }; 961 };
962 962
963 PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory, 963 PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory,
964 ParserRecorder* log, uintptr_t stack_limit) 964 ParserRecorder* log, uintptr_t stack_limit)
965 : ParserBase<PreParserTraits>(zone, scanner, stack_limit, NULL, 965 : ParserBase<PreParserTraits>(zone, scanner, stack_limit, NULL,
966 ast_value_factory, log, this) {} 966 ast_value_factory, log, this),
967 use_counts_(nullptr) {}
967 968
968 // Pre-parse the program from the character stream; returns true on 969 // Pre-parse the program from the character stream; returns true on
969 // success (even if parsing failed, the pre-parse data successfully 970 // success (even if parsing failed, the pre-parse data successfully
970 // captured the syntax error), and false if a stack-overflow happened 971 // captured the syntax error), and false if a stack-overflow happened
971 // during parsing. 972 // during parsing.
972 PreParseResult PreParseProgram(int* materialized_literals = 0, 973 PreParseResult PreParseProgram(int* materialized_literals = 0,
973 bool is_module = false) { 974 bool is_module = false) {
974 Scope* scope = NewScope(scope_, is_module ? MODULE_SCOPE : SCRIPT_SCOPE); 975 Scope* scope = NewScope(scope_, is_module ? MODULE_SCOPE : SCRIPT_SCOPE);
975 PreParserFactory factory(NULL); 976 PreParserFactory factory(NULL);
976 FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction, 977 FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction,
(...skipping 17 matching lines...) Expand all
994 // Parses a single function literal, from the opening parentheses before 995 // Parses a single function literal, from the opening parentheses before
995 // parameters to the closing brace after the body. 996 // parameters to the closing brace after the body.
996 // Returns a FunctionEntry describing the body of the function in enough 997 // Returns a FunctionEntry describing the body of the function in enough
997 // detail that it can be lazily compiled. 998 // detail that it can be lazily compiled.
998 // The scanner is expected to have matched the "function" or "function*" 999 // The scanner is expected to have matched the "function" or "function*"
999 // keyword and parameters, and have consumed the initial '{'. 1000 // keyword and parameters, and have consumed the initial '{'.
1000 // At return, unless an error occurred, the scanner is positioned before the 1001 // At return, unless an error occurred, the scanner is positioned before the
1001 // the final '}'. 1002 // the final '}'.
1002 PreParseResult PreParseLazyFunction( 1003 PreParseResult PreParseLazyFunction(
1003 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, 1004 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters,
1004 ParserRecorder* log, Scanner::BookmarkScope* bookmark = nullptr); 1005 ParserRecorder* log, Scanner::BookmarkScope* bookmark, int* use_counts);
1005 1006
1006 private: 1007 private:
1007 friend class PreParserTraits; 1008 friend class PreParserTraits;
1008 1009
1009 static const int kLazyParseTrialLimit = 200; 1010 static const int kLazyParseTrialLimit = 200;
1010 1011
1011 // These types form an algebra over syntactic categories that is just 1012 // These types form an algebra over syntactic categories that is just
1012 // rich enough to let us recognize and propagate the constructs that 1013 // rich enough to let us recognize and propagate the constructs that
1013 // are either being counted in the preparser data, or is important 1014 // are either being counted in the preparser data, or is important
1014 // to throw the correct syntax error exceptions. 1015 // to throw the correct syntax error exceptions.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 FunctionNameValidity function_name_validity, FunctionKind kind, 1068 FunctionNameValidity function_name_validity, FunctionKind kind,
1068 int function_token_pos, FunctionLiteral::FunctionType function_type, 1069 int function_token_pos, FunctionLiteral::FunctionType function_type,
1069 LanguageMode language_mode, bool* ok); 1070 LanguageMode language_mode, bool* ok);
1070 void ParseLazyFunctionLiteralBody(bool* ok, 1071 void ParseLazyFunctionLiteralBody(bool* ok,
1071 Scanner::BookmarkScope* bookmark = nullptr); 1072 Scanner::BookmarkScope* bookmark = nullptr);
1072 1073
1073 PreParserExpression ParseClassLiteral(PreParserIdentifier name, 1074 PreParserExpression ParseClassLiteral(PreParserIdentifier name,
1074 Scanner::Location class_name_location, 1075 Scanner::Location class_name_location,
1075 bool name_is_strict_reserved, int pos, 1076 bool name_is_strict_reserved, int pos,
1076 bool* ok); 1077 bool* ok);
1078
1079 int* use_counts_;
1077 }; 1080 };
1078 1081
1079 1082
1080 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { 1083 void PreParserTraits::MaterializeTemplateCallsiteLiterals() {
1081 pre_parser_->function_state_->NextMaterializedLiteralIndex(); 1084 pre_parser_->function_state_->NextMaterializedLiteralIndex();
1082 pre_parser_->function_state_->NextMaterializedLiteralIndex(); 1085 pre_parser_->function_state_->NextMaterializedLiteralIndex();
1083 } 1086 }
1084 1087
1085 1088
1086 void PreParserTraits::MaterializeUnspreadArgumentsLiterals(int count) { 1089 void PreParserTraits::MaterializeUnspreadArgumentsLiterals(int count) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 const PreParserFormalParameters& parameters, FunctionKind kind, 1172 const PreParserFormalParameters& parameters, FunctionKind kind,
1170 FunctionLiteral::FunctionType function_type, bool* ok) { 1173 FunctionLiteral::FunctionType function_type, bool* ok) {
1171 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, 1174 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters,
1172 kind, function_type, ok); 1175 kind, function_type, ok);
1173 } 1176 }
1174 1177
1175 } // namespace internal 1178 } // namespace internal
1176 } // namespace v8 1179 } // namespace v8
1177 1180
1178 #endif // V8_PARSING_PREPARSER_H 1181 #endif // V8_PARSING_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698