mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-12-09 02:00:25 +08:00
Add methods to submit class file directly as byte array
This commit is contained in:
parent
c7d640a2af
commit
6d45f57a39
@ -44,6 +44,10 @@ public class DependencyAgent implements DependencyInfo, ServiceRepository {
|
||||
return checker.generateClassName();
|
||||
}
|
||||
|
||||
public String submitClassFile(byte[] data) {
|
||||
return checker.submitClassFile(data);
|
||||
}
|
||||
|
||||
public void submitClass(ClassHolder cls) {
|
||||
checker.submitClass(cls);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.teavm.callgraph.CallGraph;
|
||||
import org.teavm.callgraph.DefaultCallGraph;
|
||||
import org.teavm.callgraph.DefaultCallGraphNode;
|
||||
@ -52,6 +53,7 @@ import org.teavm.model.ValueType;
|
||||
import org.teavm.model.util.ModelUtils;
|
||||
import org.teavm.model.util.ProgramUtils;
|
||||
import org.teavm.optimization.UnreachableBasicBlockEliminator;
|
||||
import org.teavm.parsing.Parser;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -157,6 +159,14 @@ public class DependencyChecker implements DependencyInfo {
|
||||
return "$$teavm_generated_class$$" + classNameSuffix++;
|
||||
}
|
||||
|
||||
public String submitClassFile(byte[] data) {
|
||||
ClassNode node = new ClassNode();
|
||||
org.objectweb.asm.ClassReader reader = new org.objectweb.asm.ClassReader(data);
|
||||
reader.accept(node, 0);
|
||||
submitClass(Parser.parseClass(node));
|
||||
return node.name;
|
||||
}
|
||||
|
||||
public void submitClass(ClassHolder cls) {
|
||||
if (completing) {
|
||||
throw new IllegalStateException("Can't submit class during completion phase");
|
||||
|
Loading…
Reference in New Issue
Block a user