Java Code Examples for org.objectweb.asm.Opcodes#SALOAD
The following examples show how to use
org.objectweb.asm.Opcodes#SALOAD .
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: Utils.java From Concurnas with MIT License | 5 votes |
public static void applyArrayLoad(BytecodeOutputter mv, Type origType) { if(origType instanceof PrimativeType && origType.getArrayLevels() == 1 ) { PrimativeTypeEnum ee = ((PrimativeType)origType).type; int op; switch(ee) { case BOOLEAN: op = Opcodes.BALOAD; break; case CHAR: op = Opcodes.CALOAD; break; case FLOAT: op = Opcodes.FALOAD; break; case DOUBLE: op = Opcodes.DALOAD; break; case SHORT: op = Opcodes.SALOAD; break; case INT: op = Opcodes.IALOAD; break; case BYTE: op = Opcodes.BALOAD; break; default: op = Opcodes.LALOAD; break;//long } mv.visitInsn(op); } else {//HERE BE PROBLEMS if(TypeCheckUtils.hasRefLevelsAndIsArray(origType)){ mv.visitInsn(Opcodes.SWAP); extractAndCastArrayRef(mv, origType); mv.visitInsn(Opcodes.SWAP); } mv.visitInsn(Opcodes.AALOAD); } }
Example 2
Source File: JVMImpl.java From serianalyzer with GNU General Public License v3.0 | 5 votes |
/** * @param opcode * @return */ private static Type toType ( int opcode ) { switch ( opcode ) { case Opcodes.LLOAD: return Type.LONG_TYPE; case Opcodes.ILOAD: return Type.INT_TYPE; case Opcodes.FLOAD: return Type.FLOAT_TYPE; case Opcodes.DLOAD: return Type.DOUBLE_TYPE; case Opcodes.ALOAD: return Type.getType("Ljava/lang/Object;"); //$NON-NLS-1$ case Opcodes.IALOAD: return Type.INT_TYPE; case Opcodes.LALOAD: return Type.LONG_TYPE; case Opcodes.FALOAD: return Type.FLOAT_TYPE; case Opcodes.DALOAD: return Type.DOUBLE_TYPE; case Opcodes.BALOAD: return Type.BYTE_TYPE; case Opcodes.CALOAD: return Type.CHAR_TYPE; case Opcodes.SALOAD: return Type.SHORT_TYPE; } return Type.VOID_TYPE; }
Example 3
Source File: InstructionAssembler.java From es6draft with MIT License | 5 votes |
public final void aload(Type type) { switch (type.getOpcode(Opcodes.IALOAD)) { case Opcodes.IALOAD: iaload(); return; case Opcodes.LALOAD: laload(); return; case Opcodes.FALOAD: faload(); return; case Opcodes.DALOAD: daload(); return; case Opcodes.AALOAD: aaload(); return; case Opcodes.BALOAD: baload(); return; case Opcodes.CALOAD: caload(); return; case Opcodes.SALOAD: saload(); return; default: throw new IllegalArgumentException(); } }
Example 4
Source File: StackHelper.java From zelixkiller with GNU General Public License v3.0 | 4 votes |
public InsnValue loadFromArray(AbstractInsnNode insn, InsnValue value1, InsnValue indexValue) throws AnalyzerException { Object indexObj = indexValue.getValue(), arrayObj = value1.getValue(); int index = indexObj == null ? -1 : ((Number) indexObj).intValue(); boolean arrayNotSimulated = arrayObj == null; Type t = arrayNotSimulated ? null : Type.getType(arrayObj.getClass()); switch (insn.getOpcode()) { case Opcodes.IALOAD: if (arrayNotSimulated) { return InsnValue.INT_VALUE; } // Sometimes Object[] contain values. Stringer obfuscator does this. // TODO: Have this sort of check for others? boolean oarr = t.equals(InsnValue.REFERENCE_ARR_VALUE.getType()); if (oarr) { int[] ia = (int[]) arrayObj; return InsnValue.intValue(ia[index]); }else{ Object[] obarr = (Object[]) arrayObj; Object o = obarr[index]; if (o == null){ return InsnValue.INT_VALUE; } return InsnValue.intValue(((Number) o).intValue()); } case Opcodes.LALOAD: if (arrayNotSimulated) { return InsnValue.LONG_VALUE; } long[] la = (long[]) arrayObj; return InsnValue.longValue(la[index]); case Opcodes.FALOAD: if (arrayNotSimulated) { return InsnValue.FLOAT_VALUE; } float[] fa = (float[]) arrayObj; return InsnValue.floatValue(fa[index]); case Opcodes.DALOAD: if (arrayNotSimulated) { return InsnValue.DOUBLE_VALUE; } double[] da = (double[]) arrayObj; return InsnValue.doubleValue(da[index]); case Opcodes.AALOAD: // TODO: Check if it's an object array, but the contents aren't objects return InsnValue.REFERENCE_VALUE; case Opcodes.BALOAD: if (arrayNotSimulated) { return InsnValue.BYTE_VALUE; } 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()); if (db) { double[] dba = (double[]) arrayObj; return InsnValue.intValue(dba[index]); } else if (in) { int[] ina = (int[]) arrayObj; return InsnValue.intValue(ina[index]); } else if (saa){ short[] saaa = (short[]) arrayObj; return InsnValue.intValue(saaa[index]); } else { System.err.println("UNKNOWN TYPE BALOAD: " + t); throw new RuntimeException(); } case Opcodes.CALOAD: if (arrayNotSimulated) { return InsnValue.CHAR_VALUE; } char[] ca = (char[]) arrayObj; return InsnValue.charValue(ca[index]); case Opcodes.SALOAD: if (arrayNotSimulated) { return InsnValue.SHORT_VALUE; } short[] sa = (short[]) arrayObj; return InsnValue.intValue((short) sa[index]); } return null; }
Example 5
Source File: ArrayLoadExpression.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public static int tryReduce(List<Instruction> instructions, int index) { Instruction instr = instructions.get(index); switch (instr.getOpcode()) { case Opcodes.AALOAD: case Opcodes.FALOAD: case Opcodes.CALOAD: case Opcodes.DALOAD: case Opcodes.BALOAD: case Opcodes.IALOAD: case Opcodes.LALOAD: case Opcodes.SALOAD: break; default: return -1; } if (index < 2) { return -1; } Instruction indexInstr = instructions.get(index-1); if (!(indexInstr instanceof AssignableExpression)) { return -1; } Instruction arrInstr = instructions.get(index-2); if (!(arrInstr instanceof AssignableExpression)) { return -1; } ArrayLoadExpression out = new ArrayLoadExpression(); out.loadInstruction = instr; out.indexInstruction = indexInstr; out.targetArrayInstruction = arrInstr; instructions.remove(index-2); instructions.remove(index-2); instructions.remove(index-2); instructions.add(index-2, out); return index-2; }
Example 6
Source File: UOI3Mutator.java From pitest with Apache License 2.0 | 4 votes |
@Override public void visitInsn(final int opcode) { // I F L D + BS switch (opcode) { case Opcodes.IALOAD: if (this.shouldMutate("Incremented (++a) integer array field")) { mv.visitInsn(Opcodes.DUP2); // stack = ... [array] [index] [array] [index] mv.visitInsn(opcode); // stack = ... [array] [index] [array[index]] mv.visitInsn(Opcodes.ICONST_1); // stack = ... [array] [index] [array[index]] [1] mv.visitInsn(Opcodes.IADD); // stack = ... [array] [index] [array[index]+1] mv.visitInsn(Opcodes.DUP_X2); // stack = ... [array[index]+1] [array] [index] [array[index]+1] mv.visitInsn(Opcodes.IASTORE); // stack = ... [array[index]+1] } else { mv.visitInsn(opcode); } break; case Opcodes.FALOAD: if (this.shouldMutate("Incremented (++a) float array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FADD); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.FASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.LALOAD: if (this.shouldMutate("Incremented (++a) long array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LADD); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.LASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.DALOAD: if (this.shouldMutate("Incremented (++a) double array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DADD); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.DASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.BALOAD: if (this.shouldMutate("Incremented (++a) byte array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2B); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.BASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.SALOAD: if (this.shouldMutate("Incremented (++a) short array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2S); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.SASTORE); } else { mv.visitInsn(opcode); } break; default: mv.visitInsn(opcode); break; } }
Example 7
Source File: UOI1Mutator.java From pitest with Apache License 2.0 | 4 votes |
@Override public void visitInsn(final int opcode) { // I F L D + BS switch (opcode) { case Opcodes.IALOAD: if (this.shouldMutate("Incremented (a++) integer array field")) { mv.visitInsn(Opcodes.DUP2); // stack = ... [array] [index] [array] [index] mv.visitInsn(opcode); // stack = ... [array] [index] [array[index]] mv.visitInsn(Opcodes.DUP_X2); //stack = ... [array[index]] [array] [index] [array[index]] mv.visitInsn(Opcodes.ICONST_1); //stack = ... [array[index]] [array] [index] [array[index]] [1] mv.visitInsn(Opcodes.IADD); //stack = ... [array[index]] [array] [index] [array[index] + 1] mv.visitInsn(Opcodes.IASTORE); //stack = ... [array[index]] } else { mv.visitInsn(opcode); } break; case Opcodes.FALOAD: if (this.shouldMutate("Incremented (a++) float array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FADD); mv.visitInsn(Opcodes.FASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.LALOAD: if (this.shouldMutate("Incremented (a++) long array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LADD); mv.visitInsn(Opcodes.LASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.DALOAD: if (this.shouldMutate("Incremented (a++) double array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DADD); mv.visitInsn(Opcodes.DASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.BALOAD: if (this.shouldMutate("Incremented (a++) byte array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2B); mv.visitInsn(Opcodes.BASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.SALOAD: if (this.shouldMutate("Incremented (a++) short array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.IADD); mv.visitInsn(Opcodes.I2S); mv.visitInsn(Opcodes.SASTORE); } else { mv.visitInsn(opcode); } break; default: mv.visitInsn(opcode); break; } }
Example 8
Source File: UOI4Mutator.java From pitest with Apache License 2.0 | 4 votes |
@Override public void visitInsn(final int opcode) { // I F L D + BS switch (opcode) { case Opcodes.IALOAD: if (this.shouldMutate("Decremented (--a) integer array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.IASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.FALOAD: if (this.shouldMutate("Decremented (--a) float array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FSUB); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.FASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.LALOAD: if (this.shouldMutate("Decremented (--a) long array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LSUB); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.LASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.DALOAD: if (this.shouldMutate("Decremented (--a) double array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DSUB); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.DASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.BALOAD: if (this.shouldMutate("Decremented (--a) byte array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2B); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.BASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.SALOAD: if (this.shouldMutate("Decremented (--a) short array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2S); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.SASTORE); } else { mv.visitInsn(opcode); } break; default: mv.visitInsn(opcode); break; } }
Example 9
Source File: UOI2Mutator.java From pitest with Apache License 2.0 | 4 votes |
@Override public void visitInsn(final int opcode) { // I F L D + BS switch (opcode) { case Opcodes.IALOAD: if (this.shouldMutate("Decremented (a--) integer array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.IASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.FALOAD: if (this.shouldMutate("Decremented (a--) float array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.FCONST_1); mv.visitInsn(Opcodes.FSUB); mv.visitInsn(Opcodes.FASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.LALOAD: if (this.shouldMutate("Decremented (a--) long array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.LCONST_1); mv.visitInsn(Opcodes.LSUB); mv.visitInsn(Opcodes.LASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.DALOAD: if (this.shouldMutate("Decremented (a--) double array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.DCONST_1); mv.visitInsn(Opcodes.DSUB); mv.visitInsn(Opcodes.DASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.BALOAD: if (this.shouldMutate("Decremented (a--) byte array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2B); mv.visitInsn(Opcodes.BASTORE); } else { mv.visitInsn(opcode); } break; case Opcodes.SALOAD: if (this.shouldMutate("Decremented (a--) short array field")) { mv.visitInsn(Opcodes.DUP2); mv.visitInsn(opcode); mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.ICONST_1); mv.visitInsn(Opcodes.ISUB); mv.visitInsn(Opcodes.I2S); mv.visitInsn(Opcodes.SASTORE); } else { mv.visitInsn(opcode); } break; default: mv.visitInsn(opcode); break; } }
Example 10
Source File: ABSMutator.java From pitest with Apache License 2.0 | 4 votes |
@Override public void visitInsn(final int opcode) { mv.visitInsn(opcode); switch (opcode) { // ARRAYS I F L D , loading case Opcodes.IALOAD: if (this.shouldMutate("Negated integer array field")) { mv.visitInsn(Opcodes.INEG); } break; case Opcodes.FALOAD: if (this.shouldMutate("Negated float array field")) { mv.visitInsn(Opcodes.FNEG); } break; case Opcodes.LALOAD: if (this.shouldMutate("Negated long array field")) { mv.visitInsn(Opcodes.LNEG); } break; case Opcodes.DALOAD: if (this.shouldMutate("Negated double array field")) { mv.visitInsn(Opcodes.DNEG); } break; case Opcodes.BALOAD: if (this.shouldMutate("Negated byte array field")) { mv.visitInsn(Opcodes.INEG); mv.visitInsn(Opcodes.I2B); } break; case Opcodes.SALOAD: if (this.shouldMutate("Negated short array field")) { mv.visitInsn(Opcodes.INEG); mv.visitInsn(Opcodes.I2S); } break; default: break; } }