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

The following examples show how to use com.sun.org.apache.bcel.internal.generic.BranchInstruction. These examples are extracted from open source projects. 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 Project: Bytecoder   Author: mirkosertic   File: BCELFactory.java    License: 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 Project: jdk1.8-source-analysis   Author: raysonfang   File: EqualityExpr.java    License: 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 Project: jdk8u60   Author: chenghanpeng   File: EqualityExpr.java    License: 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 Project: Bytecoder   Author: mirkosertic   File: EqualityExpr.java    License: 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 Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: EqualityExpr.java    License: 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 Project: jdk1.8-source-analysis   Author: raysonfang   File: RelationalExpr.java    License: 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 #7
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: IntType.java    License: 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 #8
Source Project: Bytecoder   Author: mirkosertic   File: Type.java    License: Apache License 2.0 4 votes vote down vote up
public BranchInstruction GE(boolean tozero) {
    return null;            // should never be called
}
 
Example #9
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: IntType.java    License: Apache License 2.0 4 votes vote down vote up
public BranchInstruction LT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLT(null) :
        (BranchInstruction) new IF_ICMPLT(null);
}
 
Example #10
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: IntType.java    License: 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 #11
Source Project: Bytecoder   Author: mirkosertic   File: Type.java    License: Apache License 2.0 4 votes vote down vote up
public BranchInstruction LT(boolean tozero) {
    return null;            // should never be called
}
 
Example #12
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: Type.java    License: Apache License 2.0 4 votes vote down vote up
public BranchInstruction LT(boolean tozero) {
    return null;            // should never be called
}
 
Example #13
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: BooleanType.java    License: 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 #14
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: BooleanType.java    License: 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 #15
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: BooleanType.java    License: 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 #16
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction GT(boolean tozero) {
    return null;            // should never be called
}
 
Example #17
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: BooleanType.java    License: 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 #18
Source Project: Bytecoder   Author: mirkosertic   File: Type.java    License: Apache License 2.0 4 votes vote down vote up
public BranchInstruction LE(boolean tozero) {
    return null;            // should never be called
}
 
Example #19
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: BooleanType.java    License: 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 #20
Source Project: TencentKona-8   Author: Tencent   File: IntType.java    License: 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 #21
Source Project: TencentKona-8   Author: Tencent   File: IntType.java    License: 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 #22
Source Project: TencentKona-8   Author: Tencent   File: IntType.java    License: 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 #23
Source Project: TencentKona-8   Author: Tencent   File: IntType.java    License: 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 #24
Source Project: TencentKona-8   Author: Tencent   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction GT(boolean tozero) {
    return null;            // should never be called
}
 
Example #25
Source Project: TencentKona-8   Author: Tencent   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction GE(boolean tozero) {
    return null;            // should never be called
}
 
Example #26
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: IntType.java    License: 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 #27
Source Project: TencentKona-8   Author: Tencent   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
public BranchInstruction LE(boolean tozero) {
    return null;            // should never be called
}
 
Example #28
Source Project: TencentKona-8   Author: Tencent   File: BooleanType.java    License: 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 #29
Source Project: TencentKona-8   Author: Tencent   File: BooleanType.java    License: 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 #30
Source Project: TencentKona-8   Author: Tencent   File: BooleanType.java    License: 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);
}