use of org.powermock.api.mockito.repackaged.asm.Type in project powermock by powermock.
the class TypeUtils method add.
public static Type[] add(Type[] types, Type extra) {
if (types == null) {
return new Type[] { extra };
} else {
List list = Arrays.asList(types);
if (list.contains(extra)) {
return types;
}
Type[] copy = new Type[types.length + 1];
System.arraycopy(types, 0, copy, 0, types.length);
copy[types.length] = extra;
return copy;
}
}
use of org.powermock.api.mockito.repackaged.asm.Type in project powermock by powermock.
the class TypeUtils method parseTypes.
public static Type[] parseTypes(String s) {
List names = parseTypes(s, 0, s.length());
Type[] types = new Type[names.size()];
for (int i = 0; i < types.length; i++) {
types[i] = Type.getType((String) names.get(i));
}
return types;
}
use of org.powermock.api.mockito.repackaged.asm.Type in project powermock by powermock.
the class ClassEmitter method begin_class.
public void begin_class(int version, final int access, String className, final Type superType, final Type[] interfaces, String source) {
final Type classType = Type.getType("L" + className.replace('.', '/') + ";");
classInfo = new ClassInfo() {
public Type getType() {
return classType;
}
public Type getSuperType() {
return (superType != null) ? superType : Constants.TYPE_OBJECT;
}
public Type[] getInterfaces() {
return interfaces;
}
public int getModifiers() {
return access;
}
};
cv.visit(version, access, classInfo.getType().getInternalName(), null, classInfo.getSuperType().getInternalName(), TypeUtils.toInternalNames(interfaces));
if (source != null)
cv.visitSource(source, null);
init();
}
use of org.powermock.api.mockito.repackaged.asm.Type in project powermock by powermock.
the class CodeEmitter method unbox.
/**
* If the argument is a primitive class, replaces the object
* on the top of the stack with the unwrapped (primitive)
* equivalent. For example, Character -> char.
* @param type the class indicating the desired type of the top stack value
*/
public void unbox(Type type) {
Type t = Constants.TYPE_NUMBER;
Signature sig = null;
switch(type.getSort()) {
case Type.VOID:
return;
case Type.CHAR:
t = Constants.TYPE_CHARACTER;
sig = CHAR_VALUE;
break;
case Type.BOOLEAN:
t = Constants.TYPE_BOOLEAN;
sig = BOOLEAN_VALUE;
break;
case Type.DOUBLE:
sig = DOUBLE_VALUE;
break;
case Type.FLOAT:
sig = FLOAT_VALUE;
break;
case Type.LONG:
sig = LONG_VALUE;
break;
case Type.INT:
case Type.SHORT:
case Type.BYTE:
sig = INT_VALUE;
}
if (sig == null) {
checkcast(type);
} else {
checkcast(t);
invoke_virtual(t, sig);
}
}
use of org.powermock.api.mockito.repackaged.asm.Type in project powermock by powermock.
the class CodeEmitter method invoke.
public void invoke(MethodInfo method, Type virtualType) {
ClassInfo classInfo = method.getClassInfo();
Type type = classInfo.getType();
Signature sig = method.getSignature();
if (sig.getName().equals(Constants.CONSTRUCTOR_NAME)) {
invoke_constructor(type, sig);
} else if (TypeUtils.isInterface(classInfo.getModifiers())) {
invoke_interface(type, sig);
} else if (TypeUtils.isStatic(method.getModifiers())) {
invoke_static(type, sig);
} else {
invoke_virtual(virtualType, sig);
}
}
Aggregations