Title: [114844] trunk/Source/_javascript_Core
Revision
114844
Author
da...@apple.com
Date
2012-04-21 12:46:02 -0700 (Sat, 21 Apr 2012)

Log Message

Change _javascript_ lexer to use 0 instead of -1 for sentinel, eliminating the need to put characters into ints
https://bugs.webkit.org/show_bug.cgi?id=84523

Reviewed by Oliver Hunt.

Separate preparation step of copyright dates, renaming, and other small tweaks.

* parser/Lexer.cpp:
(JSC::Lexer::invalidCharacterMessage): Removed "get" from name to match WebKit naming conventions.
(JSC::Lexer::peek): Removed meaningless comment.
(JSC::Lexer::parseFourDigitUnicodeHex): Renamed from getUnicodeCharacter to be more precise about
what this function does.
(JSC::Lexer::shiftLineTerminator): Renamed local variable that had a data-member-style name.
(JSC::Lexer::parseStringSlowCase): Updated for new name of parseFourDigitUnicodeHex.
(JSC::Lexer::lex): Updated for new name of invalidCharacterMessage.

* parser/Lexer.h: Removed an unneeded forward declaration of the RegExp class.
Renamed getInvalidCharMessage to invalidCharacterMessage and made it const. Renamed
getUnicodeCharacter to parseFourDigitUnicodeHex.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (114843 => 114844)


--- trunk/Source/_javascript_Core/ChangeLog	2012-04-21 16:43:25 UTC (rev 114843)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-04-21 19:46:02 UTC (rev 114844)
@@ -1,3 +1,25 @@
+2012-04-21  Darin Adler  <da...@apple.com>
+
+        Change _javascript_ lexer to use 0 instead of -1 for sentinel, eliminating the need to put characters into ints
+        https://bugs.webkit.org/show_bug.cgi?id=84523
+
+        Reviewed by Oliver Hunt.
+
+        Separate preparation step of copyright dates, renaming, and other small tweaks.
+
+        * parser/Lexer.cpp:
+        (JSC::Lexer::invalidCharacterMessage): Removed "get" from name to match WebKit naming conventions.
+        (JSC::Lexer::peek): Removed meaningless comment.
+        (JSC::Lexer::parseFourDigitUnicodeHex): Renamed from getUnicodeCharacter to be more precise about
+        what this function does.
+        (JSC::Lexer::shiftLineTerminator): Renamed local variable that had a data-member-style name.
+        (JSC::Lexer::parseStringSlowCase): Updated for new name of parseFourDigitUnicodeHex.
+        (JSC::Lexer::lex): Updated for new name of invalidCharacterMessage.
+
+        * parser/Lexer.h: Removed an unneeded forward declaration of the RegExp class.
+        Renamed getInvalidCharMessage to invalidCharacterMessage and made it const. Renamed
+        getUnicodeCharacter to parseFourDigitUnicodeHex.
+
 2012-04-20  Filip Pizlo  <fpi...@apple.com>
 
         DFG should optimize int8 and int16 arrays on ARMv7

Modified: trunk/Source/_javascript_Core/parser/Lexer.cpp (114843 => 114844)


--- trunk/Source/_javascript_Core/parser/Lexer.cpp	2012-04-21 16:43:25 UTC (rev 114843)
+++ trunk/Source/_javascript_Core/parser/Lexer.cpp	2012-04-21 19:46:02 UTC (rev 114844)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2000 Harri Porten (por...@kde.org)
- *  Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All Rights Reserved.
+ *  Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All Rights Reserved.
  *  Copyright (C) 2007 Cameron Zwarich (cwzwar...@uwaterloo.ca)
  *  Copyright (C) 2010 Zoltan Herczeg (zherc...@inf.u-szeged.hu)
  *  Copyright (C) 2012 Mathias Bynens (math...@qiwi.be)
@@ -368,7 +368,7 @@
 }
 
 template <typename T>
-UString Lexer<T>::getInvalidCharMessage()
+UString Lexer<T>::invalidCharacterMessage() const
 {
     switch (m_current) {
     case 0:
@@ -450,14 +450,13 @@
 template <typename T>
 ALWAYS_INLINE int Lexer<T>::peek(int offset)
 {
-    // Only use if necessary
     ASSERT(offset > 0 && offset < 5);
     const T* code = m_code + offset;
     return (code < m_codeEnd) ? *code : -1;
 }
 
 template <typename T>
-int Lexer<T>::getUnicodeCharacter()
+int Lexer<T>::parseFourDigitUnicodeHex()
 {
     int char1 = peek(1);
     int char2 = peek(2);
@@ -479,11 +478,11 @@
 {
     ASSERT(isLineTerminator(static_cast<T>(m_current)));
 
-    int m_prev = m_current;
+    int prev = m_current;
     shift();
 
     // Allow both CRLF and LFCR.
-    if (m_prev + m_current == '\n' + '\r')
+    if (prev + m_current == '\n' + '\r')
         shift();
 
     ++m_lineNumber;
@@ -633,7 +632,7 @@
 }
 
 template <>
-    template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<LChar>::parseIdentifier(JSTokenData* tokenData, unsigned lexerFlags, bool strictMode)
+template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<LChar>::parseIdentifier(JSTokenData* tokenData, unsigned lexerFlags, bool strictMode)
 {
     const ptrdiff_t remaining = m_codeEnd - m_code;
     if ((remaining >= maxTokenLength) && !(lexerFlags & LexerFlagsIgnoreReservedWords)) {
@@ -691,6 +690,7 @@
             return keyword == RESERVED_IF_STRICT && !strictMode ? IDENT : keyword;
         }
     }
+
     const UChar* identifierStart = currentCharacter();
 
     UChar orAllChars = 0;
@@ -762,7 +762,7 @@
         if (UNLIKELY(m_current != 'u'))
             return ERRORTOK;
         shift();
-        int character = getUnicodeCharacter();
+        int character = parseFourDigitUnicodeHex();
         if (UNLIKELY(character == -1))
             return ERRORTOK;
         UChar ucharacter = static_cast<UChar>(character);
@@ -910,7 +910,7 @@
                 shift();
             } else if (m_current == 'u') {
                 shift();
-                int character = getUnicodeCharacter();
+                int character = parseFourDigitUnicodeHex();
                 if (character != -1) {
                     if (shouldBuildStrings)
                         record16(character);
@@ -1508,7 +1508,7 @@
         m_terminator = true;
         goto start;
     case CharacterInvalid:
-        m_lexErrorMessage = getInvalidCharMessage();
+        m_lexErrorMessage = invalidCharacterMessage();
         goto returnError;
     default:
         ASSERT_NOT_REACHED();

Modified: trunk/Source/_javascript_Core/parser/Lexer.h (114843 => 114844)


--- trunk/Source/_javascript_Core/parser/Lexer.h	2012-04-21 16:43:25 UTC (rev 114843)
+++ trunk/Source/_javascript_Core/parser/Lexer.h	2012-04-21 19:46:02 UTC (rev 114844)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2000 Harri Porten (por...@kde.org)
- *  Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *  Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All rights reserved.
  *  Copyright (C) 2010 Zoltan Herczeg (zherc...@inf.u-szeged.hu)
  *
  *  This library is free software; you can redistribute it and/or
@@ -67,8 +67,6 @@
     LexexFlagsDontBuildKeywords = 4
 };
 
-class RegExp;
-
 template <typename T>
 class Lexer {
     WTF_MAKE_NONCOPYABLE(Lexer);
@@ -134,10 +132,10 @@
 
     ALWAYS_INLINE void shift();
     ALWAYS_INLINE int peek(int offset);
-    int getUnicodeCharacter();
+    int parseFourDigitUnicodeHex();
     void shiftLineTerminator();
 
-    UString getInvalidCharMessage();
+    UString invalidCharacterMessage() const;
     ALWAYS_INLINE const T* currentCharacter() const;
     ALWAYS_INLINE int currentOffset() const { return m_code - m_codeStart; }
     ALWAYS_INLINE void setOffsetFromCharOffset(const T* charOffset) { setOffset(charOffset - m_codeStart); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to