# HG changeset patch # User Michael Starzinger # Date 1301246920 -7200 # Node ID 31ee0b85dbfc1bf3ac61368646f78b5eb1a024fb # Parent 953c5b35ad791ddea9b699d58678176f40e817d9 Remove obsolete dexlib library wrapper. * pom.xml: Removed dependency on smali. * dex/dexlib/DexLibDexReader.java: Removed. * dex/dexlib/OpcodesEncoder.java: Removed. * rewriter/Main.java: Removed obsolete import. * rewriter/Registers.java (packRegisters): Removed. diff -r 953c5b35ad79 -r 31ee0b85dbfc pom.xml --- a/pom.xml Sat Mar 26 20:07:38 2011 +0100 +++ b/pom.xml Sun Mar 27 19:28:40 2011 +0200 @@ -83,11 +83,6 @@ 3.3.1 - org.jf - smali - 1.2.7-dev - - junit junit 4.8.2 diff -r 953c5b35ad79 -r 31ee0b85dbfc src/main/java/org/icedrobot/daneel/dex/dexlib/DexLibDexReader.java --- a/src/main/java/org/icedrobot/daneel/dex/dexlib/DexLibDexReader.java Sat Mar 26 20:07:38 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,430 +0,0 @@ -/* - * Daneel - Dalvik to Java bytecode compiler - * Copyright (C) 2011 IcedRobot team - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * This file is subject to the "Classpath" exception: - * - * Linking this library statically or dynamically with other modules is - * making a combined work based on this library. Thus, the terms and - * conditions of the GNU General Public License cover the whole - * combination. - * - * As a special exception, the copyright holders of this library give you - * permission to link this library with independent modules to produce an - * executable, regardless of the license terms of these independent - * modules, and to copy and distribute the resulting executable under terms - * of your choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from or based on - * this library. If you modify this library, you may extend this exception - * to your version of the library, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ - -package org.icedrobot.daneel.dex.dexlib; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.List; - -import org.icedrobot.daneel.dex.DexClassVisitor; -import org.icedrobot.daneel.dex.DexFieldVisitor; -import org.icedrobot.daneel.dex.DexFileVisitor; -import org.icedrobot.daneel.dex.DexMethodVisitor; -import org.icedrobot.daneel.dex.DexReader; -import org.icedrobot.daneel.dex.Opcode; -import org.icedrobot.daneel.rewriter.Registers; -import org.jf.dexlib.ClassDataItem; -import org.jf.dexlib.ClassDataItem.EncodedField; -import org.jf.dexlib.ClassDataItem.EncodedMethod; -import org.jf.dexlib.ClassDefItem; -import org.jf.dexlib.CodeItem; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.EncodedArrayItem; -import org.jf.dexlib.FieldIdItem; -import org.jf.dexlib.Item; -import org.jf.dexlib.MethodIdItem; -import org.jf.dexlib.ProtoIdItem; -import org.jf.dexlib.StringIdItem; -import org.jf.dexlib.TypeIdItem; -import org.jf.dexlib.TypeListItem; -import org.jf.dexlib.Code.FiveRegisterInstruction; -import org.jf.dexlib.Code.Instruction; -import org.jf.dexlib.Code.InstructionWithReference; -import org.jf.dexlib.Code.LiteralInstruction; -import org.jf.dexlib.Code.RegisterRangeInstruction; -import org.jf.dexlib.Code.SingleRegisterInstruction; -import org.jf.dexlib.Code.Format.Instruction11x; -import org.jf.dexlib.Code.Format.Instruction21c; -import org.jf.dexlib.Code.Format.Instruction22c; -import org.jf.dexlib.EncodedValue.BooleanEncodedValue; -import org.jf.dexlib.EncodedValue.ByteEncodedValue; -import org.jf.dexlib.EncodedValue.CharEncodedValue; -import org.jf.dexlib.EncodedValue.DoubleEncodedValue; -import org.jf.dexlib.EncodedValue.EncodedValue; -import org.jf.dexlib.EncodedValue.FloatEncodedValue; -import org.jf.dexlib.EncodedValue.IntEncodedValue; -import org.jf.dexlib.EncodedValue.LongEncodedValue; -import org.jf.dexlib.EncodedValue.ShortEncodedValue; -import org.objectweb.asm.Type; - -public class DexLibDexReader implements DexReader { - private final DexFile dex; - private HashMap classIndexMap; - - public DexLibDexReader(File file) throws IOException { - dex = new DexFile(file); - } - - @Override - public void accept(DexFileVisitor dv) { - List classItems = dex.ClassDefsSection.getItems(); - for (ClassDefItem classItem : classItems) { - DexClassVisitor cv = dv.visitClass(classItem.getClassType() - .getTypeDescriptor()); - if (cv != null) { - accept(classItem, cv); - } - } - dv.visitEnd(); - } - - @Override - public void accept(String className, DexClassVisitor cv) - throws ClassNotFoundException { - if (classIndexMap == null) { - HashMap map = new HashMap(); - int index = 0; - List classItems = dex.ClassDefsSection.getItems(); - for (ClassDefItem classItem : classItems) { - map.put(asInternalName(classItem.getClassType()).replace('/', - '.'), index++); - } - classIndexMap = map; - } - - Integer index = classIndexMap.get(className); - if (index == null) { - throw new ClassNotFoundException(className); - } - accept(dex.ClassDefsSection.getItemByIndex(index), cv); - } - - private static void accept(ClassDefItem classItem, DexClassVisitor cv) { - TypeListItem interfaceListItem = classItem.getInterfaces(); - String[] interfaces = null; - if (interfaceListItem != null) { - interfaces = new String[interfaceListItem.getTypeCount()]; - for (int i = 0; i < interfaces.length; i++) { - interfaces[i] = interfaceListItem.getTypeIdItem(i) - .getTypeDescriptor(); - } - } - - cv.visit(classItem.getAccessFlags(), - classItem.getClassType().getTypeDescriptor(), - classItem.getSuperclass().getTypeDescriptor(), interfaces); - - StringIdItem sourceFile = classItem.getSourceFile(); - if (sourceFile != null) { - cv.visitSource(sourceFile.getStringValue()); - } - - // outer-class - - // annotations - - // attributes - - // inner classes - - // fields - ClassDataItem classData = classItem.getClassData(); - acceptField(classData.getStaticFields(), - classItem.getStaticFieldInitializers(), cv); - acceptField(classData.getInstanceFields(), null, cv); - - // methods - acceptMethod(classData.getDirectMethods(), cv); - acceptMethod(classData.getVirtualMethods(), cv); - - cv.visitEnd(); - } - - private static String asInternalName(TypeIdItem typeIdItem) { - return Type.getType(typeIdItem.getTypeDescriptor()).getInternalName(); - } - - private static void acceptField(EncodedField[] fields, - EncodedArrayItem staticInitItem, DexClassVisitor cv) { - EncodedValue[] constants = (staticInitItem == null) ? null - : staticInitItem.getEncodedArray().values; - - for (int i = 0; i < fields.length; i++) { - EncodedField field = fields[i]; - FieldIdItem fieldIdItem = field.field; - - DexFieldVisitor fv = cv.visitField(field.accessFlags, fieldIdItem - .getFieldName().getStringValue(), - fieldIdItem.getFieldType().getTypeDescriptor(), - (constants == null ? null : getConstant(constants[i]))); - if (fv != null) { - // visit annotation - - // visit attribute - - fv.visitEnd(); - } - } - } - - private static Object getConstant(EncodedValue value) { - switch (value.getValueType()) { - case VALUE_BOOLEAN: - return ((BooleanEncodedValue) value).value; - case VALUE_BYTE: - return ((ByteEncodedValue) value).value; - case VALUE_SHORT: - return ((ShortEncodedValue) value).value; - case VALUE_CHAR: - return ((CharEncodedValue) value).value; - case VALUE_INT: - return ((IntEncodedValue) value).value; - case VALUE_LONG: - return ((LongEncodedValue) value).value; - case VALUE_FLOAT: - return ((FloatEncodedValue) value).value; - case VALUE_DOUBLE: - return ((DoubleEncodedValue) value).value; - default: - throw new AssertionError("invalid type " + value.getValueType()); - } - } - - private static void acceptMethod(EncodedMethod[] methods, DexClassVisitor cv) { - for (EncodedMethod method : methods) { - MethodIdItem methodIdItem = method.method; - ProtoIdItem protoIdItem = methodIdItem.getPrototype(); - - DexMethodVisitor mv = cv.visitMethod(method.accessFlags, - methodIdItem.getMethodName().getStringValue(), protoIdItem - .getConciseIdentity(), protoIdItem.getReturnType() - .getTypeDescriptor(), - asDescriptorArray(protoIdItem)); - if (mv != null) { - CodeItem codeItem = method.codeItem; - - // visit annotation default - - // visit annotation - - // visit parameter annotation - - // visit attribute - - int inWords, outWords; - try { - inWords = IN_WORDS.getInt(codeItem); - outWords = OUT_WORDS.getInt(codeItem); - } catch (IllegalArgumentException e) { - throw (AssertionError) new AssertionError().initCause(e); - } catch (IllegalAccessException e) { - throw (AssertionError) new AssertionError().initCause(e); - } - - mv.visitCode(codeItem.getRegisterCount(), inWords, outWords); - acceptCode(codeItem, mv); - mv.visitEnd(); - } - } - } - - private static final Field IN_WORDS; - private static final Field OUT_WORDS; - static { - Field inWords, outWords; - try { - inWords = CodeItem.class.getDeclaredField("inWords"); - outWords = CodeItem.class.getDeclaredField("outWords"); - } catch (NoSuchFieldException e) { - throw (AssertionError) new AssertionError().initCause(e); - } - inWords.setAccessible(true); - outWords.setAccessible(true); - IN_WORDS = inWords; - OUT_WORDS = outWords; - } - - private static String[] asDescriptorArray(ProtoIdItem protoIdItem) { - TypeListItem parameters = protoIdItem.getParameters(); - if (parameters == null) { - return new String[0]; - } - int length = parameters.getTypeCount(); - String[] types = new String[length]; - for (int i = 0; i < length; i++) { - types[i] = parameters.getTypeIdItem(i).getTypeDescriptor(); - } - return types; - } - - // opcode categories - private static final int INSTR = 0; - private static final int INSTR_OP = 1; - private static final int INSTR_UNARY_OP = 2; - private static final int INSTR_BIN_OP = 3; - private static final int INSTR_BIN_AND_LITERAL = 4; - private static final int INSTR_CONST_STRING = 5; - private static final int INSTR_CONST_U32 = 6; - private static final int INSTR_CONST_U64 = 7; - private static final int INSTR_CLASS = 8; - private static final int INSTR_INSTANCEOF = 9; - private static final int INSTR_GOTO = 10; - private static final int INSTR_IF_TESTZ = 11; - private static final int INSTR_IF_TEST = 12; - private static final int INSTR_SWITCH = 13; - private static final int INSTR_ARRAY = 14; - private static final int INSTR_FIELD = 15; - private static final int INSTR_METHOD = 16; - private static final int INSTR_FILLED_NEW_ARRAY = 17; - private static final int INSTR_NEW_ARRAY = 18; - private static final int INSTR_FILL_ARRAY_DATA = 19; - - private static final int[] OPCODE_CATEGORY; - static { // see OpcodesEncoder - int[] categories = new int[256]; - String text = "ACCCCCCCCCBBBBABBBGGGGHHHHFFIBBI" - + "JCISRRTBKKKNNDDDDDMMMMMMLLLLLL@@" - + "@@@@OOOOOOOOOOOOOOPPPPPPPPPPPPPP" - + "PPPPPPPPPPPPPPQQQQQ@QQQQQ@@CCCCC" - + "CCCCCCCCC@CCCCCCDDDDDDDDDDDDDDDD" - + "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" - + "DDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEE" - + "EEE@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"; - for (int i = 0; i < text.length(); i++) { - categories[i] = text.charAt(i) - 'A'; - } - OPCODE_CATEGORY = categories; - } - - private static void acceptCode(CodeItem codeItem, DexMethodVisitor mv) { - Instruction[] instrs = codeItem.getInstructions(); - for (int i = 0; i < instrs.length; i++) { - Instruction instr = instrs[i]; - acceptInstr(instr, mv); - } - } - - private static void acceptInstr(Instruction instr, DexMethodVisitor mv) { - org.jf.dexlib.Code.Opcode dexOpcode = instr.opcode; - Opcode opcode = Opcode.getOpcode(dexOpcode.value); - switch (OPCODE_CATEGORY[dexOpcode.value]) { - - case INSTR: - mv.visitInstr(opcode); - break; - - case INSTR_FIELD: { - FieldIdItem field; - int vsrcOrDest; - int vref; - if (instr instanceof Instruction21c) { - Instruction21c i21c = (Instruction21c) instr; - field = (FieldIdItem) i21c.getReferencedItem(); - vsrcOrDest = i21c.getRegisterA(); - vref = 0; // no instance - } else { - Instruction22c i22c = (Instruction22c) instr; - field = (FieldIdItem) i22c.getReferencedItem(); - vsrcOrDest = i22c.getRegisterA(); - vref = i22c.getRegisterB(); - } - mv.visitInstrField(opcode, vsrcOrDest, vref, field - .getContainingClass().getTypeDescriptor(), field.getFieldName() - .getStringValue(), field.getFieldType().getTypeDescriptor()); - break; - } - - case INSTR_CONST_U32: { - int vdest = ((SingleRegisterInstruction) instr).getRegisterA(); - long value = ((LiteralInstruction) instr).getLiteral(); - mv.visitInstrConstU32(opcode, vdest, (int)value); - break; - } - - case INSTR_CONST_U64: { - int vdest = ((SingleRegisterInstruction) instr).getRegisterA(); - long value = ((LiteralInstruction) instr).getLiteral(); - mv.visitInstrConstU64(opcode, vdest, value); - break; - } - - case INSTR_CONST_STRING: { - Item item = ((InstructionWithReference) instr) - .getReferencedItem(); - int registerA = ((SingleRegisterInstruction) instr).getRegisterA(); - mv.visitInstrConstString(opcode, registerA, - ((StringIdItem) item).getStringValue()); - break; - } - - case INSTR_METHOD: { - int va, vpacked, size; - if (instr instanceof RegisterRangeInstruction) { // range - RegisterRangeInstruction rangeInstr = (RegisterRangeInstruction) instr; - size = rangeInstr.getRegCount(); - va = rangeInstr.getStartRegister(); - vpacked = 0; - } else { // packed - FiveRegisterInstruction fiveInstr = (FiveRegisterInstruction) instr; - size = fiveInstr.getRegCount(); - va = fiveInstr.getRegisterA(); - vpacked = Registers.packRegisters(fiveInstr.getRegisterD(), - fiveInstr.getRegisterE(), fiveInstr.getRegisterF(), - fiveInstr.getRegisterG()); - } - InstructionWithReference refInstr = (InstructionWithReference) instr; - MethodIdItem methodIdItem = (MethodIdItem) refInstr.getReferencedItem(); - String desc = methodIdItem.getPrototype().getPrototypeString(); - mv.visitInstrMethod(opcode, - size, va, vpacked, - methodIdItem.getContainingClass().getTypeDescriptor(), - methodIdItem.getMethodName().getStringValue(), - desc); - break; - } - - case INSTR_CLASS: { - Instruction21c i21c = (Instruction21c) instr; - String type = ((TypeIdItem)i21c.getReferencedItem()).getTypeDescriptor(); - mv.visitInstrClass(opcode, i21c.getRegisterA(), type); - break; - } - - case INSTR_OP: { - Instruction11x i11x = (Instruction11x) instr; - mv.visitInstrOp(opcode, i11x.getRegisterA()); - break; - } - - default: - throw new AssertionError("unknown category for " + dexOpcode); - } - } -} diff -r 953c5b35ad79 -r 31ee0b85dbfc src/main/java/org/icedrobot/daneel/dex/dexlib/OpcodesEncoder.java --- a/src/main/java/org/icedrobot/daneel/dex/dexlib/OpcodesEncoder.java Sat Mar 26 20:07:38 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,168 +0,0 @@ -/* - * Daneel - Dalvik to Java bytecode compiler - * Copyright (C) 2011 IcedRobot team - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * This file is subject to the "Classpath" exception: - * - * Linking this library statically or dynamically with other modules is - * making a combined work based on this library. Thus, the terms and - * conditions of the GNU General Public License cover the whole - * combination. - * - * As a special exception, the copyright holders of this library give you - * permission to link this library with independent modules to produce an - * executable, regardless of the license terms of these independent - * modules, and to copy and distribute the resulting executable under terms - * of your choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from or based on - * this library. If you modify this library, you may extend this exception - * to your version of the library, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ - -package org.icedrobot.daneel.dex.dexlib; - -import java.util.Arrays; - -import org.icedrobot.daneel.dex.Opcode; - -import static org.icedrobot.daneel.dex.Opcode.*; - -class OpcodesEncoder { - // opcode categories - private static final int INSTR = 0; - private static final int INSTR_OP = 1; - private static final int INSTR_UNARY_OP = 2; - private static final int INSTR_BIN_OP = 3; - private static final int INSTR_BIN_AND_LITERAL = 4; - private static final int INSTR_CONST_STRING = 5; - private static final int INSTR_CONST_U32 = 6; - private static final int INSTR_CONST_U64 = 7; - private static final int INSTR_CLASS = 8; - private static final int INSTR_INSTANCEOF = 9; - private static final int INSTR_GOTO = 10; - private static final int INSTR_IF_TESTZ = 11; - private static final int INSTR_IF_TEST = 12; - private static final int INSTR_SWITCH = 13; - private static final int INSTR_ARRAY = 14; - private static final int INSTR_FIELD = 15; - private static final int INSTR_METHOD = 16; - private static final int INSTR_FILLED_NEW_ARRAY = 17; - private static final int INSTR_NEW_ARRAY = 18; - private static final int INSTR_FILL_ARRAY_DATA = 19; - - public static void main(String[] args) { - Object[] assoc = { - INSTR, - new Opcode[] { NOP, RETURN_VOID }, - INSTR_OP, - new Opcode[] { MOVE_RESULT, MOVE_RESULT_WIDE, - MOVE_RESULT_OBJECT, MOVE_EXCEPTION, RETURN, - MONITOR_ENTER, MONITOR_EXIT, RETURN_WIDE, - RETURN_OBJECT, THROW }, - INSTR_UNARY_OP, - new Opcode[] { MOVE, MOVE_FROM16, MOVE_16, MOVE_WIDE, - MOVE_WIDE_FROM16, MOVE_WIDE_16, MOVE_OBJECT, - MOVE_OBJECT_FROM16, MOVE_OBJECT_16, NEG_INT, NOT_INT, - NEG_LONG, NOT_LONG, NEG_FLOAT, NEG_DOUBLE, INT_TO_LONG, - INT_TO_FLOAT, INT_TO_DOUBLE, LONG_TO_INT, - LONG_TO_FLOAT, LONG_TO_DOUBLE, FLOAT_TO_INT, - FLOAT_TO_LONG, DOUBLE_TO_INT, DOUBLE_TO_LONG, - DOUBLE_TO_FLOAT, INT_TO_BYTE, INT_TO_CHAR, - INT_TO_SHORT, ARRAY_LENGTH }, - INSTR_BIN_OP, - new Opcode[] { CMPL_FLOAT, CMPG_FLOAT, CMPL_DOUBLE, - CMPG_DOUBLE, CMP_LONG, ADD_INT, SUB_INT, MUL_INT, - DIV_INT, REM_INT, AND_INT, OR_INT, XOR_INT, SHL_INT, - SHR_INT, USHR_INT, ADD_LONG, SUB_LONG, MUL_LONG, - DIV_LONG, REM_LONG, AND_LONG, OR_LONG, XOR_LONG, - SHL_LONG, SHR_LONG, USHR_LONG, ADD_FLOAT, SUB_FLOAT, - MUL_FLOAT, DIV_FLOAT, REM_FLOAT, ADD_DOUBLE, - SUB_DOUBLE, MUL_DOUBLE, DIV_DOUBLE, REM_DOUBLE, - ADD_INT_2ADDR, SUB_INT_2ADDR, MUL_INT_2ADDR, - DIV_INT_2ADDR, REM_INT_2ADDR, AND_INT_2ADDR, - OR_INT_2ADDR, XOR_INT_2ADDR, SHL_INT_2ADDR, - SHR_INT_2ADDR, USHR_INT_2ADDR, ADD_LONG_2ADDR, - SUB_LONG_2ADDR, MUL_LONG_2ADDR, DIV_LONG_2ADDR, - REM_LONG_2ADDR, AND_LONG_2ADDR, OR_LONG_2ADDR, - XOR_LONG_2ADDR, SHL_LONG_2ADDR, SHR_LONG_2ADDR, - USHR_LONG_2ADDR, ADD_FLOAT_2ADDR, SUB_FLOAT_2ADDR, - MUL_FLOAT_2ADDR, DIV_FLOAT_2ADDR, REM_FLOAT_2ADDR, - ADD_DOUBLE_2ADDR, SUB_DOUBLE_2ADDR, MUL_DOUBLE_2ADDR, - DIV_DOUBLE_2ADDR, REM_DOUBLE_2ADDR }, - INSTR_BIN_AND_LITERAL, - new Opcode[] { ADD_INT_LIT16, RSUB_INT_LIT16, MUL_INT_LIT16, - DIV_INT_LIT16, REM_INT_LIT16, AND_INT_LIT16, - OR_INT_LIT16, XOR_INT_LIT16, ADD_INT_LIT8, - RSUB_INT_LIT8, MUL_INT_LIT8, DIV_INT_LIT8, - REM_INT_LIT8, AND_INT_LIT8, OR_INT_LIT8, XOR_INT_LIT8, - SHL_INT_LIT8, SHR_INT_LIT8, USHR_INT_LIT8 }, - INSTR_CONST_STRING, - new Opcode[] { CONST_STRING, CONST_STRING_JUMBO }, - INSTR_CONST_U32, - new Opcode[] { CONST_4, CONST_16, CONST, CONST_HIGH16 }, - INSTR_CONST_U64, - new Opcode[] { CONST_WIDE_16, CONST_WIDE_32, CONST_WIDE, - CONST_WIDE_HIGH16 }, - INSTR_CLASS, - new Opcode[] { CONST_CLASS, CHECK_CAST, NEW_INSTANCE }, - INSTR_INSTANCEOF, - new Opcode[] { INSTANCE_OF }, - INSTR_GOTO, - new Opcode[] { GOTO_32, GOTO, GOTO_16 }, - INSTR_IF_TESTZ, - new Opcode[] { IF_EQZ, IF_NEZ, IF_LTZ, IF_GEZ, IF_GTZ, IF_LEZ }, - INSTR_IF_TEST, - new Opcode[] { IF_EQ, IF_NE, IF_LT, IF_GE, IF_GT, IF_LE }, - INSTR_SWITCH, - new Opcode[] { PACKED_SWITCH, SPARSE_SWITCH }, - INSTR_ARRAY, - new Opcode[] { APUT, APUT_WIDE, APUT_OBJECT, APUT_BOOLEAN, - APUT_BYTE, APUT_CHAR, APUT_SHORT, AGET, AGET_WIDE, - AGET_OBJECT, AGET_BOOLEAN, AGET_BYTE, AGET_CHAR, - AGET_SHORT }, - INSTR_FIELD, - new Opcode[] { IGET, IGET_WIDE, IGET_OBJECT, IGET_BOOLEAN, - IGET_BYTE, IGET_CHAR, IGET_SHORT, IPUT, IPUT_WIDE, - IPUT_OBJECT, IPUT_BOOLEAN, IPUT_BYTE, IPUT_CHAR, - IPUT_SHORT, SGET, SGET_WIDE, SGET_OBJECT, SGET_BOOLEAN, - SGET_BYTE, SGET_CHAR, SGET_SHORT, SPUT, SPUT_WIDE, - SPUT_OBJECT, SPUT_BOOLEAN, SPUT_BYTE, SPUT_CHAR, - SPUT_SHORT }, - INSTR_METHOD, - new Opcode[] { INVOKE_VIRTUAL, INVOKE_SUPER, INVOKE_DIRECT, - INVOKE_STATIC, INVOKE_INTERFACE, INVOKE_VIRTUAL_RANGE, - INVOKE_SUPER_RANGE, INVOKE_DIRECT_RANGE, - INVOKE_STATIC_RANGE, INVOKE_INTERFACE_RANGE }, - INSTR_FILLED_NEW_ARRAY, - new Opcode[] { FILLED_NEW_ARRAY, FILLED_NEW_ARRAY_RANGE }, - INSTR_NEW_ARRAY, new Opcode[] { NEW_ARRAY }, - INSTR_FILL_ARRAY_DATA, new Opcode[] { FILL_ARRAY_DATA }, }; - - char[] text = new char[256]; - Arrays.fill(text, '@'); - for (int i = 0; i < assoc.length; i += 2) { - int category = (Integer) assoc[i]; - Opcode[] opcodes = (Opcode[]) assoc[i + 1]; - for (Opcode opcode : opcodes) { - text[opcode.ordinal()] = (char) ('A' + category); - } - } - System.out.println(new String(text)); - } -} diff -r 953c5b35ad79 -r 31ee0b85dbfc src/main/java/org/icedrobot/daneel/rewriter/Main.java --- a/src/main/java/org/icedrobot/daneel/rewriter/Main.java Sat Mar 26 20:07:38 2011 +0100 +++ b/src/main/java/org/icedrobot/daneel/rewriter/Main.java Sun Mar 27 19:28:40 2011 +0200 @@ -46,7 +46,6 @@ import org.icedrobot.daneel.dex.DexFile; import org.icedrobot.daneel.dex.DexReader; -import org.icedrobot.daneel.dex.dexlib.DexLibDexReader; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.util.CheckClassAdapter; @@ -59,7 +58,6 @@ public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException { - //final DexReader dexReader = new DexLibDexReader(new File(args[0])); final DexReader dexReader = DexFile.parse(new File(args[0])); ClassLoader classLoader = new ClassLoader() { diff -r 953c5b35ad79 -r 31ee0b85dbfc src/main/java/org/icedrobot/daneel/rewriter/Registers.java --- a/src/main/java/org/icedrobot/daneel/rewriter/Registers.java Sat Mar 26 20:07:38 2011 +0100 +++ b/src/main/java/org/icedrobot/daneel/rewriter/Registers.java Sun Mar 27 19:28:40 2011 +0200 @@ -57,8 +57,4 @@ public static int getRegisterG(int packed) { return (packed >> 12) & 0x0F; } - - public static int packRegisters(int vd, int ve, int vf, int vg) { - return vg << 12 | vf << 8 | ve << 4 | vd; - } }