Title: [193460] branches/safari-601.1.46-branch

Diff

Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (193459 => 193460)


--- branches/safari-601.1.46-branch/LayoutTests/ChangeLog	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/LayoutTests/ChangeLog	2015-12-04 20:54:33 UTC (rev 193460)
@@ -1,5 +1,20 @@
 2015-12-04  Timothy Hatcher  <timo...@apple.com>
 
+        Merge r191355. rdar://problem/23581597
+
+    2015-10-20  Joseph Pecoraro  <pecor...@apple.com>
+
+            Web Inspector: _javascript_Core should parse sourceURL and sourceMappingURL directives
+            https://bugs.webkit.org/show_bug.cgi?id=150096
+
+            Reviewed by Geoffrey Garen.
+
+            * inspector/debugger/sourceURLs-expected.txt: Added.
+            * inspector/debugger/sourceURLs.html: Added.
+            sourceURL and sourceMappingURL detection.
+
+2015-12-04  Timothy Hatcher  <timo...@apple.com>
+
         Merge r188403. rdar://problem/23581597
 
     2015-08-13  Joseph Pecoraro  <pecor...@apple.com>

Added: branches/safari-601.1.46-branch/LayoutTests/inspector/debugger/sourceURLs-expected.txt (0 => 193460)


--- branches/safari-601.1.46-branch/LayoutTests/inspector/debugger/sourceURLs-expected.txt	                        (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/inspector/debugger/sourceURLs-expected.txt	2015-12-04 20:54:33 UTC (rev 193460)
@@ -0,0 +1,26 @@
+Tests for the Debugger.scriptParsed sourceURL and sourceMappingURL comment directive parsing.
+
+
+== Running test suite: Debugger.scriptParsed.sourceURL-directives
+-- Running test case: TestExpressionsForSourceURL
+Found Script with sourceURL 'test1.js'
+Found Script with sourceURL 'test2.js'
+Found Script with sourceURL 'test3.js'
+Found Script with sourceURL 'test4.js'
+Found Script with sourceURL 'test5.js'
+Found Script with sourceURL 'test6.js'
+Found Script with sourceURL 'test7.js'
+Found Script with sourceURL 'test8.js'
+Found Script with sourceURL 'test9.js'
+
+-- Running test case: TestExpressionsForSourceMappingURL
+Found Script with sourceMappingURL 'test1.js'
+Found Script with sourceMappingURL 'test2.js'
+Found Script with sourceMappingURL 'test3.js'
+Found Script with sourceMappingURL 'test4.js'
+Found Script with sourceMappingURL 'test5.js'
+Found Script with sourceMappingURL 'test6.js'
+Found Script with sourceMappingURL 'test7.js'
+Found Script with sourceMappingURL 'test8.js'
+Found Script with sourceMappingURL 'test9.js'
+

Added: branches/safari-601.1.46-branch/LayoutTests/inspector/debugger/sourceURLs.html (0 => 193460)


--- branches/safari-601.1.46-branch/LayoutTests/inspector/debugger/sourceURLs.html	                        (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/inspector/debugger/sourceURLs.html	2015-12-04 20:54:33 UTC (rev 193460)
@@ -0,0 +1,207 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    let suite = ProtocolTest.createAsyncSuite("Debugger.scriptParsed.sourceURL-directives");
+
+    // Because InspectorTest output causes scripts to be parsed
+    // we cannot check sourceURL per evaluation easily. Instead
+    // just run a bunch of tests for valid and invalid directives
+    // and check that the output only includes the valid results.
+
+    let expressions = [];
+    let sourceURLExpectations = [];
+    let sourceMappingURLExpectations = [];
+
+    function addInvalidTestCase(args) {
+        let {_expression_} = args;
+        expressions.push(_expression_);
+    }
+
+    function addValidTestCase(args) {
+        let {_expression_, expected} = args;
+        expressions.push(_expression_);
+        sourceURLExpectations.push(expected);
+        sourceMappingURLExpectations.push(expected);
+    }
+
+    suite.addTestCase({
+        name: "TestExpressionsForSourceURL",
+        test: (resolve, reject) => {
+            for (let _expression_ of expressions)
+                ProtocolTest.evaluateInPage(_expression_);
+
+            InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject) {
+                // Ignore named inspector internal scripts.
+                if (messageObject.params.url.startsWith("__WebInspector"))
+                    return;
+
+                // Has a sourceURL, must be one of the valid ones.
+                if (messageObject.params.hasSourceURL) {
+                    let sourceURL = messageObject.params.url;
+                    ProtocolTest.log(`Found Script with sourceURL '${sourceURL}'`);
+                    ProtocolTest.assert(sourceURLExpectations[0] === sourceURL, "Did not expect to see sourceURL: " + sourceURL);
+                    sourceURLExpectations.shift();
+                    if (!sourceURLExpectations.length)
+                        resolve();
+                }
+            }
+        }
+    });
+
+    suite.addTestCase({
+        name: "TestExpressionsForSourceMappingURL",
+        test: (resolve, reject) => {
+            // Rewrite the "sourceURL" to "sourceMappingURL" in the original expressions.
+            for (let _expression_ of expressions)
+                ProtocolTest.evaluateInPage(_expression_.replace(/sourceURL/g, "sourceMappingURL"));
+
+            InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject) {
+                // Has a sourceMapURL, must be one of the valid ones.
+                if (messageObject.params.sourceMapURL) {
+                    let sourceMappingURL = messageObject.params.sourceMapURL;
+                    ProtocolTest.log(`Found Script with sourceMappingURL '${sourceMappingURL}'`);
+                    ProtocolTest.assert(sourceMappingURLExpectations[0] === sourceMappingURL, "Did not expect to see sourceMappingURL: " + sourceMappingURL);
+                    sourceMappingURLExpectations.shift();
+                    if (!sourceMappingURLExpectations.length)
+                        resolve();
+                }
+            }
+        }
+    });
+
+    // ------
+
+    addInvalidTestCase({
+        description: "Evaluation without a SourceURL.",
+        _expression_: "eval('1')",
+    });
+
+    addInvalidTestCase({
+        description: "SourceURL missing '#'.",
+        _expression_: "eval('// sourceURL=invalid.js')",
+    });
+
+    addInvalidTestCase({
+        description: "SourceURL missing space after '#'.",
+        _expression_: "eval('//#sourceURL=invalid.js')",
+    });
+
+    addInvalidTestCase({
+        description: "SourceURL with space before '#'.",
+        _expression_: "eval('// #sourceURL=invalid.js')",
+    });
+
+    addInvalidTestCase({
+        description: "SourceURL with multiple spaces after '#'.",
+        _expression_: "eval('//#  sourceURL=invalid.js')",
+    });
+
+    addInvalidTestCase({
+        description: "SourceURL with space between name and '='.",
+        _expression_: "eval('//# sourceURL =invalid.js')",
+    });
+
+    addInvalidTestCase({
+        description: "SourceURL with quotes in value.",
+        _expression_: "eval('//# sourceURL=\\\'invalid.js\\\'')",
+    });
+
+    addInvalidTestCase({
+        description: "SourceURL value must be a single non-whitespace enclosed value.",
+        _expression_: "eval('//# sourceURL=invalid.js a')",
+    });
+
+    addInvalidTestCase({
+        description: "Unknown directive.",
+        _expression_: "eval('//# unknown=invalid.js')",
+    });
+
+    addInvalidTestCase({
+        description: "Missing parts.",
+        _expression_: "eval('//#')",
+    });
+
+    addInvalidTestCase({
+        description: "Missing parts.",
+        _expression_: "eval('//# ')",
+    });
+
+    addInvalidTestCase({
+        description: "Missing parts.",
+        _expression_: "eval('//# source')",
+    });
+
+    addInvalidTestCase({
+        description: "Missing parts.",
+        _expression_: "eval('//# sourceURL=')",
+    });
+
+    // ------
+
+    addValidTestCase({
+        description: "SourceURL basic form.",
+        _expression_: "eval('//# sourceURL=test1.js')",
+        expected: "test1.js",
+    });
+
+    addValidTestCase({
+        description: "SourceURL extra leading whitespace.",
+        _expression_: "eval('//# sourceURL=   test2.js')",
+        expected: "test2.js",
+    });
+
+    addValidTestCase({
+        description: "SourceURL extra trailing whitespace.",
+        _expression_: "eval('//# sourceURL=test3.js    ')",
+        expected: "test3.js",
+    });
+
+    addValidTestCase({
+        description: "SourceURL extra leading and trailing whitespace.",
+        _expression_: "eval('//# sourceURL=   test4.js   ')",
+        expected: "test4.js",
+    });
+
+    addValidTestCase({
+        description: "SourceURL with tabs.",
+        _expression_: "eval('//#\\tsourceURL=test5.js')",
+        expected: "test5.js",
+    });
+
+    addValidTestCase({
+        description: "SourceURLs not at the start of a line.",
+        _expression_: "eval('1 //# sourceURL=test6.js')",
+        expected: "test6.js",
+    });
+
+    addValidTestCase({
+        description: "SourceURL with deprecated '@' instead of '#'.",
+        _expression_: "eval('//@ sourceURL=test7.js   ')",
+        expected: "test7.js",
+    });
+
+    addValidTestCase({
+        description: "SourceURLs not on the first line.",
+        _expression_: "eval('\\n\\n//# sourceURL=test8.js')",
+        expected: "test8.js",
+    });
+
+    addValidTestCase({
+        description: "Multiple SourceURLs will return the first.",
+        _expression_: "eval('//# sourceURL=test9.js\\n//# sourceURL=second.js')",
+        expected: "test9.js",
+    });
+
+    InspectorProtocol.sendCommand("Debugger.enable", {});
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for the Debugger.scriptParsed sourceURL and sourceMappingURL comment directive parsing.</p>
+</body>
+</html>

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/ChangeLog (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/ChangeLog	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/ChangeLog	2015-12-04 20:54:33 UTC (rev 193460)
@@ -1,5 +1,58 @@
 2015-12-04  Timothy Hatcher  <timo...@apple.com>
 
+        Merge r191355. rdar://problem/23581597
+
+    2015-10-20  Joseph Pecoraro  <pecor...@apple.com>
+
+            Web Inspector: _javascript_Core should parse sourceURL and sourceMappingURL directives
+            https://bugs.webkit.org/show_bug.cgi?id=150096
+
+            Reviewed by Geoffrey Garen.
+
+            * inspector/ContentSearchUtilities.cpp:
+            (Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted.
+            (Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted.
+            (Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted.
+            * inspector/ContentSearchUtilities.h:
+            No longer need to search script content.
+
+            * inspector/ScriptDebugServer.cpp:
+            (Inspector::ScriptDebugServer::dispatchDidParseSource):
+            Carry over the sourceURL and sourceMappingURL from the SourceProvider.
+
+            * inspector/agents/InspectorDebuggerAgent.cpp:
+            (Inspector::InspectorDebuggerAgent::sourceMapURLForScript):
+            (Inspector::InspectorDebuggerAgent::didParseSource):
+            No longer do content searching.
+
+            * parser/Lexer.cpp:
+            (JSC::Lexer<T>::setCode):
+            (JSC::Lexer<T>::skipWhitespace):
+            (JSC::Lexer<T>::parseCommentDirective):
+            (JSC::Lexer<T>::parseCommentDirectiveValue):
+            (JSC::Lexer<T>::consume):
+            (JSC::Lexer<T>::lex):
+            * parser/Lexer.h:
+            (JSC::Lexer::sourceURL):
+            (JSC::Lexer::sourceMappingURL):
+            (JSC::Lexer::sourceProvider): Deleted.
+            Give lexer the ability to detect script comment directives.
+            This just consumes characters in single line comments and
+            ultimately sets the sourceURL or sourceMappingURL found.
+
+            * parser/Parser.h:
+            (JSC::Parser<LexerType>::parse):
+            * parser/SourceProvider.h:
+            (JSC::SourceProvider::url):
+            (JSC::SourceProvider::sourceURL):
+            (JSC::SourceProvider::sourceMappingURL):
+            (JSC::SourceProvider::setSourceURL):
+            (JSC::SourceProvider::setSourceMappingURL):
+            After parsing a script, update the Source Provider with the
+            value of directives that may have been found in the script.
+
+2015-12-04  Timothy Hatcher  <timo...@apple.com>
+
         Merge r190542. rdar://problem/23581597
 
     2015-10-02  Matt Baker  <mattba...@apple.com>

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp	2015-12-04 20:54:33 UTC (rev 193460)
@@ -166,12 +166,6 @@
     return result;
 }
 
-static String scriptCommentPattern(const String& name)
-{
-    // "//# <name>=<value>" and deprecated "//@"
-    return "//[#@][\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
-}
-
 static String stylesheetCommentPattern(const String& name)
 {
     // "/*# <name>=<value> */" and deprecated "/*@"
@@ -199,16 +193,6 @@
     return content.substring(matches[2], matches[3] - matches[2]);
 }
 
-String findScriptSourceURL(const String& content)
-{
-    return findMagicComment(content, scriptCommentPattern(ASCIILiteral("sourceURL")));
-}
-
-String findScriptSourceMapURL(const String& content)
-{
-    return findMagicComment(content, scriptCommentPattern(ASCIILiteral("sourceMappingURL")));
-}
-
 String findStylesheetSourceMapURL(const String& content)
 {
     return findMagicComment(content, stylesheetCommentPattern(ASCIILiteral("sourceMappingURL")));

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ContentSearchUtilities.h (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ContentSearchUtilities.h	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ContentSearchUtilities.h	2015-12-04 20:54:33 UTC (rev 193460)
@@ -48,8 +48,6 @@
 JS_EXPORT_PRIVATE TextPosition textPositionFromOffset(size_t offset, const Vector<size_t>& lineEndings);
 JS_EXPORT_PRIVATE std::unique_ptr<Vector<size_t>> lineEndings(const String&);
 
-JS_EXPORT_PRIVATE String findScriptSourceURL(const String& content);
-JS_EXPORT_PRIVATE String findScriptSourceMapURL(const String& content);
 JS_EXPORT_PRIVATE String findStylesheetSourceMapURL(const String& content);
 
 } // namespace ContentSearchUtilities

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ScriptDebugServer.cpp (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ScriptDebugServer.cpp	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/ScriptDebugServer.cpp	2015-12-04 20:54:33 UTC (rev 193460)
@@ -207,6 +207,8 @@
     script.startLine = sourceProvider->startPosition().m_line.zeroBasedInt();
     script.startColumn = sourceProvider->startPosition().m_column.zeroBasedInt();
     script.isContentScript = isContentScript;
+    script.sourceURL = sourceProvider->sourceURL();
+    script.sourceMappingURL = sourceProvider->sourceMappingURL();
 
     int sourceLength = script.source.length();
     int lineCount = 1;

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2015-12-04 20:54:33 UTC (rev 193460)
@@ -606,20 +606,16 @@
 
 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script)
 {
-    return ContentSearchUtilities::findScriptSourceMapURL(script.source);
+    return script.sourceMappingURL;
 }
 
-void InspectorDebuggerAgent::didParseSource(JSC::SourceID sourceID, const Script& inScript)
+void InspectorDebuggerAgent::didParseSource(JSC::SourceID sourceID, const Script& script)
 {
-    Script script = inScript;
-    if (script.startLine <= 0 && !script.startColumn)
-        script.sourceURL = ContentSearchUtilities::findScriptSourceURL(script.source);
-    script.sourceMappingURL = sourceMapURLForScript(script);
-
     bool hasSourceURL = !script.sourceURL.isEmpty();
     String scriptURL = hasSourceURL ? script.sourceURL : script.url;
     bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
-    String* sourceMapURLParam = script.sourceMappingURL.isNull() ? nullptr : &script.sourceMappingURL;
+    String sourceMappingURL = sourceMapURLForScript(script);
+    String* sourceMapURLParam = sourceMappingURL.isNull() ? nullptr : &sourceMappingURL;
     const bool* isContentScript = script.isContentScript ? &script.isContentScript : nullptr;
     String scriptIDStr = String::number(sourceID);
     m_frontendDispatcher->scriptParsed(scriptIDStr, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam);

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Lexer.cpp (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Lexer.cpp	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Lexer.cpp	2015-12-04 20:54:33 UTC (rev 193460)
@@ -25,23 +25,21 @@
 #include "config.h"
 #include "Lexer.h"
 
+#include "BuiltinNames.h"
+#include "Identifier.h"
+#include "JSCInlines.h"
 #include "JSFunctionInlines.h"
-
-#include "BuiltinNames.h"
 #include "JSGlobalObjectFunctions.h"
-#include "Identifier.h"
+#include "KeywordLookup.h"
+#include "Lexer.lut.h"
 #include "Nodes.h"
-#include "JSCInlines.h"
-#include <wtf/dtoa.h>
+#include "Parser.h"
 #include <ctype.h>
 #include <limits.h>
 #include <string.h>
 #include <wtf/Assertions.h>
+#include <wtf/dtoa.h>
 
-#include "KeywordLookup.h"
-#include "Lexer.lut.h"
-#include "Parser.h"
-
 namespace JSC {
 
 Keywords::Keywords(VM& vm)
@@ -566,6 +564,8 @@
     m_atLineStart = true;
     m_lineStart = m_code;
     m_lexErrorMessage = String();
+    m_sourceURLDirective = String();
+    m_sourceMappingURLDirective = String();
     
     m_buffer8.reserveInitialCapacity(initialReadBufferCapacity);
     m_buffer16.reserveInitialCapacity((m_codeEnd - m_code) / 2);
@@ -689,6 +689,13 @@
     return m_lastToken == CONTINUE || m_lastToken == BREAK || m_lastToken == RETURN || m_lastToken == THROW;
 }
 
+template <typename T>
+ALWAYS_INLINE void Lexer<T>::skipWhitespace()
+{
+    while (isWhiteSpace(m_current))
+        shift();
+}
+
 static NEVER_INLINE bool isNonLatin1IdentStart(UChar c)
 {
     return U_GET_GC_MASK(c) & U_GC_L_MASK;
@@ -1706,6 +1713,60 @@
 }
 
 template <typename T>
+ALWAYS_INLINE void Lexer<T>::parseCommentDirective()
+{
+    // sourceURL and sourceMappingURL directives.
+    if (!consume("source"))
+        return;
+
+    if (consume("URL="" {
+        if (!m_sourceURLDirective.isEmpty())
+            return;
+        m_sourceURLDirective = parseCommentDirectiveValue();
+        return;
+    }
+
+    if (consume("MappingURL=")) {
+        if (!m_sourceMappingURLDirective.isEmpty())
+            return;
+        m_sourceMappingURLDirective = parseCommentDirectiveValue();
+        return;
+    }
+}
+
+template <typename T>
+ALWAYS_INLINE String Lexer<T>::parseCommentDirectiveValue()
+{
+    skipWhitespace();
+    const T* stringStart = currentSourcePtr();
+    while (!isWhiteSpace(m_current) && !isLineTerminator(m_current) && m_current != '"' && m_current != '\'' && !atEnd())
+        shift();
+    const T* stringEnd = currentSourcePtr();
+    skipWhitespace();
+
+    if (!isLineTerminator(m_current) && !atEnd())
+        return String();
+
+    append8(stringStart, stringEnd - stringStart);
+    String result = String(m_buffer8.data(), m_buffer8.size());
+    m_buffer8.shrink(0);
+    return result;
+}
+
+template <typename T>
+template <unsigned length>
+ALWAYS_INLINE bool Lexer<T>::consume(const char (&input)[length])
+{
+    unsigned lengthToCheck = length - 1; // Ignore the ending NULL byte in the string literal.
+
+    unsigned i = 0;
+    for (; i < lengthToCheck && m_current == input[i]; i++)
+        shift();
+
+    return i == lengthToCheck;
+}
+
+template <typename T>
 bool Lexer<T>::nextTokenIsColon()
 {
     const T* code = m_code;
@@ -1742,8 +1803,7 @@
     m_terminator = false;
 
 start:
-    while (isWhiteSpace(m_current))
-        shift();
+    skipWhitespace();
 
     if (atEnd())
         return EOFTOK;
@@ -1901,7 +1961,7 @@
         shift();
         if (m_current == '/') {
             shift();
-            goto inSingleLineComment;
+            goto inSingleLineCommentCheckForDirectives;
         }
         if (m_current == '*') {
             shift();
@@ -2207,6 +2267,15 @@
     m_atLineStart = false;
     goto returnToken;
 
+inSingleLineCommentCheckForDirectives:
+    // Script comment directives like "//# sourceURL=test.js".
+    if (UNLIKELY((m_current == '#' || m_current == '@') && isWhiteSpace(peek(1)))) {
+        shift();
+        shift();
+        parseCommentDirective();
+    }
+    // Fall through to complete single line comment parsing.
+
 inSingleLineComment:
     while (!isLineTerminator(m_current)) {
         if (atEnd())

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Lexer.h (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Lexer.h	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Lexer.h	2015-12-04 20:54:33 UTC (rev 193460)
@@ -114,6 +114,8 @@
     // Functions for use after parsing.
     bool sawError() const { return m_error; }
     String getErrorMessage() const { return m_lexErrorMessage; }
+    String sourceURL() const { return m_sourceURLDirective; }
+    String sourceMappingURL() const { return m_sourceMappingURLDirective; }
     void clear();
     void setOffset(int offset, int lineStartOffset)
     {
@@ -140,8 +142,6 @@
         m_terminator = terminator;
     }
 
-    SourceProvider* sourceProvider() const { return m_source->provider(); }
-
     JSTokenType lexExpectIdentifier(JSToken*, unsigned, bool strictMode);
 
 private:
@@ -178,6 +178,8 @@
     ALWAYS_INLINE const Identifier* makeEmptyIdentifier();
 
     ALWAYS_INLINE bool lastTokenWasRestrKeyword() const;
+    
+    ALWAYS_INLINE void skipWhitespace();
 
     template <int shiftAmount> void internalShift();
     template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType parseKeyword(JSTokenData*);
@@ -204,6 +206,12 @@
     ALWAYS_INLINE bool parseNumberAfterExponentIndicator();
     ALWAYS_INLINE bool parseMultilineComment();
 
+    ALWAYS_INLINE void parseCommentDirective();
+    ALWAYS_INLINE String parseCommentDirectiveValue();
+
+    template <unsigned length>
+    ALWAYS_INLINE bool consume(const char (&input)[length]);
+
     static const size_t initialReadBufferCapacity = 32;
 
     int m_lineNumber;
@@ -229,6 +237,9 @@
     bool m_error;
     String m_lexErrorMessage;
 
+    String m_sourceURLDirective;
+    String m_sourceMappingURLDirective;
+
     T m_current;
 
     IdentifierArena* m_arena;

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Parser.h (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Parser.h	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/parser/Parser.h	2015-12-04 20:54:33 UTC (rev 193460)
@@ -1026,6 +1026,9 @@
                                     m_numConstants);
         result->setLoc(m_source->firstLine(), m_lexer->lineNumber(), m_lexer->currentOffset(), m_lexer->currentLineStartOffset());
         result->setEndOffset(m_lexer->currentOffset());
+
+        m_source->provider()->setSourceURLDirective(m_lexer->sourceURL());
+        m_source->provider()->setSourceMappingURLDirective(m_lexer->sourceMappingURL());
     } else {
         // We can never see a syntax error when reparsing a function, since we should have
         // reported the error when parsing the containing program or eval code. So if we're

Modified: branches/safari-601.1.46-branch/Source/_javascript_Core/parser/SourceProvider.h (193459 => 193460)


--- branches/safari-601.1.46-branch/Source/_javascript_Core/parser/SourceProvider.h	2015-12-04 20:54:23 UTC (rev 193459)
+++ branches/safari-601.1.46-branch/Source/_javascript_Core/parser/SourceProvider.h	2015-12-04 20:54:33 UTC (rev 193460)
@@ -49,7 +49,10 @@
             return source().substringSharingImpl(start, end - start);
         }
 
-        const String& url() { return m_url; }
+        const String& url() const { return m_url; }
+        const String& sourceURL() const { return m_sourceURLDirective; }
+        const String& sourceMappingURL() const { return m_sourceMappingURLDirective; }
+
         TextPosition startPosition() const { return m_startPosition; }
         intptr_t asID()
         {
@@ -62,11 +65,17 @@
         void setValid() { m_validated = true; }
 
     private:
+        template <typename T> friend class Parser;
 
+        void setSourceURLDirective(const String& sourceURL) { m_sourceURLDirective = sourceURL; }
+        void setSourceMappingURLDirective(const String& sourceMappingURL) { m_sourceMappingURLDirective = sourceMappingURL; }
+
         JS_EXPORT_PRIVATE void getID();
         Vector<size_t>& lineStarts();
 
         String m_url;
+        String m_sourceURLDirective;
+        String m_sourceMappingURLDirective;
         TextPosition m_startPosition;
         bool m_validated : 1;
         uintptr_t m_id : sizeof(uintptr_t) * 8 - 1;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to