-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/variable-renaming
- Loading branch information
Showing
24 changed files
with
2,481 additions
and
1,645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,89 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="src" path="src/main/rascal"/> | ||
<classpathentry kind="src" path="src/test/java"/> | ||
<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"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>br.unb.cic</groupId> | ||
<artifactId>JimpleFramework</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<repositories> | ||
<repository> | ||
<id>usethesource</id> | ||
<name>your custom repo</name> | ||
<url>https://nexus.usethesource.io/content/repositories/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>usethesource</id> | ||
<url>https://nexus.usethesource.io/content/repositories/public/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.rascalmpl</groupId> | ||
<artifactId>rascal</artifactId> | ||
<version>0.18.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.18.12</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
<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> | ||
</build> | ||
|
||
</project> |
130 changes: 130 additions & 0 deletions
130
src/main/java/lang/jimple/internal/BranchInstructionFlow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package lang.jimple.internal; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import lang.jimple.internal.generated.Expression; | ||
import lang.jimple.internal.generated.Statement; | ||
|
||
public class BranchInstructionFlow implements InstructionFlow { | ||
|
||
private Environment left; | ||
private Environment right; | ||
|
||
private Expression condition; | ||
|
||
private String targetStatement; | ||
private String mergeStatement; | ||
|
||
private BranchState status; | ||
|
||
private Statement gotoMergeStmt; | ||
|
||
enum BranchState { | ||
LEFT, | ||
RIGHT, | ||
ReadyToMerge | ||
} | ||
|
||
public BranchInstructionFlow(Expression condition, String target) { | ||
this.condition = condition; | ||
this.targetStatement = target; | ||
left = new Environment(); | ||
right = new Environment(); | ||
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) { | ||
res.add(gotoMergeStmt); | ||
} | ||
|
||
res.add(Statement.label(targetStatement)); | ||
res.addAll(right.instructions); | ||
|
||
if(mergeStatement != null) { | ||
res.add(Statement.label(mergeStatement)); | ||
} | ||
|
||
return res; | ||
} | ||
|
||
@Override | ||
public boolean matchMergePoint(String label) { | ||
if(status.equals(BranchState.LEFT)) { | ||
return this.targetStatement.equals(label); | ||
} | ||
else if(status.equals(BranchState.RIGHT)) { | ||
return this.mergeStatement.equals(label); | ||
} | ||
return false; | ||
} | ||
|
||
@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); | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
@Override | ||
public void notifyGotoStmt(Statement stmt, String label) { | ||
if(status.equals(BranchState.LEFT)) { | ||
mergeStatement = label; | ||
gotoMergeStmt = stmt; | ||
} | ||
else if(status.equals(BranchState.RIGHT)) { | ||
right.instructions.add(stmt); | ||
} | ||
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) { | ||
status = BranchState.RIGHT; | ||
} | ||
else { | ||
left.instructions.add(Statement.label(targetStatement)); | ||
status = BranchState.ReadyToMerge; | ||
} | ||
break; | ||
case RIGHT: status = BranchState.ReadyToMerge; break; | ||
case ReadyToMerge: // | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isBranch() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean readyToMerge(String label) { | ||
return status.equals(BranchState.ReadyToMerge); | ||
} | ||
} |
Oops, something went wrong.