01: /**************************************************************************/
02: /* N I C E */
03: /* A high-level object-oriented research language */
04: /* (c) Daniel Bonniot 2004 */
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.syntax;
12:
13: public final class NiceUtils {
14: public static gnu.expr.Expression doInline(
15: gnu.mapping.Procedure1 proc) {
16: return nice.tools.code.Inline.inline(proc);
17: }
18:
19: public static gnu.expr.Expression doInline(
20: gnu.mapping.Procedure1 proc, gnu.expr.Expression arg1) {
21: return nice.tools.code.Inline.inline(proc, arg1);
22: }
23:
24: public static gnu.expr.Expression doInline(
25: gnu.mapping.Procedure2 proc, gnu.expr.Expression arg1,
26: gnu.expr.Expression arg2) {
27: return nice.tools.code.Inline.inline(proc, arg1, arg2);
28: }
29:
30: public static gnu.mapping.Procedure getThrowInstance() {
31: return nice.lang.inline.Throw.instance;
32: }
33:
34: static ClassLoader inlineLoader;
35:
36: static {
37: String inlinedMethodsRepository = System
38: .getProperty("nice.inlined");
39: if (inlinedMethodsRepository != null) {
40: inlineLoader = new nice.tools.util.DirectoryClassLoader(
41: new java.io.File[] { new java.io.File(
42: inlinedMethodsRepository) }, null) {
43: protected Class loadClass(String name, boolean resolve)
44: throws ClassNotFoundException {
45: /* Change the default behviour, which is to look up the
46: parent classloader first. Instead, look it up after this one,
47: so that the inlined methods are found here, but the
48: interfaces they implement are found in the system classloader,
49: so that the casts for using them succeed.
50: */
51: Class res = findLoadedClass(name);
52:
53: if (res == null)
54: try {
55: res = this .findClass(name);
56: } catch (ClassNotFoundException ex) {
57: }
58:
59: if (res == null) {
60: ClassLoader parent = getParent();
61: // A JVM may represent the system classloader by null.
62: if (parent == null)
63: parent = ClassLoader.getSystemClassLoader();
64: res = parent.loadClass(name);
65: }
66:
67: if (resolve && res != null)
68: resolveClass(res);
69:
70: return res;
71: }
72: };
73: }
74: }
75:
76: }
|