com.sun.org.apache.bcel.internal.generic.BranchInstruction Java Examples

The following examples show how to use com.sun.org.apache.bcel.internal.generic.BranchInstruction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BCELFactory.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public void start() {
    if (!_mg.isAbstract() && !_mg.isNative()) {
        for (InstructionHandle ih = _mg.getInstructionList().getStart(); ih != null; ih = ih
                .getNext()) {
            final Instruction i = ih.getInstruction();
            if (i instanceof BranchInstruction) {
                branch_map.put(i, ih); // memorize container
            }
            if (ih.hasTargeters()) {
                if (i instanceof BranchInstruction) {
                    _out.println("    InstructionHandle ih_" + ih.getPosition() + ";");
                } else {
                    _out.print("    InstructionHandle ih_" + ih.getPosition() + " = ");
                }
            } else {
                _out.print("    ");
            }
            if (!visitInstruction(i)) {
                i.accept(this);
            }
        }
        updateBranchTargets();
        updateExceptionHandlers();
    }
}
 
Example #2
Source File: EqualityExpr.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #3
Source File: EqualityExpr.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #4
Source File: EqualityExpr.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #5
Source File: EqualityExpr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    final Type tleft = _left.getType();
    final InstructionList il = methodGen.getInstructionList();

    if (tleft instanceof BooleanType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);
    _falseList.add(il.append(_op == Operators.EQ ?
                                 (BranchInstruction)new IF_ICMPNE(null) :
                                 (BranchInstruction)new IF_ICMPEQ(null)));
    }
    else if (tleft instanceof NumberType) {
        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        if (tleft instanceof RealType) {
            il.append(DCMPG);
    _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IFNE(null) :
                                     (BranchInstruction)new IFEQ(null)));
        }
        else {
        _falseList.add(il.append(_op == Operators.EQ ?
                                     (BranchInstruction)new IF_ICMPNE(null) :
                                     (BranchInstruction)new IF_ICMPEQ(null)));
        }
    }
    else {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
}
 
Example #6
Source File: IntType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction GE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGE(null) :
        (BranchInstruction) new IF_ICMPGE(null);
}
 
Example #7
Source File: IntType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction LT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLT(null) :
        (BranchInstruction) new IF_ICMPLT(null);
}
 
Example #8
Source File: IntType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
 
Example #9
Source File: RelationalExpr.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    if (hasNodeSetArgs() || hasReferenceArgs()) {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
    else {
        BranchInstruction bi = null;
        final InstructionList il = methodGen.getInstructionList();

        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        // TODO: optimize if one of the args is 0

        boolean tozero = false;
        Type tleft = _left.getType();

        if (tleft instanceof RealType) {
    il.append(tleft.CMP(_op == Operators.LT || _op == Operators.LE));
            tleft = Type.Int;
            tozero = true;
        }

        switch (_op) {
    case Operators.LT:
            bi = tleft.GE(tozero);
            break;

    case Operators.GT:
            bi = tleft.LE(tozero);
            break;

    case Operators.LE:
            bi = tleft.GT(tozero);
            break;

    case Operators.GE:
            bi = tleft.LT(tozero);
            break;

        default:
            ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_RELAT_OP_ERR,this);
            getParser().reportError(Constants.FATAL, msg);
        }

        _falseList.add(il.append(bi));              // must be backpatched
    }
}
 
Example #10
Source File: IntType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
 
Example #11
Source File: IntType.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction GE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGE(null) :
        (BranchInstruction) new IF_ICMPGE(null);
}
 
Example #12
Source File: Type.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction GE(boolean tozero) {
    return null;            // should never be called
}
 
Example #13
Source File: BooleanType.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
 
Example #14
Source File: RelationalExpr.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    if (hasNodeSetArgs() || hasReferenceArgs()) {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
    else {
        BranchInstruction bi = null;
        final InstructionList il = methodGen.getInstructionList();

        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        // TODO: optimize if one of the args is 0

        boolean tozero = false;
        Type tleft = _left.getType();

        if (tleft instanceof RealType) {
    il.append(tleft.CMP(_op == Operators.LT || _op == Operators.LE));
            tleft = Type.Int;
            tozero = true;
        }

        switch (_op) {
    case Operators.LT:
            bi = tleft.GE(tozero);
            break;

    case Operators.GT:
            bi = tleft.LE(tozero);
            break;

    case Operators.LE:
            bi = tleft.GT(tozero);
            break;

    case Operators.GE:
            bi = tleft.LT(tozero);
            break;

        default:
            ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_RELAT_OP_ERR,this);
            getParser().reportError(Constants.FATAL, msg);
        }

        _falseList.add(il.append(bi));              // must be backpatched
    }
}
 
Example #15
Source File: RelationalExpr.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    if (hasNodeSetArgs() || hasReferenceArgs()) {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
    else {
        BranchInstruction bi = null;
        final InstructionList il = methodGen.getInstructionList();

        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        // TODO: optimize if one of the args is 0

        boolean tozero = false;
        Type tleft = _left.getType();

        if (tleft instanceof RealType) {
    il.append(tleft.CMP(_op == Operators.LT || _op == Operators.LE));
            tleft = Type.Int;
            tozero = true;
        }

        switch (_op) {
    case Operators.LT:
            bi = tleft.GE(tozero);
            break;

    case Operators.GT:
            bi = tleft.LE(tozero);
            break;

    case Operators.LE:
            bi = tleft.GT(tozero);
            break;

    case Operators.GE:
            bi = tleft.LT(tozero);
            break;

        default:
            ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_RELAT_OP_ERR,this);
            getParser().reportError(Constants.FATAL, msg);
        }

        _falseList.add(il.append(bi));              // must be backpatched
    }
}
 
Example #16
Source File: BooleanType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
 
Example #17
Source File: RelationalExpr.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    if (hasNodeSetArgs() || hasReferenceArgs()) {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
    else {
        BranchInstruction bi = null;
        final InstructionList il = methodGen.getInstructionList();

        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        // TODO: optimize if one of the args is 0

        boolean tozero = false;
        Type tleft = _left.getType();

        if (tleft instanceof RealType) {
    il.append(tleft.CMP(_op == Operators.LT || _op == Operators.LE));
            tleft = Type.Int;
            tozero = true;
        }

        switch (_op) {
    case Operators.LT:
            bi = tleft.GE(tozero);
            break;

    case Operators.GT:
            bi = tleft.LE(tozero);
            break;

    case Operators.LE:
            bi = tleft.GT(tozero);
            break;

    case Operators.GE:
            bi = tleft.LT(tozero);
            break;

        default:
            ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_RELAT_OP_ERR,this);
            getParser().reportError(Constants.FATAL, msg);
        }

        _falseList.add(il.append(bi));              // must be backpatched
    }
}
 
Example #18
Source File: RelationalExpr.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void translateDesynthesized(ClassGenerator classGen,
                                   MethodGenerator methodGen) {
    if (hasNodeSetArgs() || hasReferenceArgs()) {
        translate(classGen, methodGen);
        desynthesize(classGen, methodGen);
    }
    else {
        BranchInstruction bi = null;
        final InstructionList il = methodGen.getInstructionList();

        _left.translate(classGen, methodGen);
        _right.translate(classGen, methodGen);

        // TODO: optimize if one of the args is 0

        boolean tozero = false;
        Type tleft = _left.getType();

        if (tleft instanceof RealType) {
    il.append(tleft.CMP(_op == Operators.LT || _op == Operators.LE));
            tleft = Type.Int;
            tozero = true;
        }

        switch (_op) {
    case Operators.LT:
            bi = tleft.GE(tozero);
            break;

    case Operators.GT:
            bi = tleft.LE(tozero);
            break;

    case Operators.LE:
            bi = tleft.GT(tozero);
            break;

    case Operators.GE:
            bi = tleft.LT(tozero);
            break;

        default:
            ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_RELAT_OP_ERR,this);
            getParser().reportError(Constants.FATAL, msg);
        }

        _falseList.add(il.append(bi));              // must be backpatched
    }
}
 
Example #19
Source File: BooleanType.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
 
Example #20
Source File: BooleanType.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
 
Example #21
Source File: IntType.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
 
Example #22
Source File: Type.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public BranchInstruction LT(boolean tozero) {
    return null;            // should never be called
}
 
Example #23
Source File: Type.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction LT(boolean tozero) {
    return null;            // should never be called
}
 
Example #24
Source File: Type.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public BranchInstruction GT(boolean tozero) {
    return null;            // should never be called
}
 
Example #25
Source File: IntType.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
 
Example #26
Source File: IntType.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public BranchInstruction LT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLT(null) :
        (BranchInstruction) new IF_ICMPLT(null);
}
 
Example #27
Source File: IntType.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public BranchInstruction GE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGE(null) :
        (BranchInstruction) new IF_ICMPGE(null);
}
 
Example #28
Source File: IntType.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
 
Example #29
Source File: Type.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public BranchInstruction GT(boolean tozero) {
    return null;            // should never be called
}
 
Example #30
Source File: Type.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction LE(boolean tozero) {
    return null;            // should never be called
}