mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix async virtual methods
This commit is contained in:
parent
ce2c625f53
commit
268b66e523
|
@ -446,11 +446,12 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
debugEmitter.emitMethod(method.getReference().getDescriptor());
|
debugEmitter.emitMethod(method.getReference().getDescriptor());
|
||||||
MethodReference ref = method.getReference();
|
MethodReference ref = method.getReference();
|
||||||
writer.append(",").newLine();
|
writer.append(",").newLine();
|
||||||
|
String methodName = method.isAsync() ? naming.getNameForAsync(ref) : naming.getNameFor(ref);
|
||||||
if (method.isOriginalNamePreserved()) {
|
if (method.isOriginalNamePreserved()) {
|
||||||
writer.append("[\"").appendMethod(ref).append("\",").ws().append("\"").append(ref.getName())
|
writer.append("[\"").append(methodName).append("\",").ws().append("\"").append(ref.getName())
|
||||||
.append("\"]");
|
.append("\"]");
|
||||||
} else {
|
} else {
|
||||||
writer.append("\"").appendMethod(ref).append("\"");
|
writer.append("\"").append(methodName).append("\"");
|
||||||
}
|
}
|
||||||
writer.append(",").ws().append("function(");
|
writer.append(",").ws().append("function(");
|
||||||
for (int i = 1; i <= ref.parameterCount(); ++i) {
|
for (int i = 1; i <= ref.parameterCount(); ++i) {
|
||||||
|
|
|
@ -227,5 +227,8 @@ class UnusedVariableEliminator implements ExprVisitor, StatementVisitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(RestoreAsyncStatement statement) {
|
public void visit(RestoreAsyncStatement statement) {
|
||||||
|
if (statement.getReceiver() != null) {
|
||||||
|
statement.setReceiver(renumber(statement.getReceiver()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,5 +85,38 @@ public class AsyncMethodFinder {
|
||||||
for (CallSite callSite : node.getCallerCallSites()) {
|
for (CallSite callSite : node.getCallerCallSites()) {
|
||||||
add(callSite.getCaller().getMethod());
|
add(callSite.getCaller().getMethod());
|
||||||
}
|
}
|
||||||
|
Set<MethodReference> visited = new HashSet<>();
|
||||||
|
Set<MethodReference> overriden = new HashSet<>();
|
||||||
|
if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) {
|
||||||
|
findOverridenMethods(new MethodReference(cls.getParent(), methodRef.getDescriptor()), overriden, visited);
|
||||||
|
}
|
||||||
|
for (String iface : cls.getInterfaces()) {
|
||||||
|
findOverridenMethods(new MethodReference(iface, methodRef.getDescriptor()), overriden, visited);
|
||||||
|
}
|
||||||
|
for (MethodReference overridenMethod : overriden) {
|
||||||
|
add(overridenMethod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findOverridenMethods(MethodReference methodRef, Set<MethodReference> result,
|
||||||
|
Set<MethodReference> visited) {
|
||||||
|
if (!visited.add(methodRef)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClassReader cls = classSource.get(methodRef.getClassName());
|
||||||
|
if (cls == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MethodReader method = cls.getMethod(methodRef.getDescriptor());
|
||||||
|
if (method != null) {
|
||||||
|
result.add(methodRef);
|
||||||
|
} else {
|
||||||
|
if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) {
|
||||||
|
findOverridenMethods(new MethodReference(cls.getParent(), methodRef.getDescriptor()), result, visited);
|
||||||
|
}
|
||||||
|
for (String iface : cls.getInterfaces()) {
|
||||||
|
findOverridenMethods(new MethodReference(iface, methodRef.getDescriptor()), result, visited);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user