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 mlsub.typing;
12:
13: /**
14: * Structural interface.
15: *
16: * @author Daniel Bonniot
17: */
18:
19: public final class Interface implements TypeSymbol {
20: /**
21: Creates a new interface in the given variance.
22: The interface is introduced in the rigid context.
23: */
24: public Interface(Variance variance) {
25: this .variance = variance;
26: itf = variance.newInterface(this );
27: }
28:
29: /**
30: @param associatedTC a type constructor linked to this interface
31: (should this go outside mlsub.typing?)
32: */
33: public Interface(Variance variance, TypeConstructor associatedTC) {
34: this (variance);
35: this .associatedTC = associatedTC;
36: }
37:
38: /**
39: @param name the name of the interface
40: */
41: public Interface(Variance variance, String name) {
42: this (variance);
43: this .name = name;
44: if (bossa.util.Debug.engine)
45: Debug.println(this + " has ID " + itf);
46: }
47:
48: public TypeSymbol cloneTypeSymbol() {
49: return new Interface(variance, associatedTC);
50: }
51:
52: public TypeConstructor associatedTC() {
53: return associatedTC;
54: }
55:
56: public String toString() {
57: if (associatedTC != null)
58: return associatedTC.toString();
59: else if (name != null)
60: return name;
61: else
62: return super .toString();
63: }
64:
65: int itf; // lowlevel interface
66: Variance variance;
67: private TypeConstructor associatedTC;
68:
69: /** Can be set for debugging reasons */
70: public String name;
71: }
|