Ignore:
Timestamp:
Sep 5, 2015, 12:45:58 PM (10 years ago)
Author:
Yusuke Suzuki
Message:

Unreviewed, fix the module name resolution in Windows
https://bugs.webkit.org/show_bug.cgi?id=148689

Attempt to fix the module name resolution in Windows.
A module name is represented as the UNIX path under the current module tests.
This fix split the module name with '/' instead of pathSeparator().

This is only utilized by the jsc.cpp for the local module tests.
So, WebKit production and JavaScriptCore framework are not affected by this change.

  • jsc.cpp:

(ModuleName::startsWithRoot):
(ModuleName::ModuleName):
(resolvePath):
(GlobalObject::moduleLoaderResolve):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r189431 r189439  
    748748};
    749749
     750struct ModuleName {
     751    ModuleName(const String& moduleName);
     752
     753    bool startsWithRoot() const
     754    {
     755        return !queries.isEmpty() && queries[0].isEmpty();
     756    }
     757
     758    Vector<String> queries;
     759};
     760
     761ModuleName::ModuleName(const String& moduleName)
     762{
     763    // A module name given from code is represented as the UNIX style path. Like, `./A/B.js`.
     764    moduleName.split('/', true, queries);
     765}
     766
    750767static bool extractDirectoryName(const String& absolutePathToFile, DirectoryName& directoryName)
    751768{
     
    787804}
    788805
    789 static String resolvePath(const DirectoryName& directoryName, const String& query)
     806static String resolvePath(const DirectoryName& directoryName, const ModuleName& moduleName)
    790807{
    791808    Vector<String> directoryPieces;
    792809    directoryName.queryName.split(pathSeparator(), false, directoryPieces);
    793810
    794     Vector<String> queryPieces;
    795     query.split(pathSeparator(), true, queryPieces);
    796 
    797811    // Only first '/' is recognized as the path from the root.
    798     if (!queryPieces.isEmpty() && queryPieces[0].isEmpty())
     812    if (moduleName.startsWithRoot())
    799813        directoryPieces.clear();
    800814
    801     for (const auto& query : queryPieces) {
     815    for (const auto& query : moduleName.queries) {
    802816        if (query == String(ASCIILiteral(".."))) {
    803817            if (!directoryPieces.isEmpty())
     
    851865    }
    852866
    853     return deferred->resolve(exec, jsString(exec, resolvePath(directoryName, key.impl())));
     867    return deferred->resolve(exec, jsString(exec, resolvePath(directoryName, ModuleName(key.impl()))));
    854868}
    855869
Note: See TracChangeset for help on using the changeset viewer.