当前位置: 首页>>代码示例>>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;未经允许,请勿转载。