use of org.springframework.cglib.core.CodeEmitter in project spring-framework by spring-projects.
the class Enhancer method emitSetCallbacks.
private void emitSetCallbacks(ClassEmitter ce) {
CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, SET_CALLBACKS, null);
e.load_this();
e.load_arg(0);
for (int i = 0; i < callbackTypes.length; i++) {
e.dup2();
e.aaload(i);
e.checkcast(callbackTypes[i]);
e.putfield(getCallbackField(i));
}
e.return_value();
e.end_method();
}
use of org.springframework.cglib.core.CodeEmitter in project spring-framework by spring-projects.
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(CodeEmitter.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();
}
use of org.springframework.cglib.core.CodeEmitter in project spring-framework by spring-projects.
the class Enhancer method emitSetCallback.
private void emitSetCallback(ClassEmitter ce, int[] keys) {
final CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, SET_CALLBACK, null);
e.load_arg(0);
e.process_switch(keys, new ProcessSwitchCallback() {
public void processCase(int key, Label end) {
e.load_this();
e.load_arg(1);
e.checkcast(callbackTypes[key]);
e.putfield(getCallbackField(key));
e.goTo(end);
}
public void processDefault() {
// TODO: error?
}
});
e.return_value();
e.end_method();
}
use of org.springframework.cglib.core.CodeEmitter in project spring-framework by spring-projects.
the class Enhancer method emitGetCallback.
private void emitGetCallback(ClassEmitter ce, int[] keys) {
final CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, GET_CALLBACK, null);
e.load_this();
e.invoke_static_this(BIND_CALLBACKS);
e.load_this();
e.load_arg(0);
e.process_switch(keys, new ProcessSwitchCallback() {
public void processCase(int key, Label end) {
e.getfield(getCallbackField(key));
e.goTo(end);
}
public void processDefault() {
// stack height
e.pop();
e.aconst_null();
}
});
e.return_value();
e.end_method();
}
use of org.springframework.cglib.core.CodeEmitter in project spring-framework by spring-projects.
the class Enhancer method emitGetCallbacks.
private void emitGetCallbacks(ClassEmitter ce) {
CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, GET_CALLBACKS, null);
e.load_this();
e.invoke_static_this(BIND_CALLBACKS);
e.load_this();
e.push(callbackTypes.length);
e.newarray(CALLBACK);
for (int i = 0; i < callbackTypes.length; i++) {
e.dup();
e.push(i);
e.load_this();
e.getfield(getCallbackField(i));
e.aastore();
}
e.return_value();
e.end_method();
}
Aggregations