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

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

Issue 2258123002: [parser] Refactor parser and preparser traits (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@nickie-2264483003-ord-traits
Patch Set: Created 4 years, 4 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/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 23 matching lines...) Expand all
34 #define DUMMY ) // to make indentation work 34 #define DUMMY ) // to make indentation work
35 #undef DUMMY 35 #undef DUMMY
36 36
37 // Used in functions where the return type is not ExpressionT. 37 // Used in functions where the return type is not ExpressionT.
38 #define CHECK_OK_CUSTOM(x) ok); \ 38 #define CHECK_OK_CUSTOM(x) ok); \
39 if (!*ok) return this->x(); \ 39 if (!*ok) return this->x(); \
40 ((void)0 40 ((void)0
41 #define DUMMY ) // to make indentation work 41 #define DUMMY ) // to make indentation work
42 #undef DUMMY 42 #undef DUMMY
43 43
44 void PreParserTraits::ReportMessageAt(Scanner::Location location, 44 void PreParserTraits::ReportMessageAt(Scanner::Location source_location,
45 MessageTemplate::Template message, 45 MessageTemplate::Template message,
46 const char* arg, 46 const char* arg,
47 ParseErrorType error_type) { 47 ParseErrorType error_type) {
48 pre_parser_->log_->LogMessage(location.beg_pos, location.end_pos, message, 48 pre_parser_->log_->LogMessage(source_location.beg_pos,
49 arg, error_type); 49 source_location.end_pos, message, arg,
50 error_type);
50 } 51 }
51 52
52 void PreParserTraits::ReportMessageAt(Scanner::Location location, 53 void PreParserTraits::ReportMessageAt(Scanner::Location source_location,
53 MessageTemplate::Template message, 54 MessageTemplate::Template message,
54 const AstRawString* arg, 55 const AstRawString* arg,
55 ParseErrorType error_type) { 56 ParseErrorType error_type) {
56 UNREACHABLE(); 57 UNREACHABLE();
57 } 58 }
58 59
59 60
60 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) { 61 PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) const {
61 switch (scanner->current_token()) { 62 switch (scanner->current_token()) {
62 case Token::ENUM: 63 case Token::ENUM:
63 return PreParserIdentifier::Enum(); 64 return PreParserIdentifier::Enum();
64 case Token::AWAIT: 65 case Token::AWAIT:
65 return PreParserIdentifier::Await(); 66 return PreParserIdentifier::Await();
66 case Token::FUTURE_STRICT_RESERVED_WORD: 67 case Token::FUTURE_STRICT_RESERVED_WORD:
67 return PreParserIdentifier::FutureStrictReserved(); 68 return PreParserIdentifier::FutureStrictReserved();
68 case Token::LET: 69 case Token::LET:
69 return PreParserIdentifier::Let(); 70 return PreParserIdentifier::Let();
70 case Token::STATIC: 71 case Token::STATIC:
(...skipping 12 matching lines...) Expand all
83 if (scanner->LiteralMatches("prototype", 9)) 84 if (scanner->LiteralMatches("prototype", 9))
84 return PreParserIdentifier::Prototype(); 85 return PreParserIdentifier::Prototype();
85 if (scanner->LiteralMatches("constructor", 11)) 86 if (scanner->LiteralMatches("constructor", 11))
86 return PreParserIdentifier::Constructor(); 87 return PreParserIdentifier::Constructor();
87 return PreParserIdentifier::Default(); 88 return PreParserIdentifier::Default();
88 } 89 }
89 } 90 }
90 91
91 92
92 PreParserExpression PreParserTraits::ExpressionFromString( 93 PreParserExpression PreParserTraits::ExpressionFromString(
93 int pos, Scanner* scanner, PreParserFactory* factory) { 94 int pos, Scanner* scanner, PreParserFactory* factory) const {
94 if (scanner->UnescapedLiteralMatches("use strict", 10)) { 95 if (scanner->UnescapedLiteralMatches("use strict", 10)) {
95 return PreParserExpression::UseStrictStringLiteral(); 96 return PreParserExpression::UseStrictStringLiteral();
96 } 97 }
97 return PreParserExpression::StringLiteral(); 98 return PreParserExpression::StringLiteral();
98 } 99 }
99 100
100 101
101 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { 102 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) {
102 return pre_parser_->ParseV8Intrinsic(ok); 103 return pre_parser_->ParseV8Intrinsic(ok);
103 } 104 }
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 1303
1303 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); 1304 body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
1304 } 1305 }
1305 1306
1306 #undef CHECK_OK 1307 #undef CHECK_OK
1307 #undef CHECK_OK_CUSTOM 1308 #undef CHECK_OK_CUSTOM
1308 1309
1309 1310
1310 } // namespace internal 1311 } // namespace internal
1311 } // namespace v8 1312 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698