List of usage examples for org.objectweb.asm Opcodes TABLESWITCH
int TABLESWITCH
To view the source code for org.objectweb.asm Opcodes TABLESWITCH.
Click Source Link
From source file:edu.mit.streamjit.util.bytecode.MethodResolver.java
License:Open Source License
private void interpret(TableSwitchInsnNode insn, FrameState frame, BBInfo block) { assert insn.getOpcode() == Opcodes.TABLESWITCH; ConstantFactory cf = module.constants(); SwitchInst inst = new SwitchInst(frame.stack.pop(), blockByInsn(insn.dflt).block); for (int i = insn.min; i <= insn.max; ++i) inst.put(cf.getConstant(i), blockByInsn(insn.labels.get(i - insn.min)).block); block.block.instructions().add(inst); }
From source file:edu.ubc.mirrors.holograms.FrameAnalyzer.java
License:Open Source License
@Override protected void newControlFlowEdge(int insn, int successor) { if (successor == insn + 1 && (currentInsn == null || (currentInsn.getOpcode() != Opcodes.TABLESWITCH && currentInsn.getOpcode() != Opcodes.LOOKUPSWITCH && currentInsn.getOpcode() != Opcodes.GOTO))) { stepIn[successor] = true;//from w w w . j ava 2 s . c o m } else { jumpIn[successor] = true; } super.newControlFlowEdge(insn, successor); }
From source file:org.decojer.cavaj.readers.asm.ReadMethodVisitor.java
License:Open Source License
@Override public void visitTableSwitchInsn(final int min, final int max, final Label dflt, final Label... labels) { /**********/*from ww w. j ava 2 s . co m*/ * SWITCH * **********/ final SWITCH op = new SWITCH(this.ops.size(), Opcodes.TABLESWITCH, this.line); add(op); // default int targetPc = getPc(dflt); op.setDefaultPc(targetPc); if (targetPc < 0) { getUnresolved(dflt).add(op); } // keys final int[] keys = new int[labels.length]; final int[] keyTargets = new int[labels.length]; for (int i = labels.length; i-- > 0;) { keys[i] = min + i; targetPc = getPc(labels[i]); keyTargets[i] = targetPc; if (targetPc < 0) { getUnresolved(labels[i]).add(op); } } op.setCaseKeys(keys); op.setCasePcs(keyTargets); }
From source file:org.evosuite.coverage.branch.BranchPool.java
License:Open Source License
private void registerSwitchInstruction(BytecodeInstruction v) { if (!v.isSwitch()) throw new IllegalArgumentException("expect a switch instruction"); LabelNode defaultLabel = null;/* w w w. j av a 2 s .c om*/ 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); }
From source file:org.evosuite.graphs.cfg.BytecodeInstructionPool.java
License:Open Source License
/** * Determine how many bytes the current instruction occupies together with * its operands/*from www.j a va 2s. c o m*/ * * @return */ private int getBytecodeIncrement(AbstractInsnNode instructionNode) { int opcode = instructionNode.getOpcode(); switch (opcode) { case Opcodes.ALOAD: // index case Opcodes.ASTORE: // index case Opcodes.DLOAD: case Opcodes.DSTORE: case Opcodes.FLOAD: case Opcodes.FSTORE: case Opcodes.ILOAD: case Opcodes.ISTORE: case Opcodes.LLOAD: case Opcodes.LSTORE: VarInsnNode varNode = (VarInsnNode) instructionNode; if (varNode.var > 3) return 1; else return 0; case Opcodes.BIPUSH: // byte case Opcodes.NEWARRAY: case Opcodes.RET: return 1; case Opcodes.LDC: LdcInsnNode ldcNode = (LdcInsnNode) instructionNode; if (ldcNode.cst instanceof Double || ldcNode.cst instanceof Long) return 2; // LDC2_W else return 1; case 19: //LDC_W case 20: //LDC2_W return 2; case Opcodes.ANEWARRAY: // indexbyte1, indexbyte2 case Opcodes.CHECKCAST: // indexbyte1, indexbyte2 case Opcodes.GETFIELD: case Opcodes.GETSTATIC: case Opcodes.GOTO: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: case Opcodes.IF_ICMPLT: case Opcodes.IFLE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFNE: case Opcodes.IFEQ: case Opcodes.IFNONNULL: case Opcodes.IFNULL: case Opcodes.IINC: case Opcodes.INSTANCEOF: case Opcodes.INVOKESPECIAL: case Opcodes.INVOKESTATIC: case Opcodes.INVOKEVIRTUAL: case Opcodes.JSR: case Opcodes.NEW: case Opcodes.PUTFIELD: case Opcodes.PUTSTATIC: case Opcodes.SIPUSH: // case Opcodes.LDC_W // case Opcodes.LDC2_W return 2; case Opcodes.MULTIANEWARRAY: return 3; case Opcodes.INVOKEDYNAMIC: case Opcodes.INVOKEINTERFACE: return 4; case Opcodes.LOOKUPSWITCH: case Opcodes.TABLESWITCH: // TODO: Could be more return 4; // case Opcodes.GOTO_W // case Opcodes.JSR_W } return 0; }
From source file:org.jacoco.core.internal.analysis.filter.AbstractMatcher.java
License:Open Source License
/** * Moves {@link #cursor} to next instruction if it is * <code>TABLESWITCH</code> or <code>LOOKUPSWITCH</code>, otherwise sets it * to <code>null</code>./*www .ja v a 2s . com*/ */ final void nextIsSwitch() { next(); if (cursor == null) { return; } switch (cursor.getOpcode()) { case Opcodes.TABLESWITCH: case Opcodes.LOOKUPSWITCH: return; default: cursor = null; } }
From source file:org.jacoco.core.internal.analysis.filter.KotlinWhenFilter.java
License:Open Source License
private static LabelNode getDefaultLabel(final AbstractInsnNode i) { switch (i.getOpcode()) { case Opcodes.LOOKUPSWITCH: return ((LookupSwitchInsnNode) i).dflt; case Opcodes.TABLESWITCH: return ((TableSwitchInsnNode) i).dflt; default:/* w w w . ja va 2 s .c om*/ return null; } }
From source file:org.jacoco.core.internal.analysis.filter.StringSwitchJavacFilter.java
License:Open Source License
/** * javac generates two switches. First one by {@link String#hashCode()}. * Number of handlers in the second switch is equal to number of handlers in * source code, so it is enough to completely filter-out first switch. * Handler for default case of the first switch - is the second switch. *///from w w w . ja v a 2 s.c o m private void filter(final AbstractInsnNode start, final IFilterOutput output) { final LabelNode dflt; if (start.getOpcode() == Opcodes.LOOKUPSWITCH) { dflt = ((LookupSwitchInsnNode) start).dflt; } else if (start.getOpcode() == Opcodes.TABLESWITCH) { dflt = ((TableSwitchInsnNode) start).dflt; } else { return; } if (new Matcher().match(start, dflt)) { output.ignore(start, dflt); } }
From source file:org.jboss.byteman.agent.adapter.RuleTriggerMethodAdapter.java
License:Open Source License
@Override public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) { super.visitTableSwitchInsn(min, max, dflt, labels); cfg.add(Opcodes.TABLESWITCH, min, max); // create a new current block and then add the default lable and each of the switch labels as an // outgoing path from the current block Label newStart = super.newLabel(); // must call split before visiting the label cfg.split(newStart, dflt, labels);/*from w ww .jav a2 s .c o m*/ visitLabel(newStart); }
From source file:org.jboss.byteman.agent.adapter.RuleTriggerMethodAdapter.java
License:Open Source License
@Override public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) { super.visitLookupSwitchInsn(dflt, keys, labels); cfg.add(Opcodes.TABLESWITCH, keys); // create a new current block and then add the default lable and each of the switch labels as an // outgoing path from the current block Label newStart = super.newLabel(); // must call split before visiting the label cfg.split(newStart, dflt, labels);// w ww . j av a2s. co m visitLabel(newStart); }