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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 typedef PreParserExpression Expression; | 832 typedef PreParserExpression Expression; |
833 typedef PreParserStatement Statement; | 833 typedef PreParserStatement Statement; |
834 | 834 |
835 enum PreParseResult { | 835 enum PreParseResult { |
836 kPreParseStackOverflow, | 836 kPreParseStackOverflow, |
837 kPreParseAbort, | 837 kPreParseAbort, |
838 kPreParseSuccess | 838 kPreParseSuccess |
839 }; | 839 }; |
840 | 840 |
841 PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory, | 841 PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory, |
| 842 PendingCompilationErrorHandler* pending_error_handler, |
842 uintptr_t stack_limit) | 843 uintptr_t stack_limit) |
843 : ParserBase<PreParser>(zone, scanner, stack_limit, nullptr, | 844 : ParserBase<PreParser>(zone, scanner, stack_limit, nullptr, |
844 ast_value_factory), | 845 ast_value_factory), |
845 use_counts_(nullptr), | 846 use_counts_(nullptr), |
846 track_unresolved_variables_(false) {} | 847 track_unresolved_variables_(false), |
| 848 pending_error_handler_(pending_error_handler) {} |
847 | 849 |
848 PreParserLogger* logger() { return &log_; } | 850 PreParserLogger* logger() { return &log_; } |
849 | 851 |
850 // Pre-parse the program from the character stream; returns true on | 852 // Pre-parse the program from the character stream; returns true on |
851 // success (even if parsing failed, the pre-parse data successfully | 853 // success (even if parsing failed, the pre-parse data successfully |
852 // captured the syntax error), and false if a stack-overflow happened | 854 // captured the syntax error), and false if a stack-overflow happened |
853 // during parsing. | 855 // during parsing. |
854 PreParseResult PreParseProgram(int* materialized_literals = 0, | 856 PreParseResult PreParseProgram(int* materialized_literals = 0, |
855 bool is_module = false) { | 857 bool is_module = false) { |
856 DCHECK_NULL(scope_state_); | 858 DCHECK_NULL(scope_state_); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 V8_INLINE PreParserExpression NewThrowTypeError( | 1269 V8_INLINE PreParserExpression NewThrowTypeError( |
1268 MessageTemplate::Template message, PreParserIdentifier arg, int pos) { | 1270 MessageTemplate::Template message, PreParserIdentifier arg, int pos) { |
1269 return PreParserExpression::Default(); | 1271 return PreParserExpression::Default(); |
1270 } | 1272 } |
1271 | 1273 |
1272 // Reporting errors. | 1274 // Reporting errors. |
1273 V8_INLINE void ReportMessageAt(Scanner::Location source_location, | 1275 V8_INLINE void ReportMessageAt(Scanner::Location source_location, |
1274 MessageTemplate::Template message, | 1276 MessageTemplate::Template message, |
1275 const char* arg = NULL, | 1277 const char* arg = NULL, |
1276 ParseErrorType error_type = kSyntaxError) { | 1278 ParseErrorType error_type = kSyntaxError) { |
1277 log_.LogMessage(source_location.beg_pos, source_location.end_pos, message, | 1279 pending_error_handler_->ReportMessageAt(source_location.beg_pos, |
1278 arg, error_type); | 1280 source_location.end_pos, message, |
| 1281 arg, error_type); |
1279 } | 1282 } |
1280 | 1283 |
1281 V8_INLINE void ReportMessageAt(Scanner::Location source_location, | 1284 V8_INLINE void ReportMessageAt(Scanner::Location source_location, |
1282 MessageTemplate::Template message, | 1285 MessageTemplate::Template message, |
1283 PreParserIdentifier arg, | 1286 PreParserIdentifier arg, |
1284 ParseErrorType error_type = kSyntaxError) { | 1287 ParseErrorType error_type = kSyntaxError) { |
1285 UNREACHABLE(); | 1288 UNREACHABLE(); |
1286 } | 1289 } |
1287 | 1290 |
1288 // "null" return type creators. | 1291 // "null" return type creators. |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 | 1505 |
1503 V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) { | 1506 V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) { |
1504 if (use_counts_ != nullptr) ++use_counts_[feature]; | 1507 if (use_counts_ != nullptr) ++use_counts_[feature]; |
1505 } | 1508 } |
1506 | 1509 |
1507 // Preparser's private field members. | 1510 // Preparser's private field members. |
1508 | 1511 |
1509 int* use_counts_; | 1512 int* use_counts_; |
1510 bool track_unresolved_variables_; | 1513 bool track_unresolved_variables_; |
1511 PreParserLogger log_; | 1514 PreParserLogger log_; |
| 1515 PendingCompilationErrorHandler* pending_error_handler_; |
1512 }; | 1516 }; |
1513 | 1517 |
1514 PreParserExpression PreParser::SpreadCall(PreParserExpression function, | 1518 PreParserExpression PreParser::SpreadCall(PreParserExpression function, |
1515 PreParserExpressionList args, | 1519 PreParserExpressionList args, |
1516 int pos) { | 1520 int pos) { |
1517 return factory()->NewCall(function, args, pos); | 1521 return factory()->NewCall(function, args, pos); |
1518 } | 1522 } |
1519 | 1523 |
1520 PreParserExpression PreParser::SpreadCallNew(PreParserExpression function, | 1524 PreParserExpression PreParser::SpreadCallNew(PreParserExpression function, |
1521 PreParserExpressionList args, | 1525 PreParserExpressionList args, |
(...skipping 29 matching lines...) Expand all Loading... |
1551 function_state_->NextMaterializedLiteralIndex(); | 1555 function_state_->NextMaterializedLiteralIndex(); |
1552 function_state_->NextMaterializedLiteralIndex(); | 1556 function_state_->NextMaterializedLiteralIndex(); |
1553 } | 1557 } |
1554 return EmptyExpression(); | 1558 return EmptyExpression(); |
1555 } | 1559 } |
1556 | 1560 |
1557 } // namespace internal | 1561 } // namespace internal |
1558 } // namespace v8 | 1562 } // namespace v8 |
1559 | 1563 |
1560 #endif // V8_PARSING_PREPARSER_H | 1564 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |