mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-27 01:30:35 +08:00
C: fix generation of virtual tables inheriting interface default methods
This commit is contained in:
parent
b3b324d73c
commit
f5c2cf0fa3
@ -114,6 +114,9 @@ public class CallSiteGenerator {
|
||||
}
|
||||
|
||||
private void generateLocations() {
|
||||
if (locations.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
includes.includeClass(CALL_SITE_LOCATION);
|
||||
writer.print("static ").print(callSiteLocationName).print(" callSiteLocations_" + callSitesName
|
||||
+ "[" + locations.size() + "] = {").indent();
|
||||
@ -147,6 +150,9 @@ public class CallSiteGenerator {
|
||||
}
|
||||
|
||||
private void generateHandlers() {
|
||||
if (exceptionHandlers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
includes.includeClass(EXCEPTION_HANDLER);
|
||||
writer.print("static ").print(exceptionHandlerName).print(" exceptionHandlers_" + callSitesName + "["
|
||||
+ exceptionHandlers.size() + "] = {").indent();
|
||||
|
@ -613,7 +613,6 @@ public class ClassGenerator {
|
||||
codeWriter.println(".superclass = " + parent + ",");
|
||||
codeWriter.println(".superinterfaceCount = " + superinterfaceCount + ",");
|
||||
codeWriter.println(".superinterfaces = " + superinterfaces + ",");
|
||||
codeWriter.println(".enumValues = NULL,");
|
||||
codeWriter.println(".layout = " + layout + ",");
|
||||
codeWriter.println(".enumValues = " + enumConstants + ",");
|
||||
codeWriter.println(".init = " + initFunction);
|
||||
|
@ -69,12 +69,11 @@ public class VirtualTableProvider {
|
||||
}
|
||||
if (cls.getParent() != null) {
|
||||
fillClass(cls.getParent(), methodCalledVirtually);
|
||||
VirtualTable parentTable = virtualTables.get(cls.getParent());
|
||||
for (VirtualTableEntry parentEntry : parentTable.entries.values()) {
|
||||
VirtualTableEntry entry = new VirtualTableEntry(table, parentEntry.getMethod(),
|
||||
parentEntry.getImplementor(), parentEntry.getIndex());
|
||||
table.entries.put(entry.getMethod(), entry);
|
||||
}
|
||||
copyEntriesFromSupertype(table, virtualTables.get(cls.getParent()));
|
||||
}
|
||||
for (String itf : cls.getInterfaces()) {
|
||||
fillClass(itf, methodCalledVirtually);
|
||||
copyEntriesFromSupertype(table, virtualTables.get(itf));
|
||||
}
|
||||
|
||||
Set<MethodDescriptor> newDescriptors = virtualMethodMap.get(className);
|
||||
@ -106,6 +105,14 @@ public class VirtualTableProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private void copyEntriesFromSupertype(VirtualTable table, VirtualTable supertypeTable) {
|
||||
for (VirtualTableEntry parentEntry : supertypeTable.entries.values()) {
|
||||
VirtualTableEntry entry = new VirtualTableEntry(table, parentEntry.getMethod(),
|
||||
parentEntry.getImplementor(), parentEntry.getIndex());
|
||||
table.entries.put(entry.getMethod(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
public VirtualTableEntry lookup(MethodReference method) {
|
||||
VirtualTable vtable = virtualTables.get(interfaceMapping.mapClass(method.getClassName()));
|
||||
if (vtable == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user