Skip to content

Commit

Permalink
Modifying Transformer and Main and config
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-moloney committed Dec 11, 2024
1 parent dda1760 commit 3c59fce
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 163 deletions.
8 changes: 7 additions & 1 deletion .project
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
Expand All @@ -27,4 +33,4 @@
</matcher>
</filter>
</filteredResources>
</projectDescription>
</projectDescription>
1 change: 1 addition & 0 deletions config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ maxLoc=10000
minLoc=100
downloadDir=database
benchmarkDir=benchmarks
transformAll=true
debugLevel=2
type=I
minExpr=3
Expand Down
2 changes: 1 addition & 1 deletion src/java/nonlinearExprSub/Transformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private void applyEdits(File file) throws IOException {
*/
private void setupAST(File file) throws IOException {
source = new String(Files.readAllBytes(file.toPath()));
ASTParser parser = ASTParser.newParser(AST.JLS3);
ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setSource(source.toCharArray());
parser.setKind(ASTParser.K_COMPILATION_UNIT);

Expand Down
37 changes: 16 additions & 21 deletions src/java/transform/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ public class Main {
private final static String DEFAULT_MIN_TYPE_PARAMS = "0";
private final static String DEFAULT_TRANSFORM_ALL = "False";
private final static CType DEFAULT_TYPE = CType.INT;

public static String source = "suitablePrgms";
public static String dest = "benchmarks";
// public static String source = "test/transformer/regression";
// public static String dest = "testOutput";

public static void main(String[] args) throws IOException {
File tmpDir = Files.createTempDirectory("paclab-transform").toFile();
buildDir = new File(tmpDir, "bin");

String source = "suitablePrgms";
String dest = "benchmarks";
// String source = "test/transformer/regression";
// String dest = "testOutput";


if (args.length == 2) {
source = args[0];
Expand Down Expand Up @@ -129,23 +131,6 @@ public static void main(String[] args) throws IOException {
ArrayList<File> unsuccessfulCompiles = new ArrayList<File>();
Iterator<File> file_itr = FileUtils.iterateFiles(destDir, new String[] { "java" }, true);

file_itr.forEachRemaining(file -> {
boolean success = compile(file);
if (!success) {
unsuccessfulCompiles.add(file);
} else {
successfulCompiles.add(file);
}
});

System.out.println("================================================\t");
System.out.println("Before Transformation:\t");
System.out.println("Number of unsuccessful intial compilation " + unsuccessfulCompiles.size() + "\t");
System.out.println("Number of successful intial compilation " + successfulCompiles.size());
System.out.println("================================================");

// System.out.println(unsuccessfulCompiles + " ------- " + successfulCompiles);

if (transformAll) {
file_itr.forEachRemaining(file -> unsuccessfulCompiles.add(file));
} else {
Expand All @@ -158,6 +143,16 @@ public static void main(String[] args) throws IOException {
}
});
}

System.out.println("================================================\t");
System.out.println("Before Transformation:\t");
System.out.println("Number of unsuccessful intial compilation " + unsuccessfulCompiles.size() + "\t");
System.out.println("Number of successful intial compilation " + successfulCompiles.size());
System.out.println("================================================");

// System.out.println(unsuccessfulCompiles + " ------- " + successfulCompiles);



System.out.println(unsuccessfulCompiles + " ------- " + successfulCompiles);

Expand Down
11 changes: 1 addition & 10 deletions src/java/transform/Transformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,17 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.io.FileUtils;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
Expand Down Expand Up @@ -149,7 +140,7 @@ public void transformFiles(int minTypeExpr, int minTypeCond, int minTypeParams,
parser.setUnitName(file.getPath());

String[] classPath = {Paths.get("build", "classes").toString()};
String[] sourcePath = { Paths.get("suitablePrgms").toString() , Paths.get("src").toString()};
String[] sourcePath = { Paths.get(Main.source).toString() , Paths.get("src").toString()};
parser.setEnvironment(classPath, sourcePath, new String[] { "UTF-8", "UTF-8" }, true);

CompilationUnit cu = (CompilationUnit) parser.createAST(null);
Expand Down
65 changes: 0 additions & 65 deletions src/transform/benchmark/CreateYmlFile.java

This file was deleted.

65 changes: 0 additions & 65 deletions src/transform/benchmark_sv/CreateYmlFile.java

This file was deleted.

0 comments on commit 3c59fce

Please sign in to comment.