]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - parser/SourceCode.h
JavaScriptCore-1097.3.tar.gz
[apple/javascriptcore.git] / parser / SourceCode.h
index 9ba4da3d80678f48de6d1bfa269330fa448842ba..11a00337da853cb09bdd5d61e5ed2392345f448f 100644 (file)
@@ -67,13 +67,21 @@ namespace JSC {
             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;
@@ -82,9 +90,16 @@ namespace JSC {
         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