[Nice-commit] Nice/src/bossa/link Dispatch.java,1.48,1.49
Brought to you by:
bonniot
From: <bo...@us...> - 2003-02-18 14:21:25
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1:/tmp/cvs-serv7825/src/bossa/link Modified Files: Dispatch.java Log Message: Dispatch on boolean values: @true and @false (by Arjan). Index: Dispatch.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Dispatch.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** Dispatch.java 10 Dec 2002 18:46:33 -0000 1.48 --- Dispatch.java 18 Feb 2003 14:21:20 -0000 1.49 *************** *** 186,194 **** if(sortedAlternatives.size()==0) User.error ! (method, "Method " + method + " is declared but never defined:\n" + "no alternative matches " + toString(tags)); else User.warning(method, ! "Method " + method + " is not exhaustive:\n" + "no alternative matches " + toString(tags)); --- 186,194 ---- if(sortedAlternatives.size()==0) User.error ! (method, "Method " + method + " is declared but never implemented:\n" + "no alternative matches " + toString(tags)); else User.warning(method, ! "Method " + method + " is not completely covered:\n" + "no alternative matches " + toString(tags)); *************** *** 259,263 **** List res = mlsub.typing.Enumeration.enumerate(cst, types, used); ! return mergeNullCases(res, domains.length); } --- 259,264 ---- List res = mlsub.typing.Enumeration.enumerate(cst, types, used); ! res = mergeNullCases(res, domains.length); ! return enumerateBooleans(res, domains.length); } *************** *** 305,308 **** --- 306,339 ---- return res; + } + + /** Expand the 'boolean' case into 'true' and 'false'. + */ + private static List enumerateBooleans(List tags, int length) + { + if (tags.size() < 1) return tags; + + List res; + for (int pos = 0; pos < length; pos++) + { + res = new ArrayList(); + for (Iterator i = tags.iterator(); i.hasNext(); ) + { + TypeConstructor[] tc = (TypeConstructor[]) i.next(); + if (tc[pos] == PrimitiveType.boolTC) + { + // Create two copies of this case, one for true and one for false. + TypeConstructor[] tc2 = new TypeConstructor[tc.length]; + System.arraycopy(tc, 0, tc2, 0, tc.length); + tc[pos] = PrimitiveType.trueBoolTC; + res.add(tc); + tc2[pos] = PrimitiveType.falseBoolTC; + res.add(tc2); + } + else res.add(tc); + } + tags = res; + } + return tags; } } |