Java 类com.sun.org.apache.bcel.internal.generic.BranchInstruction 实例源码

项目:openjdk-jdk10    文件:BCELFactory.java   
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();
    }
}
项目:openjdk-jdk10    文件:BCELFactory.java   
private void updateBranchTargets() {
    for (final BranchInstruction bi : branches) {
        final BranchHandle bh = (BranchHandle) branch_map.get(bi);
        final int pos = bh.getPosition();
        final String name = bi.getName() + "_" + pos;
        int t_pos = bh.getTarget().getPosition();
        _out.println("    " + name + ".setTarget(ih_" + t_pos + ");");
        if (bi instanceof Select) {
            final InstructionHandle[] ihs = ((Select) bi).getTargets();
            for (int j = 0; j < ihs.length; j++) {
                t_pos = ihs[j].getPosition();
                _out.println("    " + name + ".setTarget(" + j + ", ih_" + t_pos + ");");
            }
        }
    }
}
项目:OpenJSharp    文件:EqualityExpr.java   
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);
    }
}
项目:openjdk-jdk10    文件:EqualityExpr.java   
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);
    }
}
项目:openjdk9    文件:EqualityExpr.java   
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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:EqualityExpr.java   
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);
    }
}
项目:infobip-open-jdk-8    文件:EqualityExpr.java   
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);
    }
}
项目:OLD-OpenJDK8    文件:EqualityExpr.java   
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);
    }
}
项目:openjdk-icedtea7    文件:EqualityExpr.java   
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);
    }
}
项目:OpenJSharp    文件:RelationalExpr.java   
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
    }
}
项目:OpenJSharp    文件:IntType.java   
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
项目:OpenJSharp    文件:IntType.java   
public BranchInstruction GE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGE(null) :
        (BranchInstruction) new IF_ICMPGE(null);
}
项目:OpenJSharp    文件:IntType.java   
public BranchInstruction LT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLT(null) :
        (BranchInstruction) new IF_ICMPLT(null);
}
项目:OpenJSharp    文件:IntType.java   
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
项目:OpenJSharp    文件:Type.java   
public BranchInstruction GT(boolean tozero) {
    return null;            // should never be called
}
项目:OpenJSharp    文件:Type.java   
public BranchInstruction GE(boolean tozero) {
    return null;            // should never be called
}
项目:OpenJSharp    文件:Type.java   
public BranchInstruction LT(boolean tozero) {
    return null;            // should never be called
}
项目:OpenJSharp    文件:Type.java   
public BranchInstruction LE(boolean tozero) {
    return null;            // should never be called
}
项目:OpenJSharp    文件:BooleanType.java   
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
项目:OpenJSharp    文件:BooleanType.java   
public BranchInstruction GE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGE(null) :
        (BranchInstruction) new IF_ICMPGE(null);
}
项目:OpenJSharp    文件:BooleanType.java   
public BranchInstruction LT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLT(null) :
        (BranchInstruction) new IF_ICMPLT(null);
}
项目:OpenJSharp    文件:BooleanType.java   
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
项目:openjdk-jdk10    文件:RelationalExpr.java   
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
    }
}
项目:openjdk-jdk10    文件:IntType.java   
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
项目:openjdk-jdk10    文件:IntType.java   
public BranchInstruction GE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGE(null) :
        (BranchInstruction) new IF_ICMPGE(null);
}
项目:openjdk-jdk10    文件:IntType.java   
public BranchInstruction LT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLT(null) :
        (BranchInstruction) new IF_ICMPLT(null);
}
项目:openjdk-jdk10    文件:IntType.java   
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
项目:openjdk-jdk10    文件:Type.java   
public BranchInstruction GT(boolean tozero) {
    return null;            // should never be called
}
项目:openjdk-jdk10    文件:Type.java   
public BranchInstruction GE(boolean tozero) {
    return null;            // should never be called
}
项目:openjdk-jdk10    文件:Type.java   
public BranchInstruction LT(boolean tozero) {
    return null;            // should never be called
}
项目:openjdk-jdk10    文件:Type.java   
public BranchInstruction LE(boolean tozero) {
    return null;            // should never be called
}
项目:openjdk-jdk10    文件:BooleanType.java   
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
项目:openjdk-jdk10    文件:BooleanType.java   
public BranchInstruction GE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGE(null) :
        (BranchInstruction) new IF_ICMPGE(null);
}
项目:openjdk-jdk10    文件:BooleanType.java   
public BranchInstruction LT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLT(null) :
        (BranchInstruction) new IF_ICMPLT(null);
}
项目:openjdk-jdk10    文件:BooleanType.java   
public BranchInstruction LE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLE(null) :
        (BranchInstruction) new IF_ICMPLE(null);
}
项目:openjdk-jdk10    文件:BCELFactory.java   
@Override
public void visitBranchInstruction( final BranchInstruction bi ) {
    final BranchHandle bh = (BranchHandle) branch_map.get(bi);
    final int pos = bh.getPosition();
    final String name = bi.getName() + "_" + pos;
    if (bi instanceof Select) {
        final Select s = (Select) bi;
        branches.add(bi);
        final StringBuilder args = new StringBuilder("new int[] { ");
        final int[] matchs = s.getMatchs();
        for (int i = 0; i < matchs.length; i++) {
            args.append(matchs[i]);
            if (i < matchs.length - 1) {
                args.append(", ");
            }
        }
        args.append(" }");
        _out.print("Select " + name + " = new " + bi.getName().toUpperCase(Locale.ENGLISH)
                + "(" + args + ", new InstructionHandle[] { ");
        for (int i = 0; i < matchs.length; i++) {
            _out.print("null");
            if (i < matchs.length - 1) {
                _out.print(", ");
            }
        }
        _out.println(" }, null);");
    } else {
        final int t_pos = bh.getTarget().getPosition();
        String target;
        if (pos > t_pos) {
            target = "ih_" + t_pos;
        } else {
            branches.add(bi);
            target = "null";
        }
        _out.println("    BranchInstruction " + name + " = _factory.createBranchInstruction("
                + CONSTANT_PREFIX + bi.getName().toUpperCase(Locale.ENGLISH) + ", " + target
                + ");");
    }
    if (bh.hasTargeters()) {
        _out.println("    ih_" + pos + " = il.append(" + name + ");");
    } else {
        _out.println("    il.append(" + name + ");");
    }
}
项目:openjdk9    文件:RelationalExpr.java   
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
    }
}
项目:openjdk9    文件:IntType.java   
public BranchInstruction GT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGT(null) :
        (BranchInstruction) new IF_ICMPGT(null);
}
项目:openjdk9    文件:IntType.java   
public BranchInstruction GE(boolean tozero) {
    return tozero ? (BranchInstruction) new IFGE(null) :
        (BranchInstruction) new IF_ICMPGE(null);
}
项目:openjdk9    文件:IntType.java   
public BranchInstruction LT(boolean tozero) {
    return tozero ? (BranchInstruction) new IFLT(null) :
        (BranchInstruction) new IF_ICMPLT(null);
}