]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - parser/SourceCode.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / parser / SourceCode.h
index f221f9244c9824aebd027cc0af1dd0ee9106d7c6..f4a19029b5808d2bb0453b103e210ea140c99319 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -10,7 +10,7 @@
  * 2.  Redistributions in binary form must reproduce the above copyright
  *     notice, this list of conditions and the following disclaimer in the
  *     documentation and/or other materials provided with the distribution.
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
  *     its contributors may be used to endorse or promote products derived
  *     from this software without specific prior written permission.
  *
@@ -86,6 +86,8 @@ namespace JSC {
             return m_provider->getRange(m_startChar, m_endChar);
         }
         
+        CString toUTF8() const;
+        
         intptr_t providerID() const
         {
             if (!m_provider)
@@ -103,6 +105,9 @@ namespace JSC {
         
         SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn);
 
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+        SourceCode subArrowExpression(unsigned startArrowFunction, unsigned endArrowFunction, int firstLine, int startColumn);
+#endif
     private:
         RefPtr<SourceProvider> m_provider;
         int m_startChar;
@@ -115,6 +120,16 @@ namespace JSC {
     {
         return SourceCode(StringSourceProvider::create(source, url, startPosition), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
     }
+    
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+    inline SourceCode SourceCode::subArrowExpression(unsigned startArrowFunction, unsigned endArrowFunction, int firstLine, int startColumn)
+    {
+        ASSERT(provider()->source()[startArrowFunction] == '=' && provider()->source()[startArrowFunction + 1] == '>');
+
+        startColumn += 1; // Convert to base 1.
+        return SourceCode(provider(), startArrowFunction, endArrowFunction, firstLine, startColumn);
+    }
+#endif
 
     inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn)
     {