void Lexer::setCode(const SourceCode& source, ParserArena& arena) { m_arena = &arena.identifierArena(); m_lineNumber = source.firstLine(); m_delimited = false; m_lastToken = -1; const UChar* data = source.provider()->data(); m_source = &source; m_codeStart = data; m_code = data + source.startOffset(); m_codeEnd = data + source.endOffset(); m_error = false; m_atLineStart = true; // ECMA-262 calls for stripping all Cf characters, but we only strip BOM characters. // See <https://bugs.webkit.org/show_bug.cgi?id=4931> for details. if (source.provider()->hasBOMs()) { for (const UChar* p = m_codeStart; p < m_codeEnd; ++p) { if (UNLIKELY(*p == byteOrderMark)) { copyCodeWithoutBOMs(); break; } } } // Read the first characters into the 4-character buffer. shift4(); ASSERT(currentOffset() == source.startOffset()); }
void Lexer<T>::setCode(const SourceCode& source, ParserArena* arena) { m_arena = &arena->identifierArena(); m_lineNumber = source.firstLine(); m_delimited = false; m_lastToken = -1; const StringImpl* sourceString = source.provider()->data(); if (sourceString) setCodeStart(sourceString); else m_codeStart = 0; m_source = &source; m_code = m_codeStart + source.startOffset(); m_codeEnd = m_codeStart + source.endOffset(); m_error = false; m_atLineStart = true; m_lexErrorMessage = UString(); m_buffer8.reserveInitialCapacity(initialReadBufferCapacity); m_buffer16.reserveInitialCapacity((m_codeEnd - m_code) / 2); if (LIKELY(m_code < m_codeEnd)) m_current = *m_code; else m_current = -1; ASSERT(currentOffset() == source.startOffset()); }
void Lexer::setCode(const SourceCode& source, ParserArena& arena) { m_arena = &arena.identifierArena(); m_lineNumber = source.firstLine(); m_delimited = false; m_lastToken = -1; const UChar* data = source.provider()->data(); m_source = &source; m_codeStart = data; m_code = data + source.startOffset(); m_codeEnd = data + source.endOffset(); m_error = false; m_atLineStart = true; m_buffer8.reserveInitialCapacity(initialReadBufferCapacity); m_buffer16.reserveInitialCapacity((m_codeEnd - m_code) / 2); if (LIKELY(m_code < m_codeEnd)) m_current = *m_code; else m_current = -1; ASSERT(currentOffset() == source.startOffset()); }