Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LambdaTransformer bootstrap class generation #39

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/rascal"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/rascal"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand All @@ -26,11 +11,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
78 changes: 39 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,44 +46,44 @@
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal-maven-plugin</artifactId>
<version>0.3.4</version>
<configuration>
<bin>${project.build.outputDirectory}</bin>
<errorsAsWarnings>true</errorsAsWarnings>
<enableStandardLibrary>true</enableStandardLibrary>
<srcs>
<src>${project.basedir}/src/main/rascal</src>
</srcs>
<srcIgnores>
<ignore>${project.basedir}/src/main/rascal/lang/jimple/toolkit/GraphUtil.rsc</ignore>
<ignore>${project.basedir}/src/main/rascal/lang/jimple/toolkit/CallGraph.rsc</ignore>
</srcIgnores>
</configuration>
<executions>
<execution>
<id>it-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal-maven-plugin</artifactId>
<version>0.3.4</version>
<configuration>
<bin>${project.build.outputDirectory}</bin>
<errorsAsWarnings>true</errorsAsWarnings>
<enableStandardLibrary>true</enableStandardLibrary>
<srcs>
<src>${project.basedir}/src/main/rascal</src>
</srcs>
<srcIgnores>
<ignore>${project.basedir}/src/main/rascal/lang/jimple/toolkit/GraphUtil.rsc</ignore>
<ignore>${project.basedir}/src/main/rascal/lang/jimple/toolkit/CallGraph.rsc</ignore>
</srcIgnores>
</configuration>
<executions>
<execution>
<id>it-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
4 changes: 2 additions & 2 deletions src/main/java/lang/jimple/internal/BinExpressionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lang.jimple.internal.generated.Immediate;

public interface BinExpressionFactory {

public Expression createExpression(Immediate lhs, Immediate rhs);

}
80 changes: 39 additions & 41 deletions src/main/java/lang/jimple/internal/BranchInstructionFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ public class BranchInstructionFlow implements InstructionFlow {
private BranchState status;

private Statement gotoMergeStmt;

enum BranchState {
LEFT,
RIGHT,
ReadyToMerge
LEFT, RIGHT, ReadyToMerge
}

public BranchInstructionFlow(Expression condition, String target) {
this.condition = condition;
this.targetStatement = target;
Expand All @@ -35,34 +33,32 @@ public BranchInstructionFlow(Expression condition, String target) {
status = BranchState.LEFT;
}


@Override
public Collection<Statement> merge() {
List<Statement> res = new ArrayList<>();

res.add(Statement.ifStmt(condition, targetStatement));
res.addAll(left.instructions);

if(gotoMergeStmt != null) {
if (gotoMergeStmt != null) {
res.add(gotoMergeStmt);
}

res.add(Statement.label(targetStatement));
res.addAll(right.instructions);

if(mergeStatement != null) {
if (mergeStatement != null) {
res.add(Statement.label(mergeStatement));
}
return res;

return res;
}

@Override
public boolean matchMergePoint(String label) {
if(status.equals(BranchState.LEFT)) {
if (status.equals(BranchState.LEFT)) {
return this.targetStatement.equals(label);
}
else if(status.equals(BranchState.RIGHT)) {
} else if (status.equals(BranchState.RIGHT)) {
return this.mergeStatement.equals(label);
}
return false;
Expand All @@ -71,53 +67,55 @@ else if(status.equals(BranchState.RIGHT)) {
@Override
public List<Environment> environments() {
List<Environment> res = new ArrayList<>();
switch(status) {
case LEFT: res.add(left); break;
case RIGHT: res.add(right); break;
case ReadyToMerge:
if(mergeStatement != null) {
res.add(left);
res.add(right);
}
else {
res.add(left);
}
switch (status) {
case LEFT:
res.add(left);
break;
case RIGHT:
res.add(right);
break;
case ReadyToMerge:
if (mergeStatement != null) {
res.add(left);
res.add(right);
} else {
res.add(left);
}
}
return res;
}

@Override
public void notifyGotoStmt(Statement stmt, String label) {
if(status.equals(BranchState.LEFT)) {
if (status.equals(BranchState.LEFT)) {
mergeStatement = label;
gotoMergeStmt = stmt;
}
else if(status.equals(BranchState.RIGHT)) {
} else if (status.equals(BranchState.RIGHT)) {
right.instructions.add(stmt);
}
else if(status.equals(BranchState.ReadyToMerge)) {
} else if (status.equals(BranchState.ReadyToMerge)) {
left.instructions.add(stmt);
right.instructions.add(stmt);
}
}

@Override
public void nextBranch() {
switch(status) {
case LEFT:
if(mergeStatement != null) {
switch (status) {
case LEFT:
if (mergeStatement != null) {
status = BranchState.RIGHT;
} else {
left.instructions.add(Statement.label(targetStatement));
status = BranchState.ReadyToMerge;
}
else {
left.instructions.add(Statement.label(targetStatement));
status = BranchState.ReadyToMerge;
}
break;
case RIGHT: status = BranchState.ReadyToMerge; break;
case ReadyToMerge: //
break;
case RIGHT:
status = BranchState.ReadyToMerge;
break;
case ReadyToMerge: //
}
}

@Override
public boolean isBranch() {
return true;
Expand Down
Loading