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


Java LineNumberNode類代碼示例

本文整理匯總了Java中org.objectweb.asm.tree.LineNumberNode的典型用法代碼示例。如果您正苦於以下問題:Java LineNumberNode類的具體用法?Java LineNumberNode怎麽用?Java LineNumberNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LineNumberNode類屬於org.objectweb.asm.tree包,在下文中一共展示了LineNumberNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getImportantList

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
public static InsnList getImportantList(InsnList list) {
	if (list.size() == 0) {
		return list;
	}

	HashMap<LabelNode, LabelNode> labels = new HashMap<>();

	for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
		if (insn instanceof LabelNode) {
			labels.put((LabelNode) insn, (LabelNode) insn);
		}
	}

	InsnList importantNodeList = new InsnList();

	for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
		if (insn instanceof LabelNode || insn instanceof LineNumberNode) {
			continue;
		}

		importantNodeList.add(insn.clone(labels));
	}
	return importantNodeList;
}
 
開發者ID:roryclaasen,項目名稱:RorysMod,代碼行數:25,代碼來源:InstructionComparator.java

示例2: run

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
@Override
public void run() {
	try {
		ListIterator<AbstractInsnNode> iterator = mn.instructions.iterator();
		AbstractInsnNode next;
		//TODO: implement stream
		while (iterator.hasNext()) {
			next = iterator.next();

			if (next instanceof LineNumberNode)
				iterator.set (
					new LineNumberNode (
						rand.nextInt(),
						((LineNumberNode) next).start
					)
				);
		}
	} catch(Throwable t) {
	}
}
 
開發者ID:MoofMonkey,項目名稱:NeonObf,代碼行數:21,代碼來源:LineNumberObfuscation.java

示例3: findLineNumber

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
/**
 * Finds the line number closest to the given node
 *
 * @param node the instruction node to get a line number for
 * @return the closest line number, or -1 if not known
 */
public static int findLineNumber(@NonNull AbstractInsnNode node) {
    AbstractInsnNode curr = node;

    // First search backwards
    while (curr != null) {
        if (curr.getType() == AbstractInsnNode.LINE) {
            return ((LineNumberNode) curr).line;
        }
        curr = curr.getPrevious();
    }

    // Then search forwards
    curr = node;
    while (curr != null) {
        if (curr.getType() == AbstractInsnNode.LINE) {
            return ((LineNumberNode) curr).line;
        }
        curr = curr.getNext();
    }

    return -1;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:29,代碼來源:ClassContext.java

示例4: getImportantList

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
public static InsnList getImportantList(InsnList list) {
	if (list.size() == 0) {
		return list;
	}

	HashMap<LabelNode, LabelNode> labels = new HashMap<LabelNode, LabelNode>();
	for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
		if (insn instanceof LabelNode) {
			labels.put((LabelNode) insn, (LabelNode) insn);
		}
	}

	InsnList importantNodeList = new InsnList();
	for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
		if (insn instanceof LabelNode || insn instanceof LineNumberNode) {
			continue;
		}

		importantNodeList.add(insn.clone(labels));
	}
	return importantNodeList;
}
 
開發者ID:NOVA-Team,項目名稱:NOVA-Core,代碼行數:23,代碼來源:InstructionComparator.java

示例5: visitEnd

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void visitEnd() {
	MethodNode methodNode = (MethodNode) mv;
	Iterator<AbstractInsnNode> nodeIter = methodNode.instructions.iterator();
	while (nodeIter.hasNext()) {
		AbstractInsnNode insnNode = nodeIter.next();
		if (insnNode.getType() == AbstractInsnNode.LINE) {
			currentLine = ((LineNumberNode) insnNode).line;
			methodNode.instructions.insertBefore(insnNode, getLineNumberInstrumentation());
			continue;
		}
		if ((insnNode.getType() == AbstractInsnNode.VAR_INSN)
				|| (insnNode.getType() == AbstractInsnNode.FIELD_INSN)
				|| (insnNode.getType() == AbstractInsnNode.IINC_INSN)
				|| (insnNode.getType() == AbstractInsnNode.INT_INSN)
				|| (insnNode.getType() == AbstractInsnNode.INSN)) {
			methodNode.instructions.insert(insnNode, getInstrumentation(insnNode));
		}
	}
	methodNode.accept(next);
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:23,代碼來源:TestRuntimeValuesDeterminer.java

示例6: findLineNumberForInstruction

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
/**
 * Find line number associated with an instruction.
 * @param insnList instruction list for method
 * @param insnNode instruction within method being searched against
 * @throws NullPointerException if any argument is {@code null} or contains {@code null}
 * @throws IllegalArgumentException if arguments aren't all from the same method
 * @return line number node associated with the instruction, or {@code null} if no line number exists
 */
public static LineNumberNode findLineNumberForInstruction(InsnList insnList, AbstractInsnNode insnNode) {
    Validate.notNull(insnList);
    Validate.notNull(insnNode);
    
    int idx = insnList.indexOf(insnNode);
    Validate.isTrue(idx != -1);
    
    // Get index of labels and insnNode within method
    ListIterator<AbstractInsnNode> insnIt = insnList.iterator(idx);
    while (insnIt.hasPrevious()) {
        AbstractInsnNode node = insnIt.previous();
        
        if (node instanceof LineNumberNode) {
            return (LineNumberNode) node;
        }
    }
    
    return null;
}
 
開發者ID:offbynull,項目名稱:coroutines,代碼行數:28,代碼來源:SearchUtils.java

示例7: scanForElse

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
/**
 * <p>
 * This method scans the instructions for 'else' and returns the node
 * </p>
 * 
 * @param ifTargetIndex
 *            Index of the target instruction of 'if'
 * @param endIndex
 *            Index of the end instruction upto which scanner will work
 * @param nestingLevel
 *            nesting level
 * @return Node
 */
private AbstractInsnNode scanForElse(int ifTargetIndex, int endIndex) {
	boolean lineNumberFound = false;
	LabelNode ln = (LabelNode) this.insnArr[ifTargetIndex];
	for (int i = ifTargetIndex + 1; i <= endIndex; i++) {
		AbstractInsnNode ain = this.insnArr[i];
		if (ain instanceof JumpInsnNode
				&& InstrumentUtil.getJumpInsnOpcodesMap().containsKey(
						ain.getOpcode())) {
			if (!lineNumberFound) {
				return ain;
			}
		} else if (ain instanceof LineNumberNode) {
			LineNumberNode lnn = (LineNumberNode) ain;
			// if the line does not belong to the label
			if (lnn.start != ln) {
				lineNumberFound = true;
				return null;
			}
		}
	}
	return null;
}
 
開發者ID:Impetus,項目名稱:jumbune,代碼行數:36,代碼來源:BlockLogMethodAdapter.java

示例8: getImportantList

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
public static InsnList getImportantList(InsnList list)
{
    if(list.size() == 0)
        return list;
    
    HashMap<LabelNode, LabelNode> labels = new HashMap<LabelNode, LabelNode>();
    for(AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext())
    {
        if(insn instanceof LabelNode)
            labels.put((LabelNode)insn, (LabelNode)insn);
    }        
    
    InsnList importantNodeList = new InsnList();
    for(AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext())
    {
        if(insn instanceof LabelNode || insn instanceof LineNumberNode)
            continue;
        
        importantNodeList.add(insn.clone(labels));
    }
    return importantNodeList;
}
 
開發者ID:Chicken-Bones,項目名稱:CCObfuscator,代碼行數:23,代碼來源:InstructionComparator.java

示例9: write

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
@Override
public void write(DoStmtToken token) {
    expr.writeDefineVariables(token.getLocal());

    LabelNode start = expr.writeLabel(node, token.getMeta().getStartLine());
    LabelNode end = new LabelNode();

    method.pushJump(end, start);
    expr.write(token.getBody());
    method.popJump();

    expr.writeConditional(token.getCondition(), end);

    add(new JumpInsnNode(GOTO, start));
    add(end);
    add(new LineNumberNode(token.getMeta().getEndLine(), end));

    expr.writeUndefineVariables(token.getLocal());
}
 
開發者ID:jphp-compiler,項目名稱:jphp,代碼行數:20,代碼來源:DoCompiler.java

示例10: writeBody

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
private void writeBody(IfStmtToken token) {
    LabelNode end = new LabelNode();
    LabelNode elseL = new LabelNode();

    expr.writePopBoolean();
    add(new JumpInsnNode(IFEQ, token.getElseBody() != null ? elseL : end));
    expr.stackPop();

    if (token.getBody() != null) {
        expr.write(token.getBody());
    }

    if (token.getElseBody() != null){
        add(new JumpInsnNode(GOTO, end));
        add(elseL);
        expr.write(token.getElseBody());
    }

    add(end);
    add(new LineNumberNode(token.getMeta().getEndLine(), end));
}
 
開發者ID:jphp-compiler,項目名稱:jphp,代碼行數:22,代碼來源:IfElseCompiler.java

示例11: write

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
@Override
public void write(WhileStmtToken token) {
    expr.writeDefineVariables(token.getLocal());

    LabelNode start = expr.writeLabel(node, token.getMeta().getStartLine());
    LabelNode end = new LabelNode();

    expr.writeConditional(token.getCondition(), end);

    method.pushJump(end, start);
    expr.write(BodyStmtToken.class, token.getBody());
    method.popJump();

    add(new JumpInsnNode(GOTO, start));
    add(end);
    add(new LineNumberNode(token.getMeta().getEndLine(), end));

    expr.writeUndefineVariables(token.getLocal());
}
 
開發者ID:jphp-compiler,項目名稱:jphp,代碼行數:20,代碼來源:WhileCompiler.java

示例12: areNodesEqual

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
public static boolean areNodesEqual(AbstractInsnNode node, AbstractInsnNode node2) {
	if (node.getClass() == node2.getClass() && node.getOpcode() == node2.getOpcode()) {
		if (node instanceof MethodInsnNode) {
			return ((MethodInsnNode) node).name.equals(((MethodInsnNode) node2).name)
					&& ((MethodInsnNode) node).desc.equals(((MethodInsnNode) node2).desc)
					&& ((MethodInsnNode) node).owner.equals(((MethodInsnNode) node2).owner);
		} else if (node instanceof VarInsnNode) {
			return ((VarInsnNode) node).var == ((VarInsnNode) node2).var;
		} else if (node instanceof InsnNode) {
			return true;
		} else if (node instanceof TypeInsnNode) {
			return ((TypeInsnNode) node).desc.equals(((TypeInsnNode) node2).desc);
		} else if (node instanceof JumpInsnNode) {
			return ((JumpInsnNode) node).label == ((JumpInsnNode) node2).label;
		} else if (node instanceof LabelNode) {
			return node == node2;
		} else if (node instanceof LineNumberNode) {
			return ((LineNumberNode) node).line == ((LineNumberNode) node2).line;
		} else if (node instanceof FieldInsnNode) {
			return ((FieldInsnNode) node).name.equals(((FieldInsnNode) node2).name)
					&& ((FieldInsnNode) node).desc.equals(((FieldInsnNode) node2).desc)
					&& ((FieldInsnNode) node).owner.equals(((FieldInsnNode) node2).owner);
		} else if (node instanceof LdcInsnNode) {
			return ((LdcInsnNode) node).cst.equals(((LdcInsnNode) node2).cst);
		}
	}
	return false;
}
 
開發者ID:PorPit,項目名稱:MineCamera,代碼行數:29,代碼來源:Transformer.java

示例13: getNext

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
@SuppressWarnings("all")
private static AbstractInsnNode getNext(Iterator<AbstractInsnNode> it) {
	while (it.hasNext()) {
		final AbstractInsnNode in = it.next();
		if (!(in instanceof LineNumberNode)) {
			return in;
		}
	}
	return null;
}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:11,代碼來源:SelfAssignmentAnalyzer.java

示例14: findLineNumbers

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
private static List<Integer> findLineNumbers(InsnList insnList) {
    List<Integer> lineNumbers = new ArrayList<>();

    insnList.iterator().forEachRemaining(i -> {
        if (i instanceof LineNumberNode) {
            lineNumbers.add(((LineNumberNode) i).line);
        }
    });

    return lineNumbers;
}
 
開發者ID:UniquePassive,項目名稱:osrs-exploits,代碼行數:12,代碼來源:GamepackMethodOriginalClassFinder.java

示例15: transform

import org.objectweb.asm.tree.LineNumberNode; //導入依賴的package包/類
@Override
public boolean transform() throws Throwable {
    classNodes().forEach(classNode -> {
        classNode.methods.forEach(methodNode -> {
            Iterator<AbstractInsnNode> it = methodNode.instructions.iterator();
            while (it.hasNext()) {
                if (it.next() instanceof LineNumberNode) {
                    it.remove();
                }
            }
        });
    });

    return true;
}
 
開發者ID:java-deobfuscator,項目名稱:deobfuscator,代碼行數:16,代碼來源:LineNumberRemover.java


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