01: // Copyright (C) 2002, 2003 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.kawa.xml;
05:
06: import gnu.lists.*;
07: import gnu.bytecode.*;
08: import gnu.expr.*;
09: import gnu.math.IntNum;
10:
11: /** This is only used for XSLT, which should be fixed. */
12:
13: public final class Focus extends TreePosition {
14: /* #ifdef JAVA2 */
15: static ThreadLocal current = new ThreadLocal();
16:
17: /* #endif */
18: /* #ifndef JAVA2 */
19: // static Focus current = new Focus();
20: /* #endif */
21:
22: public static Focus getCurrent() {
23: /* #ifdef JAVA2 */
24: Object obj = current.get();
25: if (obj == null) {
26: obj = new Focus();
27: current.set(obj);
28: }
29: return (Focus) obj;
30: /* #endif */
31: /* #ifndef JAVA2 */
32: // return current;
33: /* #endif */
34: }
35:
36: public long position;
37: IntNum contextPosition;
38:
39: public static void compileGetCurrent(Compilation comp) {
40: // FIXME This should be optimized so it only done once per method.
41: CodeAttr code = comp.getCode();
42: code.emitInvoke(getCurrentFocusMethod);
43: }
44:
45: public static final ClassType TYPE = ClassType
46: .make("gnu.kawa.xml.Focus");
47: static final Method getCurrentFocusMethod = TYPE.getDeclaredMethod(
48: "getCurrent", 0);
49: }
|