Update of /cvsroot/nice/Nice/src/mlsub/typing
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16026/src/mlsub/typing
Modified Files:
Typing.java
Log Message:
Methods now specialize other methods with a larger domain (ignoring
subtyping on non-dispatchable types like primitive and tuple types).
Covariance of the return type is not yet checked, and there is not yet a
way to explicitely declare that a method is a specialization.
Index: Typing.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/mlsub/typing/Typing.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** Typing.java 26 Feb 2004 22:17:37 -0000 1.34
--- Typing.java 28 Feb 2004 14:23:43 -0000 1.35
***************
*** 335,338 ****
--- 335,358 ----
}
+ /** @param dispatchable when true, we require that non dispatchable types be
+ equal, not mere subtypes.
+ */
+ public static void leq(Monotype[] ms1, Monotype[] ms2, boolean dispatchable)
+ throws TypingEx
+ {
+ if (! dispatchable)
+ for(int i = 0; i < ms1.length; i++)
+ leq(ms1[i], ms2[i]);
+ else
+ for(int i = 0; i < ms1.length; i++)
+ {
+ Monotype m1 = ms1[i];
+ Monotype m2 = ms2[i];
+ leq(m1, m2);
+ if (! nice.tools.typing.Types.isDispatchable(m2))
+ leq(m2, m1);
+ }
+ }
+
/****************************************************************
* Type constructors
***************
*** 388,391 ****
--- 408,421 ----
throws TypingEx
{
+ leq(d1, d2, false);
+ }
+
+ /** Test if d1 is a subdomain of d2.
+ @param dispatchable when true, we require that non dispatchable types be
+ equal, not mere subtypes.
+ */
+ public static void leq(Domain d1, Domain d2, boolean dispatchable)
+ throws TypingEx
+ {
if(dbg) Debug.println(d1+" leq "+d2);
***************
*** 396,400 ****
Constraint.hasBinders(d2.getConstraint())))
{
! leq(d1.getMonotypes(), d2.getMonotypes());
return;
}
--- 426,430 ----
Constraint.hasBinders(d2.getConstraint())))
{
! leq(d1.getMonotypes(), d2.getMonotypes(), dispatchable);
return;
}
***************
*** 407,411 ****
Constraint.enter(d2.getConstraint());
! leq(d1.getMonotypes(), d2.getMonotypes());
}
finally{
--- 437,441 ----
Constraint.enter(d2.getConstraint());
! leq(d1.getMonotypes(), d2.getMonotypes(), dispatchable);
}
finally{
***************
*** 413,417 ****
}
}
!
/** Test if a polytype is in a domain. */
public static void in(Polytype type, Monotype domain)
--- 443,472 ----
}
}
!
! public static boolean smaller(Domain d1, Domain d2)
! {
! try {
! leq(d1, d2);
! return true;
! }
! catch(TypingEx ex) {
! return false;
! }
! }
!
! /** @param dispatchable when true, we require that non dispatchable types be
! equal, not mere subtypes.
! */
! public static boolean smaller(Domain d1, Domain d2, boolean dispatchable)
! {
! try {
! leq(d1, d2, dispatchable);
! return true;
! }
! catch(TypingEx ex) {
! return false;
! }
! }
!
/** Test if a polytype is in a domain. */
public static void in(Polytype type, Monotype domain)
|