summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/parser/SourceCode.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/JavaScriptCore/parser/SourceCode.h
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/JavaScriptCore/parser/SourceCode.h')
-rw-r--r--Source/JavaScriptCore/parser/SourceCode.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/Source/JavaScriptCore/parser/SourceCode.h b/Source/JavaScriptCore/parser/SourceCode.h
index a094469a2..f221f9244 100644
--- a/Source/JavaScriptCore/parser/SourceCode.h
+++ b/Source/JavaScriptCore/parser/SourceCode.h
@@ -41,25 +41,44 @@ namespace JSC {
, m_startChar(0)
, m_endChar(0)
, m_firstLine(0)
+ , m_startColumn(0)
{
}
- SourceCode(PassRefPtr<SourceProvider> provider, int firstLine = 1)
+ SourceCode(WTF::HashTableDeletedValueType)
+ : m_provider(WTF::HashTableDeletedValue)
+ {
+ }
+
+ SourceCode(PassRefPtr<SourceProvider> provider)
+ : m_provider(provider)
+ , m_startChar(0)
+ , m_endChar(m_provider->source().length())
+ , m_firstLine(1)
+ , m_startColumn(1)
+ {
+ }
+
+ SourceCode(PassRefPtr<SourceProvider> provider, int firstLine, int startColumn)
: m_provider(provider)
, m_startChar(0)
, m_endChar(m_provider->source().length())
, m_firstLine(std::max(firstLine, 1))
+ , m_startColumn(std::max(startColumn, 1))
{
}
- SourceCode(PassRefPtr<SourceProvider> provider, int start, int end, int firstLine)
+ SourceCode(PassRefPtr<SourceProvider> provider, int start, int end, int firstLine, int startColumn)
: m_provider(provider)
, m_startChar(start)
, m_endChar(end)
, m_firstLine(std::max(firstLine, 1))
+ , m_startColumn(std::max(startColumn, 1))
{
}
+ bool isHashTableDeletedValue() const { return m_provider.isHashTableDeletedValue(); }
+
String toString() const
{
if (!m_provider)
@@ -77,29 +96,32 @@ namespace JSC {
bool isNull() const { return !m_provider; }
SourceProvider* provider() const { return m_provider.get(); }
int firstLine() const { return m_firstLine; }
+ int startColumn() const { return m_startColumn; }
int startOffset() const { return m_startChar; }
int endOffset() const { return m_endChar; }
int length() const { return m_endChar - m_startChar; }
- SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine);
+ SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn);
private:
RefPtr<SourceProvider> m_provider;
int m_startChar;
int m_endChar;
int m_firstLine;
+ int m_startColumn;
};
inline SourceCode makeSource(const String& source, const String& url = String(), const TextPosition& startPosition = TextPosition::minimumPosition())
{
- return SourceCode(StringSourceProvider::create(source, url, startPosition), startPosition.m_line.oneBasedInt());
+ return SourceCode(StringSourceProvider::create(source, url, startPosition), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
}
- inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine)
+ inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn)
{
ASSERT(provider()->source()[openBrace] == '{');
ASSERT(provider()->source()[closeBrace] == '}');
- return SourceCode(provider(), openBrace, closeBrace + 1, firstLine);
+ startColumn += 1; // Convert to base 1.
+ return SourceCode(provider(), openBrace, closeBrace + 1, firstLine, startColumn);
}
} // namespace JSC