Java Code Examples for org.apache.bcel.Const#ISTORE
The following examples show how to use
org.apache.bcel.Const#ISTORE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalVariableInstruction.java From commons-bcel with Apache License 2.0 | 6 votes |
/** * Read needed data (e.g. index) from file. * <pre> * (ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3) * </pre> */ @Override protected void initFromFile( final ByteSequence bytes, final boolean wide ) throws IOException { if (wide) { n = bytes.readUnsignedShort(); super.setLength(4); } else { final short _opcode = super.getOpcode(); if (((_opcode >= Const.ILOAD) && (_opcode <= Const.ALOAD)) || ((_opcode >= Const.ISTORE) && (_opcode <= Const.ASTORE))) { n = bytes.readUnsignedByte(); super.setLength(2); } else if (_opcode <= Const.ALOAD_3) { // compact load instruction such as ILOAD_2 n = (_opcode - Const.ILOAD_0) % 4; super.setLength(1); } else { // Assert ISTORE_0 <= tag <= ASTORE_3 n = (_opcode - Const.ISTORE_0) % 4; super.setLength(1); } } }
Example 2
Source File: LocalVariableInstruction.java From commons-bcel with Apache License 2.0 | 6 votes |
/** * Returns the type associated with the instruction - * in case of ALOAD or ASTORE Type.OBJECT is returned. * This is just a bit incorrect, because ALOAD and ASTORE * may work on every ReferenceType (including Type.NULL) and * ASTORE may even work on a ReturnaddressType . * @return type associated with the instruction */ @Override public Type getType( final ConstantPoolGen cp ) { switch (canonTag) { case Const.ILOAD: case Const.ISTORE: return Type.INT; case Const.LLOAD: case Const.LSTORE: return Type.LONG; case Const.DLOAD: case Const.DSTORE: return Type.DOUBLE; case Const.FLOAD: case Const.FSTORE: return Type.FLOAT; case Const.ALOAD: case Const.ASTORE: return Type.OBJECT; default: throw new ClassGenException("Unknown case in switch" + canonTag); } }
Example 3
Source File: DismantleBytecode.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
public boolean isRegisterStore(int opcode) { switch (opcode) { case Const.ISTORE_0: case Const.ISTORE_1: case Const.ISTORE_2: case Const.ISTORE_3: case Const.ASTORE_0: case Const.ASTORE_1: case Const.ASTORE_2: case Const.ASTORE_3: case Const.FSTORE_0: case Const.FSTORE_1: case Const.FSTORE_2: case Const.FSTORE_3: case Const.DSTORE_0: case Const.DSTORE_1: case Const.DSTORE_2: case Const.DSTORE_3: case Const.LSTORE_0: case Const.LSTORE_1: case Const.LSTORE_2: case Const.LSTORE_3: case Const.ISTORE: case Const.FSTORE: case Const.ASTORE: case Const.LSTORE: case Const.DSTORE: return true; default: return false; } }
Example 4
Source File: FindBadForLoop.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void sawOpcode(int seen) { if (seen == Const.ISTORE || seen == Const.ISTORE_0 || seen == Const.ISTORE_1 || seen == Const.ISTORE_2 || seen == Const.ISTORE_3) { lastRegStore = getRegisterOperand(); } if (lineNumbers != null && stack.getStackDepth() >= 2 && (seen == Const.IF_ICMPGE || seen == Const.IF_ICMPGT || seen == Const.IF_ICMPLT || seen == Const.IF_ICMPLE || seen == Const.IF_ICMPNE || seen == Const.IF_ICMPEQ)) { OpcodeStack.Item item0 = stack.getStackItem(0); OpcodeStack.Item item1 = stack.getStackItem(1); int r0 = item0.getRegisterNumber(); int r1 = item1.getRegisterNumber(); int rMin = Math.min(r0, r1); int rMax = Math.max(r0, r1); int branchTarget = getBranchTarget(); if (rMin == -1 && rMax > 0 && rMax == lastRegStore && branchTarget - 6 > getPC()) { int beforeTarget = getCodeByte(branchTarget - 3); int beforeGoto = getCodeByte(branchTarget - 6); if (beforeTarget == Const.GOTO && beforeGoto == Const.IINC) { int offset1 = (byte) getCodeByte(branchTarget - 2); int offset2 = getCodeByte(branchTarget - 1); int offset = offset1 << 8 | offset2; int backTarget = branchTarget - 3 + offset; int reg = getCodeByte(branchTarget - 5); int testLineNumber = lineNumbers.getSourceLine(getPC()); int incLineNumber = lineNumbers.getSourceLine(branchTarget - 6); int beforeIncLineNumber = lineNumbers.getSourceLine(branchTarget - 7); if (backTarget < getPC() && getPC() - 8 < backTarget && reg != rMax && incLineNumber < testLineNumber + 3 && beforeIncLineNumber > incLineNumber) { bugReporter.reportBug(new BugInstance(this, "QF_QUESTIONABLE_FOR_LOOP", NORMAL_PRIORITY) .addClassAndMethod(this).addSourceLine(this)); } } } } }
Example 5
Source File: BCELFactory.java From commons-bcel with Apache License 2.0 | 5 votes |
@Override public void visitLocalVariableInstruction( final LocalVariableInstruction i ) { final short opcode = i.getOpcode(); final Type type = i.getType(_cp); if (opcode == Const.IINC) { _out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement() + "));"); } else { final String kind = (opcode < Const.ISTORE) ? "Load" : "Store"; _out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type) + ", " + i.getIndex() + "));"); } }
Example 6
Source File: QuestionableBooleanAssignment.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void sawOpcode(int seen) { if (seen == Const.GOTO && getBranchOffset() == 4) { state = SEEN_GOTO; } else { switch (state) { case SEEN_NOTHING: if ((seen == Const.ICONST_1) || (seen == Const.ICONST_0)) { state = SEEN_ICONST_0_OR_1; } break; case SEEN_ICONST_0_OR_1: if (seen == Const.DUP) { state = SEEN_DUP; } else { state = SEEN_NOTHING; } break; case SEEN_DUP: if (((seen >= Const.ISTORE_0) && (seen <= Const.ISTORE_3)) || (seen == Const.ISTORE)) { state = SEEN_ISTORE; } else { state = SEEN_NOTHING; } break; case SEEN_ISTORE: if (seen == Const.IFEQ || seen == Const.IFNE) { bug = new BugInstance(this, "QBA_QUESTIONABLE_BOOLEAN_ASSIGNMENT", HIGH_PRIORITY).addClassAndMethod(this) .addSourceLine(this); state = SEEN_IF; } else { state = SEEN_NOTHING; } break; case SEEN_IF: state = SEEN_NOTHING; if (seen == Const.NEW) { String cName = getClassConstantOperand(); if ("java/lang/AssertionError".equals(cName)) { break; } } bugReporter.reportBug(bug); break; case SEEN_GOTO: state = SEEN_NOTHING; break; default: break; } } }