summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boil/tests/ex36.java15
-rw-r--r--boil/tests/ex37.java20
-rw-r--r--boil/tests/ex38.java20
-rw-r--r--boil/tests/ex39.java12
-rw-r--r--boil/tests/ex40.java19
-rw-r--r--boil/tests/ex41.java25
-rw-r--r--boil/tests/ex42.java26
-rw-r--r--vaporize/library/CFGNode.java48
8 files changed, 185 insertions, 0 deletions
diff --git a/boil/tests/ex36.java b/boil/tests/ex36.java
new file mode 100644
index 0000000..333bd7d
--- /dev/null
+++ b/boil/tests/ex36.java
@@ -0,0 +1,15 @@
+class ex36{
+ public static void main(String[] a){
+ Fac b ;
+ b = new Fac() ;
+ System.out.println(b.ComputeFac(10));
+ }
+}
+
+class Fac {
+ public int ComputeFac(int num){
+ int num_aux ;
+ num_aux = 4 ;
+ return num_aux ;
+ }
+}
diff --git a/boil/tests/ex37.java b/boil/tests/ex37.java
new file mode 100644
index 0000000..867116a
--- /dev/null
+++ b/boil/tests/ex37.java
@@ -0,0 +1,20 @@
+class ex37 {
+ public static void main(String[] z) {
+ A a ;
+ a = new A() ;
+ System.out.println(a.foo()) ;
+ }
+}
+
+class A {
+
+ public int foo() {
+ int v ;
+ v = 0 ;
+ while (v < 10) {
+ v = v + 1 ;
+ }
+ return v ;
+ }
+
+}
diff --git a/boil/tests/ex38.java b/boil/tests/ex38.java
new file mode 100644
index 0000000..2a021eb
--- /dev/null
+++ b/boil/tests/ex38.java
@@ -0,0 +1,20 @@
+class ex38 {
+ public static void main(String[] z) {
+ A a ;
+ a = new A() ;
+ System.out.println(a.foo()) ;
+ }
+}
+
+class A {
+
+ public int foo() {
+ int v ;
+ v = 0 ;
+ while (v < 10) {
+ v = v + 1 ;
+ }
+ return v ;
+ }
+
+}
diff --git a/boil/tests/ex39.java b/boil/tests/ex39.java
new file mode 100644
index 0000000..23526de
--- /dev/null
+++ b/boil/tests/ex39.java
@@ -0,0 +1,12 @@
+class ex39 {
+ public static void main(String[] z) {
+ int a ;
+ int b ;
+ a = 0 ;
+ b = 2 * a ;
+ b = b + a ;
+ b = b - 1 ;
+ System.out.println(a) ;
+ System.out.println(b) ;
+ }
+}
diff --git a/boil/tests/ex40.java b/boil/tests/ex40.java
new file mode 100644
index 0000000..f2f121d
--- /dev/null
+++ b/boil/tests/ex40.java
@@ -0,0 +1,19 @@
+class ex40 {
+ public static void main(String[] z) {
+ A a ;
+ a = new A() ;
+ System.out.println(a.add_two(12)) ;
+ }
+}
+
+class A {
+
+ int c ;
+
+ public int add_two(int b) {
+ c = 2 ;
+ b = b + c ;
+ return b ;
+ }
+
+}
diff --git a/boil/tests/ex41.java b/boil/tests/ex41.java
new file mode 100644
index 0000000..e07e962
--- /dev/null
+++ b/boil/tests/ex41.java
@@ -0,0 +1,25 @@
+class ex41 {
+ public static void main(String[] z) {
+ A a ;
+ a = new A() ;
+ System.out.println(a.foo()) ;
+ }
+}
+
+class A {
+
+ public int foo() {
+ int v ;
+ int w ;
+ v = 0 ;
+ w = 0 ;
+ while (v < 10) {
+ while (w < 100) {
+ w = w + 1 ;
+ }
+ v = v + 1 ;
+ }
+ return w ;
+ }
+
+}
diff --git a/boil/tests/ex42.java b/boil/tests/ex42.java
new file mode 100644
index 0000000..05af17a
--- /dev/null
+++ b/boil/tests/ex42.java
@@ -0,0 +1,26 @@
+class ex42 {
+ public static void main(String[] z) {
+ A a ;
+ a = new A() ;
+ System.out.println(a.Init()) ;
+ }
+}
+
+class A {
+
+ int age ;
+ int Salary ;
+ boolean Married ;
+ int weight ;
+ int height ;
+
+ public Boolean Init(int v_age, int v_Salary, boolean v_Married, int v_weight, int v_height) {
+ age = v_age ;
+ Salary = v_Salary ;
+ Married = v_Married ;
+ weight = v_weight ;
+ height = v_height ;
+ return true ;
+ }
+
+}
diff --git a/vaporize/library/CFGNode.java b/vaporize/library/CFGNode.java
new file mode 100644
index 0000000..ca60856
--- /dev/null
+++ b/vaporize/library/CFGNode.java
@@ -0,0 +1,48 @@
+package vaporize.library;
+
+import cs132.vapor.ast.*;
+import java.util.ArrayList;
+
+class CFGNode {
+
+ private Node instruction;
+ private ArrayList<CFGNode> sources;
+ private ArrayList<CFGNode> dests;
+ private int line;
+
+ protected CFGNode(Node instruction) {
+ this.instruction = instruction;
+ this.sources = new ArrayList<>();
+ this.dests = new ArrayList<>();
+ this.line = this.instruction.sourcePos.line;
+ }
+
+ public String toString() {
+ return this.instruction.toString();
+ }
+
+ public int hashCode() {
+ return this.line;
+ }
+
+ protected void addSource(CFGNode node) {
+ this.sources.add(node);
+ }
+
+ protected void addDest(CFGNode node) {
+ this.dests.add(node);
+ }
+
+ protected Node getInstruction() {
+ return this.instruction;
+ }
+
+ protected ArrayList<CFGNode> getSources() {
+ return this.sources;
+ }
+
+ protected ArrayList<CFGNode> getDests() {
+ return this.dests;
+ }
+
+}