use of org.robovm.compiler.clazz.SuperMethodDependency in project robovm by robovm.
the class DependencyGraph method add.
/**
* Adds the specified {@link Clazz} to the graph after it has been compiled.
* If {@code root == true} the class will be added to the root set and it as
* well as its methods will always be reachable.
*/
public void add(Clazz clazz, boolean root) {
reachableNodes.clear();
ClassNode classNode = getClassNode(clazz.getInternalName());
if (root) {
roots.add(classNode);
}
ClazzInfo ci = clazz.getClazzInfo();
for (Dependency dep : ci.getDependencies()) {
if (dep instanceof InvokeMethodDependency) {
InvokeMethodDependency mdep = (InvokeMethodDependency) dep;
classNode.addEgde(getMethodNode(mdep), mdep.isWeak());
} else if (dep instanceof SuperMethodDependency) {
SuperMethodDependency mdep = (SuperMethodDependency) dep;
classNode.addEgde(getMethodNode(mdep), mdep.isWeak());
} else {
classNode.addEgde(getClassNode(dep.getClassName()), dep.isWeak());
}
}
for (MethodInfo mi : ci.getMethods()) {
boolean strong = root || // Keep callback methods
mi.isCallback() || // Keep class initializers
(mi.isStatic() && "<clinit>".equals(mi.getName()) && "()V".equals(mi.getDesc())) || // in enum classes
(ci.isEnum() && mi.isStatic() && "values".equals(mi.getName()) && mi.getDesc().equals("()[L" + clazz.getInternalName() + ";")) || // in Struct classes
(ci.isStruct() && mi.isStatic() && "sizeOf".equals(mi.getName()) && "()I".equals(mi.getDesc()));
MethodNode methodNode = getMethodNode(clazz, mi);
classNode.addEgde(methodNode, !strong);
methodNode.addEgde(classNode, false);
for (Dependency dep : mi.getDependencies()) {
if (dep instanceof InvokeMethodDependency) {
InvokeMethodDependency mdep = (InvokeMethodDependency) dep;
methodNode.addEgde(getMethodNode(mdep), mdep.isWeak());
} else if (dep instanceof SuperMethodDependency) {
// Reverse the dependency so that the method is strongly
// linked if the super method is invoked.
SuperMethodDependency mdep = (SuperMethodDependency) dep;
getMethodNode(mdep).addEgde(methodNode, false);
} else {
methodNode.addEgde(getClassNode(dep.getClassName()), dep.isWeak());
}
}
}
}
Aggregations