use of org.objectweb.asm.tree.MethodNode in project MineCamera by PorPit.
the class CamTransformer method initTransformers.
protected void initTransformers() {
addTransformer(new Transformer("net.minecraft.client.entity.EntityPlayerSP") {
@Override
public void transform(ClassNode node) {
MethodNode m = findMethod(node, "isCurrentViewEntity", "()Z");
m.instructions.clear();
m.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/porpit/minecamera/transform/CamEventHandler", "shouldPlayerTakeInput", "()Z", false));
m.instructions.add(new InsnNode(Opcodes.IRETURN));
}
});
addTransformer(new Transformer("net.minecraft.client.renderer.EntityRenderer") {
@Override
public void transform(ClassNode node) {
MethodNode m = findMethod(node, "getMouseOver", "(F)V");
m.instructions.insert(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/porpit/minecamera/transform/CamEventHandler", "setupMouseHandlerBefore", "()V", false));
AbstractInsnNode currentNode = null;
@SuppressWarnings("unchecked") Iterator<AbstractInsnNode> iter = m.instructions.iterator();
while (iter.hasNext()) {
currentNode = iter.next();
if (currentNode instanceof InsnNode && ((InsnNode) currentNode).getOpcode() == RETURN) {
m.instructions.insertBefore(currentNode, new MethodInsnNode(Opcodes.INVOKESTATIC, "com/porpit/minecamera/transform/CamEventHandler", "setupMouseHandlerAfter", "()V", false));
}
}
}
});
}
use of org.objectweb.asm.tree.MethodNode in project MineCamera by PorPit.
the class Transformer method findMethod.
public MethodNode findMethod(ClassNode node, String name, String desc) {
if (TransformerNames.obfuscated) {
name = patchMethodName(name, desc);
desc = patchDESC(desc);
}
Iterator<MethodNode> methods = node.methods.iterator();
while (methods.hasNext()) {
MethodNode m = methods.next();
if (m.name.equals(name) && m.desc.equals(desc))
return m;
}
return null;
}
use of org.objectweb.asm.tree.MethodNode in project evosuite by EvoSuite.
the class AnnotatedClassNode method visitMethod.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
MethodNode mn = new AnnotatedMethodNode(access, name, desc, signature, exceptions);
methods.add(mn);
return mn;
}
use of org.objectweb.asm.tree.MethodNode in project evosuite by EvoSuite.
the class BooleanTestabilityTransformation method processMethods.
/**
* Handle transformation of methods defined in this class
*/
@SuppressWarnings("unchecked")
private void processMethods() {
List<MethodNode> methodNodes = cn.methods;
for (MethodNode mn : methodNodes) {
if ((mn.access & Opcodes.ACC_NATIVE) == Opcodes.ACC_NATIVE)
continue;
if (DescriptorMapping.getInstance().isTransformedMethod(className, mn.name, mn.desc)) {
logger.info("Transforming signature of method " + mn.name + mn.desc);
transformMethodSignature(mn);
logger.info("Transformed signature to " + mn.name + mn.desc);
}
transformMethod(mn);
}
}
use of org.objectweb.asm.tree.MethodNode in project evosuite by EvoSuite.
the class ErrorConditionMethodAdapter method visitEnd.
/*
public Frame currentFrame = null;
@Override
public void visitFrame(int type, int nLocal, Object[] local, int nStack,
Object[] stack) {
super.visitFrame(type, nLocal, local, nStack, stack);
// this.currentFrame = frames[numFrame++];
}
protected int numFrame = 0;
protected Frame[] frames;
@Override
public void visitCode() {
MethodNode mn = (MethodNode) mv;
try {
Analyzer a = new Analyzer(new ThisInterpreter());
a.analyze(className, mn);
frames = a.getFrames();
logger.info("Computed frames: "+frames.length);
} catch (Exception e) {
logger.info("Error during frame analysis: "+e);
frames = new Frame[0];
}
super.visitCode();
}
*/
/* (non-Javadoc)
* @see org.objectweb.asm.MethodVisitor#visitEnd()
*/
/**
* {@inheritDoc}
*/
@Override
public void visitEnd() {
MethodNode mn = (MethodNode) mv;
mn.accept(next);
}
Aggregations