Allow to submit method during dependency check

This commit is contained in:
Alexey Andreev 2015-10-21 21:35:22 +03:00
parent db364f2adc
commit f3a4d3737b

View File

@ -166,9 +166,20 @@ public class DependencyChecker implements DependencyInfo {
public void submitMethod(MethodReference methodRef, Program program) {
if (!completing) {
throw new IllegalStateException("Can't submit class during check phase");
}
ClassHolder cls = classSource.get(methodRef.getClassName());
if (cls == null) {
throw new IllegalArgumentException("Class not found: " + methodRef.getClassName());
}
if (cls.getMethod(methodRef.getDescriptor()) != null) {
throw new IllegalArgumentException("Method already exists: " + methodRef.getClassName());
}
MethodHolder method = new MethodHolder(methodRef.getDescriptor());
method.getModifiers().add(ElementModifier.STATIC);
method.setProgram(ProgramUtils.copy(program));
new UnreachableBasicBlockEliminator().optimize(program);
cls.addMethod(method);
} else {
MethodDependency dep = getMethod(methodRef);
if (dep == null) {
throw new IllegalArgumentException("Method was not reached: " + methodRef);
@ -195,6 +206,7 @@ public class DependencyChecker implements DependencyInfo {
processQueue();
}
}
public void addDependencyListener(DependencyListener listener) {
listeners.add(listener);