KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > GlobalOptions


1 /* GlobalOptions Copyright (C) 1999-2002 Jochen Hoenicke.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; see the file COPYING.LESSER. If not, write to
15  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: GlobalOptions.java.in,v 4.3.2.2 2002/05/28 17:33:58 hoenicke Exp $
18  */

19
20 package jode;
21 import java.io.PrintWriter JavaDoc;
22 import java.util.StringTokenizer JavaDoc;
23
24 public class GlobalOptions {
25     public final static String JavaDoc version = "1.1.2-pre1";
26     public final static String JavaDoc email = "jochen@gnu.org";
27     public final static String JavaDoc copyright =
28     "Jode (c) 1998-2001 Jochen Hoenicke <"+email+">";
29     public final static String JavaDoc URL = "http://jode.sourceforge.net/";
30
31     public static PrintWriter JavaDoc err = new PrintWriter JavaDoc(System.err, true);
32     public static int verboseLevel = 0;
33     public static int debuggingFlags = 0;
34
35     public static final int DEBUG_BYTECODE = 0x001;
36     public static final int DEBUG_VERIFIER = 0x002;
37     public static final int DEBUG_TYPES = 0x004;
38     public static final int DEBUG_FLOW = 0x008;
39     public static final int DEBUG_INOUT = 0x010;
40     public static final int DEBUG_ANALYZE = 0x020;
41     public static final int DEBUG_LVT = 0x040;
42     public static final int DEBUG_CHECK = 0x080;
43     public static final int DEBUG_LOCALS = 0x100;
44     public static final int DEBUG_CONSTRS = 0x200;
45     public static final int DEBUG_INTERPRT = 0x400;
46
47     public static final String JavaDoc[] debuggingNames = {
48     "bytecode", "verifier", "types", "flow",
49     "inout", "analyze", "lvt", "check", "locals",
50     "constructors", "interpreter"
51     };
52
53     public static void usageDebugging() {
54     err.println("Debugging option: --debug=flag1,flag2,...");
55     err.println("possible flags:");
56     err.println(" bytecode " +
57             "show bytecode, as it is read from class file.");
58     err.println(" verifier " +
59             "show result of bytecode verification.");
60     err.println(" types " +
61             "show type intersections");
62     err.println(" flow " +
63             "show flow block merging.");
64     err.println(" analyze " +
65             "show T1/T2 analyzation of flow blocks.");
66     err.println(" inout " +
67             "show in/out set analysis.");
68     err.println(" lvt " +
69             "dump LocalVariableTable.");
70     err.println(" check " +
71             "do time consuming sanity checks.");
72     err.println(" locals " +
73             "dump local merging information.");
74     err.println(" constructors " +
75             "dump constructor simplification.");
76     err.println(" interpreter " +
77             "debug execution of interpreter.");
78     System.exit(0);
79     }
80     
81     /**
82      * Parse the argument given to the debugging flag.
83      * @return true, if the argument parsed without problems.
84      */

85     public static boolean setDebugging(String JavaDoc debuggingString) {
86     if (debuggingString.length() == 0 || debuggingString.equals("help")) {
87         usageDebugging();
88         return false;
89     }
90
91     StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(debuggingString, ",");
92     next_token:
93     while (st.hasMoreTokens()) {
94         String JavaDoc token = st.nextToken().intern();
95         for (int i=0; i<debuggingNames.length; i++) {
96         if (token == debuggingNames[i]) {
97             debuggingFlags |= 1 << i;
98             continue next_token;
99         }
100         }
101         err.println("Illegal debugging flag: "+token);
102         return false;
103     }
104     return true;
105     }
106 }
107
Popular Tags