[Nice-commit] Nice/src/nice/tools/code Import.java,1.6,1.7 Types.java,1.60,1.61
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2004-11-22 14:41:08
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23067/F:/nice/src/nice/tools/code Modified Files: Import.java Types.java Log Message: Made default retypings of array elements not null, cleanup of related code. Index: Import.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Import.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Import.java 11 Aug 2004 16:09:35 -0000 1.6 --- Import.java 22 Nov 2004 14:40:58 -0000 1.7 *************** *** 94,121 **** (m.getDeclaringClass().getPackageName()); ! if (nonNullArgs) ! { ! for (int i = 0; i < paramTypes.length; i++) ! //arguments of a method are considered not null ! params[n++] = Types.monotype(paramTypes[i], true, typeParameters, ! niceTP, true); ! } else { ! for (int i = 0; i < paramTypes.length; i++) ! //arguments maybe null ! params[n++] = Types.monotype(paramTypes[i], false, typeParameters, ! niceTP, true); ! } - mlsub.typing.Monotype retType; - if (constructor) - { - // the return type is surely not null - retType = Types.monotype(declaringClass.thisType(), true, - typeParameters, niceTP); - } else { - // returntype not null. - retType = Types.monotype(m.getFullReturnType(), true, - typeParameters, niceTP, true); - } Constraint cst = niceTP == null ? null : new Constraint(niceTP, null); return new Polytype(cst, new FunType(params, retType)); --- 94,106 ---- (m.getDeclaringClass().getPackageName()); ! for (int i = 0; i < paramTypes.length; i++) ! params[n++] = Types.monotype(paramTypes[i], /*sure:*/nonNullArgs, ! typeParameters, niceTP); ! ! gnu.bytecode.Type javaRetType = ! constructor ? declaringClass.thisType() : m.getFullReturnType(); ! mlsub.typing.Monotype retType = ! Types.monotype(javaRetType, true, typeParameters, niceTP); Constraint cst = niceTP == null ? null : new Constraint(niceTP, null); return new Polytype(cst, new FunType(params, retType)); Index: Types.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Types.java,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** Types.java 6 Nov 2004 11:23:07 -0000 1.60 --- Types.java 22 Nov 2004 14:40:58 -0000 1.61 *************** *** 319,323 **** Monotype[] res = new Monotype[len]; for (int i = 0; i < len; i++) ! res[i] = monotype(javaTypes[i], typeVariables, niceTypeVariables); return res; } --- 319,323 ---- Monotype[] res = new Monotype[len]; for (int i = 0; i < len; i++) ! res[i] = monotype(javaTypes[i], true, typeVariables, niceTypeVariables); return res; } *************** *** 329,373 **** } - public static Monotype monotype(Type javaType, boolean sure, - TypeVariable[] typeVariables, - TypeSymbol[] niceTypeVariables) - throws ParametricClassException, NotIntroducedClassException - { - return monotype(javaType, sure, typeVariables, niceTypeVariables, false); - } - - public static Monotype monotype(Type javaType) - throws ParametricClassException, NotIntroducedClassException - { - return monotype(javaType, null, null); - } - - public static Monotype monotype(Type javaType, - TypeVariable[] typeVariables, - TypeSymbol[] niceTypeVariables) - throws ParametricClassException, NotIntroducedClassException - { - Monotype res = getMonotype(javaType, typeVariables, niceTypeVariables); - if (javaType instanceof ObjectType && - ! (javaType instanceof TypeVariable)) - return bossa.syntax.Monotype.maybe(res); - else - // the sure is already there in getMonotype - return res; - } - /** Special version for use in Import.java, it always checks whether nullness info may be added. - And can handle arrays different(not yet implemented) */ public static Monotype monotype(Type javaType, boolean sure, TypeVariable[] typeVariables, ! TypeSymbol[] niceTypeVariables, ! boolean arraySure) throws ParametricClassException, NotIntroducedClassException { ! Monotype res = getMonotype(javaType, typeVariables, niceTypeVariables, ! arraySure); //primitivetypes and typevariables should not get nullness info if (javaType instanceof ObjectType && --- 329,342 ---- } /** Special version for use in Import.java, it always checks whether nullness info may be added. */ public static Monotype monotype(Type javaType, boolean sure, TypeVariable[] typeVariables, ! TypeSymbol[] niceTypeVariables) throws ParametricClassException, NotIntroducedClassException { ! Monotype res = getMonotype(javaType, typeVariables, niceTypeVariables); //primitivetypes and typevariables should not get nullness info if (javaType instanceof ObjectType && *************** *** 381,396 **** return res; } - private static Monotype getMonotype(Type javaType, - TypeVariable[] typeVariables, - TypeSymbol[] niceTypeVariables) - throws ParametricClassException, NotIntroducedClassException - { - return getMonotype(javaType, typeVariables, niceTypeVariables, false); - } private static Monotype getMonotype(Type javaType, TypeVariable[] typeVariables, ! TypeSymbol[] niceTypeVariables, ! boolean arraySure) throws ParametricClassException, NotIntroducedClassException { --- 350,357 ---- return res; } private static Monotype getMonotype(Type javaType, TypeVariable[] typeVariables, ! TypeSymbol[] niceTypeVariables) throws ParametricClassException, NotIntroducedClassException { *************** *** 415,434 **** if (javaType instanceof ArrayType) ! if (arraySure) ! //making the component of an array sure ! return new MonotypeConstructor ! (PrimitiveType.arrayTC, new Monotype[]{ monotype(((ArrayType) javaType).getComponentType(), true, ! typeVariables, niceTypeVariables, true) }); ! else ! return new MonotypeConstructor ! (PrimitiveType.arrayTC, ! new Monotype[]{ ! monotype(((ArrayType) javaType).getComponentType(), ! typeVariables, niceTypeVariables) ! }); ! if (javaType instanceof ParameterizedType) { --- 376,385 ---- if (javaType instanceof ArrayType) ! return new MonotypeConstructor(PrimitiveType.arrayTC, new Monotype[]{ monotype(((ArrayType) javaType).getComponentType(), true, ! typeVariables, niceTypeVariables) }); ! if (javaType instanceof ParameterizedType) { |