01: /**************************************************************************/
02: /* N I C E */
03: /* A high-level object-oriented research language */
04: /* (c) Daniel Bonniot 2003 */
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: import mlsub.typing.lowlevel.Kind;
14: import mlsub.typing.lowlevel.Element;
15:
16: /**
17: A monotype greater than all others.
18:
19: @author Daniel Bonniot (bonniot@users.sourceforge.net)
20: */
21:
22: public class TopMonotype extends Monotype implements TypeSymbol {
23: private TopMonotype() {
24: }
25:
26: public static final TopMonotype instance = new TopMonotype();
27:
28: public TypeSymbol cloneTypeSymbol() {
29: return this ;
30: }
31:
32: Monotype canonify() {
33: return this ;
34: }
35:
36: Monotype substitute(java.util.Map map) {
37: return this ;
38: }
39:
40: void tag(int variance) {
41: }
42:
43: public String toString() {
44: return "Object";
45: }
46:
47: /****************************************************************
48: * low-level interface
49: ****************************************************************/
50:
51: public int getId() {
52: throw new Error();
53: }
54:
55: public void setId(int value) {
56: throw new Error();
57: }
58:
59: public Kind getKind() {
60: return TopKind.instance;
61: }
62:
63: public void setKind(Kind value) {
64: throw new Error();
65: }
66:
67: /****************************************************************
68: * The Top kind
69: ****************************************************************/
70:
71: public static class TopKind implements Kind {
72: private TopKind() {
73: }
74:
75: public static final TopKind instance = new TopKind();
76:
77: public void leq(Element e1, Element e2, boolean initial) {
78: // Nothing to do.
79: }
80:
81: public void leq(Element e1, Element e2) {
82: // Nothing to do.
83: }
84:
85: public void register(Element e) {
86: // Nothing to do.
87: }
88:
89: public Monotype freshMonotype(boolean existential) {
90: return null;
91: }
92: }
93: }
|