mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
WASM: automatically mark as reachable methods of reachable classes which are exported to WASM via `@Export` annotation See #258
This commit is contained in:
parent
74eda7e63c
commit
09b3f18a2c
|
@ -689,4 +689,4 @@ public class WasmTarget implements TeaVMTarget {
|
|||
|
||||
return new VirtualTableProvider(classes, virtualMethods);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import org.teavm.dependency.DependencyAgent;
|
|||
import org.teavm.dependency.MethodDependency;
|
||||
import org.teavm.diagnostics.Diagnostics;
|
||||
import org.teavm.interop.DelegateTo;
|
||||
import org.teavm.interop.Export;
|
||||
import org.teavm.model.AnnotationReader;
|
||||
import org.teavm.model.CallLocation;
|
||||
import org.teavm.model.ClassHolder;
|
||||
|
@ -31,6 +32,19 @@ import org.teavm.model.MethodHolder;
|
|||
import org.teavm.model.MethodReader;
|
||||
|
||||
public class WasmDependencyListener extends AbstractDependencyListener implements ClassHolderTransformer {
|
||||
|
||||
@Override
|
||||
public void classReached(DependencyAgent agent, String className, CallLocation location) {
|
||||
super.classReached(agent, className, location);
|
||||
|
||||
for (MethodReader reader : agent.getClassSource().get(className).getMethods()) {
|
||||
AnnotationReader annotation = reader.getAnnotations().get(Export.class.getName());
|
||||
if (annotation != null) {
|
||||
agent.linkMethod(reader.getReference(), null).use();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
AnnotationReader delegateAnnot = method.getMethod().getAnnotations().get(DelegateTo.class.getName());
|
||||
|
@ -57,4 +71,4 @@ public class WasmDependencyListener extends AbstractDependencyListener implement
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -575,4 +575,4 @@ public class DependencyChecker implements DependencyInfo {
|
|||
public void addBootstrapMethodSubstitutor(MethodReference method, BootstrapMethodSubstitutor substitutor) {
|
||||
bootstrapMethodSubstitutors.put(method, substitutor);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user