Changeset 191145 in webkit for trunk/Source/JavaScriptCore/parser/Lexer.cpp
- Timestamp:
- Oct 15, 2015, 4:02:43 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/Lexer.cpp
r191135 r191145 26 26 #include "Lexer.h" 27 27 28 #include "JSFunctionInlines.h" 29 28 30 #include "BuiltinNames.h" 31 #include "JSGlobalObjectFunctions.h" 29 32 #include "Identifier.h" 33 #include "Nodes.h" 30 34 #include "JSCInlines.h" 31 #include "JSFunctionInlines.h" 32 #include "JSGlobalObjectFunctions.h" 33 #include "KeywordLookup.h" 34 #include "Lexer.lut.h" 35 #include "Nodes.h" 36 #include "Parser.h" 35 #include <wtf/dtoa.h> 37 36 #include <ctype.h> 38 37 #include <limits.h> 39 38 #include <string.h> 40 39 #include <wtf/Assertions.h> 41 #include <wtf/dtoa.h> 40 41 #include "KeywordLookup.h" 42 #include "Lexer.lut.h" 43 #include "Parser.h" 42 44 43 45 namespace JSC { … … 564 566 m_lineStart = m_code; 565 567 m_lexErrorMessage = String(); 566 m_sourceURL = String();567 m_sourceMappingURL = String();568 568 569 569 m_buffer8.reserveInitialCapacity(initialReadBufferCapacity); … … 687 687 { 688 688 return m_lastToken == CONTINUE || m_lastToken == BREAK || m_lastToken == RETURN || m_lastToken == THROW; 689 }690 691 template <typename T>692 ALWAYS_INLINE void Lexer<T>::skipWhitespace()693 {694 while (isWhiteSpace(m_current))695 shift();696 689 } 697 690 … … 1713 1706 1714 1707 template <typename T> 1715 ALWAYS_INLINE void Lexer<T>::parseCommentDirective()1716 {1717 // sourceURL and sourceMappingURL directives.1718 if (!consume("source"))1719 return;1720 1721 if (consume("URL=")) {1722 if (!m_sourceURL.isEmpty())1723 return;1724 m_sourceURL = parseCommentDirectiveValue();1725 return;1726 }1727 1728 if (consume("MappingURL=")) {1729 if (!m_sourceMappingURL.isEmpty())1730 return;1731 m_sourceMappingURL = parseCommentDirectiveValue();1732 return;1733 }1734 }1735 1736 template <typename T>1737 ALWAYS_INLINE String Lexer<T>::parseCommentDirectiveValue()1738 {1739 skipWhitespace();1740 const T* stringStart = currentSourcePtr();1741 while (!isWhiteSpace(m_current) && !isLineTerminator(m_current) && m_current != '"' && m_current != '\'' && !atEnd())1742 shift();1743 const T* stringEnd = currentSourcePtr();1744 skipWhitespace();1745 1746 if (!isLineTerminator(m_current) && !atEnd())1747 return String();1748 1749 append8(stringStart, stringEnd - stringStart);1750 return String(m_buffer8.data(), m_buffer8.size());1751 }1752 1753 template <typename T>1754 template <unsigned length>1755 ALWAYS_INLINE bool Lexer<T>::consume(const char (&input)[length])1756 {1757 unsigned lengthToCheck = length - 1; // Ignore the ending NUL byte in the string literal.1758 1759 unsigned i = 0;1760 for (; i < lengthToCheck && m_current == input[i]; i++)1761 shift();1762 1763 return i == lengthToCheck;1764 }1765 1766 template <typename T>1767 1708 bool Lexer<T>::nextTokenIsColon() 1768 1709 { … … 1799 1740 1800 1741 start: 1801 skipWhitespace(); 1742 while (isWhiteSpace(m_current)) 1743 shift(); 1802 1744 1803 1745 if (atEnd()) … … 1957 1899 if (m_current == '/') { 1958 1900 shift(); 1959 goto inSingleLineComment CheckForDirectives;1901 goto inSingleLineComment; 1960 1902 } 1961 1903 if (m_current == '*') { … … 2262 2204 goto returnToken; 2263 2205 2264 inSingleLineCommentCheckForDirectives:2265 // Script comment directives like "//# sourceURL=test.js".2266 if (UNLIKELY((m_current == '#' || m_current == '@') && isWhiteSpace(peek(1)))) {2267 shift();2268 shift();2269 parseCommentDirective();2270 }2271 // Fall through to complete single line comment parsing.2272 2273 2206 inSingleLineComment: 2274 2207 while (!isLineTerminator(m_current)) {
Note:
See TracChangeset
for help on using the changeset viewer.