當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractInsnNode類代碼示例

本文整理匯總了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);
}
 
開發者ID:ItzSomebody,項目名稱:Simple-JAR-Watermark,代碼行數:23,代碼來源:SourceInterpreter.java

示例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;
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:17,代碼來源:Analysis.java

示例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]);
}
 
開發者ID:jonathanedgecombe,項目名稱:anvil,代碼行數:17,代碼來源:VeinCapTransformer.java

示例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;
                    }
                }
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:AccessTransformer.java

示例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);
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:24,代碼來源:SourceInterpreter.java

示例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;
}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:18,代碼來源:LocalVariablesAnalyzer.java

示例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;
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:22,代碼來源:JarSourceCode.java

示例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);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:25,代碼來源:ReplacingInterpreter.java

示例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;
				}
			}
		}
	}

}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:25,代碼來源:LocalVariablesAnalyzer.java

示例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;
}
 
開發者ID:Parabot,項目名稱:Parabot-317-API-Minified-OS-Scape,代碼行數:24,代碼來源:ArchiveClassLoader.java

示例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);
                    }
                }
            }
        }
    }
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Nonce-ID-Finder,代碼行數:20,代碼來源:Finder.java

示例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);
}
 
開發者ID:shaunlebron,項目名稱:flex-fov,代碼行數:33,代碼來源:ParticleTransformer.java

示例13: methodInvokeInsn

import org.objectweb.asm.tree.AbstractInsnNode; //導入依賴的package包/類
public AbstractInsnNode methodInvokeInsn() {
  return new MethodInsnNode(
      INVOKESPECIAL,
      context.thisClassType().getInternalName(),
      methodName(),
      methodType().getDescriptor(),
      false);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:9,代碼來源:RunMethod.java

示例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);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:11,代碼來源:ConversionMethods.java

示例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);
}
 
開發者ID:Col-E,項目名稱:Recaf,代碼行數:13,代碼來源:TagTypeSwitchPanel.java


注:本文中的org.objectweb.asm.tree.AbstractInsnNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。