本文整理汇总了Java中org.objectweb.asm.tree.AbstractInsnNode类的典型用法代码示例。如果您正苦于以下问题:Java AbstractInsnNode类的具体用法?Java AbstractInsnNode怎么用?Java AbstractInsnNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractInsnNode类属于org.objectweb.asm.tree包,在下文中一共展示了AbstractInsnNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
int size;
switch (insn.getOpcode()) {
case LCONST_0:
case LCONST_1:
case DCONST_0:
case DCONST_1:
size = 2;
break;
case LDC:
Object cst = ((LdcInsnNode) insn).cst;
size = cst instanceof Long || cst instanceof Double ? 2 : 1;
break;
case GETSTATIC:
size = Type.getType(((FieldInsnNode) insn).desc).getSize();
break;
default:
size = 1;
}
return new SourceValue(size, insn);
}
示例2: getEntryPoints
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
private static BitSet getEntryPoints(MethodNode asmNode, Map<AbstractInsnNode, int[]> exitPoints) {
InsnList il = asmNode.instructions;
BitSet entryPoints = new BitSet(il.size());
for (int[] eps : exitPoints.values()) {
if (eps != null) {
for (int ep : eps) entryPoints.set(ep);
}
}
for (TryCatchBlockNode n : asmNode.tryCatchBlocks) {
entryPoints.set(il.indexOf(n.handler));
}
return entryPoints;
}
示例3: transform
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
@Override
public void transform(ClassNode clazz, MethodNode method, InsnMatcher matcher) {
AbstractInsnNode[] match = Iterators.getOnlyElement(matcher.match("BIPUSH ISTORE", m -> {
IntInsnNode push = (IntInsnNode) m[0];
if (push.operand != 50) {
return false;
}
VarInsnNode store = (VarInsnNode) m[1];
LocalVariableNode node = AsmUtils.getLocalVariable(method, store.var, store);
return node != null && node.name.equals("resource") && node.desc.equals("I");
}));
method.instructions.remove(match[0]);
method.instructions.remove(match[1]);
}
示例4: replaceInvokeSpecial
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
private void replaceInvokeSpecial(ClassNode clazz, List<MethodNode> toReplace)
{
for (MethodNode method : clazz.methods)
{
for (Iterator<AbstractInsnNode> it = method.instructions.iterator(); it.hasNext();)
{
AbstractInsnNode insn = it.next();
if (insn.getOpcode() == INVOKESPECIAL)
{
MethodInsnNode mInsn = (MethodInsnNode) insn;
for (MethodNode n : toReplace)
{
if (n.name.equals(mInsn.name) && n.desc.equals(mInsn.desc))
{
mInsn.setOpcode(INVOKEVIRTUAL);
break;
}
}
}
}
}
}
示例5: unaryOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
@Override
public SourceValue unaryOperation(final AbstractInsnNode insn,
final SourceValue value) {
int size;
switch (insn.getOpcode()) {
case LNEG:
case DNEG:
case I2L:
case I2D:
case L2D:
case F2L:
case F2D:
case D2L:
size = 2;
break;
case GETFIELD:
size = Type.getType(((FieldInsnNode) insn).desc).getSize();
break;
default:
size = 1;
}
return new SourceValue(size, insn);
}
示例6: analyzeMethod
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
@SuppressWarnings(UNCHECKED)
Set<LocalVariableNode> analyzeMethod() {
// si seulement 1 variable locale ("this") ou si seulement des "variables locales" pour les paramètres et pour "this",
// alors on passe à la méthode suivante
if (localVariables.isEmpty()) {
return Collections.emptySet();
}
for (final Iterator<AbstractInsnNode> it = methodNode.instructions.iterator(); it
.hasNext();) {
analyzeInstruction(it.next());
if (localVariables.isEmpty()) {
// si toutes les variables ont été utilisées, inutile de continuer à lire les instructions
return Collections.emptySet();
}
}
return localVariables;
}
示例7: getTryHandlers
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
private List<TryCatchBlock> getTryHandlers(AbstractInsnNode insn) {
List<TryCatchBlock> handlers = new ArrayList<>();
Set<String> seen = new HashSet<>();
// The try-catch blocks are ordered by precedence.
for (TryCatchBlock tryCatchBlock : getPotentialTryHandlers(insn)) {
if (tryCatchBlock.getType() == null) {
handlers.add(tryCatchBlock);
return handlers;
}
if (!seen.contains(tryCatchBlock.getType())) {
seen.add(tryCatchBlock.getType());
handlers.add(tryCatchBlock);
}
}
if (isSynchronized()) {
// Add synchronized exceptional exit for synchronized-method instructions without a default.
assert handlers.isEmpty() || handlers.get(handlers.size() - 1).getType() != null;
handlers.add(EXCEPTIONAL_SYNC_EXIT);
}
return handlers;
}
示例8: binaryOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
@Override
public BasicValue binaryOperation(final AbstractInsnNode insn,
final BasicValue value1, final BasicValue value2) throws AnalyzerException {
/*
* We're looking for the assignment of a local holder objectref to a member variable.
* If we spot that, then the local holder can't be replaced, since we don't (yet)
* have the mechanics to replace the member variable with the holder's members or
* to assign all of them when this happens.
*/
if (insn.getOpcode() == Opcodes.PUTFIELD) {
if (value2.isReference() && (value1 instanceof ReplacingBasicValue)) {
final ReplacingBasicValue possibleThis = (ReplacingBasicValue) value1;
if (possibleThis.isThis() && (value2 instanceof ReplacingBasicValue)) {
// if this is a reference for a holder class, we can't replace it
if (HOLDERS.get(value2.getType().getDescriptor()) != null) {
final ReplacingBasicValue localRef = (ReplacingBasicValue) value2;
localRef.setAssignedToMember();
}
}
}
}
return super.binaryOperation(insn, value1, value2);
}
示例9: analyzeInnerClass
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
@SuppressWarnings(UNCHECKED)
void analyzeInnerClass(ClassNode innerClass) {
if (methodNode.name.equals(innerClass.outerMethod)
&& methodNode.desc.equals(innerClass.outerMethodDesc)) {
// s'il y a une classe interne créée dans cette méthode
// utilisant éventuellement une variable finale de cette méthode,
// alors on cherche les constantes de variables (et uniquement celles-ci) dans toutes ses méthodes
// (si ce n'est pas une constante, alors elle serait déjà détectée utilisée dans la méthode)
for (final MethodNode innerMethodNode : (List<MethodNode>) innerClass.methods) {
for (final Iterator<AbstractInsnNode> it = innerMethodNode.instructions
.iterator(); it.hasNext();) {
// CHECKSTYLE:OFF
final AbstractInsnNode instruction = it.next();
// CHECKSTYLE:ON
analyzeConstantInstruction(instruction);
if (localVariables.isEmpty()) {
// si toutes les variables ont été utilisées, inutile de continuer à lire les instructions
return;
}
}
}
}
}
示例10: setSuper
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
public static void setSuper(ClassNode node, String superClass) {
String replacedSuper = "";
if (node.superName != "") {
replacedSuper = node.superName;
}
if (replacedSuper != "") {
ListIterator<?> mli = node.methods.listIterator();
while (mli.hasNext()) {
MethodNode mn = (MethodNode) mli.next();
ListIterator<?> ili = mn.instructions.iterator();
while (ili.hasNext()) {
AbstractInsnNode ain = (AbstractInsnNode) ili.next();
if (ain.getOpcode() == Opcodes.INVOKESPECIAL) {
MethodInsnNode min = (MethodInsnNode) ain;
if (min.owner.equals(replacedSuper)) {
min.owner = superClass;
}
}
}
}
}
node.superName = superClass;
}
示例11: findID
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
private static void findID(ClassNode classNode) throws Throwable {
for (MethodNode methodNode : classNode.methods) {
Iterator<AbstractInsnNode> insnIterator = methodNode.instructions.iterator();
while (insnIterator.hasNext()) {
AbstractInsnNode insnNode = insnIterator.next();
String str;
if ((insnNode.getType() == 9)) {
Object cst = ((LdcInsnNode) insnNode).cst;
if (cst instanceof String) {
str = ((LdcInsnNode) insnNode).cst.toString();
Matcher matcher = NONCEID_PATTERN.matcher(str);
if (matcher.find()) {
possiblenonces.add(str);
}
}
}
}
}
}
示例12: transformParticle
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
protected void transformParticle(ClassNode classNode, MethodNode method, AbstractInsnNode instruction, int firstInsn) {
InsnList toInsert = new InsnList();
toInsert.add(new VarInsnNode(FLOAD, 4));
toInsert.add(new VarInsnNode(FLOAD, 5));
toInsert.add(new VarInsnNode(FLOAD, 6));
toInsert.add(new VarInsnNode(FLOAD, 7));
toInsert.add(new VarInsnNode(FLOAD, 8));
toInsert.add(new VarInsnNode(FLOAD, firstInsn));
toInsert.add(new VarInsnNode(FLOAD, firstInsn+1));
toInsert.add(new VarInsnNode(FLOAD, firstInsn+2));
toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(ParticleTransformer.class),
"rotateParticle", "(FFFFFFFF)V", false));
toInsert.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(ParticleTransformer.class),
"rotX", "F"));
toInsert.add(new VarInsnNode(FSTORE, 4));
toInsert.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(ParticleTransformer.class),
"rotZ", "F"));
toInsert.add(new VarInsnNode(FSTORE, 5));
toInsert.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(ParticleTransformer.class),
"rotYZ", "F"));
toInsert.add(new VarInsnNode(FSTORE, 6));
toInsert.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(ParticleTransformer.class),
"rotXY", "F"));
toInsert.add(new VarInsnNode(FSTORE, 7));
toInsert.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(ParticleTransformer.class),
"rotXZ", "F"));
toInsert.add(new VarInsnNode(FSTORE, 8));
method.instructions.insertBefore(instruction, toInsert);
}
示例13: methodInvokeInsn
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
public AbstractInsnNode methodInvokeInsn() {
return new MethodInsnNode(
INVOKESPECIAL,
context.thisClassType().getInternalName(),
methodName(),
methodType().getDescriptor(),
false);
}
示例14: boxedNumberToLuaFormatString
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
public static AbstractInsnNode boxedNumberToLuaFormatString() {
return new MethodInsnNode(
INVOKESTATIC,
Type.getInternalName(Conversions.class),
"stringValueOf",
Type.getMethodDescriptor(
Type.getType(String.class),
Type.getType(Number.class)),
false);
}
示例15: TagTypeSwitchPanel
import org.objectweb.asm.tree.AbstractInsnNode; //导入依赖的package包/类
public TagTypeSwitchPanel(JList<AbstractInsnNode> list, Handle handle) {
this.list = list;
this.handle = handle;
//setMaximumSize(new Dimension(300, 300));
// content.setMaximumSize(new Dimension(300, 300));
// scroll.setMaximumSize(new Dimension(300, 300));
content.setLayout(new GridLayout(0, 2));
populate(OpcodeUtil.OPS_TAG, s -> OpcodeUtil.nameToTag(s));
setLayout(new BorderLayout());
JScrollPane scroll = new JScrollPane(content);
add(scroll, BorderLayout.CENTER);
}