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

Side by Side Diff: src/scanner.cc

Issue 1472323002: [es6] Correct parsing of regular expression literal flags. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix oversight in interpreter Created 5 years 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/scanner.h ('k') | test/cctest/interpreter/test-bytecode-generator.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 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 // Features shared by parsing and pre-parsing scanners. 5 // Features shared by parsing and pre-parsing scanners.
6 6
7 #include "src/scanner.h" 7 #include "src/scanner.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 } 1386 }
1387 } 1387 }
1388 Advance(); // consume '/' 1388 Advance(); // consume '/'
1389 1389
1390 literal.Complete(); 1390 literal.Complete();
1391 1391
1392 return true; 1392 return true;
1393 } 1393 }
1394 1394
1395 1395
1396 bool Scanner::ScanRegExpFlags() { 1396 Maybe<RegExp::Flags> Scanner::ScanRegExpFlags() {
1397 // Scan regular expression flags. 1397 // Scan regular expression flags.
1398 LiteralScope literal(this); 1398 LiteralScope literal(this);
1399 int flags = 0;
1399 while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) { 1400 while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) {
1400 if (c0_ != '\\') { 1401 RegExp::Flags flag = RegExp::kNone;
1401 AddLiteralCharAdvance(); 1402 switch (c0_) {
1402 } else { 1403 case 'g':
1403 return false; 1404 flag = RegExp::kGlobal;
1405 break;
1406 case 'i':
1407 flag = RegExp::kIgnoreCase;
1408 break;
1409 case 'm':
1410 flag = RegExp::kMultiline;
1411 break;
1412 case 'u':
1413 if (!FLAG_harmony_unicode_regexps) return Nothing<RegExp::Flags>();
1414 flag = RegExp::kUnicode;
1415 break;
1416 case 'y':
1417 if (!FLAG_harmony_regexps) return Nothing<RegExp::Flags>();
1418 flag = RegExp::kSticky;
1419 break;
1420 default:
1421 return Nothing<RegExp::Flags>();
1404 } 1422 }
1423 if (flags & flag) return Nothing<RegExp::Flags>();
1424 AddLiteralCharAdvance();
1425 flags |= flag;
1405 } 1426 }
1406 literal.Complete(); 1427 literal.Complete();
1407 1428
1408 next_.location.end_pos = source_pos(); 1429 next_.location.end_pos = source_pos();
1409 return true; 1430 return Just(RegExp::Flags(flags));
1410 } 1431 }
1411 1432
1412 1433
1413 const AstRawString* Scanner::CurrentSymbol(AstValueFactory* ast_value_factory) { 1434 const AstRawString* Scanner::CurrentSymbol(AstValueFactory* ast_value_factory) {
1414 if (is_literal_one_byte()) { 1435 if (is_literal_one_byte()) {
1415 return ast_value_factory->GetOneByteString(literal_one_byte_string()); 1436 return ast_value_factory->GetOneByteString(literal_one_byte_string());
1416 } 1437 }
1417 return ast_value_factory->GetTwoByteString(literal_two_byte_string()); 1438 return ast_value_factory->GetTwoByteString(literal_two_byte_string());
1418 } 1439 }
1419 1440
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); 1664 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u));
1644 } 1665 }
1645 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); 1666 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f));
1646 1667
1647 backing_store_.AddBlock(bytes); 1668 backing_store_.AddBlock(bytes);
1648 return backing_store_.EndSequence().start(); 1669 return backing_store_.EndSequence().start();
1649 } 1670 }
1650 1671
1651 } // namespace internal 1672 } // namespace internal
1652 } // namespace v8 1673 } // namespace v8
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698