01: /**************************************************************************/
02: /* B O S S A */
03: /* A simple imperative object-oriented research language */
04: /* (c) Daniel Bonniot 1999 */
05: /* */
06: /* This program is free software; you can redistribute it and/or modify */
07: /* it under the terms of the GNU General Public License as published by */
08: /* the Free Software Foundation; either version 2 of the License, or */
09: /* (at your option) any later version. */
10: /* */
11: /**************************************************************************/package bossa.util;
12:
13: import bossa.util.*;
14: import java.util.*;
15: import java.io.*;
16:
17: /**
18: * Static class for debug output.
19: *
20: * @author bonniot
21: */
22:
23: public abstract class Debug {
24: public static void println(String msg) {
25: System.out.println(msg);
26: }
27:
28: public static void print(String msg) {
29: System.out.print(msg);
30: }
31:
32: final private static Properties props;
33: static {
34: props = new Properties();
35: try {
36: File f = new File(System.getProperty("user.home"),
37: ".nice.conf");
38:
39: FileInputStream in = new FileInputStream(f);
40: props.load(new BufferedInputStream(in));
41: in.close();
42: } catch (Exception e) {
43: //Debug.println("Can't read "+f);
44: }
45: }
46:
47: public static boolean getBoolean(String name, boolean defaultValue) {
48: String value = props.getProperty(name);
49: if (value == null)
50: return defaultValue;
51: else
52: return value.equals("true");
53: }
54:
55: public static String getProperty(String name, String def) {
56: String res = props.getProperty(name, null);
57: if (res == null)
58: res = System.getProperty(name, def);
59:
60: return res;
61: }
62:
63: public static final boolean resolution = getBoolean(
64: "debug.resolution", false),
65: K0 = getBoolean("debug.K0", false),
66: typing = getBoolean("debug.typing", false),
67: engine = getBoolean("debug.engine", false),
68: modules = getBoolean("debug.modules", false),
69: IDs = getBoolean("debug.IDs", false),
70: overloading = getBoolean("debug.overloading", false),
71: powerUser = getBoolean("debug.powerUser", false),
72: bytecodeAttributes = getBoolean("debug.bytecodeAttributes",
73: false),
74: codeGeneration = getBoolean("debug.codeGeneration", false),
75: javaTypes = getBoolean("debug.javaTypes", false),
76: linkTests = getBoolean("debug.linkTests", false),
77: passes = getBoolean("debug.passes", false),
78:
79: alwaysDumpStack = getBoolean("debug.alwaysDumpStack", false),
80: ignorePrelude = getBoolean("debug.ignorePrelude", false),
81: noSimplify = getBoolean("debug.noSimplify", false);
82:
83: public static final String defaultFile = props.getProperty(
84: "debug.defaultFile", null);
85: }
|