use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class BeanMapEmitter method generateConstructor.
private void generateConstructor() {
CodeEmitter e = begin_method(Constants.ACC_PUBLIC, CSTRUCT_OBJECT, null);
e.load_this();
e.load_arg(0);
e.super_invoke_constructor(CSTRUCT_OBJECT);
e.return_value();
e.end_method();
}
use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class BeanMapEmitter method generateGetPropertyType.
private void generateGetPropertyType(final Map allProps, String[] allNames) {
final CodeEmitter e = begin_method(Constants.ACC_PUBLIC, GET_PROPERTY_TYPE, null);
e.load_arg(0);
EmitUtils.string_switch(e, allNames, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
public void processCase(Object key, Label end) {
PropertyDescriptor pd = (PropertyDescriptor) allProps.get(key);
EmitUtils.load_class(e, Type.getType(pd.getPropertyType()));
e.return_value();
}
public void processDefault() {
e.aconst_null();
e.return_value();
}
});
e.end_method();
}
use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class BulkBeanEmitter method generateGet.
private void generateGet(final Class target, final Method[] getters) {
CodeEmitter e = begin_method(Constants.ACC_PUBLIC, GET_PROPERTY_VALUES, null);
if (getters.length >= 0) {
e.load_arg(0);
e.checkcast(Type.getType(target));
Local bean = e.make_local();
e.store_local(bean);
for (int i = 0; i < getters.length; i++) {
if (getters[i] != null) {
MethodInfo getter = ReflectUtils.getMethodInfo(getters[i]);
e.load_arg(1);
e.push(i);
e.load_local(bean);
e.invoke(getter);
e.box(getter.getSignature().getReturnType());
e.aastore();
}
}
}
e.return_value();
e.end_method();
}
use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class DispatcherGenerator method generate.
public void generate(ClassEmitter ce, Context context, List methods) {
for (Iterator it = methods.iterator(); it.hasNext(); ) {
MethodInfo method = (MethodInfo) it.next();
if (!TypeUtils.isProtected(method.getModifiers())) {
CodeEmitter e = context.beginMethod(ce, method);
context.emitCallback(e, context.getIndex(method));
if (proxyRef) {
e.load_this();
e.invoke_interface(PROXY_REF_DISPATCHER, PROXY_REF_LOAD_OBJECT);
} else {
e.invoke_interface(DISPATCHER, LOAD_OBJECT);
}
e.checkcast(method.getClassInfo().getType());
e.load_args();
e.invoke(method);
e.return_value();
e.end_method();
}
}
}
use of org.powermock.api.mockito.repackaged.cglib.core.CodeEmitter in project powermock by powermock.
the class Enhancer method emitBindCallbacks.
private void emitBindCallbacks(ClassEmitter ce) {
CodeEmitter e = ce.begin_method(Constants.PRIVATE_FINAL_STATIC, BIND_CALLBACKS, null);
Local me = e.make_local();
e.load_arg(0);
e.checkcast_this();
e.store_local(me);
Label end = e.make_label();
e.load_local(me);
e.getfield(BOUND_FIELD);
e.if_jump(e.NE, end);
e.load_local(me);
e.push(1);
e.putfield(BOUND_FIELD);
e.getfield(THREAD_CALLBACKS_FIELD);
e.invoke_virtual(THREAD_LOCAL, THREAD_LOCAL_GET);
e.dup();
Label found_callback = e.make_label();
e.ifnonnull(found_callback);
e.pop();
e.getfield(STATIC_CALLBACKS_FIELD);
e.dup();
e.ifnonnull(found_callback);
e.pop();
e.goTo(end);
e.mark(found_callback);
e.checkcast(CALLBACK_ARRAY);
e.load_local(me);
e.swap();
for (int i = callbackTypes.length - 1; i >= 0; i--) {
if (i != 0) {
e.dup2();
}
e.aaload(i);
e.checkcast(callbackTypes[i]);
e.putfield(getCallbackField(i));
}
e.mark(end);
e.return_value();
e.end_method();
}
Aggregations