Skip to content

Commit 35477ef

Browse files
authored
Merge branch 'master' into feature/variable-renaming
2 parents 5da3143 + f5e9d8f commit 35477ef

File tree

24 files changed

+2481
-1645
lines changed

24 files changed

+2481
-1645
lines changed

META-INF/RASCAL.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Project-Name: JimpleFramework
44
Courses: courses
55
Main-Module: Plugin
66
Source: src/main/rascal,src/test/rascal
7+
Require-Libraries: |lib://rascal_eclipse|

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,20 @@ A Rascal implementation of the Jimple framework. The current version supports:
77
* parsing Java Byte Code into a JIMPLE representation.
88
* JIMPLE code optmization constructs.
99
* a framework for dataflow analysis.
10-
10+
11+
### Requirements
12+
13+
* Java ?
14+
* Maven
15+
* Rascal
16+
* Eclipse IDE
17+
* Lombok
18+
19+
### Setting up your requirements
20+
21+
1. Make sure Eclipse is running on Java ?. Also, you need to setup your PATH to use Java ? when using Maven.
22+
2. Install Lombok into Eclipse IDE. https://projectlombok.org/setup/eclipse
23+
24+
### Installation Procedure
25+
1126

pom.xml

Lines changed: 89 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,89 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" path="src/main/java"/>
4-
<classpathentry kind="src" path="src/main/rascal"/>
5-
<classpathentry kind="src" path="src/test/java"/>
6-
<classpathentry kind="src" path="src/test/rascal"/>
7-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
8-
<attributes>
9-
<attribute name="maven.pomderived" value="true"/>
10-
</attributes>
11-
</classpathentry>
12-
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
13-
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
14-
<attributes>
15-
<attribute name="maven.pomderived" value="true"/>
16-
</attributes>
17-
</classpathentry>
18-
<classpathentry kind="output" path="target/classes"/>
19-
</classpath>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>br.unb.cic</groupId>
6+
<artifactId>JimpleFramework</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
9+
<repositories>
10+
<repository>
11+
<id>usethesource</id>
12+
<name>your custom repo</name>
13+
<url>https://nexus.usethesource.io/content/repositories/public/</url>
14+
</repository>
15+
</repositories>
16+
17+
<pluginRepositories>
18+
<pluginRepository>
19+
<id>usethesource</id>
20+
<url>https://nexus.usethesource.io/content/repositories/public/</url>
21+
</pluginRepository>
22+
</pluginRepositories>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.rascalmpl</groupId>
27+
<artifactId>rascal</artifactId>
28+
<version>0.18.0</version>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>junit</groupId>
33+
<artifactId>junit</artifactId>
34+
<version>4.13.1</version>
35+
<scope>test</scope>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.projectlombok</groupId>
40+
<artifactId>lombok</artifactId>
41+
<version>1.18.12</version>
42+
<scope>provided</scope>
43+
</dependency>
44+
45+
</dependencies>
46+
<build>
47+
<sourceDirectory>src/main/java</sourceDirectory>
48+
<testSourceDirectory>src/test/java</testSourceDirectory>
49+
<plugins>
50+
<plugin>
51+
<artifactId>maven-compiler-plugin</artifactId>
52+
<version>3.7.0</version>
53+
<configuration>
54+
<source>1.8</source>
55+
<target>1.8</target>
56+
</configuration>
57+
</plugin>
58+
59+
<plugin>
60+
<groupId>org.rascalmpl</groupId>
61+
<artifactId>rascal-maven-plugin</artifactId>
62+
<version>0.3.4</version>
63+
<configuration>
64+
<bin>${project.build.outputDirectory}</bin>
65+
<errorsAsWarnings>true</errorsAsWarnings>
66+
<enableStandardLibrary>true</enableStandardLibrary>
67+
<srcs>
68+
<src>${project.basedir}/src/main/rascal</src>
69+
</srcs>
70+
<srcIgnores>
71+
<ignore>${project.basedir}/src/main/rascal/lang/jimple/toolkit/GraphUtil.rsc</ignore>
72+
<ignore>${project.basedir}/src/main/rascal/lang/jimple/toolkit/CallGraph.rsc</ignore>
73+
</srcIgnores>
74+
</configuration>
75+
<executions>
76+
<execution>
77+
<id>it-compile</id>
78+
<phase>compile</phase>
79+
<goals>
80+
<goal>compile</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
86+
</plugins>
87+
</build>
88+
89+
</project>
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package lang.jimple.internal;
2+
3+
import java.util.ArrayList;
4+
import java.util.Collection;
5+
import java.util.List;
6+
7+
import lang.jimple.internal.generated.Expression;
8+
import lang.jimple.internal.generated.Statement;
9+
10+
public class BranchInstructionFlow implements InstructionFlow {
11+
12+
private Environment left;
13+
private Environment right;
14+
15+
private Expression condition;
16+
17+
private String targetStatement;
18+
private String mergeStatement;
19+
20+
private BranchState status;
21+
22+
private Statement gotoMergeStmt;
23+
24+
enum BranchState {
25+
LEFT,
26+
RIGHT,
27+
ReadyToMerge
28+
}
29+
30+
public BranchInstructionFlow(Expression condition, String target) {
31+
this.condition = condition;
32+
this.targetStatement = target;
33+
left = new Environment();
34+
right = new Environment();
35+
status = BranchState.LEFT;
36+
}
37+
38+
39+
@Override
40+
public Collection<Statement> merge() {
41+
List<Statement> res = new ArrayList<>();
42+
43+
res.add(Statement.ifStmt(condition, targetStatement));
44+
res.addAll(left.instructions);
45+
46+
if(gotoMergeStmt != null) {
47+
res.add(gotoMergeStmt);
48+
}
49+
50+
res.add(Statement.label(targetStatement));
51+
res.addAll(right.instructions);
52+
53+
if(mergeStatement != null) {
54+
res.add(Statement.label(mergeStatement));
55+
}
56+
57+
return res;
58+
}
59+
60+
@Override
61+
public boolean matchMergePoint(String label) {
62+
if(status.equals(BranchState.LEFT)) {
63+
return this.targetStatement.equals(label);
64+
}
65+
else if(status.equals(BranchState.RIGHT)) {
66+
return this.mergeStatement.equals(label);
67+
}
68+
return false;
69+
}
70+
71+
@Override
72+
public List<Environment> environments() {
73+
List<Environment> res = new ArrayList<>();
74+
switch(status) {
75+
case LEFT: res.add(left); break;
76+
case RIGHT: res.add(right); break;
77+
case ReadyToMerge:
78+
if(mergeStatement != null) {
79+
res.add(left);
80+
res.add(right);
81+
}
82+
else {
83+
res.add(left);
84+
}
85+
}
86+
return res;
87+
}
88+
89+
@Override
90+
public void notifyGotoStmt(Statement stmt, String label) {
91+
if(status.equals(BranchState.LEFT)) {
92+
mergeStatement = label;
93+
gotoMergeStmt = stmt;
94+
}
95+
else if(status.equals(BranchState.RIGHT)) {
96+
right.instructions.add(stmt);
97+
}
98+
else if(status.equals(BranchState.ReadyToMerge)) {
99+
left.instructions.add(stmt);
100+
right.instructions.add(stmt);
101+
}
102+
}
103+
104+
@Override
105+
public void nextBranch() {
106+
switch(status) {
107+
case LEFT:
108+
if(mergeStatement != null) {
109+
status = BranchState.RIGHT;
110+
}
111+
else {
112+
left.instructions.add(Statement.label(targetStatement));
113+
status = BranchState.ReadyToMerge;
114+
}
115+
break;
116+
case RIGHT: status = BranchState.ReadyToMerge; break;
117+
case ReadyToMerge: //
118+
}
119+
}
120+
121+
@Override
122+
public boolean isBranch() {
123+
return true;
124+
}
125+
126+
@Override
127+
public boolean readyToMerge(String label) {
128+
return status.equals(BranchState.ReadyToMerge);
129+
}
130+
}

0 commit comments

Comments
 (0)