return m_provider->getRange(m_startChar, m_endChar);
}
+ intptr_t providerID() const
+ {
+ if (!m_provider)
+ return SourceProvider::nullID;
+ return m_provider->asID();
+ }
+
bool isNull() const { return !m_provider; }
SourceProvider* provider() const { return m_provider.get(); }
int firstLine() const { return m_firstLine; }
int startOffset() const { return m_startChar; }
int endOffset() const { return m_endChar; }
- const UChar* data() const { return m_provider->data() + m_startChar; }
int length() const { return m_endChar - m_startChar; }
+
+ SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine);
private:
RefPtr<SourceProvider> m_provider;
int m_firstLine;
};
- inline SourceCode makeSource(const UString& source, const UString& url = UString(), int firstLine = 1)
+ inline SourceCode makeSource(const UString& source, const UString& url = UString(), const TextPosition& startPosition = TextPosition::minimumPosition())
+ {
+ return SourceCode(UStringSourceProvider::create(source, url, startPosition), startPosition.m_line.oneBasedInt());
+ }
+
+ inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine)
{
- return SourceCode(UStringSourceProvider::create(source, url), firstLine);
+ ASSERT((*provider()->data())[openBrace] == '{');
+ ASSERT((*provider()->data())[closeBrace] == '}');
+ return SourceCode(provider(), openBrace, closeBrace + 1, firstLine);
}
} // namespace JSC