01: // Copyright (c) 2001 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.expr;
05:
06: import gnu.bytecode.*;
07:
08: // Should be moved to some other package? FIXME
09:
10: /** A class type implemented as a pair of an interface and a class.
11: * This is how true multiple inheritance can be implemented.
12: */
13:
14: public class PairClassType extends ClassType {
15: // FIXME should probably inherit from ObjectType or even Type
16: // rather than ClassType, and have an interfaceType field,
17: // which getImplementationType would return
18: /*
19: public ClassType interfaceType;
20: public Type getImplementationType()
21: {
22: return interfaceType;
23: }
24: String name;
25: */
26:
27: Object staticLink;
28:
29: public ClassType instanceType;
30:
31: public PairClassType() {
32: }
33:
34: PairClassType(Class reflectInterface, Class reflectInstanceClass) {
35: super (reflectInterface.getName());
36: setExisting(true);
37: reflectClass = reflectInterface;
38: Type.registerTypeForClass(reflectInterface, this );
39: this .instanceType = (ClassType) Type.make(reflectInstanceClass);
40: }
41:
42: public static PairClassType make(Class reflectInterface,
43: Class reflectInstanceClass) {
44: return new PairClassType(reflectInterface, reflectInstanceClass);
45: }
46:
47: public static PairClassType make(Class reflectInterface,
48: Class reflectInstanceClass, Object staticLink) {
49: PairClassType type = new PairClassType(reflectInterface,
50: reflectInstanceClass);
51: type.staticLink = staticLink;
52: return type;
53: }
54:
55: public Object getStaticLink() {
56: return staticLink;
57: }
58:
59: /** This method is called from compiled code. */
60: public static Object extractStaticLink(ClassType type) {
61: return ((PairClassType) type).staticLink;
62: }
63: }
|