本文整理匯總了Java中org.objectweb.asm.tree.FieldInsnNode.getOpcode方法的典型用法代碼示例。如果您正苦於以下問題:Java FieldInsnNode.getOpcode方法的具體用法?Java FieldInsnNode.getOpcode怎麽用?Java FieldInsnNode.getOpcode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.tree.FieldInsnNode
的用法示例。
在下文中一共展示了FieldInsnNode.getOpcode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateState
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
private void updateState(FieldInsnNode insn) {
Type type = Type.getType(insn.desc);
switch (insn.getOpcode()) {
case Opcodes.GETSTATIC:
state.push(type);
break;
case Opcodes.PUTSTATIC:
state.pop();
break;
case Opcodes.GETFIELD: {
state.pop(JarState.OBJECT_TYPE);
state.push(type);
break;
}
case Opcodes.PUTFIELD: {
state.pop();
state.pop(JarState.OBJECT_TYPE);
break;
}
default:
throw new Unreachable("Unexpected FieldInsn opcode: " + insn.getOpcode());
}
}
示例2: shouldMarkStack
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
public static boolean shouldMarkStack(MethodNode methodNode) {
for (Iterator<AbstractInsnNode> iterator = methodNode.instructions.iterator(); iterator.hasNext();) {
AbstractInsnNode insn = iterator.next();
if (insn instanceof FieldInsnNode) {
FieldInsnNode field = (FieldInsnNode) insn;
if (field.getOpcode() == PUTFIELD && field.name.equals("stackContext") &&
field.owner.equals(AlchemyTransformerManager.HOOK_RESULT_DESC))
return true;
}
if (insn instanceof MethodInsnNode) {
MethodInsnNode method = (MethodInsnNode) insn;
if (method.name.equals("operationStack") && method.owner.equals(AlchemyTransformerManager.HOOK_RESULT_DESC))
return true;
}
}
return false;
}
示例3: transformFieldInsnNode
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
@Override
protected AbstractInsnNode transformFieldInsnNode(MethodNode mn,
FieldInsnNode fieldNode) {
// This handles the else branch for field assignments
if (DescriptorMapping.getInstance().isTransformedOrBooleanField(this.booleanTestabilityTransformation.className,
fieldNode.name,
fieldNode.desc)) {
if (fieldNode.getNext() instanceof FieldInsnNode) {
FieldInsnNode other = (FieldInsnNode) fieldNode.getNext();
if (fieldNode.owner.equals(other.owner)
&& fieldNode.name.equals(other.name)
&& fieldNode.desc.equals(other.desc)) {
if (fieldNode.getOpcode() == Opcodes.GETFIELD
&& other.getOpcode() == Opcodes.PUTFIELD) {
this.booleanTestabilityTransformation.insertGetBefore(other, mn.instructions);
} else if (fieldNode.getOpcode() == Opcodes.GETSTATIC
&& other.getOpcode() == Opcodes.PUTSTATIC) {
this.booleanTestabilityTransformation.insertGetBefore(other, mn.instructions);
}
}
}
}
return fieldNode;
}
示例4: getInfectionDistance
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
/**
* <p>
* getInfectionDistance
* </p>
*
* @param original
* a {@link org.objectweb.asm.tree.FieldInsnNode} object.
* @param mutant
* a {@link org.objectweb.asm.tree.InsnList} object.
* @return a {@link org.objectweb.asm.tree.InsnList} object.
*/
public InsnList getInfectionDistance(FieldInsnNode original, InsnList mutant) {
InsnList distance = new InsnList();
if (original.getOpcode() == Opcodes.GETFIELD)
distance.add(new InsnNode(Opcodes.DUP)); //make sure to re-load this for GETFIELD
distance.add(new FieldInsnNode(original.getOpcode(), original.owner,
original.name, original.desc));
Type type = Type.getType(original.desc);
if (type.getDescriptor().startsWith("L") || type.getDescriptor().startsWith("[")) {
ReplaceVariable.addReferenceDistanceCheck(distance, type, mutant);
} else {
ReplaceVariable.addPrimitiveDistanceCheck(distance, type, mutant);
}
return distance;
}
示例5: transform
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
@Override
public byte[] transform(String name, String transformedName, byte[] basicClass) {
if (basicClass == null)
return null;
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(basicClass);
classReader.accept(classNode, 0);
for (MethodNode m: classNode.methods)
{
for (ListIterator<AbstractInsnNode> it = m.instructions.iterator(); it.hasNext(); )
{
AbstractInsnNode insnNode = it.next();
if (insnNode.getType() == AbstractInsnNode.FIELD_INSN)
{
FieldInsnNode fi = (FieldInsnNode)insnNode;
if (FLUID_TYPE.equals(fi.owner) && LEGACY_FIELDNAME.equals(fi.name) && fi.getOpcode() == Opcodes.GETFIELD)
{
FMLLog.fine("Method %s.%s%s: Replacing GETFIELD fluidID with INVOKEVIRTUAL getFluidID", name, m.name, m.desc);
it.remove();
MethodInsnNode replace = new MethodInsnNode(Opcodes.INVOKEVIRTUAL, FLUID_TYPE, GETID_NAME, GETID_DESC, false);
it.add(replace);
}
}
}
}
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
return writer.toByteArray();
}
示例6: convertGetFieldInsn
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
private void convertGetFieldInsn(FieldInsnNode insn) {
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr;
Type type;
if (out == null) {
SootClass declClass = Scene.v().getSootClass(
AsmUtil.toQualifiedName(insn.owner));
type = AsmUtil.toJimpleType(insn.desc);
Value val;
SootFieldRef ref;
if (insn.getOpcode() == GETSTATIC) {
ref = Scene.v().makeFieldRef(declClass, insn.name, type, true);
val = Jimple.v().newStaticFieldRef(ref);
} else {
Operand base = popLocal();
ref = Scene.v().makeFieldRef(declClass, insn.name, type, false);
InstanceFieldRef ifr =
Jimple.v().newInstanceFieldRef(
base.stackOrValue(), ref);
val = ifr;
base.addBox(ifr.getBaseBox());
frame.in(base);
frame.boxes(ifr.getBaseBox());
}
opr = new Operand(insn, val);
frame.out(opr);
} else {
opr = out[0];
type = opr.<FieldRef>value().getFieldRef().type();
if (insn.getOpcode() == GETFIELD)
frame.mergeIn(pop());
}
push(type, opr);
}
示例7: convertFieldInsn
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
private void convertFieldInsn(FieldInsnNode insn) {
int op = insn.getOpcode();
if (op == GETSTATIC || op == GETFIELD)
convertGetFieldInsn(insn);
else
convertPutFieldInsn(insn);
}
示例8: TransformerInjectTracker
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
private TransformerInjectTracker(Transformer transformer, FieldInsnNode fieldInsnNode, InsnList insnList)
{
this.transformer = transformer;
this.fieldInsnNode = fieldInsnNode;
this.isStatic = fieldInsnNode.getOpcode() == PUTSTATIC;
this.resultNodeList = insnList;
this.initNodeList = insnList;
}
示例9: handleFieldInsnNode
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
/**
* Descend into a static field read
*
*/
private static void handleFieldInsnNode(GetStaticGraph staticUsageTree,
ClassNode cn, MethodNode mn, FieldInsnNode insn, int depth) {
// Skip field instructions that are not reads to static fields
if (insn.getOpcode() != Opcodes.GETSTATIC) {
return;
}
// Only collect relations for instrumentable classes
String calleeClassName = insn.owner.replaceAll("/", ".");
if (BytecodeInstrumentation.checkIfCanInstrument(calleeClassName)) {
logger.debug("Handling field read: " + insn.name);
if (!staticUsageTree.hasStaticFieldRead(cn.name, mn.name + mn.desc,
insn.owner, insn.name)) {
handleClassInitializer(staticUsageTree, cn, mn, insn.owner,
depth);
// Add static read from mn to insn to static usage graph
staticUsageTree.addStaticFieldRead(cn.name, mn.name + mn.desc,
insn.owner, insn.name);
handle(staticUsageTree, insn.owner, insn.name + insn.desc,
depth);
}
}
}
示例10: apply
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public List<Mutation> apply(MethodNode mn, String className, String methodName,
BytecodeInstruction instruction, Frame frame) {
List<Mutation> mutations = new LinkedList<Mutation>();
FieldInsnNode node = (FieldInsnNode) instruction.getASMNode();
Type fieldType = Type.getType(node.desc);
// insert mutation into bytecode with conditional
InsnList mutation = new InsnList();
logger.debug("Mutation deletefield for statement " + node.name + node.desc);
if (node.getOpcode() == Opcodes.GETFIELD) {
logger.debug("Deleting source of type " + node.owner);
mutation.add(new InsnNode(Opcodes.POP));
}
mutation.add(getDefault(fieldType));
// insert mutation into pool
Mutation mutationObject = MutationPool.addMutation(className,
methodName,
NAME + " " + node.name
+ node.desc,
instruction,
mutation,
getInfectionDistance(node,
mutation));
mutations.add(mutationObject);
return mutations;
}
示例11: convertPutFieldInsn
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
private void convertPutFieldInsn(FieldInsnNode insn) {
boolean instance = insn.getOpcode() == PUTFIELD;
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr, rvalue;
Type type;
if (out == null) {
SootClass declClass = Scene.v().getSootClass(
AsmUtil.toQualifiedName(insn.owner));
type = AsmUtil.toJimpleType(insn.desc);
Value val;
SootFieldRef ref;
rvalue = popImmediate(type);
if (!instance) {
ref = Scene.v().makeFieldRef(declClass, insn.name, type, true);
val = Jimple.v().newStaticFieldRef(ref);
frame.in(rvalue);
} else {
Operand base = popLocal();
ref = Scene.v().makeFieldRef(declClass, insn.name, type, false);
InstanceFieldRef ifr =
Jimple.v().newInstanceFieldRef(
base.stackOrValue(), ref);
val = ifr;
base.addBox(ifr.getBaseBox());
frame.in(rvalue, base);
}
opr = new Operand(insn, val);
frame.out(opr);
AssignStmt as = Jimple.v().newAssignStmt(val, rvalue.stackOrValue());
rvalue.addBox(as.getRightOpBox());
if (!instance) {
frame.boxes(as.getRightOpBox());
} else {
frame.boxes(as.getRightOpBox(),
((InstanceFieldRef) val).getBaseBox());
}
setUnit(insn, as);
} else {
opr = out[0];
type = opr.<FieldRef>value().getFieldRef().type();
rvalue = pop(type);
if (!instance) {
/* PUTSTATIC only needs one operand on the stack, the rvalue */
frame.mergeIn(rvalue);
} else {
/* PUTFIELD has a rvalue and a base */
frame.mergeIn(rvalue, pop());
}
}
/*
* in case any static field or array is read from, and the static constructor
* or the field this instruction writes to, modifies that field, write out any
* previous read from field/array
*/
assignReadOps(null);
}
示例12: transform
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
@Override
@Unsafe(Unsafe.ASM_API)
public byte[] transform(String name, String transformedName, byte[] basicClass) {
String renderWorldPass = "func_175068_a", debugView = "field_175078_W",
updateCameraAndRender = "func_181560_a", thePlayer = "field_71439_g", getRenderViewEntity = "func_175606_aa",
clazzName = ASMHelper.getClassName(transformedName), minecraft = "net/minecraft/client/Minecraft";
if (!AlchemyEngine.isRuntimeDeobfuscationEnabled()) {
renderWorldPass = DeobfuscatingRemapper.instance().mapMethodName(clazzName, renderWorldPass, "(IFJ)V");
debugView = DeobfuscatingRemapper.instance().mapFieldName(clazzName, debugView, "Z");
updateCameraAndRender = DeobfuscatingRemapper.instance().mapMethodName(clazzName, updateCameraAndRender, "(FJ)V");
thePlayer = DeobfuscatingRemapper.instance().mapFieldName(clazzName, thePlayer, "Lnet/minecraft/client/entity/EntityPlayerSP;");
getRenderViewEntity = DeobfuscatingRemapper.instance().mapMethodName(minecraft, getRenderViewEntity, "()Lnet/minecraft/entity/Entity;");
}
ClassReader reader = new ClassReader(basicClass);
ClassWriter writer = ASMHelper.newClassWriter(ClassWriter.COMPUTE_FRAMES);
ClassNode node = new ClassNode(ASM5);
reader.accept(node, 0);
for (MethodNode method : node.methods) {
// if (method.name.equals(renderWorldPass)) {
// AlchemyTransformerManager.transform("<remove>" + name + "|" + transformedName + "#" + renderWorldPass + method.desc);
// int i = 0;
// for (Iterator<AbstractInsnNode> iterator = method.instructions.iterator(); iterator.hasNext();) {
// AbstractInsnNode insn = iterator.next();
// if (insn instanceof FieldInsnNode) {
// FieldInsnNode field = (FieldInsnNode) insn;
// if (field.getOpcode() == GETFIELD &&
// field.owner.equals(clazzName) && field.name.equals(debugView) && field.desc.equals("Z")) {
// if (i == 1) {
// AbstractInsnNode first = field.getPrevious();
// LabelNode label = ((JumpInsnNode) field.getNext()).label;
// AbstractInsnNode last = label.getNext();
// insn = insn.getPrevious().getPrevious();
// AbstractInsnNode next = insn;
// while (next != last) {
// insn = next;
// next = next.getNext();
// method.instructions.remove(insn);
// }
// break insn_node;
// } else
// i++;
// }
// }
// }
// }
if (method.name.equals(updateCameraAndRender)) {
AlchemyTransformerManager.transform("<fix>" + name + "|" + transformedName + "#" + updateCameraAndRender + method.desc);
boolean flag = false;
for (ListIterator<AbstractInsnNode> iterator = method.instructions.iterator(); iterator.hasNext();) {
AbstractInsnNode insn = iterator.next();
if (insn instanceof FieldInsnNode) {
FieldInsnNode field = (FieldInsnNode) insn;
if (field.getOpcode() == GETFIELD &&
field.owner.equals(minecraft) && field.name.equals(thePlayer) &&
field.desc.equals("Lnet/minecraft/client/entity/EntityPlayerSP;")) {
iterator.remove();
iterator.add(new MethodInsnNode(INVOKEVIRTUAL, minecraft,
"getRenderViewEntity", "()Lnet/minecraft/entity/Entity;", false));
flag = true;
}
}
if (flag && insn instanceof MethodInsnNode) {
MethodInsnNode methodInsn = (MethodInsnNode) insn;
methodInsn.owner = "net/minecraft/entity/Entity";
flag = false;
}
}
}
}
node.accept(writer);
return writer.toByteArray();
}
示例13: createAccessMethodsForAsyncMethod
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
protected void createAccessMethodsForAsyncMethod() {
List<MethodNode> methods = methodsOf(classNode);
for (Iterator<?> i = originalAsyncMethod.instructions.iterator(); i.hasNext();) {
AbstractInsnNode instruction = (AbstractInsnNode) i.next();
if (instruction instanceof MethodInsnNode) {
MethodInsnNode methodInstructionNode = (MethodInsnNode) instruction;
if ((methodInstructionNode.getOpcode() == INVOKEVIRTUAL ||
methodInstructionNode.getOpcode() == INVOKESPECIAL ||
methodInstructionNode.getOpcode() == INVOKESTATIC
) && methodInstructionNode.owner.equals(classNode.name)) {
MethodNode targetMethodNode = getMethod(methodInstructionNode.name, methodInstructionNode.desc,
methods);
if (null != targetMethodNode && (targetMethodNode.access & ACC_PRIVATE) != 0) {
log.debug("Found private call " + BytecodeTraceUtil.toString(methodInstructionNode));
createAccessMethod(methodInstructionNode,
(targetMethodNode.access & ACC_STATIC) != 0, methods);
}
}
if (methodInstructionNode.getOpcode() == INVOKESPECIAL &&
!"<init>".equals(methodInstructionNode.name) &&
!methodInstructionNode.owner.equals(classNode.name)) {
// INVOKESPECIAL is used for constructors/super-call,
// private instance methods
// Here we filtered out only to private super-method calls
log.debug("Found super-call " + BytecodeTraceUtil.toString(methodInstructionNode));
createAccessMethod(methodInstructionNode, false, methods);
}
}
if (instruction instanceof FieldInsnNode) {
FieldInsnNode fieldInstructionNode = (FieldInsnNode) instruction;
if (fieldInstructionNode.owner.equals(classNode.name)) {
FieldNode targetFieldNode =
getField(classNode, fieldInstructionNode.name, fieldInstructionNode.desc);
if (null != targetFieldNode && (targetFieldNode.access & ACC_PRIVATE) != 0) {
// log.debug("Found " +
// BytecodeTraceUtil.toString(fieldInstructionNode));
if (fieldInstructionNode.getOpcode() == GETSTATIC ||
fieldInstructionNode.getOpcode() == GETFIELD) {
createAccessGetter(fieldInstructionNode, (targetFieldNode.access & ACC_STATIC) != 0, methods);
} else if (fieldInstructionNode.getOpcode() == PUTSTATIC ||
fieldInstructionNode.getOpcode() == PUTFIELD) {
createAccessSetter(fieldInstructionNode, (targetFieldNode.access & ACC_STATIC) != 0, methods);
}
}
}
}
}
}
示例14: collectMethods
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public Set<MethodIdentifier> collectMethods() {
Set<MethodIdentifier> methods = new LinkedHashSet<MethodIdentifier>();
for (String calledClassName : getStaticFields.keySet()) {
ClassNode classNode = DependencyAnalysis
.getClassNode(calledClassName);
List<MethodNode> classMethods = classNode.methods;
for (MethodNode mn : classMethods) {
if (mn.name.equals(CLINIT))
continue;
InsnList instructions = mn.instructions;
Iterator<AbstractInsnNode> it = instructions.iterator();
while (it.hasNext()) {
AbstractInsnNode insn = it.next();
if (insn instanceof FieldInsnNode) {
FieldInsnNode fieldInsn = (FieldInsnNode) insn;
if (fieldInsn.getOpcode() != Opcodes.PUTSTATIC) {
continue;
}
String calleeClassName = fieldInsn.owner.replaceAll(
"/", ".");
String calleeFieldName = fieldInsn.name;
if (contains(getStaticFields, calleeClassName,
calleeFieldName)) {
MethodIdentifier methodIdentifier = new MethodIdentifier(
calledClassName, mn.name, mn.desc);
methods.add(methodIdentifier);
}
}
}
}
}
return methods;
}
示例15: processBlockWorkbenchClass
import org.objectweb.asm.tree.FieldInsnNode; //導入方法依賴的package包/類
@Mapping(provides={
"net/minecraft/stats/StatList",
"net/minecraft/util/ChatComponentTranslation",
"net/minecraft/inventory/ContainerWorkbench"
},
depends={
"net/minecraft/block/BlockWorkbench",
"net/minecraft/block/BlockWorkbench$InterfaceCraftingTable",
"net/minecraft/inventory/Container"
})
public boolean processBlockWorkbenchClass()
{
ClassNode workbench = getClassNodeFromMapping("net/minecraft/block/BlockWorkbench");
ClassNode workbenchIface = getClassNodeFromMapping("net/minecraft/block/BlockWorkbench$InterfaceCraftingTable");
ClassNode container = getClassNodeFromMapping("net/minecraft/inventory/Container");
if (!MeddleUtil.notNull(workbench, workbenchIface, container)) return false;
List<FieldInsnNode> fieldNodes = getAllInsnNodesOfType(workbench, FieldInsnNode.class);
for (FieldInsnNode fn : fieldNodes) {
if (fn.getOpcode() != Opcodes.GETSTATIC) continue;
if (searchConstantPoolForStrings(fn.owner, "stat.leaveGame", "stat.playerKills")) {
addClassMapping("net/minecraft/stats/StatList", fn.owner);
}
}
boolean foundTranslate = false;
List<TypeInsnNode> typeNodes = getAllInsnNodesOfType(workbenchIface, TypeInsnNode.class);
List<TypeInsnNode> containers = new ArrayList<>();
for (TypeInsnNode tn : typeNodes) {
if (!foundTranslate && searchConstantPoolForStrings(tn.desc, "TranslatableComponent{key=\'")) {
foundTranslate = true;
addClassMapping("net/minecraft/util/ChatComponentTranslation", tn.desc);
}
else {
ClassNode cn = getClassNode(tn.desc);
if (cn != null && cn.superName != null && cn.superName.equals(container.name)) containers.add(tn);
}
}
if (containers.size() == 1) {
addClassMapping("net/minecraft/inventory/ContainerWorkbench", containers.get(0).desc);
}
return true;
}