Example usage for org.objectweb.asm MethodVisitor visitLabel

List of usage examples for org.objectweb.asm MethodVisitor visitLabel

Introduction

In this page you can find the example usage for org.objectweb.asm MethodVisitor visitLabel.

Prototype

public void visitLabel(final Label label) 

Source Link

Document

Visits a label.

Usage

From source file:com.nginious.http.xsp.expr.LessEqualsOperator.java

License:Apache License

/**
 * Creates bytecode for evaluating the argument values as doubles. The bytecode
 * is generated using the specified method visitor.
 * //from w ww.ja  v  a2s  . c om
 * @param visitor the method visitor
 */
private void compileDouble(MethodVisitor visitor) {
    Label labelFalse = new Label();
    Label labelEnd = new Label();

    value2.compile(visitor, Type.DOUBLE);
    value1.compile(visitor, Type.DOUBLE);

    visitor.visitInsn(Opcodes.DCMPL);
    visitor.visitJumpInsn(Opcodes.IFLT, labelFalse);

    // True
    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, labelEnd);

    // False
    visitor.visitLabel(labelFalse);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(labelEnd);
}

From source file:com.nginious.http.xsp.expr.LessOperator.java

License:Apache License

/**
 * Creates bytecode for evaluating the argument values as integers. The bytecode
 * is generated using the specified method visitor.
 * //from   ww  w  . j  ava2s  .  c om
 * @param visitor the method visitor
 */
private void compileInt(MethodVisitor visitor) {
    Label labelFalse = new Label();
    Label labelEnd = new Label();

    value2.compile(visitor, Type.INT);
    value1.compile(visitor, Type.INT);

    visitor.visitJumpInsn(Opcodes.IF_ICMPLE, labelFalse);

    // True
    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, labelEnd);

    // False
    visitor.visitLabel(labelFalse);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(labelEnd);
}

From source file:com.nginious.http.xsp.expr.LessOperator.java

License:Apache License

/**
 * Creates bytecode for evaluating the argument values as doubles. The bytecode
 * is generated using the specified method visitor.
 * // w w  w  . ja v a2  s  .  c om
 * @param visitor the method visitor
 */
private void compileDouble(MethodVisitor visitor) {
    Label labelFalse = new Label();
    Label labelEnd = new Label();

    value2.compile(visitor, Type.DOUBLE);
    value1.compile(visitor, Type.DOUBLE);

    visitor.visitInsn(Opcodes.DCMPL);
    visitor.visitJumpInsn(Opcodes.IFLE, labelFalse);

    // True
    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, labelEnd);

    // False
    visitor.visitLabel(labelFalse);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(labelEnd);
}

From source file:com.nginious.http.xsp.expr.MoreEqualsOperator.java

License:Apache License

/**
 * Creates bytecode for evaluating the argument values as integers. The bytecode
 * is generated using the specified method visitor.
 * /*from w  w w .j  a va 2  s .  c om*/
 * @param visitor the method visitor
 */
private void compileInt(MethodVisitor visitor) {
    Label labelFalse = new Label();
    Label labelEnd = new Label();

    value1.compile(visitor, Type.INT);
    value2.compile(visitor, Type.INT);

    visitor.visitJumpInsn(Opcodes.IF_ICMPLT, labelFalse);

    // True
    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, labelEnd);

    // False
    visitor.visitLabel(labelFalse);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(labelEnd);
}

From source file:com.nginious.http.xsp.expr.MoreEqualsOperator.java

License:Apache License

/**
 * Creates bytecode for evaluating the argument values as doubles. The bytecode
 * is generated using the specified method visitor.
 * //from  w  w w  .  j a va 2s  .co m
 * @param visitor the method visitor
 */
private void compileDouble(MethodVisitor visitor) {
    Label labelFalse = new Label();
    Label labelEnd = new Label();

    value1.compile(visitor, Type.DOUBLE);
    value2.compile(visitor, Type.DOUBLE);

    visitor.visitInsn(Opcodes.DCMPL);
    visitor.visitJumpInsn(Opcodes.IFLT, labelFalse);

    // True
    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, labelEnd);

    // False
    visitor.visitLabel(labelFalse);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(labelEnd);
}

From source file:com.nginious.http.xsp.expr.MoreOperator.java

License:Apache License

/**
 * Creates bytecode for evaluating the argument values as integers. The bytecode
 * is generated using the specified method visitor.
 * //from   ww w.ja v  a  2 s .c  om
 * @param visitor the method visitor
 */
private void compileInt(MethodVisitor visitor) {
    Label labelFalse = new Label();
    Label labelEnd = new Label();

    value1.compile(visitor, Type.INT);
    value2.compile(visitor, Type.INT);

    visitor.visitJumpInsn(Opcodes.IF_ICMPLE, labelFalse);

    // True
    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, labelEnd);

    // False
    visitor.visitLabel(labelFalse);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(labelEnd);
}

From source file:com.nginious.http.xsp.expr.MoreOperator.java

License:Apache License

/**
 * Creates bytecode for evaluating the argument values as doubles. The bytecode
 * is generated using the specified method visitor.
 * /*from   w  ww .  j  ava 2s .  co  m*/
 * @param visitor the method visitor
 */
private void compileDouble(MethodVisitor visitor) {
    Label labelFalse = new Label();
    Label labelEnd = new Label();

    value1.compile(visitor, Type.DOUBLE);
    value2.compile(visitor, Type.DOUBLE);

    visitor.visitInsn(Opcodes.DCMPL);
    visitor.visitJumpInsn(Opcodes.IFLE, labelFalse);

    // True
    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, labelEnd);

    // False
    visitor.visitLabel(labelFalse);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(labelEnd);
}

From source file:com.nginious.http.xsp.expr.NotEqualsOperator.java

License:Apache License

/**
 * Compiles bytecode for evaluating this not equals operator producing
 * a string as result. The specified method visitor is used for generating
 * bytecode./*from   w  w  w.  j  a va  2s  . c o m*/
 * 
 * @param visitor the method visitor
 */
private void compileString(MethodVisitor visitor) {
    Label trueLabel = new Label();
    Label falseLabel = new Label();
    Label nullLabel = new Label();

    value1.compile(visitor, Type.STRING);
    visitor.visitVarInsn(Opcodes.ASTORE, 1);
    value2.compile(visitor, Type.STRING);
    visitor.visitVarInsn(Opcodes.ASTORE, 2);

    visitor.visitVarInsn(Opcodes.ALOAD, 1);
    visitor.visitJumpInsn(Opcodes.IFNULL, nullLabel);
    visitor.visitVarInsn(Opcodes.ALOAD, 2);
    visitor.visitJumpInsn(Opcodes.IFNULL, nullLabel);

    visitor.visitVarInsn(Opcodes.ALOAD, 1);
    visitor.visitVarInsn(Opcodes.ALOAD, 2);
    visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z");
    visitor.visitJumpInsn(Opcodes.IFNE, falseLabel);

    visitor.visitLabel(nullLabel);
    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, trueLabel);

    visitor.visitLabel(falseLabel);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(trueLabel);
}

From source file:com.nginious.http.xsp.expr.NotEqualsOperator.java

License:Apache License

/**
 * Compiles bytecode for evaluating this not equals operator producing
 * an integer as result. The specified method visitor is used for generating
 * bytecode.//  w w w . jav  a  2 s. c  om
 * 
 * @param visitor the method visitor
 */
private void compileInt(MethodVisitor visitor) {
    Label trueLabel = new Label();
    Label falseLabel = new Label();

    value1.compile(visitor, Type.INT);
    value2.compile(visitor, Type.INT);
    visitor.visitJumpInsn(Opcodes.IF_ICMPEQ, trueLabel);

    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, falseLabel);

    visitor.visitLabel(trueLabel);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(falseLabel);
}

From source file:com.nginious.http.xsp.expr.NotEqualsOperator.java

License:Apache License

/**
 * Compiles bytecode for evaluating this not equals operator producing
 * a double as result. The specified method visitor is used for generating
 * bytecode./*from   w w  w.  j a v  a2 s . c  o m*/
 * 
 * @param visitor the method visitor
 */
private void compileDouble(MethodVisitor visitor) {
    Label trueLabel = new Label();
    Label falseLabel = new Label();

    value1.compile(visitor, Type.DOUBLE);
    value2.compile(visitor, Type.DOUBLE);
    visitor.visitInsn(Opcodes.DCMPL);
    visitor.visitJumpInsn(Opcodes.IFEQ, trueLabel);

    visitor.visitLdcInsn(true);
    visitor.visitJumpInsn(Opcodes.GOTO, falseLabel);

    visitor.visitLabel(trueLabel);
    visitor.visitLdcInsn(false);

    visitor.visitLabel(falseLabel);
}