Java Code Examples for com.android.dx.util.Hex#u1()
The following examples show how to use
com.android.dx.util.Hex#u1() .
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 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 2
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 3
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 4
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 5
Source File: ByteOps.java From Box with Apache License 2.0 | 5 votes |
/** * Gets the name of the given opcode. * * @param opcode {@code >= 0, <= 255;} the opcode * @return {@code non-null;} its name */ public static String opName(int opcode) { String result = OPCODE_NAMES[opcode]; if (result == null) { result = "unused_" + Hex.u1(opcode); OPCODE_NAMES[opcode] = result; } return result; }
Example 6
Source File: ByteOps.java From buck with Apache License 2.0 | 5 votes |
/** * Gets the name of the given opcode. * * @param opcode {@code >= 0, <= 255;} the opcode * @return {@code non-null;} its name */ public static String opName(int opcode) { String result = OPCODE_NAMES[opcode]; if (result == null) { result = "unused_" + Hex.u1(opcode); OPCODE_NAMES[opcode] = result; } return result; }
Example 7
Source File: ByteOps.java From Box with Apache License 2.0 | 5 votes |
/** * Gets the name of the given opcode. * * @param opcode {@code >= 0, <= 255;} the opcode * @return {@code non-null;} its name */ public static String opName(int opcode) { String result = OPCODE_NAMES[opcode]; if (result == null) { result = "unused_" + Hex.u1(opcode); OPCODE_NAMES[opcode] = result; } return result; }
Example 8
Source File: Simulator.java From Box with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visitInvalid(int opcode, int offset, int length) { throw new SimException("invalid opcode " + Hex.u1(opcode)); }
Example 9
Source File: RegOps.java From Box with Apache License 2.0 | 4 votes |
/** * Gets the name of the given opcode. * * @param opcode the opcode * @return {@code non-null;} its name */ public static String opName(int opcode) { switch (opcode) { case NOP: return "nop"; case MOVE: return "move"; case MOVE_PARAM: return "move-param"; case MOVE_EXCEPTION: return "move-exception"; case CONST: return "const"; case GOTO: return "goto"; case IF_EQ: return "if-eq"; case IF_NE: return "if-ne"; case IF_LT: return "if-lt"; case IF_GE: return "if-ge"; case IF_LE: return "if-le"; case IF_GT: return "if-gt"; case SWITCH: return "switch"; case ADD: return "add"; case SUB: return "sub"; case MUL: return "mul"; case DIV: return "div"; case REM: return "rem"; case NEG: return "neg"; case AND: return "and"; case OR: return "or"; case XOR: return "xor"; case SHL: return "shl"; case SHR: return "shr"; case USHR: return "ushr"; case NOT: return "not"; case CMPL: return "cmpl"; case CMPG: return "cmpg"; case CONV: return "conv"; case TO_BYTE: return "to-byte"; case TO_CHAR: return "to-char"; case TO_SHORT: return "to-short"; case RETURN: return "return"; case ARRAY_LENGTH: return "array-length"; case THROW: return "throw"; case MONITOR_ENTER: return "monitor-enter"; case MONITOR_EXIT: return "monitor-exit"; case AGET: return "aget"; case APUT: return "aput"; case NEW_INSTANCE: return "new-instance"; case NEW_ARRAY: return "new-array"; case FILLED_NEW_ARRAY: return "filled-new-array"; case CHECK_CAST: return "check-cast"; case INSTANCE_OF: return "instance-of"; case GET_FIELD: return "get-field"; case GET_STATIC: return "get-static"; case PUT_FIELD: return "put-field"; case PUT_STATIC: return "put-static"; case INVOKE_STATIC: return "invoke-static"; case INVOKE_VIRTUAL: return "invoke-virtual"; case INVOKE_SUPER: return "invoke-super"; case INVOKE_DIRECT: return "invoke-direct"; case INVOKE_INTERFACE: return "invoke-interface"; case MOVE_RESULT: return "move-result"; case MOVE_RESULT_PSEUDO: return "move-result-pseudo"; case FILL_ARRAY_DATA: return "fill-array-data"; case INVOKE_POLYMORPHIC: return "invoke-polymorphic"; case INVOKE_CUSTOM: return "invoke-custom"; } return "unknown-" + Hex.u1(opcode); }
Example 10
Source File: CstByte.java From buck with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public String toString() { int value = getIntBits(); return "byte{0x" + Hex.u1(value) + " / " + value + '}'; }
Example 11
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 12
Source File: ConstantPoolParser.java From Box with Apache License 2.0 | 4 votes |
/** * Populates {@link #offsets} and also completely parse utf8 constants. */ private void determineOffsets() { int at = 10; // offset from the start of the file to the first cst int lastCategory; for (int i = 1; i < offsets.length; i += lastCategory) { offsets[i] = at; int tag = bytes.getUnsignedByte(at); try { switch (tag) { case CONSTANT_Integer: case CONSTANT_Float: case CONSTANT_Fieldref: case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref: case CONSTANT_NameAndType: { lastCategory = 1; at += 5; break; } case CONSTANT_Long: case CONSTANT_Double: { lastCategory = 2; at += 9; break; } case CONSTANT_Class: case CONSTANT_String: { lastCategory = 1; at += 3; break; } case CONSTANT_Utf8: { lastCategory = 1; at += bytes.getUnsignedShort(at + 1) + 3; break; } case CONSTANT_MethodHandle: { lastCategory = 1; at += 4; break; } case CONSTANT_MethodType: { lastCategory = 1; at += 3; break; } case CONSTANT_InvokeDynamic: { lastCategory = 1; at += 5; break; } default: { throw new ParseException("unknown tag byte: " + Hex.u1(tag)); } } } catch (ParseException ex) { ex.addContext("...while preparsing cst " + Hex.u2(i) + " at offset " + Hex.u4(at)); throw ex; } } endOffset = at; }
Example 13
Source File: RegOps.java From J2ME-Loader with Apache License 2.0 | 4 votes |
/** * Gets the name of the given opcode. * * @param opcode the opcode * @return {@code non-null;} its name */ public static String opName(int opcode) { switch (opcode) { case NOP: return "nop"; case MOVE: return "move"; case MOVE_PARAM: return "move-param"; case MOVE_EXCEPTION: return "move-exception"; case CONST: return "const"; case GOTO: return "goto"; case IF_EQ: return "if-eq"; case IF_NE: return "if-ne"; case IF_LT: return "if-lt"; case IF_GE: return "if-ge"; case IF_LE: return "if-le"; case IF_GT: return "if-gt"; case SWITCH: return "switch"; case ADD: return "add"; case SUB: return "sub"; case MUL: return "mul"; case DIV: return "div"; case REM: return "rem"; case NEG: return "neg"; case AND: return "and"; case OR: return "or"; case XOR: return "xor"; case SHL: return "shl"; case SHR: return "shr"; case USHR: return "ushr"; case NOT: return "not"; case CMPL: return "cmpl"; case CMPG: return "cmpg"; case CONV: return "conv"; case TO_BYTE: return "to-byte"; case TO_CHAR: return "to-char"; case TO_SHORT: return "to-short"; case RETURN: return "return"; case ARRAY_LENGTH: return "array-length"; case THROW: return "throw"; case MONITOR_ENTER: return "monitor-enter"; case MONITOR_EXIT: return "monitor-exit"; case AGET: return "aget"; case APUT: return "aput"; case NEW_INSTANCE: return "new-instance"; case NEW_ARRAY: return "new-array"; case FILLED_NEW_ARRAY: return "filled-new-array"; case CHECK_CAST: return "check-cast"; case INSTANCE_OF: return "instance-of"; case GET_FIELD: return "get-field"; case GET_STATIC: return "get-static"; case PUT_FIELD: return "put-field"; case PUT_STATIC: return "put-static"; case INVOKE_STATIC: return "invoke-static"; case INVOKE_VIRTUAL: return "invoke-virtual"; case INVOKE_SUPER: return "invoke-super"; case INVOKE_DIRECT: return "invoke-direct"; case INVOKE_INTERFACE: return "invoke-interface"; case MOVE_RESULT: return "move-result"; case MOVE_RESULT_PSEUDO: return "move-result-pseudo"; case FILL_ARRAY_DATA: return "fill-array-data"; case INVOKE_POLYMORPHIC: return "invoke-polymorphic"; } return "unknown-" + Hex.u1(opcode); }
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: RegOps.java From buck with Apache License 2.0 | 4 votes |
/** * Gets the name of the given opcode. * * @param opcode the opcode * @return {@code non-null;} its name */ public static String opName(int opcode) { switch (opcode) { case NOP: return "nop"; case MOVE: return "move"; case MOVE_PARAM: return "move-param"; case MOVE_EXCEPTION: return "move-exception"; case CONST: return "const"; case GOTO: return "goto"; case IF_EQ: return "if-eq"; case IF_NE: return "if-ne"; case IF_LT: return "if-lt"; case IF_GE: return "if-ge"; case IF_LE: return "if-le"; case IF_GT: return "if-gt"; case SWITCH: return "switch"; case ADD: return "add"; case SUB: return "sub"; case MUL: return "mul"; case DIV: return "div"; case REM: return "rem"; case NEG: return "neg"; case AND: return "and"; case OR: return "or"; case XOR: return "xor"; case SHL: return "shl"; case SHR: return "shr"; case USHR: return "ushr"; case NOT: return "not"; case CMPL: return "cmpl"; case CMPG: return "cmpg"; case CONV: return "conv"; case TO_BYTE: return "to-byte"; case TO_CHAR: return "to-char"; case TO_SHORT: return "to-short"; case RETURN: return "return"; case ARRAY_LENGTH: return "array-length"; case THROW: return "throw"; case MONITOR_ENTER: return "monitor-enter"; case MONITOR_EXIT: return "monitor-exit"; case AGET: return "aget"; case APUT: return "aput"; case NEW_INSTANCE: return "new-instance"; case NEW_ARRAY: return "new-array"; case FILLED_NEW_ARRAY: return "filled-new-array"; case CHECK_CAST: return "check-cast"; case INSTANCE_OF: return "instance-of"; case GET_FIELD: return "get-field"; case GET_STATIC: return "get-static"; case PUT_FIELD: return "put-field"; case PUT_STATIC: return "put-static"; case INVOKE_STATIC: return "invoke-static"; case INVOKE_VIRTUAL: return "invoke-virtual"; case INVOKE_SUPER: return "invoke-super"; case INVOKE_DIRECT: return "invoke-direct"; case INVOKE_INTERFACE: return "invoke-interface"; case MOVE_RESULT: return "move-result"; case MOVE_RESULT_PSEUDO: return "move-result-pseudo"; case FILL_ARRAY_DATA: return "fill-array-data"; } return "unknown-" + Hex.u1(opcode); }
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); }
Example 17
Source File: Simulator.java From buck with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public void visitInvalid(int opcode, int offset, int length) { throw new SimException("invalid opcode " + Hex.u1(opcode)); }
Example 18
Source File: CstString.java From Box with Apache License 2.0 | 2 votes |
/** * Helper for {@link #utf8BytesToString}, which throws the right * exception for a bogus utf-8 byte. * * @param value the byte value * @param offset the file offset * @return never * @throws IllegalArgumentException always thrown */ private static String throwBadUtf8(int value, int offset) { throw new IllegalArgumentException("bad utf-8 byte " + Hex.u1(value) + " at offset " + Hex.u4(offset)); }
Example 19
Source File: CstString.java From Box with Apache License 2.0 | 2 votes |
/** * Helper for {@link #utf8BytesToString}, which throws the right * exception for a bogus utf-8 byte. * * @param value the byte value * @param offset the file offset * @return never * @throws IllegalArgumentException always thrown */ private static String throwBadUtf8(int value, int offset) { throw new IllegalArgumentException("bad utf-8 byte " + Hex.u1(value) + " at offset " + Hex.u4(offset)); }
Example 20
Source File: CstString.java From J2ME-Loader with Apache License 2.0 | 2 votes |
/** * Helper for {@link #utf8BytesToString}, which throws the right * exception for a bogus utf-8 byte. * * @param value the byte value * @param offset the file offset * @return never * @throws IllegalArgumentException always thrown */ private static String throwBadUtf8(int value, int offset) { throw new IllegalArgumentException("bad utf-8 byte " + Hex.u1(value) + " at offset " + Hex.u4(offset)); }