public static SourceFileModule makeSourceModule(URL script, String dir, String name) { // DO NOT use File.separator here, since this name is matched against // URLs. It seems that, in DOS, URL.getFile() does not return a // \-separated file name, but rather one with /'s. Rather makes one // wonder why the function is called get_File_ :( return makeSourceModule(script, dir + '/' + name); }
public static IClassHierarchy makeHierarchyForScripts(String... scriptFiles) throws ClassHierarchyException { JavaScriptLoaderFactory loaders = makeLoaders(); AnalysisScope scope = CAstCallGraphUtil.makeScope(scriptFiles, loaders, JavaScriptLoader.JS); return makeHierarchy(scope, loaders); } public static IClassHierarchy makeHierarchy(AnalysisScope scope, ClassLoaderFactory loaders) throws ClassHierarchyException {
public static String getShortName(CGNode nd) { IMethod method = nd.getMethod(); return getShortName(method); }
@Test public void testPage3WithoutHack() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/page3.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); }
@Test public void testArgs() throws IOException, IllegalArgumentException, CancelException, ClassHierarchyException, WalaException { JavaScriptLoaderFactory loaders = JSCallGraphUtil.makeLoaders(null); AnalysisScope scope = JSCallGraphBuilderUtil.makeScriptScope("tests", "args.js", loaders); IClassHierarchy cha = JSCallGraphUtil.makeHierarchy(scope, loaders); com.ibm.wala.cast.util.Util.checkForFrontEndErrors(cha); Iterable<Entrypoint> roots = JSCallGraphUtil.makeScriptRoots(cha); JSAnalysisOptions options = JSCallGraphUtil.makeOptions(scope, cha, roots); IAnalysisCacheView cache = CAstCallGraphUtil.makeCache(new ArgumentSpecialization.ArgumentCountIRFactory(options.getSSAOptions())); JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS, false); builder.setContextSelector(new ArgumentSpecialization.ArgumentCountContextSelector(builder.getContextSelector())); builder.setContextInterpreter(new ArgumentSpecialization.ArgumentSpecializationContextIntepreter(options, cache)); CallGraph CG = builder.makeCallGraph(options); // CAstCallGraphUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForArgs); }
@Test public void testPage3WithHack() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/page3.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); addHackedForInLoopSensitivity(builder); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); }
public static SourceFileModule makeSourceModule(URL script, String dir, String name) { // DO NOT use File.separator here, since this name is matched against // URLs. It seems that, in DOS, URL.getFile() does not return a // \-separated file name, but rather one with /'s. Rather makes one // wonder why the function is called get_File_ :( return makeSourceModule(script, dir + '/' + name); }
@Ignore("This tries to analyze unmodified jquery, which we can't do yet") @Test public void testEx1() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/jquery/ex1.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); } }
public static IClassHierarchy makeHierarchyForScripts(String... scriptFiles) throws ClassHierarchyException { JavaScriptLoaderFactory loaders = makeLoaders(); AnalysisScope scope = CAstCallGraphUtil.makeScope(scriptFiles, loaders, JavaScriptLoader.JS); return makeHierarchy(scope, loaders); } public static IClassHierarchy makeHierarchy(AnalysisScope scope, ClassLoaderFactory loaders) throws ClassHierarchyException {
public static String getShortName(CGNode nd) { IMethod method = nd.getMethod(); return getShortName(method); }
public static SourceFileModule[] handleFileNames(String[] fileNameArgs) { SourceFileModule[] fileNames = new SourceFileModule[fileNameArgs.length]; for (int i = 0; i < fileNameArgs.length; i++) { if (new File(fileNameArgs[i]).exists()) { try { fileNames[i] = CAstCallGraphUtil.makeSourceModule(new File(fileNameArgs[i]).toURI().toURL(), fileNameArgs[i]); } catch (MalformedURLException e) { Assertions.UNREACHABLE(e.toString()); } } else { URL url = CAstCallGraphUtil.class.getClassLoader().getResource(fileNameArgs[i]); fileNames[i] = CAstCallGraphUtil.makeSourceModule(url, fileNameArgs[i]); } } return fileNames; }
@Test public void testList() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/list.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); CallGraph CG = builder.makeCallGraph(builder.getOptions()); // JSCallGraphBuilderUtil.AVOID_DUMP = false; CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); verifySourceAssertions(CG, sourceAssertionsForList); }
public ClassHierarchy runTranslator(SourceFileModule[] fileNames) throws Exception { SingleClassLoaderFactory loaders = getClassLoaderFactory(); AnalysisScope scope = CAstCallGraphUtil.makeScope(fileNames, loaders, getLanguage()); ClassHierarchy cha = ClassHierarchyFactory.make(scope, loaders, getLanguage()); return cha; }
return; for (CGNode N : CG) { System.err.print("callees of node " + getShortName(N) + " : ["); boolean fst = true; for (CGNode n : Iterator2Iterable.make(CG.getSuccNodes(N))) { else System.err.print(", "); System.err.print(getShortName(n));
public static SourceFileModule[] handleFileNames(String[] fileNameArgs) { SourceFileModule[] fileNames = new SourceFileModule[fileNameArgs.length]; for (int i = 0; i < fileNameArgs.length; i++) { if (new File(fileNameArgs[i]).exists()) { try { fileNames[i] = CAstCallGraphUtil.makeSourceModule(new File(fileNameArgs[i]).toURI().toURL(), fileNameArgs[i]); } catch (MalformedURLException e) { Assertions.UNREACHABLE(e.toString()); } } else { URL url = CAstCallGraphUtil.class.getClassLoader().getResource(fileNameArgs[i]); fileNames[i] = CAstCallGraphUtil.makeSourceModule(url, fileNameArgs[i]); } } return fileNames; }
@Test public void testWindowx() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/windowx.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForWindowx); }
return; for (CGNode N : CG) { System.err.print("callees of node " + getShortName(N) + " : ["); boolean fst = true; for (CGNode n : Iterator2Iterable.make(CG.getSuccNodes(N))) { else System.err.print(", "); System.err.print(getShortName(n));
public static NodejsRequiredCoreModule make(String name) throws IOException { if (! names.containsKey(name)) { java.nio.file.Path p = Files.createTempDirectory("nodejs"); File f = new File(p.toFile(), name + ".js"); f.deleteOnExit(); p.toFile().deleteOnExit(); names.put(name, f); } File file = names.get(name); TemporaryFile.streamToFile(file, getModule(name)); SourceFileModule sourceFileModule = CAstCallGraphUtil.makeSourceModule(file.toURI().toURL(), file.getName()); return new NodejsRequiredCoreModule(file, sourceFileModule); }
@Test public void testWindowOnload() throws IllegalArgumentException, CancelException, WalaException { URL url = getClass().getClassLoader().getResource("pages/windowonload.html"); JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url); CallGraph CG = builder.makeCallGraph(builder.getOptions()); CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG); verifyGraphAssertions(CG, assertionsForWindowOnload); }
public static NodejsRequiredSourceModule make(File rootDir, File file) throws IOException { String className = convertFileToClassName(rootDir, file); SourceFileModule sourceFileModule = CAstCallGraphUtil.makeSourceModule(file.toURI().toURL(), file.getName()); return new NodejsRequiredSourceModule(className, file, sourceFileModule); } }