KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > toolkits > base > AST > transformations > ExtraLabelNamesRemover


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2005 Nomair A. Naeem
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot.dava.toolkits.base.AST.transformations;
21
22 import soot.dava.toolkits.base.AST.analysis.*;
23
24 public class ExtraLabelNamesRemover extends DepthFirstAdapter{
25
26     /*
27       label_0:
28       while(cond){
29          if(cond1) NO NEED for break label_0
30         break label_0 Use just break;
31       }
32
33       label_0:
34       switch(cond){
35           case 0:
36             Body
37         break label_0; NO NEED for break label_0
38       case 1: Use just break
39             Body
40         break label_0;
41
42        IDEA: In gerneral store the current label name
43        Go through the tree rooted at this label name and find all breaks
44        if any break targets the current label name and not some previous
45        one the label name can be removed from the break statement since it
46        is the most recent break....TEST IT ON CASES AND SEE IF THIS IS TRUE
47        THE JAVA LANGUAGE SAYS IT SHOULD BE TRUE
48
49     */

50     public ExtraLabelNamesRemover(){
51     }
52
53     public ExtraLabelNamesRemover(boolean verbose){
54     super(verbose);
55     }
56
57
58 }
Popular Tags