Revision: 24880
Author:   [email protected]
Date:     Fri Oct 24 15:02:29 2014 UTC
Log:      Check string literals with escapes in PreParserTraits::GetSymbol()

LOG=Y
BUG=v8:3606
[email protected], [email protected]

Review URL: https://codereview.chromium.org/615813004

Patch from Caitlin Potter <[email protected]>.
https://code.google.com/p/v8/source/detail?r=24880

Modified:
 /branches/bleeding_edge/src/preparser.cc
 /branches/bleeding_edge/src/scanner.h
 /branches/bleeding_edge/test/cctest/test-parsing.cc

=======================================
--- /branches/bleeding_edge/src/preparser.cc    Thu Oct 23 12:30:20 2014 UTC
+++ /branches/bleeding_edge/src/preparser.cc    Fri Oct 24 15:02:29 2014 UTC
@@ -59,10 +59,10 @@
   if (scanner->UnescapedLiteralMatches("arguments", 9)) {
     return PreParserIdentifier::Arguments();
   }
-  if (scanner->UnescapedLiteralMatches("prototype", 9)) {
+  if (scanner->LiteralMatches("prototype", 9)) {
     return PreParserIdentifier::Prototype();
   }
-  if (scanner->UnescapedLiteralMatches("constructor", 11)) {
+  if (scanner->LiteralMatches("constructor", 11)) {
     return PreParserIdentifier::Constructor();
   }
   return PreParserIdentifier::Default();
=======================================
--- /branches/bleeding_edge/src/scanner.h       Tue Oct 14 13:25:19 2014 UTC
+++ /branches/bleeding_edge/src/scanner.h       Fri Oct 24 15:02:29 2014 UTC
@@ -394,16 +394,20 @@
   const AstRawString* NextSymbol(AstValueFactory* ast_value_factory);

   double DoubleValue();
-  bool UnescapedLiteralMatches(const char* data, int length) {
+ bool LiteralMatches(const char* data, int length, bool allow_escapes = true) {
     if (is_literal_one_byte() &&
         literal_length() == length &&
-        !literal_contains_escapes()) {
+        (allow_escapes || !literal_contains_escapes())) {
       const char* token =
           reinterpret_cast<const char*>(literal_one_byte_string().start());
       return !strncmp(token, data, length);
     }
     return false;
   }
+  inline bool UnescapedLiteralMatches(const char* data, int length) {
+    return LiteralMatches(data, length, false);
+  }
+
   void IsGetOrSet(bool* is_get, bool* is_set) {
     if (is_literal_one_byte() &&
         literal_length() == 3 &&
=======================================
--- /branches/bleeding_edge/test/cctest/test-parsing.cc Thu Oct 23 12:30:20 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-parsing.cc Fri Oct 24 15:02:29 2014 UTC
@@ -3973,6 +3973,13 @@
     "static get prototype() {}",
     "static set prototype(_) {}",
     "static *prototype() {}",
+    "static 'prototype'() {}",
+    "static *'prototype'() {}",
+    "static prot\\u006ftype() {}",
+    "static 'prot\\u006ftype'() {}",
+    "static get 'prot\\u006ftype'() {}",
+    "static set 'prot\\u006ftype'(_) {}",
+    "static *'prot\\u006ftype'() {}",
     NULL};

   static const ParserFlag always_flags[] = {
@@ -3993,6 +4000,13 @@
     "get constructor() {}",
     "get constructor(_) {}",
     "*constructor() {}",
+    "get 'constructor'() {}",
+    "*'constructor'() {}",
+    "get c\\u006fnstructor() {}",
+    "*c\\u006fnstructor() {}",
+    "get 'c\\u006fnstructor'() {}",
+    "get 'c\\u006fnstructor'(_) {}",
+    "*'c\\u006fnstructor'() {}",
     NULL};

   static const ParserFlag always_flags[] = {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to