@@ -31,10 +31,6 @@ public Node buildCFG(){
3131 //if is not the last node
3232 if (i != graph .size ()-2 ){
3333 Node aux = graph .get (i +1 );
34- System .out .println (i );
35- if (aux ==null ){
36- System .out .println ("null" );
37- }
3834 n .addNext (aux );
3935 }
4036 }
@@ -48,7 +44,7 @@ public Node buildCFG(){
4844 }
4945 else {
5046 int numLabel = labelNode .get (strAux .get (j ));
51- n .addNext (graph .get (numLabel ));
47+ n .addNext (graph .get (numLabel ));
5248 }
5349
5450 }
@@ -72,6 +68,10 @@ public void buildNodes(){
7268 //save label and its number
7369 labelNode .put (l .getName (), i );
7470 }
71+ //the label can be in one line but actually represents the next one
72+ else {
73+ labelNode .put (l .getName (),i +1 );
74+ }
7575 }
7676
7777 }
@@ -89,7 +89,7 @@ public void buildNodes(){
8989 }
9090 graph .add (n );
9191 }
92- System .out .println ("Graph without flow:" );
92+ System .out .println ("\n Graph without flow:" );
9393 printGraph ();
9494 System .out .println ();
9595 }
@@ -98,17 +98,19 @@ public void printGraph(){
9898 for (int i = 0 ; i < graph .size (); i ++) {
9999
100100 Node n = graph .get (i );
101- System .out .print (i +" " );
102- System .out .println (n .getInstr ().toString ());
103- /*List<Node> listN = n.nextNode();
104- if(listN!=null){
105- System.out.println("Nexts:");
101+ System .out .print (n .getNum ()+ " " );
102+ System .out .println (n .getInstr ().toString ());
103+ List <Node > listN = n .nextNode ();
104+ if (listN .size ()!=0 ){
105+
106+ System .out .println ("Nexts:" );
106107 for (int j = 0 ; j < listN .size (); j ++) {
107- System.out.println(listN.get(i).getInstr().toString());
108+ System .out .print (listN .get (j ).getNum ()+ " " );
109+ System .out .println (listN .get (j ).getInstr ().toString ());
108110
109111 }
110112 }
111- */
113+
112114
113115 }
114116
0 commit comments