MCPcopy Create free account
hub / github.com/GraxCode/zelixkiller / storeInArray

Method storeInArray

src/me/lpk/analysis/StackHelper.java:304–385  ·  view source on GitHub ↗
(AbstractInsnNode insn, InsnValue arrayRef, InsnValue index, InsnValue value)

Source from the content-addressed store, hash-verified

302 }
303
304 public InsnValue storeInArray(AbstractInsnNode insn, InsnValue arrayRef, InsnValue index, InsnValue value) throws AnalyzerException {
305 boolean anythingNull = arrayRef.getValue() == null || index.getValue() == null || value.getValue() == null;
306 int i = anythingNull ? -1 : ((Number) index.getValue()).intValue();
307 switch (insn.getOpcode()) {
308 case Opcodes.IASTORE:
309 case Opcodes.CASTORE:
310 if (anythingNull) {
311 return InsnValue.INT_ARR_VALUE;
312 }
313 if (arrayRef.getType().equals(InsnValue.INT_ARR_VALUE.getType())) {
314 // Unsure why arrayRef when IASTORE isn't always [I
315 int[] ia = (int[]) arrayRef.getValue();
316 ia[i] = (int) value.getValue();
317 return new InsnValue(InsnValue.INT_ARR_VALUE.getType(), ia);
318 } else {
319 return InsnValue.INT_ARR_VALUE;
320 }
321
322 case Opcodes.LASTORE:
323 if (anythingNull) {
324 return InsnValue.LONG_ARR_VALUE;
325 }
326 long[] la = (long[]) arrayRef.getValue();
327 la[i] = (long) value.getValue();
328 return new InsnValue(InsnValue.LONG_ARR_VALUE.getType(), la);
329 case Opcodes.FASTORE:
330 if (anythingNull) {
331 return InsnValue.FLOAT_ARR_VALUE;
332 }
333 float[] fa = (float[]) arrayRef.getValue();
334 fa[i] = (float) value.getValue();
335 return new InsnValue(InsnValue.FLOAT_ARR_VALUE.getType(), fa);
336 case Opcodes.DASTORE:
337 if (anythingNull) {
338 return InsnValue.DOUBLE_ARR_VALUE;
339 }
340 double[] da = (double[]) arrayRef.getValue();
341 da[i] = ((Number) value.getValue()).doubleValue();
342 return new InsnValue(InsnValue.DOUBLE_ARR_VALUE.getType(), da);
343 case Opcodes.BASTORE:
344 if (anythingNull) {
345 return InsnValue.DOUBLE_ARR_VALUE;
346 }
347 Type t = Type.getType(arrayRef.getValue().getClass());
348 boolean db = t.equals(InsnValue.DOUBLE_ARR_VALUE.getType()), in = t.equals(InsnValue.INT_ARR_VALUE.getType()), saaa = t.equals(InsnValue.SHORT_ARR_VALUE.getType());
349 if (db) {
350 double[] da2 = (double[]) arrayRef.getValue();
351 da2[i] = ((Number) value.getValue()).doubleValue();
352 return new InsnValue(InsnValue.DOUBLE_ARR_VALUE.getType(), da2);
353 } else if (in) {
354 int[] ia = (int[]) arrayRef.getValue();
355 ia[i] = (int) value.getValue();
356 return new InsnValue(InsnValue.INT_ARR_VALUE.getType(), ia);
357 } else if (saaa) {
358 short[] saa = (short[]) arrayRef.getValue();
359 saa[i] = ((Number)value.getValue()).shortValue();
360 return new InsnValue(InsnValue.SHORT_ARR_VALUE.getType(), saa);
361 } else {

Callers 1

executeMethod · 0.80

Calls 6

intValueMethod · 0.80
getTypeMethod · 0.80
doubleValueMethod · 0.80
shortValueMethod · 0.80
getValueMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected