当前位置: 首页>>代码示例>>Java>>正文


Java LookupSwitchInsnNode类代码示例

本文整理汇总了Java中org.objectweb.asm.tree.LookupSwitchInsnNode的典型用法代码示例。如果您正苦于以下问题:Java LookupSwitchInsnNode类的具体用法?Java LookupSwitchInsnNode怎么用?Java LookupSwitchInsnNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LookupSwitchInsnNode类属于org.objectweb.asm.tree包,在下文中一共展示了LookupSwitchInsnNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitLookupSwitchInsnNode

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
private void visitLookupSwitchInsnNode(LookupSwitchInsnNode node) {
	ExpressionStack stack = mState.getActiveStack();
	int defaultLabel = stack.getLabelId(node.dflt.getLabel());
	Map<Integer, String> labelCaseMap = new HashMap<>();
	for (int i = 0; i < node.labels.size(); i++) {
		int labelId = stack.getLabelId(((LabelNode) node.labels.get(i)).getLabel());
		String caseKey = String.valueOf(node.keys.get(i));
		labelCaseMap.put(labelId, caseKey);
	}
	labelCaseMap.put(defaultLabel, SwitchExpression.CaseExpression.DEFAULT);

	SwitchExpression switchExp = new SwitchExpression(node.getOpcode());
	mState.moveNode();
	updateSwitchWithCases(switchExp, defaultLabel, labelCaseMap);
	stack.push(switchExp);
}
 
开发者ID:JozefCeluch,项目名称:thesis-disassembler,代码行数:17,代码来源:SwitchInsnNodeHandler.java

示例2: findJumpTargets

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
private static Set<AbstractInsnNode> findJumpTargets(final InsnList instructions) {
  final Set<AbstractInsnNode> jumpTargets = new HashSet<AbstractInsnNode>();
  final ListIterator<AbstractInsnNode> it = instructions.iterator();
  while (it.hasNext()) {
    final AbstractInsnNode o = it.next();
    if (o instanceof JumpInsnNode) {
      jumpTargets.add(((JumpInsnNode) o).label);
    } else if (o instanceof TableSwitchInsnNode) {
      final TableSwitchInsnNode twn = (TableSwitchInsnNode) o;
      jumpTargets.add(twn.dflt);
      jumpTargets.addAll(twn.labels);
    } else if (o instanceof LookupSwitchInsnNode) {
      final LookupSwitchInsnNode lsn = (LookupSwitchInsnNode) o;
      jumpTargets.add(lsn.dflt);
      jumpTargets.addAll(lsn.labels);
    }
  }
  return jumpTargets;
}
 
开发者ID:ncredinburgh,项目名称:QuickTheories,代码行数:20,代码来源:ControlFlowAnalyser.java

示例3: registerSwitchInstruction

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
private void registerSwitchInstruction(BytecodeInstruction v) {
	if (!v.isSwitch())
		throw new IllegalArgumentException("expect a switch instruction");

	LabelNode defaultLabel = null;

	switch (v.getASMNode().getOpcode()) {
	case Opcodes.TABLESWITCH:
		TableSwitchInsnNode tableSwitchNode = (TableSwitchInsnNode) v.getASMNode();
		registerTableSwitchCases(v, tableSwitchNode);
		defaultLabel = tableSwitchNode.dflt;

		break;
	case Opcodes.LOOKUPSWITCH:
		LookupSwitchInsnNode lookupSwitchNode = (LookupSwitchInsnNode) v.getASMNode();
		registerLookupSwitchCases(v, lookupSwitchNode);
		defaultLabel = lookupSwitchNode.dflt;
		break;
	default:
		throw new IllegalStateException(
		        "expect ASMNode of a switch to either be a LOOKUP- or TABLESWITCH");
	}

	registerDefaultCase(v, defaultLabel);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:26,代码来源:BranchPool.java

示例4: instrumentswitchBlock

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
/**
 * <p>
 * This method finds Switch block in a method and processes it
 * </p>.
 *
 * @param scanStartIndex Start index for the scan
 * @param scanEndIndex End index for the scan
 */
private void instrumentswitchBlock(int scanStartIndex,
		int scanEndIndex) {
	for (scanIndexForswitch = scanStartIndex; scanIndexForswitch <= scanEndIndex; scanIndexForswitch++) {
		AbstractInsnNode currentInsnNode = insnArr[scanIndexForswitch];

		if (currentInsnNode instanceof TableSwitchInsnNode
				&& Opcodes.TABLESWITCH == currentInsnNode.getOpcode()) {
			processTableSwitchBlock((TableSwitchInsnNode) currentInsnNode);
		} else if (currentInsnNode instanceof LookupSwitchInsnNode
				&& Opcodes.LOOKUPSWITCH == currentInsnNode.getOpcode()) {
			processLookupSwitchBlock((LookupSwitchInsnNode) currentInsnNode);
		}

	}
}
 
开发者ID:Impetus,项目名称:jumbune,代码行数:24,代码来源:CaseAdapter.java

示例5: findJumpTargets

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
private static Set<AbstractInsnNode> findJumpTargets(final InsnList instructions) {
  final Set<AbstractInsnNode> jumpTargets = new HashSet<>();
  final ListIterator<AbstractInsnNode> it = instructions.iterator();
  while (it.hasNext()) {
    final AbstractInsnNode o = it.next();
    if (o instanceof JumpInsnNode) {
      jumpTargets.add(((JumpInsnNode) o).label);
    } else if (o instanceof TableSwitchInsnNode) {
      final TableSwitchInsnNode twn = (TableSwitchInsnNode) o;
      jumpTargets.add(twn.dflt);
      jumpTargets.addAll(twn.labels);
    } else if (o instanceof LookupSwitchInsnNode) {
      final LookupSwitchInsnNode lsn = (LookupSwitchInsnNode) o;
      jumpTargets.add(lsn.dflt);
      jumpTargets.addAll(lsn.labels);
    }
  }
  return jumpTargets;
}
 
开发者ID:hcoles,项目名称:pitest,代码行数:20,代码来源:ControlFlowAnalyser.java

示例6: build

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
private void build(LookupSwitchInsnNode insn, IRBuilder builder) {
  processLocalVariablesAtControlEdge(insn, builder);
  int[] keys = new int[insn.keys.size()];
  for (int i = 0; i < insn.keys.size(); i++) {
    keys[i] = (int) insn.keys.get(i);
  }
  buildSwitch(insn.dflt, insn.labels, keys, builder);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:9,代码来源:JarSourceCode.java

示例7: switchStatement

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
public MethodDefinition switchStatement(String defaultCase, List<CaseStatement> cases)
{
    LabelNode defaultLabel = getLabel(defaultCase);

    int[] keys = new int[cases.size()];
    LabelNode[] labels = new LabelNode[cases.size()];
    for (int i = 0; i < cases.size(); i++) {
        keys[i] = cases.get(i).getKey();
        labels[i] = getLabel(cases.get(i).getLabel());
    }

    instructionList.add(new LookupSwitchInsnNode(defaultLabel, keys, labels));
    return this;
}
 
开发者ID:airlift,项目名称:drift,代码行数:15,代码来源:MethodDefinition.java

示例8: convertLookupSwitchInsn

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
private void convertLookupSwitchInsn(LookupSwitchInsnNode insn) {
	StackFrame frame = getFrame(insn);
	if (units.containsKey(insn)) {
		frame.mergeIn(pop());
		return;
	}
	Operand key = popImmediate();
	UnitBox dflt = Jimple.v().newStmtBox(null);
	
	List<UnitBox> targets = new ArrayList<UnitBox>(insn.labels.size());
	labels.put(insn.dflt, dflt);
	for (LabelNode ln : insn.labels) {
		UnitBox box = Jimple.v().newStmtBox(null);
		targets.add(box);
		labels.put(ln, box);
	}
	
	List<IntConstant> keys = new ArrayList<IntConstant>(insn.keys.size());
	for (Integer i : insn.keys)
		keys.add(IntConstant.v(i));
	
	LookupSwitchStmt lss = Jimple.v().newLookupSwitchStmt(key.stackOrValue(),
			keys, targets, dflt);
	key.addBox(lss.getKeyBox());
	frame.in(key);
	frame.boxes(lss.getKeyBox());
	setUnit(insn, lss);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:29,代码来源:AsmMethodSource.java

示例9: handle

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
@Override
public void handle(AbstractInsnNode node) throws IncorrectNodeException {
	super.handle(node);
	LOG.debug(logNode(node));
	if (node instanceof TableSwitchInsnNode) {
		visitTableSwitchInsnNode((TableSwitchInsnNode) node);
	} else if (node instanceof LookupSwitchInsnNode) {
		visitLookupSwitchInsnNode((LookupSwitchInsnNode) node);
	} else {
		throw new IncorrectNodeException("Incorrect node type, expected switch but was " + node.getClass().getSimpleName());
	}
}
 
开发者ID:JozefCeluch,项目名称:thesis-disassembler,代码行数:13,代码来源:SwitchInsnNodeHandler.java

示例10: testSwitch

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
private void testSwitch() {
    InsnList insnList = new InsnList();
    LabelNode defaultLabelNode = new LabelNode(new Label());
    LabelNode[] nodes = new LabelNode[2];
    nodes[0] = new LabelNode(new Label());
    nodes[1] = new LabelNode(new Label());
    nodes[0].accept(ga);
    ga.push(42);
    nodes[1].accept(ga);
    ga.push(43);
    LookupSwitchInsnNode lookupSwitchInsnNode = new LookupSwitchInsnNode(defaultLabelNode, new int[]{1, 2}, nodes);
    insnList.add(lookupSwitchInsnNode);
    insnList.accept(ga);
}
 
开发者ID:devictr,项目名称:fst-jit,代码行数:15,代码来源:FstCompiler.java

示例11: registerLookupSwitchCases

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
private void registerLookupSwitchCases(BytecodeInstruction v,
        LookupSwitchInsnNode lookupSwitchNode) {

	for (int i = 0; i < lookupSwitchNode.keys.size(); i++) {
		LabelNode targetLabel = (LabelNode) lookupSwitchNode.labels.get(i);
		Branch switchBranch = createSwitchCaseBranch(v,
		                                             (Integer) lookupSwitchNode.keys.get(i),
		                                             targetLabel);
		if (!switchBranch.isSwitchCaseBranch() || !switchBranch.isActualCase())
			throw new IllegalStateException(
			        "expect created branch to be an actual case branch of a switch");
	}
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:14,代码来源:BranchPool.java

示例12: handleLookupSwitchCases

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
/**
 * <p>
 * This method Handled the Switch cases of LookupSwitchInsnNode type in a
 * method
 * </p>.
 *
 * @param currentTableSwithInsn Type of switch block
 */
@SuppressWarnings("unchecked")
private void handleLookupSwitchCases(
		LookupSwitchInsnNode currentTableSwithInsn) {
	List<AbstractInsnNode> caseList = currentTableSwithInsn.labels;
	LabelNode currentLabel = currentTableSwithInsn.dflt;
	List<Integer> casekeys = currentTableSwithInsn.keys;

	int totalcaselogs = casekeys.size() * 2;

	String[] logMsgs = new String[totalcaselogs];
	int[] caseValues = new int[totalcaselogs];
	AbstractInsnNode abstractCaseInsnNode[] = new AbstractInsnNode[totalcaselogs];

	int index = 0;
	for (int i = 0; i < casekeys.size(); i++) {
		abstractCaseInsnNode[index] = caseList.get(i);
		caseValues[index] = casekeys.get(i);
		caseValues[index + 1] = casekeys.get(i);

		AbstractInsnNode nextNode = lookNode(caseList,
				abstractCaseInsnNode[index], currentLabel);

		abstractCaseInsnNode[index + 1] = nextNode;

		logMsgs[index] = InstrumentationMessageLoader
				.getMessage(MessageConstants.MSG_IN_SWITCHCASE);
		logMsgs[index + 1] = InstrumentationMessageLoader
				.getMessage(MessageConstants.MSG_OUT_SWITCHCASE);

		index += 2;
	}

	Integer[] lineNumbers = getLineNumbersForSwitchCase(abstractCaseInsnNode);

	InsnList[] il = getInsnForswitchCaseBlock(logMsgs, caseValues,
			lineNumbers);
	addInsnForswitchBlock(il, abstractCaseInsnNode);
}
 
开发者ID:Impetus,项目名称:jumbune,代码行数:47,代码来源:CaseAdapter.java

示例13: processLookupSwitchBlock

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
/**
 * <p>
 * This method Handled the Switch block of LookupSwitchInsnNode type in a
 * method
 * </p>.
 *
 * @param currentTableSwithInsn Type of switch block
 */
private void processLookupSwitchBlock(
		LookupSwitchInsnNode currentTableSwithInsn) {
	LabelNode currentLabel = currentTableSwithInsn.dflt;

	int switchStartIndex = CollectionUtil.getObjectIndexInArray(insnArr,
			currentTableSwithInsn);
	int switchTargetIndex = CollectionUtil.getObjectIndexInArray(insnArr,
			currentLabel);

	if (switchTargetIndex > switchStartIndex) {
		LOGGER.debug("switch block ended at: " + switchTargetIndex);
		switchCount++;

		AbstractInsnNode[] ainSwitchBlock = new AbstractInsnNode[] {
				currentTableSwithInsn.getPrevious(), currentLabel };

		Integer[] lineNumbers = getLineNumbersForSwitchBlock(ainSwitchBlock);

		InsnList[] il = getInsnForswitchBlock(switchCount, lineNumbers);
		addInsnForswitchBlock(il, ainSwitchBlock);

		scanIndexForswitch = switchTargetIndex;

		handleLookupSwitchCases(currentTableSwithInsn);
	}
}
 
开发者ID:Impetus,项目名称:jumbune,代码行数:35,代码来源:CaseAdapter.java

示例14: lookupswitch

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
public CodeBlock lookupswitch(final LabelNode defaultHandler,
    final int[] keys,
    final LabelNode[] handlers)
{
    instructionList.add(new LookupSwitchInsnNode(defaultHandler, keys,
        handlers));
    return this;
}
 
开发者ID:fge,项目名称:grappa,代码行数:9,代码来源:CodeBlock.java

示例15: visitLookupSwitchInsn

import org.objectweb.asm.tree.LookupSwitchInsnNode; //导入依赖的package包/类
public CodeBlock visitLookupSwitchInsn(final LabelNode defaultHandler,
    final int[] keys, final LabelNode[] handlers)
{
    instructionList.add(new LookupSwitchInsnNode(defaultHandler, keys,
        handlers));
    return this;
}
 
开发者ID:fge,项目名称:grappa,代码行数:8,代码来源:CodeBlock.java


注:本文中的org.objectweb.asm.tree.LookupSwitchInsnNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。