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

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

Issue 1723313002: [parser] Enforce module-specific identifier restriction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
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 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-rewriter.h" 9 #include "src/ast/ast-expression-rewriter.h"
10 #include "src/ast/ast-expression-visitor.h" 10 #include "src/ast/ast-expression-visitor.h"
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 // IdentifierName 1379 // IdentifierName
1380 // IdentifierName 'as' IdentifierName 1380 // IdentifierName 'as' IdentifierName
1381 1381
1382 Expect(Token::LBRACE, CHECK_OK); 1382 Expect(Token::LBRACE, CHECK_OK);
1383 1383
1384 Token::Value name_tok; 1384 Token::Value name_tok;
1385 while ((name_tok = peek()) != Token::RBRACE) { 1385 while ((name_tok = peek()) != Token::RBRACE) {
1386 // Keep track of the first reserved word encountered in case our 1386 // Keep track of the first reserved word encountered in case our
1387 // caller needs to report an error. 1387 // caller needs to report an error.
1388 if (!reserved_loc->IsValid() && 1388 if (!reserved_loc->IsValid() &&
1389 !Token::IsIdentifier(name_tok, STRICT, false)) { 1389 !Token::IsIdentifier(name_tok, STRICT, false, true)) {
1390 *reserved_loc = scanner()->location(); 1390 *reserved_loc = scanner()->location();
1391 } 1391 }
1392 const AstRawString* local_name = ParseIdentifierName(CHECK_OK); 1392 const AstRawString* local_name = ParseIdentifierName(CHECK_OK);
1393 const AstRawString* export_name = NULL; 1393 const AstRawString* export_name = NULL;
1394 if (CheckContextualKeyword(CStrVector("as"))) { 1394 if (CheckContextualKeyword(CStrVector("as"))) {
1395 export_name = ParseIdentifierName(CHECK_OK); 1395 export_name = ParseIdentifierName(CHECK_OK);
1396 } 1396 }
1397 if (export_name == NULL) { 1397 if (export_name == NULL) {
1398 export_name = local_name; 1398 export_name = local_name;
1399 } 1399 }
(...skipping 30 matching lines...) Expand all
1430 new (zone()) ZoneList<ImportDeclaration*>(1, zone()); 1430 new (zone()) ZoneList<ImportDeclaration*>(1, zone());
1431 while (peek() != Token::RBRACE) { 1431 while (peek() != Token::RBRACE) {
1432 const AstRawString* import_name = ParseIdentifierName(CHECK_OK); 1432 const AstRawString* import_name = ParseIdentifierName(CHECK_OK);
1433 const AstRawString* local_name = import_name; 1433 const AstRawString* local_name = import_name;
1434 // In the presence of 'as', the left-side of the 'as' can 1434 // In the presence of 'as', the left-side of the 'as' can
1435 // be any IdentifierName. But without 'as', it must be a valid 1435 // be any IdentifierName. But without 'as', it must be a valid
1436 // BindingIdentifier. 1436 // BindingIdentifier.
1437 if (CheckContextualKeyword(CStrVector("as"))) { 1437 if (CheckContextualKeyword(CStrVector("as"))) {
1438 local_name = ParseIdentifierName(CHECK_OK); 1438 local_name = ParseIdentifierName(CHECK_OK);
1439 } 1439 }
1440 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false)) { 1440 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false, true)) {
1441 *ok = false; 1441 *ok = false;
1442 ReportMessage(MessageTemplate::kUnexpectedReserved); 1442 ReportMessage(MessageTemplate::kUnexpectedReserved);
1443 return NULL; 1443 return NULL;
1444 } else if (IsEvalOrArguments(local_name)) { 1444 } else if (IsEvalOrArguments(local_name)) {
1445 *ok = false; 1445 *ok = false;
1446 ReportMessage(MessageTemplate::kStrictEvalArguments); 1446 ReportMessage(MessageTemplate::kStrictEvalArguments);
1447 return NULL; 1447 return NULL;
1448 } else if (is_strong(language_mode()) && IsUndefined(local_name)) { 1448 } else if (is_strong(language_mode()) && IsUndefined(local_name)) {
1449 *ok = false; 1449 *ok = false;
1450 ReportMessage(MessageTemplate::kStrongUndefined); 1450 ReportMessage(MessageTemplate::kStrongUndefined);
(...skipping 5449 matching lines...) Expand 10 before | Expand all | Expand 10 after
6900 new_body->statements()->Add(loop->body(), zone); 6900 new_body->statements()->Add(loop->body(), zone);
6901 new_body->statements()->Add(set_completion_normal, zone); 6901 new_body->statements()->Add(set_completion_normal, zone);
6902 6902
6903 loop->set_body(new_body); 6903 loop->set_body(new_body);
6904 return final_loop; 6904 return final_loop;
6905 } 6905 }
6906 6906
6907 6907
6908 } // namespace internal 6908 } // namespace internal
6909 } // namespace v8 6909 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698