[Nice-commit] Nice/src/bossa/syntax TypeConstructors.java,1.10,1.11 RetypedJavaMethod.java,1.6,1.7 J
Brought to you by:
bonniot
From: <bo...@us...> - 2003-08-29 16:52:48
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv18313/src/bossa/syntax Modified Files: TypeConstructors.java RetypedJavaMethod.java JavaClasses.java Log Message: Avoid ambiguity with constructors that are retyped. Index: TypeConstructors.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/TypeConstructors.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TypeConstructors.java 8 Feb 2003 16:40:19 -0000 1.10 --- TypeConstructors.java 29 Aug 2003 16:52:42 -0000 1.11 *************** *** 55,58 **** --- 55,67 ---- } + static void removeConstructor(TypeConstructor tc, MethodDeclaration m) + { + List l = (List) constructors.get(tc); + if (l == null) + return; + + l.remove(m.getSymbol()); + } + private static HashMap constructors; public static void reset() { constructors = new HashMap(); } Index: RetypedJavaMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/RetypedJavaMethod.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RetypedJavaMethod.java 24 Jun 2003 10:00:41 -0000 1.6 --- RetypedJavaMethod.java 29 Aug 2003 16:52:42 -0000 1.7 *************** *** 171,176 **** "\nFound : " + reflectMethod.return_type.getName()); - JavaClasses.registerNativeMethod(this, reflectMethod); - if (reflectMethod.isConstructor()) { --- 171,174 ---- *************** *** 178,186 **** mlsub.typing.TypeConstructor tc = Types.typeConstructor(holder); if (tc != null) ! TypeConstructors.addConstructor(tc, this); } catch(Types.NotIntroducedClassException ex) {} } ! int javaArity; if(reflectMethod.getStaticFlag() || reflectMethod.isConstructor()) --- 176,189 ---- mlsub.typing.TypeConstructor tc = Types.typeConstructor(holder); if (tc != null) ! { ! TypeConstructors.addConstructor(tc, this); ! JavaClasses.registerNativeConstructor(this, reflectMethod, tc); ! } } catch(Types.NotIntroducedClassException ex) {} } ! else ! JavaClasses.registerNativeMethod(this, reflectMethod); ! int javaArity; if(reflectMethod.getStaticFlag() || reflectMethod.isConstructor()) Index: JavaClasses.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/JavaClasses.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** JavaClasses.java 7 Aug 2003 10:20:23 -0000 1.35 --- JavaClasses.java 29 Aug 2003 16:52:42 -0000 1.36 *************** *** 212,216 **** /* If auto is a RetypedJavaMethod, we are explicitely declaring two ! methods forthe same native method. This is useful to give it several incomparable types. Otherwise, auto is an implicit java method, and we discard it --- 212,216 ---- /* If auto is a RetypedJavaMethod, we are explicitely declaring two ! methods for the same native method. This is useful to give it several incomparable types. Otherwise, auto is an implicit java method, and we discard it *************** *** 221,224 **** --- 221,241 ---- } + static void registerNativeConstructor(RetypedJavaMethod m, + Method reflectMethod, + TypeConstructor classe) + { + MethodDeclaration auto = (MethodDeclaration) retyped.put(reflectMethod, m); + /* + If auto is a RetypedJavaMethod, we are explicitely declaring two + constructors for the same native constructor. + This is useful to give it several + incomparable types. + Otherwise, auto is an implicit java constructor, and we discard it + in favor of the new explicit one. + */ + if (auto != null && ! (auto instanceof RetypedJavaMethod)) + TypeConstructors.removeConstructor(classe, auto); + } + static void registerNativeField(JavaFieldAccess f, Field reflectField) { *************** *** 230,234 **** private static void removeFromScope(MethodDeclaration m) { ! Node.getGlobalScope().removeSymbol(m.getSymbol()); } --- 247,251 ---- private static void removeFromScope(MethodDeclaration m) { ! Node.getGlobalScope().removeSymbol(m.getSymbol()); } *************** *** 301,335 **** addSymbol(f, JavaFieldAccess.make(f)); ! for (Method m = classType.getMethods(); m!=null; m = m.getNext()) ! if(m.isConstructor()) ! { ! JavaMethod res = JavaMethod.make(m, true); ! if (res != null) ! TypeConstructors.addConstructor(tc, res); ! else if(Debug.javaTypes) ! Debug.println("Constructor " + m + " ignored"); ! } ! else ! { ! /* We don't need to put static methods in the global scope. ! They can and must be access by specifying the class explicitely, ! like in Java. ! */ ! if (m.getStaticFlag()) ! continue; ! Method base = baseMethod(classType, m); ! if (base != null) ! continue; ! // Ignore the method if it is explicitely retyped ! if (retyped.get(m) == null) ! { ! if (Debug.javaTypes) ! Debug.println("Loaded native method " + m); ! addSymbol(m, JavaMethod.make(m, false)); ! } ! } } catch(NoClassDefFoundError e){ --- 318,357 ---- addSymbol(f, JavaFieldAccess.make(f)); ! for (Method m = classType.getMethods(); m != null; m = m.getNext()) ! { ! // Ignore the method if it is explicitely retyped ! if (retyped.get(m) != null) ! continue; ! if (m.isConstructor()) ! { ! JavaMethod res = JavaMethod.make(m, true); ! if (res != null) ! { ! TypeConstructors.addConstructor(tc, res); ! retyped.put(m, res); ! } ! else if(Debug.javaTypes) ! Debug.println("Constructor " + m + " ignored"); ! } ! else ! { ! /* We don't need to put static methods in the global scope. ! They can and must be accessed by specifying the class ! explicitely, like in Java. ! */ ! if (m.getStaticFlag()) ! continue; ! Method base = baseMethod(classType, m); ! if (base != null) ! continue; ! ! if (Debug.javaTypes) ! Debug.println("Loaded native method " + m); ! addSymbol(m, JavaMethod.make(m, false)); ! } ! } } catch(NoClassDefFoundError e){ |