Search in sources :

Example 11 with Label

use of org.springframework.asm.Label in project spring-framework by spring-projects.

the class OpOr method generateCode.

@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
    // pseudo: if (leftOperandValue) { result=true; } else { result=rightOperandValue; }
    Label elseTarget = new Label();
    Label endOfIf = new Label();
    cf.enterCompilationScope();
    getLeftOperand().generateCode(mv, cf);
    cf.unboxBooleanIfNecessary(mv);
    cf.exitCompilationScope();
    mv.visitJumpInsn(IFEQ, elseTarget);
    // TRUE
    mv.visitLdcInsn(1);
    mv.visitJumpInsn(GOTO, endOfIf);
    mv.visitLabel(elseTarget);
    cf.enterCompilationScope();
    getRightOperand().generateCode(mv, cf);
    cf.unboxBooleanIfNecessary(mv);
    cf.exitCompilationScope();
    mv.visitLabel(endOfIf);
    cf.pushDescriptor(this.exitTypeDescriptor);
}
Also used : Label(org.springframework.asm.Label)

Example 12 with Label

use of org.springframework.asm.Label in project spring-framework by spring-projects.

the class OpAnd method generateCode.

@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
    // Pseudo: if (!leftOperandValue) { result=false; } else { result=rightOperandValue; }
    Label elseTarget = new Label();
    Label endOfIf = new Label();
    cf.enterCompilationScope();
    getLeftOperand().generateCode(mv, cf);
    cf.unboxBooleanIfNecessary(mv);
    cf.exitCompilationScope();
    mv.visitJumpInsn(IFNE, elseTarget);
    // FALSE
    mv.visitLdcInsn(0);
    mv.visitJumpInsn(GOTO, endOfIf);
    mv.visitLabel(elseTarget);
    cf.enterCompilationScope();
    getRightOperand().generateCode(mv, cf);
    cf.unboxBooleanIfNecessary(mv);
    cf.exitCompilationScope();
    mv.visitLabel(endOfIf);
    cf.pushDescriptor(this.exitTypeDescriptor);
}
Also used : Label(org.springframework.asm.Label)

Example 13 with Label

use of org.springframework.asm.Label 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();
}
Also used : CodeEmitter(org.springframework.cglib.core.CodeEmitter) ProcessSwitchCallback(org.springframework.cglib.core.ProcessSwitchCallback) Label(org.springframework.asm.Label)

Example 14 with Label

use of org.springframework.asm.Label in project spring-framework by spring-projects.

the class Enhancer method emitCurrentCallback.

private void emitCurrentCallback(CodeEmitter e, int index) {
    e.load_this();
    e.getfield(getCallbackField(index));
    e.dup();
    Label end = e.make_label();
    e.ifnonnull(end);
    // stack height
    e.pop();
    e.load_this();
    e.invoke_static_this(BIND_CALLBACKS);
    e.load_this();
    e.getfield(getCallbackField(index));
    e.mark(end);
}
Also used : Label(org.springframework.asm.Label)

Aggregations

Label (org.springframework.asm.Label)14 CodeEmitter (org.springframework.cglib.core.CodeEmitter)5 Method (java.lang.reflect.Method)2 Type (org.springframework.asm.Type)2 MethodInfo (org.springframework.cglib.core.MethodInfo)2 ProcessSwitchCallback (org.springframework.cglib.core.ProcessSwitchCallback)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ClassEmitter (org.springframework.cglib.core.ClassEmitter)1 CodeGenerationException (org.springframework.cglib.core.CodeGenerationException)1 Local (org.springframework.cglib.core.Local)1 ObjectSwitchCallback (org.springframework.cglib.core.ObjectSwitchCallback)1 Signature (org.springframework.cglib.core.Signature)1 EvaluationContext (org.springframework.expression.EvaluationContext)1