1917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul/* 2917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Copyright (C) 2007 The Android Open Source Project 3917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * 4917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Licensed under the Apache License, Version 2.0 (the "License"); 5917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * you may not use this file except in compliance with the License. 6917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * You may obtain a copy of the License at 7917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * 8917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * http://www.apache.org/licenses/LICENSE-2.0 9917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * 10917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Unless required by applicable law or agreed to in writing, software 11917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * distributed under the License is distributed on an "AS IS" BASIS, 12917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * See the License for the specific language governing permissions and 14917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * limitations under the License. 15917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 16917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 17917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulpackage com.android.dexgen.dex.code; 18917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 19917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.code.Insn; 20917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.code.RegOps; 21917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.code.RegisterSpec; 22917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.code.Rop; 23917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.code.Rops; 24917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.code.ThrowingCstInsn; 25917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.cst.Constant; 26917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.cst.CstFieldRef; 27917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.cst.CstString; 28917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.cst.CstType; 29917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport com.android.dexgen.rop.type.Type; 30917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 31917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulimport java.util.HashMap; 32917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 33917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul/** 34917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Translator from rop-level {@link Insn} instances to corresponding 35917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * {@link Dop} instances. 36917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 37917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgulpublic final class RopToDop { 38917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /** {@code non-null;} map from all the common rops to dalvik opcodes */ 39917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul private static final HashMap<Rop, Dop> MAP; 40917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 41917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /** 42917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * This class is uninstantiable. 43917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 44917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul private RopToDop() { 45917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // This space intentionally left blank. 46917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 47917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 48917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul static { 49917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 50917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: The choices made here are to pick the optimistically 51917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * smallest Dalvik opcode, and leave it to later processing to 52917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * pessimize. 53917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 54917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP = new HashMap<Rop, Dop>(400); 55917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.NOP, Dops.NOP); 56917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_INT, Dops.MOVE); 57917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_LONG, Dops.MOVE_WIDE); 58917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_FLOAT, Dops.MOVE); 59917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_DOUBLE, Dops.MOVE_WIDE); 60917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_OBJECT, Dops.MOVE_OBJECT); 61917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_PARAM_INT, Dops.MOVE); 62917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_PARAM_LONG, Dops.MOVE_WIDE); 63917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_PARAM_FLOAT, Dops.MOVE); 64917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_PARAM_DOUBLE, Dops.MOVE_WIDE); 65917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MOVE_PARAM_OBJECT, Dops.MOVE_OBJECT); 66917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 67917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 68917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: No entry for MOVE_EXCEPTION, since it varies by 69917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * exception type. (That is, there is no unique instance to 70917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * add to the map.) 71917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 72917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 73917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONST_INT, Dops.CONST_4); 74917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONST_LONG, Dops.CONST_WIDE_16); 75917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONST_FLOAT, Dops.CONST_4); 76917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONST_DOUBLE, Dops.CONST_WIDE_16); 77917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 78917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 79917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: No entry for CONST_OBJECT, since it needs to turn 80917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * into either CONST_STRING or CONST_CLASS. 81917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 82917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 83917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 84917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * TODO: I think the only case of this is for null, and 85917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * const/4 should cover that. 86917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 87917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONST_OBJECT_NOTHROW, Dops.CONST_4); 88917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 89917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GOTO, Dops.GOTO); 90917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_EQZ_INT, Dops.IF_EQZ); 91917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_NEZ_INT, Dops.IF_NEZ); 92917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_LTZ_INT, Dops.IF_LTZ); 93917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_GEZ_INT, Dops.IF_GEZ); 94917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_LEZ_INT, Dops.IF_LEZ); 95917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_GTZ_INT, Dops.IF_GTZ); 96917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_EQZ_OBJECT, Dops.IF_EQZ); 97917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_NEZ_OBJECT, Dops.IF_NEZ); 98917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_EQ_INT, Dops.IF_EQ); 99917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_NE_INT, Dops.IF_NE); 100917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_LT_INT, Dops.IF_LT); 101917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_GE_INT, Dops.IF_GE); 102917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_LE_INT, Dops.IF_LE); 103917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_GT_INT, Dops.IF_GT); 104917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_EQ_OBJECT, Dops.IF_EQ); 105917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.IF_NE_OBJECT, Dops.IF_NE); 106917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SWITCH, Dops.SPARSE_SWITCH); 107917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.ADD_INT, Dops.ADD_INT_2ADDR); 108917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.ADD_LONG, Dops.ADD_LONG_2ADDR); 109917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.ADD_FLOAT, Dops.ADD_FLOAT_2ADDR); 110917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.ADD_DOUBLE, Dops.ADD_DOUBLE_2ADDR); 111917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SUB_INT, Dops.SUB_INT_2ADDR); 112917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SUB_LONG, Dops.SUB_LONG_2ADDR); 113917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SUB_FLOAT, Dops.SUB_FLOAT_2ADDR); 114917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SUB_DOUBLE, Dops.SUB_DOUBLE_2ADDR); 115917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MUL_INT, Dops.MUL_INT_2ADDR); 116917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MUL_LONG, Dops.MUL_LONG_2ADDR); 117917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MUL_FLOAT, Dops.MUL_FLOAT_2ADDR); 118917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MUL_DOUBLE, Dops.MUL_DOUBLE_2ADDR); 119917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.DIV_INT, Dops.DIV_INT_2ADDR); 120917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.DIV_LONG, Dops.DIV_LONG_2ADDR); 121917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.DIV_FLOAT, Dops.DIV_FLOAT_2ADDR); 122917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.DIV_DOUBLE, Dops.DIV_DOUBLE_2ADDR); 123917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.REM_INT, Dops.REM_INT_2ADDR); 124917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.REM_LONG, Dops.REM_LONG_2ADDR); 125917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.REM_FLOAT, Dops.REM_FLOAT_2ADDR); 126917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.REM_DOUBLE, Dops.REM_DOUBLE_2ADDR); 127917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.NEG_INT, Dops.NEG_INT); 128917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.NEG_LONG, Dops.NEG_LONG); 129917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.NEG_FLOAT, Dops.NEG_FLOAT); 130917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.NEG_DOUBLE, Dops.NEG_DOUBLE); 131917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AND_INT, Dops.AND_INT_2ADDR); 132917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AND_LONG, Dops.AND_LONG_2ADDR); 133917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.OR_INT, Dops.OR_INT_2ADDR); 134917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.OR_LONG, Dops.OR_LONG_2ADDR); 135917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.XOR_INT, Dops.XOR_INT_2ADDR); 136917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.XOR_LONG, Dops.XOR_LONG_2ADDR); 137917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SHL_INT, Dops.SHL_INT_2ADDR); 138917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SHL_LONG, Dops.SHL_LONG_2ADDR); 139917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SHR_INT, Dops.SHR_INT_2ADDR); 140917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SHR_LONG, Dops.SHR_LONG_2ADDR); 141917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.USHR_INT, Dops.USHR_INT_2ADDR); 142917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.USHR_LONG, Dops.USHR_LONG_2ADDR); 143917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.NOT_INT, Dops.NOT_INT); 144917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.NOT_LONG, Dops.NOT_LONG); 145917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 146917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.ADD_CONST_INT, Dops.ADD_INT_LIT8); 147917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik ops for other types of add_const. 148917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 149917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 150917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: No dalvik ops for any type of sub_const; there's a 151917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * *reverse* sub (constant - reg) for ints, though, but that 152917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * should end up getting handled at optimization time. 153917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 154917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 155917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MUL_CONST_INT, Dops.MUL_INT_LIT8); 156917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik ops for other types of mul_const. 157917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 158917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.DIV_CONST_INT, Dops.DIV_INT_LIT8); 159917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik ops for other types of div_const. 160917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 161917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.REM_CONST_INT, Dops.REM_INT_LIT8); 162917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik ops for other types of rem_const. 163917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 164917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AND_CONST_INT, Dops.AND_INT_LIT8); 165917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik op for and_const_long. 166917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 167917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.OR_CONST_INT, Dops.OR_INT_LIT8); 168917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik op for or_const_long. 169917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 170917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.XOR_CONST_INT, Dops.XOR_INT_LIT8); 171917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik op for xor_const_long. 172917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 173917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SHL_CONST_INT, Dops.SHL_INT_LIT8); 174917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik op for shl_const_long. 175917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 176917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.SHR_CONST_INT, Dops.SHR_INT_LIT8); 177917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik op for shr_const_long. 178917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 179917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.USHR_CONST_INT, Dops.USHR_INT_LIT8); 180917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul // Note: No dalvik op for shr_const_long. 181917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 182917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CMPL_LONG, Dops.CMP_LONG); 183917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CMPL_FLOAT, Dops.CMPL_FLOAT); 184917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CMPL_DOUBLE, Dops.CMPL_DOUBLE); 185917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CMPG_FLOAT, Dops.CMPG_FLOAT); 186917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CMPG_DOUBLE, Dops.CMPG_DOUBLE); 187917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_L2I, Dops.LONG_TO_INT); 188917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_F2I, Dops.FLOAT_TO_INT); 189917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_D2I, Dops.DOUBLE_TO_INT); 190917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_I2L, Dops.INT_TO_LONG); 191917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_F2L, Dops.FLOAT_TO_LONG); 192917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_D2L, Dops.DOUBLE_TO_LONG); 193917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_I2F, Dops.INT_TO_FLOAT); 194917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_L2F, Dops.LONG_TO_FLOAT); 195917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_D2F, Dops.DOUBLE_TO_FLOAT); 196917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_I2D, Dops.INT_TO_DOUBLE); 197917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_L2D, Dops.LONG_TO_DOUBLE); 198917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CONV_F2D, Dops.FLOAT_TO_DOUBLE); 199917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.TO_BYTE, Dops.INT_TO_BYTE); 200917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.TO_CHAR, Dops.INT_TO_CHAR); 201917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.TO_SHORT, Dops.INT_TO_SHORT); 202917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.RETURN_VOID, Dops.RETURN_VOID); 203917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.RETURN_INT, Dops.RETURN); 204917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.RETURN_LONG, Dops.RETURN_WIDE); 205917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.RETURN_FLOAT, Dops.RETURN); 206917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.RETURN_DOUBLE, Dops.RETURN_WIDE); 207917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.RETURN_OBJECT, Dops.RETURN_OBJECT); 208917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.ARRAY_LENGTH, Dops.ARRAY_LENGTH); 209917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.THROW, Dops.THROW); 210917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MONITOR_ENTER, Dops.MONITOR_ENTER); 211917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.MONITOR_EXIT, Dops.MONITOR_EXIT); 212917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_INT, Dops.AGET); 213917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_LONG, Dops.AGET_WIDE); 214917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_FLOAT, Dops.AGET); 215917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_DOUBLE, Dops.AGET_WIDE); 216917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_OBJECT, Dops.AGET_OBJECT); 217917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_BOOLEAN, Dops.AGET_BOOLEAN); 218917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_BYTE, Dops.AGET_BYTE); 219917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_CHAR, Dops.AGET_CHAR); 220917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.AGET_SHORT, Dops.AGET_SHORT); 221917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_INT, Dops.APUT); 222917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_LONG, Dops.APUT_WIDE); 223917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_FLOAT, Dops.APUT); 224917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_DOUBLE, Dops.APUT_WIDE); 225917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_OBJECT, Dops.APUT_OBJECT); 226917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_BOOLEAN, Dops.APUT_BOOLEAN); 227917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_BYTE, Dops.APUT_BYTE); 228917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_CHAR, Dops.APUT_CHAR); 229917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.APUT_SHORT, Dops.APUT_SHORT); 230917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.NEW_INSTANCE, Dops.NEW_INSTANCE); 231917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.CHECK_CAST, Dops.CHECK_CAST); 232917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.INSTANCE_OF, Dops.INSTANCE_OF); 233917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 234917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GET_FIELD_LONG, Dops.IGET_WIDE); 235917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GET_FIELD_FLOAT, Dops.IGET); 236917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GET_FIELD_DOUBLE, Dops.IGET_WIDE); 237917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GET_FIELD_OBJECT, Dops.IGET_OBJECT); 238917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 239917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: No map entries for get_field_* for non-long integral types, 240917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * since they need to be handled specially (see dopFor() below). 241917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 242917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 243917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GET_STATIC_LONG, Dops.SGET_WIDE); 244917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GET_STATIC_FLOAT, Dops.SGET); 245917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GET_STATIC_DOUBLE, Dops.SGET_WIDE); 246917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.GET_STATIC_OBJECT, Dops.SGET_OBJECT); 247917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 248917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: No map entries for get_static* for non-long integral types, 249917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * since they need to be handled specially (see dopFor() below). 250917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 251917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 252917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.PUT_FIELD_LONG, Dops.IPUT_WIDE); 253917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.PUT_FIELD_FLOAT, Dops.IPUT); 254917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.PUT_FIELD_DOUBLE, Dops.IPUT_WIDE); 255917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.PUT_FIELD_OBJECT, Dops.IPUT_OBJECT); 256917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 257917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: No map entries for put_field_* for non-long integral types, 258917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * since they need to be handled specially (see dopFor() below). 259917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 260917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 261917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.PUT_STATIC_LONG, Dops.SPUT_WIDE); 262917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.PUT_STATIC_FLOAT, Dops.SPUT); 263917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.PUT_STATIC_DOUBLE, Dops.SPUT_WIDE); 264917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul MAP.put(Rops.PUT_STATIC_OBJECT, Dops.SPUT_OBJECT); 265917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 266917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: No map entries for put_static* for non-long integral types, 267917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * since they need to be handled specially (see dopFor() below). 268917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 269917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 270917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 271917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Note: No map entries for invoke*, new_array, and 272917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * filled_new_array, since they need to be handled specially 273917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * (see dopFor() below). 274917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 275917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 276917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 277917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /** 278917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * Returns the dalvik opcode appropriate for the given register-based 279917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * instruction. 280917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * 281917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * @param insn {@code non-null;} the original instruction 282917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * @return the corresponding dalvik opcode; one of the constants in 283917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * {@link Dops} 284917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 285917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul public static Dop dopFor(Insn insn) { 286917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul Rop rop = insn.getOpcode(); 287917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 288917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 289917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * First, just try looking up the rop in the MAP of easy 290917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * cases. 291917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 292917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul Dop result = MAP.get(rop); 293917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul if (result != null) { 294917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul return result; 295917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 296917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 297917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul /* 298917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * There was no easy case for the rop, so look up the opcode, and 299917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * do something special for each: 300917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * 301917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * The move_exception, new_array, filled_new_array, and 302917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * invoke* opcodes won't be found in MAP, since they'll each 303917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * have different source and/or result register types / lists. 304917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * 305917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * The get* and put* opcodes for (non-long) integral types 306917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * aren't in the map, since the type signatures aren't 307917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * sufficient to distinguish between the types (the salient 308917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * source or result will always be just "int"). 309917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * 310917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * And const instruction need to distinguish between strings and 311917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul * classes. 312917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul */ 313917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 314917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul switch (rop.getOpcode()) { 315917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.MOVE_EXCEPTION: return Dops.MOVE_EXCEPTION; 316917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.INVOKE_STATIC: return Dops.INVOKE_STATIC; 317917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.INVOKE_VIRTUAL: return Dops.INVOKE_VIRTUAL; 318917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.INVOKE_SUPER: return Dops.INVOKE_SUPER; 319917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.INVOKE_DIRECT: return Dops.INVOKE_DIRECT; 320917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.INVOKE_INTERFACE: return Dops.INVOKE_INTERFACE; 321917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.NEW_ARRAY: return Dops.NEW_ARRAY; 322917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.FILLED_NEW_ARRAY: return Dops.FILLED_NEW_ARRAY; 323917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.FILL_ARRAY_DATA: return Dops.FILL_ARRAY_DATA; 324917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.MOVE_RESULT: { 325917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul RegisterSpec resultReg = insn.getResult(); 326917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 327917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul if (resultReg == null) { 328917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul return Dops.NOP; 329917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } else { 330917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul switch (resultReg.getBasicType()) { 331917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_INT: 332917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_FLOAT: 333917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BOOLEAN: 334917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BYTE: 335917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_CHAR: 336917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_SHORT: 337917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul return Dops.MOVE_RESULT; 338917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_LONG: 339917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_DOUBLE: 340917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul return Dops.MOVE_RESULT_WIDE; 341917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_OBJECT: 342917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul return Dops.MOVE_RESULT_OBJECT; 343917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul default: { 344917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul throw new RuntimeException("Unexpected basic type"); 345917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 346917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 347917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 348917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 349917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 350917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.GET_FIELD: { 351917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul CstFieldRef ref = 352917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul (CstFieldRef) ((ThrowingCstInsn) insn).getConstant(); 353917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul int basicType = ref.getBasicType(); 354917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul switch (basicType) { 355917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BOOLEAN: return Dops.IGET_BOOLEAN; 356917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BYTE: return Dops.IGET_BYTE; 357917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_CHAR: return Dops.IGET_CHAR; 358917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_SHORT: return Dops.IGET_SHORT; 359917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_INT: return Dops.IGET; 360917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 361917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul break; 362917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 363917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.PUT_FIELD: { 364917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul CstFieldRef ref = 365917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul (CstFieldRef) ((ThrowingCstInsn) insn).getConstant(); 366917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul int basicType = ref.getBasicType(); 367917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul switch (basicType) { 368917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BOOLEAN: return Dops.IPUT_BOOLEAN; 369917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BYTE: return Dops.IPUT_BYTE; 370917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_CHAR: return Dops.IPUT_CHAR; 371917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_SHORT: return Dops.IPUT_SHORT; 372917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_INT: return Dops.IPUT; 373917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 374917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul break; 375917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 376917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.GET_STATIC: { 377917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul CstFieldRef ref = 378917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul (CstFieldRef) ((ThrowingCstInsn) insn).getConstant(); 379917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul int basicType = ref.getBasicType(); 380917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul switch (basicType) { 381917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BOOLEAN: return Dops.SGET_BOOLEAN; 382917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BYTE: return Dops.SGET_BYTE; 383917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_CHAR: return Dops.SGET_CHAR; 384917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_SHORT: return Dops.SGET_SHORT; 385917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_INT: return Dops.SGET; 386917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 387917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul break; 388917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 389917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.PUT_STATIC: { 390917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul CstFieldRef ref = 391917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul (CstFieldRef) ((ThrowingCstInsn) insn).getConstant(); 392917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul int basicType = ref.getBasicType(); 393917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul switch (basicType) { 394917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BOOLEAN: return Dops.SPUT_BOOLEAN; 395917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_BYTE: return Dops.SPUT_BYTE; 396917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_CHAR: return Dops.SPUT_CHAR; 397917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_SHORT: return Dops.SPUT_SHORT; 398917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case Type.BT_INT: return Dops.SPUT; 399917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 400917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul break; 401917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 402917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul case RegOps.CONST: { 403917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul Constant cst = ((ThrowingCstInsn) insn).getConstant(); 404917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul if (cst instanceof CstType) { 405917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul return Dops.CONST_CLASS; 406917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } else if (cst instanceof CstString) { 407917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul return Dops.CONST_STRING; 408917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 409917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul break; 410917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 411917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 412917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul 413917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul throw new RuntimeException("unknown rop: " + rop); 414917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul } 415917cb222329ee8c035c3ffaf947e4265761b9367Piotr Gurgul} 416