(AbstractInsnNode insn, InsnValue value1, InsnValue indexValue)
| 93 | } |
| 94 | |
| 95 | public InsnValue loadFromArray(AbstractInsnNode insn, InsnValue value1, InsnValue indexValue) throws AnalyzerException { |
| 96 | Object indexObj = indexValue.getValue(), arrayObj = value1.getValue(); |
| 97 | int index = indexObj == null ? -1 : ((Number) indexObj).intValue(); |
| 98 | boolean arrayNotSimulated = arrayObj == null; |
| 99 | Type t = arrayNotSimulated ? null : Type.getType(arrayObj.getClass()); |
| 100 | switch (insn.getOpcode()) { |
| 101 | case Opcodes.IALOAD: |
| 102 | if (arrayNotSimulated) { |
| 103 | return InsnValue.INT_VALUE; |
| 104 | } |
| 105 | // Sometimes Object[] contain values. Stringer obfuscator does this. |
| 106 | // TODO: Have this sort of check for others? |
| 107 | boolean oarr = t.equals(InsnValue.REFERENCE_ARR_VALUE.getType()); |
| 108 | if (oarr) { |
| 109 | int[] ia = (int[]) arrayObj; |
| 110 | return InsnValue.intValue(ia[index]); |
| 111 | }else{ |
| 112 | Object[] obarr = (Object[]) arrayObj; |
| 113 | Object o = obarr[index]; |
| 114 | if (o == null){ |
| 115 | return InsnValue.INT_VALUE; |
| 116 | } |
| 117 | return InsnValue.intValue(((Number) o).intValue()); |
| 118 | } |
| 119 | case Opcodes.LALOAD: |
| 120 | if (arrayNotSimulated) { |
| 121 | return InsnValue.LONG_VALUE; |
| 122 | } |
| 123 | long[] la = (long[]) arrayObj; |
| 124 | return InsnValue.longValue(la[index]); |
| 125 | case Opcodes.FALOAD: |
| 126 | if (arrayNotSimulated) { |
| 127 | return InsnValue.FLOAT_VALUE; |
| 128 | } |
| 129 | float[] fa = (float[]) arrayObj; |
| 130 | return InsnValue.floatValue(fa[index]); |
| 131 | case Opcodes.DALOAD: |
| 132 | if (arrayNotSimulated) { |
| 133 | return InsnValue.DOUBLE_VALUE; |
| 134 | } |
| 135 | double[] da = (double[]) arrayObj; |
| 136 | return InsnValue.doubleValue(da[index]); |
| 137 | case Opcodes.AALOAD: |
| 138 | // TODO: Check if it's an object array, but the contents aren't objects |
| 139 | return InsnValue.REFERENCE_VALUE; |
| 140 | case Opcodes.BALOAD: |
| 141 | if (arrayNotSimulated) { |
| 142 | return InsnValue.BYTE_VALUE; |
| 143 | } |
| 144 | boolean db = t.equals(InsnValue.DOUBLE_ARR_VALUE.getType()), in = t.equals(InsnValue.INT_ARR_VALUE.getType()), saa = t.equals(InsnValue.SHORT_ARR_VALUE.getType()); |
| 145 | if (db) { |
| 146 | double[] dba = (double[]) arrayObj; |
| 147 | return InsnValue.intValue(dba[index]); |
| 148 | } else if (in) { |
| 149 | int[] ina = (int[]) arrayObj; |
| 150 | return InsnValue.intValue(ina[index]); |
| 151 | } else if (saa){ |
| 152 | short[] saaa = (short[]) arrayObj; |
no test coverage detected