Java Code Examples for org.objectweb.asm.Opcodes#T_INT

The following examples show how to use org.objectweb.asm.Opcodes#T_INT . 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: PrimitiveUtils.java    From obfuscator with MIT License 6 votes vote down vote up
public static Class<?> getPrimitiveByNewArrayId(int id) {
    switch (id) {
        case Opcodes.T_BOOLEAN:
            return boolean.class;
        case Opcodes.T_CHAR:
            return char.class;
        case Opcodes.T_FLOAT:
            return float.class;
        case Opcodes.T_DOUBLE:
            return double.class;
        case Opcodes.T_BYTE:
            return byte.class;
        case Opcodes.T_SHORT:
            return short.class;
        case Opcodes.T_INT:
            return int.class;
        case Opcodes.T_LONG:
            return long.class;
    }
    throw new IllegalArgumentException("Unknown type " + id);
}
 
Example 2
Source File: TypeUtils.java    From maple-ir with GNU General Public License v3.0 6 votes vote down vote up
public static int getPrimitiveArrayOpcode(Type type) {
	switch (type.getElementType().getSort()) {
		case Type.BOOLEAN:
			return Opcodes.T_BOOLEAN;
		case Type.BYTE:
			return Opcodes.T_BYTE;
		case Type.SHORT:
			return Opcodes.T_SHORT;
		case Type.CHAR:
			return Opcodes.T_CHAR;
		case Type.INT:
			return Opcodes.T_INT;
		case Type.LONG:
			return Opcodes.T_LONG;
		case Type.FLOAT:
			return Opcodes.T_FLOAT;
		case Type.DOUBLE:
			return Opcodes.T_DOUBLE;
		default:
			throw new RuntimeException("WT");
	}
}
 
Example 3
Source File: InstructionAssembler.java    From es6draft with MIT License 6 votes vote down vote up
private static final int arrayType(Type type) {
    switch (type.getSort()) {
    case Type.Sort.BOOLEAN:
        return Opcodes.T_BOOLEAN;
    case Type.Sort.CHAR:
        return Opcodes.T_CHAR;
    case Type.Sort.BYTE:
        return Opcodes.T_BYTE;
    case Type.Sort.SHORT:
        return Opcodes.T_SHORT;
    case Type.Sort.INT:
        return Opcodes.T_INT;
    case Type.Sort.FLOAT:
        return Opcodes.T_FLOAT;
    case Type.Sort.LONG:
        return Opcodes.T_LONG;
    case Type.Sort.DOUBLE:
        return Opcodes.T_DOUBLE;
    case Type.Sort.OBJECT:
    case Type.Sort.ARRAY:
    case Type.Sort.METHOD:
    case Type.Sort.VOID:
    default:
        throw new IllegalArgumentException();
    }
}
 
Example 4
Source File: MethodVisitorBuilder.java    From testability-explorer with Apache License 2.0 6 votes vote down vote up
private Type toType(int operand) {
  switch (operand) {
    case Opcodes.T_BOOLEAN :
      return JavaType.BOOLEAN;
    case Opcodes.T_BYTE :
      return JavaType.BYTE;
    case Opcodes.T_CHAR :
      return JavaType.CHAR;
    case Opcodes.T_DOUBLE :
      return JavaType.DOUBLE;
    case Opcodes.T_FLOAT :
      return JavaType.FLOAT;
    case Opcodes.T_INT :
      return JavaType.INT;
    case Opcodes.T_LONG :
      return JavaType.LONG;
    case Opcodes.T_SHORT :
      return JavaType.SHORT;
    default :
      throw new IllegalArgumentException();
  }
}
 
Example 5
Source File: PrimitiveUtils.java    From deobfuscator with Apache License 2.0 6 votes vote down vote up
public static Class<?> getPrimitiveByNewArrayId(int id) {
    switch (id) {
        case Opcodes.T_BOOLEAN:
            return boolean.class;
        case Opcodes.T_CHAR:
            return char.class;
        case Opcodes.T_FLOAT:
            return float.class;
        case Opcodes.T_DOUBLE:
            return double.class;
        case Opcodes.T_BYTE:
            return byte.class;
        case Opcodes.T_SHORT:
            return short.class;
        case Opcodes.T_INT:
            return int.class;
        case Opcodes.T_LONG:
            return long.class;
    }
    throw new IllegalArgumentException("Unknown type " + id);
}
 
Example 6
Source File: JVMImpl.java    From serianalyzer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param operand
 * @return
 */
private static Type makeBasicArrayType ( int operand ) {

    switch ( operand ) {
    case Opcodes.T_BOOLEAN:
        return Type.getType("[Z"); //$NON-NLS-1$
    case Opcodes.T_BYTE:
        return Type.getType("[B"); //$NON-NLS-1$
    case Opcodes.T_CHAR:
        return Type.getType("[C"); //$NON-NLS-1$
    case Opcodes.T_DOUBLE:
        return Type.getType("[D"); //$NON-NLS-1$
    case Opcodes.T_FLOAT:
        return Type.getType("[F"); //$NON-NLS-1$
    case Opcodes.T_INT:
        return Type.getType("[I"); //$NON-NLS-1$
    case Opcodes.T_LONG:
        return Type.getType("[J"); //$NON-NLS-1$
    case Opcodes.T_SHORT:
        return Type.getType("[S"); //$NON-NLS-1$

    default:
        log.error("Unknown array type " + operand); //$NON-NLS-1$
    }
    return null;
}
 
Example 7
Source File: InstructionAdapter.java    From Concurnas with MIT License 5 votes vote down vote up
/**
 * Generates the instruction to create and push on the stack an array of the given type.
 *
 * @param methodVisitor the method visitor to use to generate the instruction.
 * @param type an array Type.
 */
static void newarray(final MethodVisitor methodVisitor, final Type type) {
  int arrayType;
  switch (type.getSort()) {
    case Type.BOOLEAN:
      arrayType = Opcodes.T_BOOLEAN;
      break;
    case Type.CHAR:
      arrayType = Opcodes.T_CHAR;
      break;
    case Type.BYTE:
      arrayType = Opcodes.T_BYTE;
      break;
    case Type.SHORT:
      arrayType = Opcodes.T_SHORT;
      break;
    case Type.INT:
      arrayType = Opcodes.T_INT;
      break;
    case Type.FLOAT:
      arrayType = Opcodes.T_FLOAT;
      break;
    case Type.LONG:
      arrayType = Opcodes.T_LONG;
      break;
    case Type.DOUBLE:
      arrayType = Opcodes.T_DOUBLE;
      break;
    default:
      methodVisitor.visitTypeInsn(Opcodes.ANEWARRAY, type.getInternalName());
      return;
  }
  methodVisitor.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example 8
Source File: GeneratorAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Generates the instruction to create a new array.
 *
 * @param type the type of the array elements.
 */
public void newArray(final Type type) {
  int arrayType;
  switch (type.getSort()) {
    case Type.BOOLEAN:
      arrayType = Opcodes.T_BOOLEAN;
      break;
    case Type.CHAR:
      arrayType = Opcodes.T_CHAR;
      break;
    case Type.BYTE:
      arrayType = Opcodes.T_BYTE;
      break;
    case Type.SHORT:
      arrayType = Opcodes.T_SHORT;
      break;
    case Type.INT:
      arrayType = Opcodes.T_INT;
      break;
    case Type.FLOAT:
      arrayType = Opcodes.T_FLOAT;
      break;
    case Type.LONG:
      arrayType = Opcodes.T_LONG;
      break;
    case Type.DOUBLE:
      arrayType = Opcodes.T_DOUBLE;
      break;
    default:
      typeInsn(Opcodes.ANEWARRAY, type);
      return;
  }
  mv.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example 9
Source File: InstructionAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Generates the instruction to create and push on the stack an array of the given type.
 *
 * @param type an array Type.
 */
public void newarray(final Type type) {
  int arrayType;
  switch (type.getSort()) {
    case Type.BOOLEAN:
      arrayType = Opcodes.T_BOOLEAN;
      break;
    case Type.CHAR:
      arrayType = Opcodes.T_CHAR;
      break;
    case Type.BYTE:
      arrayType = Opcodes.T_BYTE;
      break;
    case Type.SHORT:
      arrayType = Opcodes.T_SHORT;
      break;
    case Type.INT:
      arrayType = Opcodes.T_INT;
      break;
    case Type.FLOAT:
      arrayType = Opcodes.T_FLOAT;
      break;
    case Type.LONG:
      arrayType = Opcodes.T_LONG;
      break;
    case Type.DOUBLE:
      arrayType = Opcodes.T_DOUBLE;
      break;
    default:
      mv.visitTypeInsn(Opcodes.ANEWARRAY, type.getInternalName());
      return;
  }
  mv.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example 10
Source File: GeneratorAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Generates the instruction to create a new array.
 *
 * @param type the type of the array elements.
 */
public void newArray(final Type type) {
  int arrayType;
  switch (type.getSort()) {
    case Type.BOOLEAN:
      arrayType = Opcodes.T_BOOLEAN;
      break;
    case Type.CHAR:
      arrayType = Opcodes.T_CHAR;
      break;
    case Type.BYTE:
      arrayType = Opcodes.T_BYTE;
      break;
    case Type.SHORT:
      arrayType = Opcodes.T_SHORT;
      break;
    case Type.INT:
      arrayType = Opcodes.T_INT;
      break;
    case Type.FLOAT:
      arrayType = Opcodes.T_FLOAT;
      break;
    case Type.LONG:
      arrayType = Opcodes.T_LONG;
      break;
    case Type.DOUBLE:
      arrayType = Opcodes.T_DOUBLE;
      break;
    default:
      typeInsn(Opcodes.ANEWARRAY, type);
      return;
  }
  mv.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example 11
Source File: InstructionAdapter.java    From JReFrameworker with MIT License 5 votes vote down vote up
/**
 * Generates the instruction to create and push on the stack an array of the given type.
 *
 * @param type an array Type.
 */
public void newarray(final Type type) {
  int arrayType;
  switch (type.getSort()) {
    case Type.BOOLEAN:
      arrayType = Opcodes.T_BOOLEAN;
      break;
    case Type.CHAR:
      arrayType = Opcodes.T_CHAR;
      break;
    case Type.BYTE:
      arrayType = Opcodes.T_BYTE;
      break;
    case Type.SHORT:
      arrayType = Opcodes.T_SHORT;
      break;
    case Type.INT:
      arrayType = Opcodes.T_INT;
      break;
    case Type.FLOAT:
      arrayType = Opcodes.T_FLOAT;
      break;
    case Type.LONG:
      arrayType = Opcodes.T_LONG;
      break;
    case Type.DOUBLE:
      arrayType = Opcodes.T_DOUBLE;
      break;
    default:
      mv.visitTypeInsn(Opcodes.ANEWARRAY, type.getInternalName());
      return;
  }
  mv.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example 12
Source File: GeneratorAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the instruction to create a new array.
 *
 * @param type the type of the array elements.
 */
public void newArray(final Type type) {
  int arrayType;
  switch (type.getSort()) {
    case Type.BOOLEAN:
      arrayType = Opcodes.T_BOOLEAN;
      break;
    case Type.CHAR:
      arrayType = Opcodes.T_CHAR;
      break;
    case Type.BYTE:
      arrayType = Opcodes.T_BYTE;
      break;
    case Type.SHORT:
      arrayType = Opcodes.T_SHORT;
      break;
    case Type.INT:
      arrayType = Opcodes.T_INT;
      break;
    case Type.FLOAT:
      arrayType = Opcodes.T_FLOAT;
      break;
    case Type.LONG:
      arrayType = Opcodes.T_LONG;
      break;
    case Type.DOUBLE:
      arrayType = Opcodes.T_DOUBLE;
      break;
    default:
      typeInsn(Opcodes.ANEWARRAY, type);
      return;
  }
  mv.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example 13
Source File: InstructionAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
public void newarray(final Type type) {
  int arrayType;
  switch (type.getSort()) {
    case Type.BOOLEAN:
      arrayType = Opcodes.T_BOOLEAN;
      break;
    case Type.CHAR:
      arrayType = Opcodes.T_CHAR;
      break;
    case Type.BYTE:
      arrayType = Opcodes.T_BYTE;
      break;
    case Type.SHORT:
      arrayType = Opcodes.T_SHORT;
      break;
    case Type.INT:
      arrayType = Opcodes.T_INT;
      break;
    case Type.FLOAT:
      arrayType = Opcodes.T_FLOAT;
      break;
    case Type.LONG:
      arrayType = Opcodes.T_LONG;
      break;
    case Type.DOUBLE:
      arrayType = Opcodes.T_DOUBLE;
      break;
    default:
      mv.visitTypeInsn(Opcodes.ANEWARRAY, type.getInternalName());
      return;
  }
  mv.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example 14
Source File: Utils.java    From Concurnas with MIT License 5 votes vote down vote up
public static void singleLevelArrayConst(BytecodeOutputter mv, Type consType) {
	if(consType instanceof PrimativeType )
	//if(consType instanceof PrimativeType && PrimativeTypeEnum.LAMBDA != ((PrimativeType)consType).type && consType.getArrayLevels() == 1)
	{
		PrimativeTypeEnum ee = ((PrimativeType)consType).type;
		int op;
		switch(ee)
		{
			case BOOLEAN: op = Opcodes.T_BOOLEAN; break; 
			case CHAR: op = Opcodes.T_CHAR; break; 
			case FLOAT: op = Opcodes.T_FLOAT; break; 
			case DOUBLE: op = Opcodes.T_DOUBLE; break; 
			case SHORT: op = Opcodes.T_SHORT; break; 
			case INT: op = Opcodes.T_INT; break; 
			case BYTE: op = Opcodes.T_BYTE; break; 
			default: op = Opcodes.T_LONG; break;//long 
		}
		
		 mv.visitIntInsn(Opcodes.NEWARRAY, op);
	}
	else
	{
		if( (consType instanceof NamedType && ((NamedType)consType).getIsRef() )){
			consType = ((NamedType)consType).copyTypeSpecific();
			consType.setArrayLevels(0);
		}
		String tt = consType.getBytecodeType();// -> [Ljava/lang/Object;		//java.lang.String[]	
		tt = tt.substring(1, tt.length()-1);
		if(consType.hasArrayLevels() && (consType.getOrigonalGenericTypeUpperBoundRaw() == null || consType instanceof GenericType)){
			tt = tt.substring(1, tt.length());
		}
		
		mv.visitTypeInsn(Opcodes.ANEWARRAY, tt);
	}
}
 
Example 15
Source File: InstructionAdapter.java    From JReFrameworker with MIT License 4 votes vote down vote up
@Override
public void visitIntInsn(final int opcode, final int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
      iconst(operand);
      break;
    case Opcodes.SIPUSH:
      iconst(operand);
      break;
    case Opcodes.NEWARRAY:
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          newarray(Type.BOOLEAN_TYPE);
          break;
        case Opcodes.T_CHAR:
          newarray(Type.CHAR_TYPE);
          break;
        case Opcodes.T_BYTE:
          newarray(Type.BYTE_TYPE);
          break;
        case Opcodes.T_SHORT:
          newarray(Type.SHORT_TYPE);
          break;
        case Opcodes.T_INT:
          newarray(Type.INT_TYPE);
          break;
        case Opcodes.T_FLOAT:
          newarray(Type.FLOAT_TYPE);
          break;
        case Opcodes.T_LONG:
          newarray(Type.LONG_TYPE);
          break;
        case Opcodes.T_DOUBLE:
          newarray(Type.DOUBLE_TYPE);
          break;
        default:
          throw new IllegalArgumentException();
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 16
Source File: InstructionAdapter.java    From JByteMod-Beta with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void visitIntInsn(final int opcode, final int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
      iconst(operand);
      break;
    case Opcodes.SIPUSH:
      iconst(operand);
      break;
    case Opcodes.NEWARRAY:
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          newarray(Type.BOOLEAN_TYPE);
          break;
        case Opcodes.T_CHAR:
          newarray(Type.CHAR_TYPE);
          break;
        case Opcodes.T_BYTE:
          newarray(Type.BYTE_TYPE);
          break;
        case Opcodes.T_SHORT:
          newarray(Type.SHORT_TYPE);
          break;
        case Opcodes.T_INT:
          newarray(Type.INT_TYPE);
          break;
        case Opcodes.T_FLOAT:
          newarray(Type.FLOAT_TYPE);
          break;
        case Opcodes.T_LONG:
          newarray(Type.LONG_TYPE);
          break;
        case Opcodes.T_DOUBLE:
          newarray(Type.DOUBLE_TYPE);
          break;
        default:
          throw new IllegalArgumentException();
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 17
Source File: Newarray.java    From nuls-v2 with MIT License 4 votes vote down vote up
public static void newarray(Frame frame) {
    VariableType type;
    int length = frame.operandStack.popInt();
    if (length < 0) {
        frame.throwNegativeArraySizeException();
        return;
    } else {
        switch (frame.intInsnNode().operand) {
            case Opcodes.T_BOOLEAN:
                type = VariableType.BOOLEAN_ARRAY_TYPE;
                break;
            case Opcodes.T_CHAR:
                type = VariableType.CHAR_ARRAY_TYPE;
                break;
            case Opcodes.T_FLOAT:
                type = VariableType.FLOAT_ARRAY_TYPE;
                break;
            case Opcodes.T_DOUBLE:
                type = VariableType.DOUBLE_ARRAY_TYPE;
                break;
            case Opcodes.T_BYTE:
                type = VariableType.BYTE_ARRAY_TYPE;
                break;
            case Opcodes.T_SHORT:
                type = VariableType.SHORT_ARRAY_TYPE;
                break;
            case Opcodes.T_INT:
                type = VariableType.INT_ARRAY_TYPE;
                break;
            case Opcodes.T_LONG:
                type = VariableType.LONG_ARRAY_TYPE;
                break;
            default:
                throw new IllegalArgumentException("unknown operand");
        }
    }

    ObjectRef arrayRef = frame.heap.newArray(type, length);
    frame.operandStack.pushRef(arrayRef);

    //Log.result(frame.getCurrentOpCode(), arrayRef);
}
 
Example 18
Source File: InstructionAdapter.java    From JReFrameworker with MIT License 4 votes vote down vote up
@Override
public void visitIntInsn(final int opcode, final int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
      iconst(operand);
      break;
    case Opcodes.SIPUSH:
      iconst(operand);
      break;
    case Opcodes.NEWARRAY:
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          newarray(Type.BOOLEAN_TYPE);
          break;
        case Opcodes.T_CHAR:
          newarray(Type.CHAR_TYPE);
          break;
        case Opcodes.T_BYTE:
          newarray(Type.BYTE_TYPE);
          break;
        case Opcodes.T_SHORT:
          newarray(Type.SHORT_TYPE);
          break;
        case Opcodes.T_INT:
          newarray(Type.INT_TYPE);
          break;
        case Opcodes.T_FLOAT:
          newarray(Type.FLOAT_TYPE);
          break;
        case Opcodes.T_LONG:
          newarray(Type.LONG_TYPE);
          break;
        case Opcodes.T_DOUBLE:
          newarray(Type.DOUBLE_TYPE);
          break;
        default:
          throw new IllegalArgumentException();
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 19
Source File: InstructionAdapter.java    From Concurnas with MIT License 4 votes vote down vote up
@Override
public void visitIntInsn(final int opcode, final int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
      iconst(operand);
      break;
    case Opcodes.SIPUSH:
      iconst(operand);
      break;
    case Opcodes.NEWARRAY:
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          newarray(Type.BOOLEAN_TYPE);
          break;
        case Opcodes.T_CHAR:
          newarray(Type.CHAR_TYPE);
          break;
        case Opcodes.T_BYTE:
          newarray(Type.BYTE_TYPE);
          break;
        case Opcodes.T_SHORT:
          newarray(Type.SHORT_TYPE);
          break;
        case Opcodes.T_INT:
          newarray(Type.INT_TYPE);
          break;
        case Opcodes.T_FLOAT:
          newarray(Type.FLOAT_TYPE);
          break;
        case Opcodes.T_LONG:
          newarray(Type.LONG_TYPE);
          break;
        case Opcodes.T_DOUBLE:
          newarray(Type.DOUBLE_TYPE);
          break;
        default:
          throw new IllegalArgumentException();
      }
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 20
Source File: BytecodeTypeInference.java    From bazel with Apache License 2.0 4 votes vote down vote up
@Override
public void visitIntInsn(int opcode, int operand) {
  switch (opcode) {
    case Opcodes.BIPUSH:
    case Opcodes.SIPUSH:
      push(InferredType.INT);
      break;
    case Opcodes.NEWARRAY:
      pop();
      switch (operand) {
        case Opcodes.T_BOOLEAN:
          pushDescriptor("[Z");
          break;
        case Opcodes.T_CHAR:
          pushDescriptor("[C");
          break;
        case Opcodes.T_FLOAT:
          pushDescriptor("[F");
          break;
        case Opcodes.T_DOUBLE:
          pushDescriptor("[D");
          break;
        case Opcodes.T_BYTE:
          pushDescriptor("[B");
          break;
        case Opcodes.T_SHORT:
          pushDescriptor("[S");
          break;
        case Opcodes.T_INT:
          pushDescriptor("[I");
          break;
        case Opcodes.T_LONG:
          pushDescriptor("[J");
          break;
        default:
          throw new RuntimeException("Unhandled operand value: " + operand);
      }
      break;
    default:
      throw new RuntimeException("Unhandled opcode " + opcode);
  }
  super.visitIntInsn(opcode, operand);
}