OLD | NEW |
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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 PreParser::Statement PreParser::ParseHoistableDeclaration( | 396 PreParser::Statement PreParser::ParseHoistableDeclaration( |
397 int pos, ParseFunctionFlags flags, bool* ok) { | 397 int pos, ParseFunctionFlags flags, bool* ok) { |
398 const bool is_generator = flags & ParseFunctionFlags::kIsGenerator; | 398 const bool is_generator = flags & ParseFunctionFlags::kIsGenerator; |
399 const bool is_async = flags & ParseFunctionFlags::kIsAsync; | 399 const bool is_async = flags & ParseFunctionFlags::kIsAsync; |
400 DCHECK(!is_generator || !is_async); | 400 DCHECK(!is_generator || !is_async); |
401 | 401 |
402 bool is_strict_reserved = false; | 402 bool is_strict_reserved = false; |
403 Identifier name = ParseIdentifierOrStrictReservedWord( | 403 Identifier name = ParseIdentifierOrStrictReservedWord( |
404 &is_strict_reserved, CHECK_OK); | 404 &is_strict_reserved, CHECK_OK); |
405 | 405 |
406 if (V8_UNLIKELY(is_async_function() && this->IsAwait(name))) { | |
407 ReportMessageAt(scanner()->location(), | |
408 MessageTemplate::kAwaitBindingIdentifier); | |
409 *ok = false; | |
410 return Statement::Default(); | |
411 } | |
412 | |
413 ParseFunctionLiteral(name, scanner()->location(), | 406 ParseFunctionLiteral(name, scanner()->location(), |
414 is_strict_reserved ? kFunctionNameIsStrictReserved | 407 is_strict_reserved ? kFunctionNameIsStrictReserved |
415 : kFunctionNameValidityUnknown, | 408 : kFunctionNameValidityUnknown, |
416 is_generator ? FunctionKind::kGeneratorFunction | 409 is_generator ? FunctionKind::kGeneratorFunction |
417 : is_async ? FunctionKind::kAsyncFunction | 410 : is_async ? FunctionKind::kAsyncFunction |
418 : FunctionKind::kNormalFunction, | 411 : FunctionKind::kNormalFunction, |
419 pos, FunctionLiteral::kDeclaration, language_mode(), | 412 pos, FunctionLiteral::kDeclaration, language_mode(), |
420 CHECK_OK); | 413 CHECK_OK); |
421 return Statement::FunctionDeclaration(); | 414 return Statement::FunctionDeclaration(); |
422 } | 415 } |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 // async [no LineTerminator here] function BindingIdentifier[Await] | 1148 // async [no LineTerminator here] function BindingIdentifier[Await] |
1156 // ( FormalParameters[Await] ) { AsyncFunctionBody } | 1149 // ( FormalParameters[Await] ) { AsyncFunctionBody } |
1157 int pos = position(); | 1150 int pos = position(); |
1158 Expect(Token::FUNCTION, CHECK_OK); | 1151 Expect(Token::FUNCTION, CHECK_OK); |
1159 bool is_strict_reserved = false; | 1152 bool is_strict_reserved = false; |
1160 Identifier name; | 1153 Identifier name; |
1161 FunctionLiteral::FunctionType type = FunctionLiteral::kAnonymousExpression; | 1154 FunctionLiteral::FunctionType type = FunctionLiteral::kAnonymousExpression; |
1162 | 1155 |
1163 if (peek_any_identifier()) { | 1156 if (peek_any_identifier()) { |
1164 type = FunctionLiteral::kNamedExpression; | 1157 type = FunctionLiteral::kNamedExpression; |
1165 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); | 1158 name = ParseIdentifierOrStrictReservedWord(FunctionKind::kAsyncFunction, |
1166 if (this->IsAwait(name)) { | 1159 &is_strict_reserved, CHECK_OK); |
1167 ReportMessageAt(scanner()->location(), | |
1168 MessageTemplate::kAwaitBindingIdentifier); | |
1169 *ok = false; | |
1170 return Expression::Default(); | |
1171 } | |
1172 } | 1160 } |
1173 | 1161 |
1174 ParseFunctionLiteral(name, scanner()->location(), | 1162 ParseFunctionLiteral(name, scanner()->location(), |
1175 is_strict_reserved ? kFunctionNameIsStrictReserved | 1163 is_strict_reserved ? kFunctionNameIsStrictReserved |
1176 : kFunctionNameValidityUnknown, | 1164 : kFunctionNameValidityUnknown, |
1177 FunctionKind::kAsyncFunction, pos, type, language_mode(), | 1165 FunctionKind::kAsyncFunction, pos, type, language_mode(), |
1178 CHECK_OK); | 1166 CHECK_OK); |
1179 return Expression::Default(); | 1167 return Expression::Default(); |
1180 } | 1168 } |
1181 | 1169 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 | 1290 |
1303 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); | 1291 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); |
1304 } | 1292 } |
1305 | 1293 |
1306 #undef CHECK_OK | 1294 #undef CHECK_OK |
1307 #undef CHECK_OK_CUSTOM | 1295 #undef CHECK_OK_CUSTOM |
1308 | 1296 |
1309 | 1297 |
1310 } // namespace internal | 1298 } // namespace internal |
1311 } // namespace v8 | 1299 } // namespace v8 |
OLD | NEW |