com.android.dx.cf.code.ByteOps Java Examples
The following examples show how to use
com.android.dx.cf.code.ByteOps.
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: CodeObserver.java From Box with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void visitLocal(int opcode, int offset, int length, int idx, Type type, int value) { String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx); boolean argComment = (length == 1); String valueStr = ""; if (opcode == ByteOps.IINC) { valueStr = ", #" + ((length <= 3) ? Hex.s1(value) : Hex.s2(value)); } String catStr = ""; if (type.isCategory2()) { catStr = (argComment ? "," : " //") + " category-2"; } observer.parsed(bytes, offset, length, header(offset) + (argComment ? " // " : " ") + idxStr + valueStr + catStr); }
Example #2
Source File: CodeObserver.java From Box with Apache License 2.0 | 6 votes |
/** * Helper to produce the first bit of output for each instruction. * * @param offset the offset to the start of the instruction */ private String header(int offset) { /* * Note: This uses the original bytecode, not the * possibly-transformed one. */ int opcode = bytes.getUnsignedByte(offset); String name = ByteOps.opName(opcode); if (opcode == ByteOps.WIDE) { opcode = bytes.getUnsignedByte(offset + 1); name += " " + ByteOps.opName(opcode); } return Hex.u2(offset) + ": " + name; }
Example #3
Source File: CodeObserver.java From Box with Apache License 2.0 | 6 votes |
/** * Helper for {@link #visitConstant} where the constant is an * {@code int}. * * @param opcode the opcode * @param offset offset to the instruction * @param length instruction length * @param value constant value */ private void visitLiteralInt(int opcode, int offset, int length, int value) { String commentOrSpace = (length == 1) ? " // " : " "; String valueStr; opcode = bytes.getUnsignedByte(offset); // Compare with orig op below. if ((length == 1) || (opcode == ByteOps.BIPUSH)) { valueStr = "#" + Hex.s1(value); } else if (opcode == ByteOps.SIPUSH) { valueStr = "#" + Hex.s2(value); } else { valueStr = "#" + Hex.s4(value); } observer.parsed(bytes, offset, length, header(offset) + commentOrSpace + valueStr); }
Example #4
Source File: CodeObserver.java From Box with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void visitLocal(int opcode, int offset, int length, int idx, Type type, int value) { String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx); boolean argComment = (length == 1); String valueStr = ""; if (opcode == ByteOps.IINC) { valueStr = ", #" + ((length <= 3) ? Hex.s1(value) : Hex.s2(value)); } String catStr = ""; if (type.isCategory2()) { catStr = (argComment ? "," : " //") + " category-2"; } observer.parsed(bytes, offset, length, header(offset) + (argComment ? " // " : " ") + idxStr + valueStr + catStr); }
Example #5
Source File: CodeObserver.java From Box with Apache License 2.0 | 6 votes |
/** * Helper to produce the first bit of output for each instruction. * * @param offset the offset to the start of the instruction */ private String header(int offset) { /* * Note: This uses the original bytecode, not the * possibly-transformed one. */ int opcode = bytes.getUnsignedByte(offset); String name = ByteOps.opName(opcode); if (opcode == ByteOps.WIDE) { opcode = bytes.getUnsignedByte(offset + 1); name += " " + ByteOps.opName(opcode); } return Hex.u2(offset) + ": " + name; }
Example #6
Source File: CodeObserver.java From Box with Apache License 2.0 | 6 votes |
/** * Helper for {@link #visitConstant} where the constant is an * {@code int}. * * @param opcode the opcode * @param offset offset to the instruction * @param length instruction length * @param value constant value */ private void visitLiteralInt(int opcode, int offset, int length, int value) { String commentOrSpace = (length == 1) ? " // " : " "; String valueStr; opcode = bytes.getUnsignedByte(offset); // Compare with orig op below. if ((length == 1) || (opcode == ByteOps.BIPUSH)) { valueStr = "#" + Hex.s1(value); } else if (opcode == ByteOps.SIPUSH) { valueStr = "#" + Hex.s2(value); } else { valueStr = "#" + Hex.s4(value); } observer.parsed(bytes, offset, length, header(offset) + commentOrSpace + valueStr); }
Example #7
Source File: CodeObserver.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void visitLocal(int opcode, int offset, int length, int idx, Type type, int value) { String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx); boolean argComment = (length == 1); String valueStr = ""; if (opcode == ByteOps.IINC) { valueStr = ", #" + ((length <= 3) ? Hex.s1(value) : Hex.s2(value)); } String catStr = ""; if (type.isCategory2()) { catStr = (argComment ? "," : " //") + " category-2"; } observer.parsed(bytes, offset, length, header(offset) + (argComment ? " // " : " ") + idxStr + valueStr + catStr); }
Example #8
Source File: CodeObserver.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Helper to produce the first bit of output for each instruction. * * @param offset the offset to the start of the instruction */ private String header(int offset) { /* * Note: This uses the original bytecode, not the * possibly-transformed one. */ int opcode = bytes.getUnsignedByte(offset); String name = ByteOps.opName(opcode); if (opcode == ByteOps.WIDE) { opcode = bytes.getUnsignedByte(offset + 1); name += " " + ByteOps.opName(opcode); } return Hex.u2(offset) + ": " + name; }
Example #9
Source File: CodeObserver.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Helper for {@link #visitConstant} where the constant is an * {@code int}. * * @param opcode the opcode * @param offset offset to the instruction * @param length instruction length * @param value constant value */ private void visitLiteralInt(int opcode, int offset, int length, int value) { String commentOrSpace = (length == 1) ? " // " : " "; String valueStr; opcode = bytes.getUnsignedByte(offset); // Compare with orig op below. if ((length == 1) || (opcode == ByteOps.BIPUSH)) { valueStr = "#" + Hex.s1(value); } else if (opcode == ByteOps.SIPUSH) { valueStr = "#" + Hex.s2(value); } else { valueStr = "#" + Hex.s4(value); } observer.parsed(bytes, offset, length, header(offset) + commentOrSpace + valueStr); }
Example #10
Source File: CodeObserver.java From buck with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ public void visitLocal(int opcode, int offset, int length, int idx, Type type, int value) { String idxStr = (length <= 3) ? Hex.u1(idx) : Hex.u2(idx); boolean argComment = (length == 1); String valueStr = ""; if (opcode == ByteOps.IINC) { valueStr = ", #" + ((length <= 3) ? Hex.s1(value) : Hex.s2(value)); } String catStr = ""; if (type.isCategory2()) { catStr = (argComment ? "," : " //") + " category-2"; } observer.parsed(bytes, offset, length, header(offset) + (argComment ? " // " : " ") + idxStr + valueStr + catStr); }
Example #11
Source File: CodeObserver.java From buck with Apache License 2.0 | 6 votes |
/** * Helper to produce the first bit of output for each instruction. * * @param offset the offset to the start of the instruction */ private String header(int offset) { /* * Note: This uses the original bytecode, not the * possibly-transformed one. */ int opcode = bytes.getUnsignedByte(offset); String name = ByteOps.opName(opcode); if (opcode == ByteOps.WIDE) { opcode = bytes.getUnsignedByte(offset + 1); name += " " + ByteOps.opName(opcode); } return Hex.u2(offset) + ": " + name; }
Example #12
Source File: CodeObserver.java From buck with Apache License 2.0 | 6 votes |
/** * Helper for {@link #visitConstant} where the constant is an * {@code int}. * * @param opcode the opcode * @param offset offset to the instruction * @param length instruction length * @param value constant value */ private void visitLiteralInt(int opcode, int offset, int length, int value) { String commentOrSpace = (length == 1) ? " // " : " "; String valueStr; opcode = bytes.getUnsignedByte(offset); // Compare with orig op below. if ((length == 1) || (opcode == ByteOps.BIPUSH)) { valueStr = "#" + Hex.s1(value); } else if (opcode == ByteOps.SIPUSH) { valueStr = "#" + Hex.s2(value); } else { valueStr = "#" + Hex.s4(value); } observer.parsed(bytes, offset, length, header(offset) + commentOrSpace + valueStr); }
Example #13
Source File: CodeObserver.java From Box with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitConstant(int opcode, int offset, int length, Constant cst, int value) { if (cst instanceof CstKnownNull) { // This is aconst_null. visitNoArgs(opcode, offset, length, null); return; } if (cst instanceof CstInteger) { visitLiteralInt(opcode, offset, length, value); return; } if (cst instanceof CstLong) { visitLiteralLong(opcode, offset, length, ((CstLong) cst).getValue()); return; } if (cst instanceof CstFloat) { visitLiteralFloat(opcode, offset, length, ((CstFloat) cst).getIntBits()); return; } if (cst instanceof CstDouble) { visitLiteralDouble(opcode, offset, length, ((CstDouble) cst).getLongBits()); return; } String valueStr = ""; if (value != 0) { valueStr = ", "; if (opcode == ByteOps.MULTIANEWARRAY) { valueStr += Hex.u1(value); } else { valueStr += Hex.u2(value); } } observer.parsed(bytes, offset, length, header(offset) + " " + cst + valueStr); }
Example #14
Source File: CodeObserver.java From Box with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitConstant(int opcode, int offset, int length, Constant cst, int value) { if (cst instanceof CstKnownNull) { // This is aconst_null. visitNoArgs(opcode, offset, length, null); return; } if (cst instanceof CstInteger) { visitLiteralInt(opcode, offset, length, value); return; } if (cst instanceof CstLong) { visitLiteralLong(opcode, offset, length, ((CstLong) cst).getValue()); return; } if (cst instanceof CstFloat) { visitLiteralFloat(opcode, offset, length, ((CstFloat) cst).getIntBits()); return; } if (cst instanceof CstDouble) { visitLiteralDouble(opcode, offset, length, ((CstDouble) cst).getLongBits()); return; } String valueStr = ""; if (value != 0) { valueStr = ", "; if (opcode == ByteOps.MULTIANEWARRAY) { valueStr += Hex.u1(value); } else { valueStr += Hex.u2(value); } } observer.parsed(bytes, offset, length, header(offset) + " " + cst + valueStr); }
Example #15
Source File: CodeObserver.java From J2ME-Loader with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitConstant(int opcode, int offset, int length, Constant cst, int value) { if (cst instanceof CstKnownNull) { // This is aconst_null. visitNoArgs(opcode, offset, length, null); return; } if (cst instanceof CstInteger) { visitLiteralInt(opcode, offset, length, value); return; } if (cst instanceof CstLong) { visitLiteralLong(opcode, offset, length, ((CstLong) cst).getValue()); return; } if (cst instanceof CstFloat) { visitLiteralFloat(opcode, offset, length, ((CstFloat) cst).getIntBits()); return; } if (cst instanceof CstDouble) { visitLiteralDouble(opcode, offset, length, ((CstDouble) cst).getLongBits()); return; } String valueStr = ""; if (value != 0) { valueStr = ", "; if (opcode == ByteOps.MULTIANEWARRAY) { valueStr += Hex.u1(value); } else { valueStr += Hex.u2(value); } } observer.parsed(bytes, offset, length, header(offset) + " " + cst + valueStr); }
Example #16
Source File: CodeObserver.java From buck with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public void visitConstant(int opcode, int offset, int length, Constant cst, int value) { if (cst instanceof CstKnownNull) { // This is aconst_null. visitNoArgs(opcode, offset, length, null); return; } if (cst instanceof CstInteger) { visitLiteralInt(opcode, offset, length, value); return; } if (cst instanceof CstLong) { visitLiteralLong(opcode, offset, length, ((CstLong) cst).getValue()); return; } if (cst instanceof CstFloat) { visitLiteralFloat(opcode, offset, length, ((CstFloat) cst).getIntBits()); return; } if (cst instanceof CstDouble) { visitLiteralDouble(opcode, offset, length, ((CstDouble) cst).getLongBits()); return; } String valueStr = ""; if (value != 0) { valueStr = ", "; if (opcode == ByteOps.MULTIANEWARRAY) { valueStr += Hex.u1(value); } else { valueStr += Hex.u2(value); } } observer.parsed(bytes, offset, length, header(offset) + " " + cst + valueStr); }