Added self (if interface) and super class interfaces to the interface table.

This commit is contained in:
Izzat Bahadirov 2013-05-03 16:16:23 -04:00
parent 063862d44c
commit 9d8cf0d67c

View File

@ -126,13 +126,14 @@ public class ClassProto implements TypeProto {
interfaceDef = classPath.getClassDef(interfaceType); interfaceDef = classPath.getClassDef(interfaceType);
interfaces.put(interfaceType, interfaceDef); interfaces.put(interfaceType, interfaceDef);
} catch (UnresolvedClassException ex) { } catch (UnresolvedClassException ex) {
interfaces.put(interfaceType, null);
interfacesFullyResolved = false; interfacesFullyResolved = false;
} }
ClassProto interfaceProto = (ClassProto) classPath.getClass(interfaceType); ClassProto interfaceProto = (ClassProto) classPath.getClass(interfaceType);
for (ClassDef superInterface: interfaceProto.getInterfaces().values()) { for (String superInterface: interfaceProto.getInterfaces().keySet()) {
if (!interfaces.containsKey(superInterface.getType())) { if (!interfaces.containsKey(superInterface)) {
interfaces.put(superInterface.getType(), superInterface); interfaces.put(superInterface, interfaceProto.getInterfaces().get(superInterface));
} }
} }
if (!interfaceProto.interfacesFullyResolved) { if (!interfaceProto.interfacesFullyResolved) {
@ -144,6 +145,28 @@ public class ClassProto implements TypeProto {
interfacesFullyResolved = false; interfacesFullyResolved = false;
} }
// now add self and super class interfaces, required for common super class lookup
// we don't really need ClassDef's for that, so let's just use null
if (isInterface() && !interfaces.containsKey(getType())) {
interfaces.put(getType(), null);
}
try {
String superclass = getSuperclass();
if (superclass != null) {
ClassProto superclassProto = (ClassProto) classPath.getClass(superclass);
for (String superclassInterface: superclassProto.getInterfaces().keySet()) {
if (!interfaces.containsKey(superclassInterface)) {
interfaces.put(superclassInterface, null);
}
}
}
} catch (UnresolvedClassException ex) {
// TODO: not sure if this is necessary
interfacesFullyResolved = false;
}
return interfaces; return interfaces;
} }
@ -529,7 +552,9 @@ public class ClassProto implements TypeProto {
addToVtable(getClassDef().getVirtualMethods(), virtualMethodList); addToVtable(getClassDef().getVirtualMethods(), virtualMethodList);
for (ClassDef interfaceDef: getInterfacesFull().values()) { for (ClassDef interfaceDef: getInterfacesFull().values()) {
addToVtable(interfaceDef.getVirtualMethods(), virtualMethodList); if (interfaceDef != null) {
addToVtable(interfaceDef.getVirtualMethods(), virtualMethodList);
}
} }
} }