01: /**************************************************************************/
02: /* N I C E */
03: /* A high-level object-oriented research language */
04: /* (c) Daniel Bonniot 2002 */
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: A monotype's head is less than a type constructor.
15:
16: @version $Date: 2002/12/10 01:52:16 $
17: @author Daniel Bonniot (bonniot@users.sourceforge.net)
18: */
19:
20: public class MonotypeLeqTcCst extends AtomicConstraint {
21: public MonotypeLeqTcCst(Monotype m, TypeConstructor tc) {
22: this .m = m;
23: this .tc = tc;
24: }
25:
26: public final Monotype m;
27: private final TypeConstructor tc;
28:
29: /**
30: * Perform type symbol substitution inside the constraint.
31: *
32: * Does not need to create a new object, but must not
33: * imperatively modify the constraint.
34: *
35: * @param map a map from TypeSymbols to TypeSymbols
36: * @return an atomic constraint with substitution performed
37: */
38: AtomicConstraint substitute(java.util.Map map) {
39: Monotype new1 = m.substitute(map);
40: TypeConstructor new2 = (TypeConstructor) map.get(tc);
41: if (new2 == null)
42: new2 = tc;
43:
44: if (new1 == m && new2 == tc)
45: return this ;
46:
47: return new MonotypeLeqTcCst(new1, new2);
48: }
49:
50: void enter() throws TypingEx {
51: Typing.leq(m, tc);
52: }
53:
54: /****************************************************************
55: * Printing
56: ****************************************************************/
57:
58: public String toString() {
59: return m + " < " + tc;
60: }
61: }
|