X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..1981f5dfe8d77d97469d20652f712a09400c48ed:/parser/SourceProvider.h diff --git a/parser/SourceProvider.h b/parser/SourceProvider.h index e9b6b56..946792b 100644 --- a/parser/SourceProvider.h +++ b/parser/SourceProvider.h @@ -40,12 +40,16 @@ namespace JSC { class SourceProvider : public RefCounted { public: - SourceProvider(const UString& url, SourceProviderCache* cache = 0) + static const intptr_t nullID = 1; + + SourceProvider(const UString& url, const TextPosition& startPosition, SourceProviderCache* cache = 0) : m_url(url) + , m_startPosition(startPosition) , m_validated(false) , m_cache(cache ? cache : new SourceProviderCache) , m_cacheOwned(!cache) { + turnOffVerifier(); } virtual ~SourceProvider() { @@ -54,12 +58,18 @@ namespace JSC { } virtual UString getRange(int start, int end) const = 0; - virtual const UChar* data() const = 0; + virtual const StringImpl* data() const = 0; virtual int length() const = 0; const UString& url() { return m_url; } - virtual TextPosition1 startPosition() const { return TextPosition1::minimumPosition(); } - intptr_t asID() { return reinterpret_cast(this); } + TextPosition startPosition() const { return m_startPosition; } + intptr_t asID() + { + ASSERT(this); + if (!this) // Be defensive in release mode. + return nullID; + return reinterpret_cast(this); + } bool isValid() const { return m_validated; } void setValid() { m_validated = true; } @@ -71,6 +81,7 @@ namespace JSC { virtual void cacheSizeChanged(int delta) { UNUSED_PARAM(delta); } UString m_url; + TextPosition m_startPosition; bool m_validated; SourceProviderCache* m_cache; bool m_cacheOwned; @@ -78,21 +89,21 @@ namespace JSC { class UStringSourceProvider : public SourceProvider { public: - static PassRefPtr create(const UString& source, const UString& url) + static PassRefPtr create(const UString& source, const UString& url, const TextPosition& startPosition = TextPosition::minimumPosition()) { - return adoptRef(new UStringSourceProvider(source, url)); + return adoptRef(new UStringSourceProvider(source, url, startPosition)); } - UString getRange(int start, int end) const + virtual UString getRange(int start, int end) const OVERRIDE { return m_source.substringSharingImpl(start, end - start); } - const UChar* data() const { return m_source.characters(); } + const StringImpl* data() const { return m_source.impl(); } int length() const { return m_source.length(); } private: - UStringSourceProvider(const UString& source, const UString& url) - : SourceProvider(url) + UStringSourceProvider(const UString& source, const UString& url, const TextPosition& startPosition) + : SourceProvider(url, startPosition) , m_source(source) { }