diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java index 58d527391..64ecc1daa 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/vis/JsViewerDriver.java @@ -40,7 +40,7 @@ public class JsViewerDriver extends Util { SourceModule[] sources = getSources(domless, url); - JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, false); + JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory), sources, false, true); builder.setBaseURL(url); CallGraph cg = builder.makeCallGraph(builder.getOptions()); diff --git a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestAjaxsltCallGraphShape.java b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestAjaxsltCallGraphShape.java index 00f9c2f09..6d76fae3c 100755 --- a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestAjaxsltCallGraphShape.java +++ b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestAjaxsltCallGraphShape.java @@ -13,12 +13,9 @@ package com.ibm.wala.cast.js.test; import java.io.IOException; import java.net.URL; -import org.junit.Ignore; import org.junit.Test; -import com.ibm.wala.cast.js.ipa.callgraph.JSAnalysisOptions; import com.ibm.wala.ipa.callgraph.CallGraph; -import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder; import com.ibm.wala.util.CancelException; public abstract class TestAjaxsltCallGraphShape extends TestJSCallGraphShape { @@ -33,9 +30,9 @@ public abstract class TestAjaxsltCallGraphShape extends TestJSCallGraphShape { @Test public void testAjaxslt() throws IOException, IllegalArgumentException, CancelException { URL url = getClass().getClassLoader().getResource("ajaxslt/test/xslt.html"); - PropagationCallGraphBuilder b = Util.makeHTMLCGBuilder(url); - ((JSAnalysisOptions) b.getOptions()).setHandleCallApply(false); - CallGraph CG = b.makeCallGraph(b.getOptions()); + // don't handle call / apply; it makes things blow up + CallGraph CG = Util.makeHTMLCG(url, false); + verifyGraphAssertions(CG, assertionsForAjaxslt); } diff --git a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/Util.java b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/Util.java index d33ee1f65..5793e3fcf 100755 --- a/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/Util.java +++ b/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/Util.java @@ -37,8 +37,10 @@ import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys; import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.util.CancelException; -import com.ibm.wala.util.MonitorUtil.IProgressMonitor; +/** + * TODO this class is a mess. rewrite. + */ public class Util extends com.ibm.wala.cast.js.ipa.callgraph.Util { public static JSCFABuilder makeScriptCGBuilder(String dir, String name, boolean useOneCFA) throws IOException { @@ -57,7 +59,7 @@ public class Util extends com.ibm.wala.cast.js.ipa.callgraph.Util { scope = makeScope(new SourceFileModule[] { makeSourceModule(script, dir, name) }, loaders, JavaScriptLoader.JS); } - return makeCG(loaders, scope, useOneCFA); + return makeCG(loaders, scope, useOneCFA, true); } public static JSCFABuilder makeScriptCGBuilder(String dir, String name) throws IOException { @@ -78,16 +80,19 @@ public class Util extends com.ibm.wala.cast.js.ipa.callgraph.Util { public static CallGraph makeScriptCG(SourceModule[] scripts, boolean useOneCFA) throws IOException, IllegalArgumentException, CancelException { - PropagationCallGraphBuilder b = makeCGBuilder(makeLoaders(), scripts, useOneCFA); + PropagationCallGraphBuilder b = makeCGBuilder(makeLoaders(), scripts, useOneCFA, true); CallGraph CG = b.makeCallGraph(b.getOptions()); dumpCG(b.getPointerAnalysis(), CG); return CG; } public static JSCFABuilder makeHTMLCGBuilder(URL url) throws IOException { + return makeHTMLCGBuilder(url, true); + } + public static JSCFABuilder makeHTMLCGBuilder(URL url, boolean handleCallApply) throws IOException { JavaScriptLoader.addBootstrapFile(WebUtil.preamble); Set script = WebUtil.extractScriptFromHTML(url); - JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory, preprocessor), script.toArray(new SourceModule[script.size()]), false); + JSCFABuilder builder = makeCGBuilder(new WebPageLoaderFactory(translatorFactory, preprocessor), script.toArray(new SourceModule[script.size()]), false, handleCallApply); builder.setBaseURL(url); return builder; } @@ -99,24 +104,25 @@ public class Util extends com.ibm.wala.cast.js.ipa.callgraph.Util { return CG; } - public static CallGraph makeHTMLCG(URL url, IProgressMonitor monitor) throws IOException, IllegalArgumentException, + public static CallGraph makeHTMLCG(URL url, boolean handleCallApply) throws IOException, IllegalArgumentException, CancelException { - PropagationCallGraphBuilder b = makeHTMLCGBuilder(url); - CallGraph CG = b.makeCallGraph(b.getOptions(), monitor); + PropagationCallGraphBuilder b = makeHTMLCGBuilder(url, handleCallApply); + CallGraph CG = b.makeCallGraph(b.getOptions()); return CG; } - public static JSCFABuilder makeCGBuilder(JavaScriptLoaderFactory loaders, SourceModule[] scripts, boolean useOneCFA) throws IOException { + public static JSCFABuilder makeCGBuilder(JavaScriptLoaderFactory loaders, SourceModule[] scripts, boolean useOneCFA, boolean handleCallApply) throws IOException { AnalysisScope scope = makeScope(scripts, loaders, JavaScriptLoader.JS); - return makeCG(loaders, scope, useOneCFA); + return makeCG(loaders, scope, useOneCFA, handleCallApply); } - protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, boolean useOneCFA) throws IOException { + protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, boolean useOneCFA, boolean handleCallApply) throws IOException { try { IClassHierarchy cha = makeHierarchy(scope, loaders); com.ibm.wala.cast.test.Util.checkForFrontEndErrors(cha); Iterable roots = makeScriptRoots(cha); JSAnalysisOptions options = makeOptions(scope, cha, roots); + options.setHandleCallApply(handleCallApply); AnalysisCache cache = makeCache(); JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS, useOneCFA); diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/Util.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/Util.java index 2899257cc..01f30ad86 100755 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/Util.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/Util.java @@ -58,12 +58,12 @@ public class Util extends com.ibm.wala.cast.ipa.callgraph.Util { * the translator factory to be used for analysis TODO: pass the factory where * needed instead of using a global? */ - protected static JavaScriptTranslatorFactory translatorFactory; + public static JavaScriptTranslatorFactory translatorFactory; /** * preprocessor to run generated CAst trees through, null if none */ - protected static CAstRewriterFactory preprocessor; + public static CAstRewriterFactory preprocessor; /** * Set up the translator factory. This method should be called before invoking