001: /* GlobalOptions Copyright (C) 1999-2002 Jochen Hoenicke.
002: *
003: * This program is free software; you can redistribute it and/or modify
004: * it under the terms of the GNU Lesser General Public License as published by
005: * the Free Software Foundation; either version 2, or (at your option)
006: * any later version.
007: *
008: * This program is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: * GNU General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public License
014: * along with this program; see the file COPYING.LESSER. If not, write to
015: * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
016: *
017: * $Id: GlobalOptions.java.in,v 4.3.2.2 2002/05/28 17:33:58 hoenicke Exp $
018: */
019:
020: package jode;
021:
022: import java.io.PrintWriter;
023: import java.util.StringTokenizer;
024:
025: public class GlobalOptions {
026: public final static String version = "1.1.2-pre1";
027: public final static String email = "jochen@gnu.org";
028: public final static String copyright = "Jode (c) 1998-2001 Jochen Hoenicke <"
029: + email + ">";
030: public final static String URL = "http://jode.sourceforge.net/";
031:
032: public static PrintWriter err = new PrintWriter(System.err, true);
033: public static int verboseLevel = 0;
034: public static int debuggingFlags = 0;
035:
036: public static final int DEBUG_BYTECODE = 0x001;
037: public static final int DEBUG_VERIFIER = 0x002;
038: public static final int DEBUG_TYPES = 0x004;
039: public static final int DEBUG_FLOW = 0x008;
040: public static final int DEBUG_INOUT = 0x010;
041: public static final int DEBUG_ANALYZE = 0x020;
042: public static final int DEBUG_LVT = 0x040;
043: public static final int DEBUG_CHECK = 0x080;
044: public static final int DEBUG_LOCALS = 0x100;
045: public static final int DEBUG_CONSTRS = 0x200;
046: public static final int DEBUG_INTERPRT = 0x400;
047:
048: public static final String[] debuggingNames = { "bytecode",
049: "verifier", "types", "flow", "inout", "analyze", "lvt",
050: "check", "locals", "constructors", "interpreter" };
051:
052: public static void usageDebugging() {
053: err.println("Debugging option: --debug=flag1,flag2,...");
054: err.println("possible flags:");
055: err.println(" bytecode "
056: + "show bytecode, as it is read from class file.");
057: err.println(" verifier "
058: + "show result of bytecode verification.");
059: err.println(" types " + "show type intersections");
060: err.println(" flow " + "show flow block merging.");
061: err.println(" analyze "
062: + "show T1/T2 analyzation of flow blocks.");
063: err.println(" inout " + "show in/out set analysis.");
064: err.println(" lvt " + "dump LocalVariableTable.");
065: err.println(" check "
066: + "do time consuming sanity checks.");
067: err.println(" locals "
068: + "dump local merging information.");
069: err.println(" constructors "
070: + "dump constructor simplification.");
071: err.println(" interpreter "
072: + "debug execution of interpreter.");
073: System.exit(0);
074: }
075:
076: /**
077: * Parse the argument given to the debugging flag.
078: * @return true, if the argument parsed without problems.
079: */
080: public static boolean setDebugging(String debuggingString) {
081: if (debuggingString.length() == 0
082: || debuggingString.equals("help")) {
083: usageDebugging();
084: return false;
085: }
086:
087: StringTokenizer st = new StringTokenizer(debuggingString, ",");
088: next_token: while (st.hasMoreTokens()) {
089: String token = st.nextToken().intern();
090: for (int i = 0; i < debuggingNames.length; i++) {
091: if (token == debuggingNames[i]) {
092: debuggingFlags |= 1 << i;
093: continue next_token;
094: }
095: }
096: err.println("Illegal debugging flag: " + token);
097: return false;
098: }
099: return true;
100: }
101: }
|