Ejemplo n.º 1
0
  public static void main(String args[])
      throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException {

    if (args.length != 1) {
      System.out.println("Usage: <URL of html page to analyze>");
      System.exit(1);
    }
    boolean domless = false;

    URL url = new URL(args[0]);

    // computing CG + PA
    JSCallGraphBuilderUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
    JavaScriptLoader.addBootstrapFile(WebUtil.preamble);

    SourceModule[] sources = getSources(domless, url);

    JSCFABuilder builder =
        makeCGBuilder(
            new WebPageLoaderFactory(translatorFactory),
            sources,
            CGBuilderType.ZERO_ONE_CFA,
            AstIRFactory.makeDefaultFactory());
    builder.setBaseURL(url);

    CallGraph cg = builder.makeCallGraph(builder.getOptions());
    PointerAnalysis pa = builder.getPointerAnalysis();

    new JsViewer(cg, pa);
  }