use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class FieldProviderTransformer method getByIndex.
private void getByIndex(final String[] names, final int[] indexes) throws Exception {
final CodeEmitter e = super.begin_method(Constants.ACC_PUBLIC, PROVIDER_GET_BY_INDEX, null);
e.load_this();
e.load_arg(0);
e.process_switch(indexes, new ProcessSwitchCallback() {
public void processCase(int key, Label end) throws Exception {
Type type = (Type) fields.get(names[key]);
e.getfield(names[key]);
e.box(type);
e.return_value();
}
public void processDefault() throws Exception {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field index");
}
});
e.end_method();
}
use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class FieldProviderTransformer method setField.
private void setField(String[] names) throws Exception {
final CodeEmitter e = begin_method(Constants.ACC_PUBLIC, PROVIDER_SET, null);
e.load_this();
e.load_arg(1);
e.load_arg(0);
EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
public void processCase(Object key, Label end) {
Type type = (Type) fields.get(key);
e.unbox(type);
e.putfield((String) key);
e.return_value();
}
public void processDefault() {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field name");
}
});
e.end_method();
}
use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class FieldProviderTransformer method getNames.
private void getNames() {
CodeEmitter e = super.begin_method(Constants.ACC_PUBLIC, PROVIDER_GET_NAMES, null);
e.getstatic(getClassType(), FIELD_NAMES, Constants.TYPE_STRING_ARRAY);
e.return_value();
e.end_method();
}
use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class InterceptFieldTransformer method begin_class.
public void begin_class(int version, int access, String className, Type superType, Type[] interfaces, String sourceFile) {
if (!TypeUtils.isInterface(access)) {
super.begin_class(version, access, className, superType, TypeUtils.add(interfaces, ENABLED), sourceFile);
super.declare_field(Constants.ACC_PRIVATE | Constants.ACC_TRANSIENT, CALLBACK_FIELD, CALLBACK, null);
CodeEmitter e;
e = super.begin_method(Constants.ACC_PUBLIC, ENABLED_GET, null);
e.load_this();
e.getfield(CALLBACK_FIELD);
e.return_value();
e.end_method();
e = super.begin_method(Constants.ACC_PUBLIC, ENABLED_SET, null);
e.load_this();
e.load_arg(0);
e.putfield(CALLBACK_FIELD);
e.return_value();
e.end_method();
} else {
super.begin_class(version, access, className, superType, interfaces, sourceFile);
}
}
use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class UndeclaredThrowableTransformer method begin_method.
public CodeEmitter begin_method(int access, final Signature sig, final Type[] exceptions) {
CodeEmitter e = super.begin_method(access, sig, exceptions);
if (TypeUtils.isAbstract(access) || sig.equals(Constants.SIG_STATIC)) {
return e;
}
return new CodeEmitter(e) {
private Block handler;
/* init */
{
handler = begin_block();
}
public void visitMaxs(int maxStack, int maxLocals) {
handler.end();
EmitUtils.wrap_undeclared_throwable(this, handler, exceptions, wrapper);
super.visitMaxs(maxStack, maxLocals);
}
};
}
Aggregations