Thread: [Nice-commit] Nice/src/mlsub/typing Typing.java,1.33,1.34 Polytype.java,1.21,1.22 Domain.java,1.6,1.
Brought to you by:
bonniot
From: <bo...@us...> - 2004-02-26 22:25:54
|
Update of /cvsroot/nice/Nice/src/mlsub/typing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12507/src/mlsub/typing Modified Files: Typing.java Polytype.java Domain.java Log Message: Changed mlsub.typing.Domain so that it contains an array of monotypes instead of a single monotype (which was normally a tuple type). This is more consistent with function types having an array of parameters, more efficient, and it allows for simpler handling of the components of the domain. Index: Typing.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Typing.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Typing.java 15 Jan 2004 12:09:53 -0000 1.33 --- Typing.java 26 Feb 2004 22:17:37 -0000 1.34 *************** *** 328,331 **** --- 328,338 ---- } + public static void leq(Monotype[] ms1, Monotype[] ms2) + throws TypingEx + { + for(int i = 0; i < ms1.length; i++) + leq(ms1[i], ms2[i]); + } + /**************************************************************** * Type constructors *************** *** 389,393 **** Constraint.hasBinders(d2.getConstraint()))) { ! leq(d1.getMonotype(), d2.getMonotype()); return; } --- 396,400 ---- Constraint.hasBinders(d2.getConstraint()))) { ! leq(d1.getMonotypes(), d2.getMonotypes()); return; } *************** *** 400,404 **** Constraint.enter(d2.getConstraint()); ! leq(d1.getMonotype(), d2.getMonotype()); } finally{ --- 407,411 ---- Constraint.enter(d2.getConstraint()); ! leq(d1.getMonotypes(), d2.getMonotypes()); } finally{ *************** *** 408,435 **** /** Test if a polytype is in a domain. */ ! public static void in(Polytype type, Domain domain) throws TypingEx { ! if(dbg) Debug.println(type+" in "+domain); ! ! if(domain == Domain.bot) ! return; Constraint.enter(type.getConstraint()); ! Constraint.enter(domain.getConstraint()); ! leq(type.getMonotype(),domain.getMonotype()); ! } ! ! /** Test if a monotype is in a domain. */ ! public static void in(Monotype type, Domain domain) ! throws TypingEx ! { ! if(dbg) Debug.println(type+" in "+domain); ! ! if(domain == Domain.bot) ! return; ! ! Constraint.enter(domain.getConstraint()); ! leq(type, domain.getMonotype()); } --- 415,425 ---- /** Test if a polytype is in a domain. */ ! public static void in(Polytype type, Monotype domain) throws TypingEx { ! if(dbg) Debug.println(type + " in " + domain); Constraint.enter(type.getConstraint()); ! leq(type.getMonotype(), domain); } *************** *** 438,467 **** * * @param types a collection of Polytypes ! * @param domains a collection of Domains * @exception TypingEx */ public static void in(Polytype[] types, ! Domain[] domains) ! throws TypingEx ! { ! int expected = domains.length; ! int actual = types.length; ! if(expected != actual) ! throw new BadSizeEx(expected, actual); ! ! for(int i = 0; i<actual; i++) ! in(types[i], domains[i]); ! } ! ! /** ! * Checks wether monotypes belong to domains. ! * This is just the special case where all polytypes are monomorphic. ! * ! * @param types a collection of Monotypes ! * @param domains a collection of Domains ! * @exception TypingEx ! */ ! public static void in(Monotype[] types, ! Domain[] domains) throws TypingEx { --- 428,436 ---- * * @param types a collection of Polytypes ! * @param domains a collection of domains * @exception TypingEx */ public static void in(Polytype[] types, ! Monotype[] domains) throws TypingEx { Index: Polytype.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Polytype.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Polytype.java 2 Feb 2004 17:25:26 -0000 1.21 --- Polytype.java 26 Feb 2004 22:17:39 -0000 1.22 *************** *** 11,18 **** /**************************************************************************/ - // File : Domain.java - // Created : Fri Jun 02 16:59:06 2000 by Daniel Bonniot - //$Modified: Thu Aug 31 18:17:47 2000 by Daniel Bonniot $ - package mlsub.typing; --- 11,14 ---- *************** *** 237,241 **** throw new InternalError("getDomain on non functional polytype "+this); ! return new Domain(constraint, new TupleType(domains)); } --- 233,237 ---- throw new InternalError("getDomain on non functional polytype "+this); ! return new Domain(constraint, domains); } Index: Domain.java =================================================================== RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Domain.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Domain.java 6 Sep 2000 12:38:27 -0000 1.6 --- Domain.java 26 Feb 2004 22:17:39 -0000 1.7 *************** *** 24,31 **** public class Domain { ! public Domain(Constraint constraint, Monotype monotype) { this.constraint = constraint; ! this.monotype = monotype; } --- 24,31 ---- public class Domain { ! public Domain(Constraint constraint, Monotype[] monotypes) { this.constraint = constraint; ! this.monotypes = monotypes; } *************** *** 40,56 **** } ! public Monotype getMonotype() ! { ! return monotype; ! } ! ! public static Domain[] fromMonotypes(Monotype[] monotypes) { ! Domain[] res = new Domain[monotypes.length]; ! for(int i=0; i<monotypes.length; i++) ! res[i] = new Domain(Constraint.True, monotypes[i]); ! return res; } ! /**************************************************************** * Misc --- 40,48 ---- } ! public Monotype[] getMonotypes() { ! return monotypes; } ! /**************************************************************** * Misc *************** *** 59,66 **** public String toString() { ! return (constraint==null ? "" : "Ex "+constraint) + monotype.toString(); } private Constraint constraint; ! private Monotype monotype; } --- 51,59 ---- public String toString() { ! return (constraint == null ? "" : "Ex " + constraint) + ! java.util.Arrays.asList(monotypes).toString(); } private Constraint constraint; ! private Monotype[] monotypes; } |