use of org.objectweb.asm.tree.AbstractInsnNode in project bytecode-viewer by Konloch.
the class NumberNode method setNumber.
public void setNumber(int number) {
AbstractInsnNode ain = insn();
if (ain instanceof IntInsnNode) {
((IntInsnNode) insn()).operand = number;
((IntInsnNode) ain).operand = number;
} else if (ain instanceof LdcInsnNode) {
((LdcInsnNode) insn()).cst = number;
((LdcInsnNode) ain).cst = number;
}
}
use of org.objectweb.asm.tree.AbstractInsnNode in project bytecode-viewer by Konloch.
the class Assembly method rename.
public static void rename(Collection<ClassNode> classes, ClassNode cn, String newName) {
for (ClassNode node : classes) {
if (node.superName.equals(cn.name))
node.superName = newName;
if (node.interfaces.contains(cn.name)) {
node.interfaces.remove(cn.name);
node.interfaces.add(newName);
}
for (FieldNode fn : node.fields) {
if (fn.desc.endsWith("L" + cn.name + ";"))
fn.desc = fn.desc.replace("L" + cn.name + ";", "L" + newName + ";");
}
for (MethodNode mn : node.methods) {
if (mn.desc.contains("L" + cn.name + ";"))
mn.desc = mn.desc.replaceAll("L" + cn.name + ";", "L" + newName + ";");
for (AbstractInsnNode ain : mn.instructions.toArray()) {
if (ain instanceof FieldInsnNode) {
FieldInsnNode fin = (FieldInsnNode) ain;
if (fin.owner.equals(cn.name))
fin.owner = newName;
} else if (ain instanceof MethodInsnNode) {
MethodInsnNode min = (MethodInsnNode) ain;
if (min.owner.equals(cn.name))
min.owner = newName;
}
}
}
}
cn.name = newName;
}
use of org.objectweb.asm.tree.AbstractInsnNode in project jacoco by jacoco.
the class MethodAnalyzer method visitEnd.
@Override
public void visitEnd() {
// Wire jumps:
for (final Jump j : jumps) {
LabelInfo.getInstruction(j.target).setPredecessor(j.source, j.branch);
}
// Propagate probe values:
for (final CoveredProbe p : coveredProbes) {
p.instruction.setCovered(p.branch);
}
// Merge:
for (final Instruction i : instructions) {
final AbstractInsnNode m = i.getNode();
final AbstractInsnNode r = findRepresentative(m);
if (r != m) {
ignored.add(m);
nodeToInstruction.get(r).merge(i);
}
}
// Report result:
coverage.ensureCapacity(firstLine, lastLine);
for (final Instruction i : instructions) {
if (ignored.contains(i.getNode())) {
continue;
}
final int total = i.getBranches();
final int covered = i.getCoveredBranches();
final ICounter instrCounter = covered == 0 ? CounterImpl.COUNTER_1_0 : CounterImpl.COUNTER_0_1;
final ICounter branchCounter = total > 1 ? CounterImpl.getInstance(total - covered, covered) : CounterImpl.COUNTER_0_0;
coverage.increment(instrCounter, branchCounter, i.getLine());
}
coverage.incrementMethodCounter();
}
use of org.objectweb.asm.tree.AbstractInsnNode in project jacoco by jacoco.
the class StringSwitchJavacFilter method filter.
public void filter(final String className, final String superClassName, final MethodNode methodNode, final IFilterOutput output) {
AbstractInsnNode i = methodNode.instructions.getFirst();
while (i != null) {
filter(i, output);
i = i.getNext();
}
}
use of org.objectweb.asm.tree.AbstractInsnNode in project jacoco by jacoco.
the class SynchronizedFilter method filter.
public void filter(final String className, final String superClassName, final MethodNode methodNode, final IFilterOutput output) {
for (TryCatchBlockNode tryCatch : methodNode.tryCatchBlocks) {
if (tryCatch.type != null) {
continue;
}
if (tryCatch.start == tryCatch.handler) {
continue;
}
final AbstractInsnNode to = new Matcher(tryCatch.handler).match();
if (to == null) {
continue;
}
output.ignore(tryCatch.handler, to);
}
}
Aggregations