[Nice-commit] Nice/src/bossa/syntax typedef.nice,1.17,1.18 methodContainer.nice,1.3,1.4 importedcons
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2005-02-16 12:13:31
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4957/src/bossa/syntax Modified Files: typedef.nice methodContainer.nice importedconstructor.nice Log Message: Properly print interface of classes that specialize their parent's type parameters. Fix loading of compiled constructors for such classes. Index: importedconstructor.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/importedconstructor.nice,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** importedconstructor.nice 14 Jan 2005 16:41:27 -0000 1.14 --- importedconstructor.nice 16 Feb 2005 12:13:17 -0000 1.15 *************** *** 96,101 **** let classDef = def.getDefinition(); ! let returnType = new MonotypeWrapper(type: sureMonotype ! (new mlsub.typing.MonotypeConstructor(classDef.getTC(), classDef.getTypeParameters()))); let constraint = classDef.classConstraint == null ? --- 96,101 ---- let classDef = def.getDefinition(); ! let returnType = new SureMonotypeWrapper ! (tc: classDef.getTC(), params: classDef.getTypeParameters()); let constraint = classDef.classConstraint == null ? Index: typedef.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/typedef.nice,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** typedef.nice 16 Jan 2005 21:51:15 -0000 1.17 --- typedef.nice 16 Feb 2005 12:13:17 -0000 1.18 *************** *** 587,592 **** s.print(c.getSimpleName()); s.print(c.printTypeParameters()); ! if (c.superClass != null) ! s.print(" extends " + c.superClass); s.print(printInterfaces(" implements ", c.interfaces, c.javaInterfaces)); if (c.abs != null) --- 587,593 ---- s.print(c.getSimpleName()); s.print(c.printTypeParameters()); ! let sup = c.superClass; ! if (sup != null) ! s.print(" extends " + c.completeParams(sup)); s.print(printInterfaces(" implements ", c.interfaces, c.javaInterfaces)); if (c.abs != null) *************** *** 596,599 **** --- 597,612 ---- } + String completeParams(TypeDefinition this, mlsub.typing.TypeConstructor tc) + { + let params = completeTypeParameters + (this, + declaredClassConstraint == null ? null : notNull(declaredClassConstraint).typeParameters); + + if (params == null) + return tc.toString(); + else + return tc.toString + Util.map("<", ",", ">", params); + } + printInterface(InterfaceDefinition i, java.io.PrintWriter s) { *************** *** 740,759 **** /** ! Returns a monotype based on this tc, provided that the class ! requires exactly these type parameters because it specializes its parent. ! */ ! ?mlsub.typing.Monotype getTypeWithTC(mlsub.typing.TypeConstructor tc, mlsub.typing.Monotype[?] sourceParams ) { - ?TypeDefinition def = getTypeDefinition(tc); - - if (def == null) - return null; - let params = def.parentParams; let paramMap = def.parentTypeParameterMap; ! if (params == null || paramMap == null) return null; ! ?mlsub.typing.Monotype[] fullParams = new mlsub.typing.Monotype[params.length]; --- 753,768 ---- /** ! Compute the full type parameters for the class (including possibly implicit ! ones made necessary by a superclass with more type parameters which have ! been specialized). ! */ ! ?(mlsub.typing.Monotype[]) completeTypeParameters(TypeDefinition def, mlsub.typing.Monotype[?] sourceParams) { let params = def.parentParams; let paramMap = def.parentTypeParameterMap; ! if (params == null || paramMap == null) return null; ! ?mlsub.typing.Monotype[] fullParams = new mlsub.typing.Monotype[params.length]; *************** *** 762,766 **** if (params[i] == null) { ! fullParams[i] = notNull(sourceParams)[paramMap[i]]; used++; } --- 771,777 ---- if (params[i] == null) { ! if (sourceParams == null) ! return null; ! fullParams[i] = sourceParams[paramMap[i]]; used++; } *************** *** 771,774 **** --- 782,803 ---- return null; + return cast(fullParams); + } + + /** + Returns a monotype based on this tc, provided that the class + requires exactly these type parameters because it specializes its parent. + */ + ?mlsub.typing.Monotype getTypeWithTC(mlsub.typing.TypeConstructor tc, mlsub.typing.Monotype[?] sourceParams ) + { + ?TypeDefinition def = getTypeDefinition(tc); + + if (def == null) + return null; + + let fullParams = completeTypeParameters(def, sourceParams); + if (fullParams == null) + return null; + return new mlsub.typing.MonotypeConstructor(tc, cast(fullParams)); } Index: methodContainer.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/methodContainer.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** methodContainer.nice 16 Jan 2005 00:28:21 -0000 1.3 --- methodContainer.nice 16 Feb 2005 12:13:17 -0000 1.4 *************** *** 26,29 **** --- 26,32 ---- ?mlsub.typing.Variance variance = null; ?ClassConstraint classConstraint = null; + /** Remember the declared class constraint, as it appears in the source. */ + ?ClassConstraint declaredClassConstraint = null; + { declaredClassConstraint = classConstraint; } mlsub.typing.AtomicConstraint[?] resolvedConstraints = null; *************** *** 90,105 **** // Always print the constraint as a prefix constraint. ! if (classConstraint == null) return; ! s.print(classConstraint); } String printTypeParameters() { ! if (classConstraint == null) return ""; ! mlsub.typing.Monotype[] typeParameters = notNull(classConstraint).typeParameters; StringBuffer res = new StringBuffer("<"); for (int n = 0; n < typeParameters.length; n++) --- 93,108 ---- // Always print the constraint as a prefix constraint. ! if (declaredClassConstraint == null) return; ! s.print(declaredClassConstraint); } String printTypeParameters() { ! if (declaredClassConstraint == null) return ""; ! mlsub.typing.Monotype[] typeParameters = notNull(declaredClassConstraint).typeParameters; StringBuffer res = new StringBuffer("<"); for (int n = 0; n < typeParameters.length; n++) *************** *** 205,207 **** return res; ! } \ No newline at end of file --- 208,210 ---- return res; ! } |