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: * Atomic constraint.
15: *
16: * @author Daniel Bonniot
17: */
18:
19: public abstract class AtomicConstraint {
20: abstract void enter() throws TypingEx;
21:
22: /**
23: * Perform type symbol substitution inside the constraint.
24: *
25: * Does not need to create a new object, but must not
26: * imperatively modify the constraint.
27: *
28: * @param map a map from TypeSymbols to TypeSymbols
29: * @return an atomic constraint with substitution performed
30: */
31: abstract AtomicConstraint substitute(java.util.Map map);
32:
33: final public static AtomicConstraint[] substitute(
34: java.util.Map map, AtomicConstraint[] atoms) {
35: if (atoms == null)
36: return null;
37:
38: AtomicConstraint[] res = new AtomicConstraint[atoms.length];
39: for (int i = atoms.length - 1; i >= 0; i--)
40: res[i] = atoms[i].substitute(map);
41: return res;
42: }
43: }
|