Commit 0362016f authored by hjk's avatar hjk Committed by hjk
Browse files

preprocessor: inline state setup



Change-Id: Icc3ee542c8e8f95dfd48604144e3f4ab638fdcd4
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent ef09a67c
......@@ -624,28 +624,6 @@ void Preprocessor::setKeepComments(bool keepComments)
m_keepComments = keepComments;
}
Preprocessor::State Preprocessor::createStateFromSource(const QString &fileName,
const QByteArray &source,
QByteArray *result,
bool noLines,
bool markGeneratedTokens,
bool inCondition) const
{
State state;
state.m_currentFileName = fileName;
state.m_source = source;
state.m_lexer = new Lexer(source.constBegin(), source.constEnd());
state.m_lexer->setScanKeywords(false);
state.m_lexer->setScanAngleStringLiteralTokens(false);
if (m_keepComments)
state.m_lexer->setScanCommentTokens(true);
state.m_result = result;
state.m_noLines = noLines;
state.m_markGeneratedTokens = markGeneratedTokens;
state.m_inCondition = inCondition;
return state;
}
void Preprocessor::genLine(unsigned lineno, const QByteArray &fileName) const
{
startNewOutputLine();
......@@ -927,7 +905,19 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
return;
const State savedState = m_state;
m_state = createStateFromSource(fileName, source, result, noLines, markGeneratedTokens, inCondition);
m_state = State();
m_state.m_currentFileName = fileName;
m_state.m_source = source;
m_state.m_lexer = new Lexer(source.constBegin(), source.constEnd());
m_state.m_lexer->setScanKeywords(false);
m_state.m_lexer->setScanAngleStringLiteralTokens(false);
if (m_keepComments)
m_state.m_lexer->setScanCommentTokens(true);
m_state.m_result = result;
m_state.m_noLines = noLines;
m_state.m_markGeneratedTokens = markGeneratedTokens;
m_state.m_inCondition = inCondition;
const QString previousFileName = m_env->currentFile;
m_env->currentFile = fileName;
......
......@@ -149,8 +149,6 @@ private:
static bool isQtReservedWord(const ByteArrayRef &name);
State createStateFromSource(const QString &fileName, const QByteArray &source, QByteArray *result, bool noLines, bool markGeneratedTokens, bool inCondition) const;
inline bool atStartOfOutputLine() const
{ return (m_state.m_result && !m_state.m_result->isEmpty()) ? m_state.m_result->end()[-1] == '\n' : true; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment