tools/clusterfuzz/js_fuzzer/source_helpers.js
/**
 * Removes V8/Spidermonkey/Chakra load expressions in a source AST and returns
 * their string values in an array.
 *
 * @param {string} originalFilePath Absolute path to file.
 * @param {AST} ast Babel AST of the sources.
 */
Removes V8/Spidermonkey/Chakra load expressions in a source AST and returns
their string values in an array.

@param {string} originalFilePath Absolute path to file.
@param {AST} ast Babel AST of the sources.
Removes V8 / Spidermonkey / Chakra load expressions in a source AST and returns their string values in an array . @param { string } originalFilePath Absolute path to file . @param { AST } ast Babel AST of the sources .
function resolveLoads(originalFilePath, ast) {
  const dependencies = [];
  babelTraverse(ast, {
    CallExpression(path) {
      const isV8OrSpiderMonkeyLoad = _isV8OrSpiderMonkeyLoad(path);
      const isChakraLoad = _isChakraLoad(path);
      if (!isV8OrSpiderMonkeyLoad && !isChakraLoad) {
        return;
      }
      let loadValue = path.node.arguments[0].extra.rawValue;
      loadValue = loadValue.replace(/\\/g, fsPath.sep);
      path.remove();
      const resolvedPath = _findDependentCodePath(
          loadValue, fsPath.dirname(originalFilePath), !isChakraLoad);
      if (!resolvedPath) {
        console.log('ERROR: Could not find dependent path for', loadValue);
        return;
      }
      if (exceptions.isTestSkippedAbs(resolvedPath)) {
        return;
      }
      dependencies.push(resolvedPath);
    }
  });
  return dependencies;
}
function resolveLoads ( originalFilePath , ast ) { const dependencies = [ ] ; babelTraverse ( ast , { CallExpression ( path ) { const isV8OrSpiderMonkeyLoad = _isV8OrSpiderMonkeyLoad ( path ) ; const isChakraLoad = _isChakraLoad ( path ) ; if ( ! isV8OrSpiderMonkeyLoad && ! isChakraLoad ) { return ; } let loadValue = path . node . arguments [ 0 ] . extra . rawValue ; loadValue = loadValue . replace ( / \\ / g , fsPath . sep ) ; path . remove ( ) ; const resolvedPath = _findDependentCodePath ( loadValue , fsPath . dirname ( originalFilePath ) , ! isChakraLoad ) ; if ( ! resolvedPath ) { console . log ( 'ERROR: Could not find dependent path for' , loadValue ) ; return ; } if ( exceptions . isTestSkippedAbs ( resolvedPath ) ) { return ; } dependencies . push ( resolvedPath ) ; } } ) ; return dependencies ; }
Removes V8/Spidermonkey/Chakra load expressions in a source AST and returns
 their string values in an array.
Removes V8 / Spidermonkey / Chakra load expressions in a source AST and returns their string values in an array .
// Normalize Windows path separators. // Remove load call. // Dependency is skipped. // Add the dependency path.