Пример #1
0
  public void start(Class<? extends ICostComputer<ICostResult>> costComputerType)
      throws InstantiationException, IllegalAccessException, IllegalArgumentException,
          WalaException, IOException, SecurityException, InvocationTargetException,
          NoSuchMethodException {
    this.costComputer =
        costComputerType
            .getDeclaredConstructor(JVMModel.class)
            .newInstance(specification.getJvmModel());

    LinkedList<CGNode> entryCGNodes = specification.getEntryPointCGNodes();

    for (CGNode entryNode : entryCGNodes) {
      // OutputPrinter.printInfo("Starting entry node " + entryNode.getMethod().toString());
      ICostResult results = new CGNodeAnalyzer(entryNode, costComputer).analyzeNode();
      // ICostResult results = new
      // CostComputerMemory(specification.getJvmModel()).dfsVisit(entryNode);
      // Test code
      CostResultMemory memRes = (CostResultMemory) results;
      OutputPrinter.printInfo(
          "Worst case allocation for "
              + entryNode.getMethod().toString()
              + ":\t"
              + results.getCostScalar());
      for (Entry<TypeName, Integer> i : memRes.aggregatedCountByTypename.entrySet()) {
        OutputPrinter.printInfo(
            "\t TYPE_NAME\t" + i.getKey().toString() + "\tCOUNT " + i.getValue());
      }
    }
    /* This is move to the program.
    if ( specification.getTypeOfAnalysisPerformed() != AnalysisType.ALLOCATIONS) {
    	stackAnalyzer.analyze();
    }

    if ( specification.getShouldGenerateAnalysisReports() == true) {
    	ReportGenerator gen = new ReportGenerator();
    	gen.Generate(AnalysisResults.getAnalysisResults().getReportEntries());
    }*/
  }