當前位置: 首頁>>代碼示例>>Java>>正文


Java InstructionConstants.OP_GOTO_W屬性代碼示例

本文整理匯總了Java中proguard.classfile.instruction.InstructionConstants.OP_GOTO_W屬性的典型用法代碼示例。如果您正苦於以下問題:Java InstructionConstants.OP_GOTO_W屬性的具體用法?Java InstructionConstants.OP_GOTO_W怎麽用?Java InstructionConstants.OP_GOTO_W使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在proguard.classfile.instruction.InstructionConstants的用法示例。


在下文中一共展示了InstructionConstants.OP_GOTO_W屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visitBranchInstruction

public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
{
    switch (branchInstruction.opcode)
    {
        case InstructionConstants.OP_GOTO:
        case InstructionConstants.OP_GOTO_W:
            // Don't replace unconditional branches.
            break;

        case InstructionConstants.OP_JSR:
        case InstructionConstants.OP_JSR_W:
            replaceJsrInstruction(clazz, offset, branchInstruction);
            break;

        default:
            replaceBranchInstruction(clazz, offset, branchInstruction);
            break;
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:19,代碼來源:EvaluationSimplifier.java

示例2: visitBranchInstruction

public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
{
    byte opcode = branchInstruction.opcode;

    // Evaluate the target instruction blocks.
    evaluateInstructionBlock(clazz,
                             method,
                             codeAttribute,
                             offset +
                             branchInstruction.branchOffset);

    // Evaluate the instructions after a subroutine branch.
    if (opcode == InstructionConstants.OP_JSR ||
        opcode == InstructionConstants.OP_JSR_W)
    {
        // We assume subroutine calls (jsr and jsr_w instructions) don't
        // change the stack, other than popping the return value.
        stackSize -= 1;

        evaluateInstructionBlock(clazz,
                                 method,
                                 codeAttribute,
                                 offset + branchInstruction.length(offset));
    }

    // Some branch instructions always end the current instruction block.
    exitInstructionBlock =
        opcode == InstructionConstants.OP_GOTO   ||
        opcode == InstructionConstants.OP_GOTO_W ||
        opcode == InstructionConstants.OP_JSR    ||
        opcode == InstructionConstants.OP_JSR_W;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:32,代碼來源:StackSizeComputer.java

示例3: visitBranchInstruction

public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
{
    // Mark the branch target.
    markBranchTarget(clazz,
                     method,
                     codeAttribute,
                     offset + branchInstruction.branchOffset);

    byte opcode = branchInstruction.opcode;
    if (opcode == InstructionConstants.OP_GOTO ||
        opcode == InstructionConstants.OP_GOTO_W)
    {
        next = false;
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:15,代碼來源:ReachableCodeMarker.java

示例4: visitBranchInstruction

public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
{
    // Mark the branch origin.
    markBranchOrigin(offset);

    // Check if this is the first instruction of a subroutine.
    checkSubroutine(offset);

    // Mark the branch target.
    markBranchTarget(offset, branchInstruction.branchOffset);

    byte opcode = branchInstruction.opcode;
    if (opcode == InstructionConstants.OP_JSR ||
        opcode == InstructionConstants.OP_JSR_W)
    {
        // Mark the subroutine invocation.
        instructionMarks[offset] |= SUBROUTINE_INVOCATION;

        // Mark the subroutine start.
        int targetOffset = offset + branchInstruction.branchOffset;
        subroutineStarts[targetOffset] = targetOffset;
    }
    else if (opcode == InstructionConstants.OP_GOTO ||
             opcode == InstructionConstants.OP_GOTO_W)
    {
        // Mark the next instruction.
        markAfterBranchOrigin(offset + branchInstruction.length(offset));
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:29,代碼來源:BranchTargetFinder.java

示例5: visitBranchInstruction

public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
{
    // Check if the instruction is an unconditional goto instruction.
    byte opcode = branchInstruction.opcode;
    if (opcode == InstructionConstants.OP_GOTO ||
        opcode == InstructionConstants.OP_GOTO_W)
    {
        // Check if the goto instruction points to a return instruction.
        int targetOffset = offset + branchInstruction.branchOffset;

        if (!codeAttributeEditor.isModified(offset) &&
            !codeAttributeEditor.isModified(targetOffset))
        {
            Instruction targetInstruction = InstructionFactory.create(codeAttribute.code,
                                                                      targetOffset);
            switch (targetInstruction.opcode)
            {
                case InstructionConstants.OP_IRETURN:
                case InstructionConstants.OP_LRETURN:
                case InstructionConstants.OP_FRETURN:
                case InstructionConstants.OP_DRETURN:
                case InstructionConstants.OP_ARETURN:
                case InstructionConstants.OP_RETURN:
                    // Replace the goto instruction by the return instruction.
                    Instruction returnInstruction =
                         new SimpleInstruction(targetInstruction.opcode);
                    codeAttributeEditor.replaceInstruction(offset,
                                                           returnInstruction);

                    // Visit the instruction, if required.
                    if (extraInstructionVisitor != null)
                    {
                        extraInstructionVisitor.visitBranchInstruction(clazz, method, codeAttribute, offset, branchInstruction);
                    }

                    break;
            }
        }
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:40,代碼來源:GotoReturnReplacer.java

示例6: visitSimpleInstruction

public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
{
    // Are we inlining this instruction?
    if (inlining)
    {
        // Replace any return instructions by branches to the end of the code.
        switch (simpleInstruction.opcode)
        {
            case InstructionConstants.OP_IRETURN:
            case InstructionConstants.OP_LRETURN:
            case InstructionConstants.OP_FRETURN:
            case InstructionConstants.OP_DRETURN:
            case InstructionConstants.OP_ARETURN:
            case InstructionConstants.OP_RETURN:
                // Are we not at the last instruction?
                if (offset < codeAttribute.u4codeLength-1)
                {
                    // Replace the return instruction by a branch instruction.
                    Instruction branchInstruction =
                        new BranchInstruction(InstructionConstants.OP_GOTO_W,
                                              codeAttribute.u4codeLength - offset);

                    codeAttributeComposer.appendInstruction(offset,
                                                            branchInstruction.shrink());
                }
                else
                {
                    // Just leave out the instruction, but put in a label,
                    // for the sake of any other branch instructions.
                    codeAttributeComposer.appendLabel(offset);
                }

                return;
        }
    }

    codeAttributeComposer.appendInstruction(offset, simpleInstruction.shrink());
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:38,代碼來源:MethodInliner.java

示例7: visitBranchInstruction

public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
{
    // Check if the instruction is an unconditional goto instruction.
    byte opcode = branchInstruction.opcode;
    if (opcode == InstructionConstants.OP_GOTO ||
        opcode == InstructionConstants.OP_GOTO_W)
    {
        // Check if the goto instruction points to another simple goto
        // instruction.
        int branchOffset = branchInstruction.branchOffset;
        int targetOffset = offset + branchOffset;

        if (branchOffset != branchInstruction.length(offset) &&
            !codeAttributeEditor.isModified(offset) &&
            !codeAttributeEditor.isModified(targetOffset))
        {
            Instruction targetInstruction =
                InstructionFactory.create(codeAttribute.code, targetOffset);

            if (targetInstruction.opcode == InstructionConstants.OP_GOTO)
            {
                // Simplify the goto instruction.
                int targetBranchOffset = ((BranchInstruction)targetInstruction).branchOffset;

                Instruction newBranchInstruction =
                     new BranchInstruction(opcode,
                                           (branchOffset + targetBranchOffset));
                codeAttributeEditor.replaceInstruction(offset,
                                                       newBranchInstruction);

                // Visit the instruction, if required.
                if (extraInstructionVisitor != null)
                {
                    extraInstructionVisitor.visitBranchInstruction(clazz, method, codeAttribute, offset, branchInstruction);
                }
            }
        }
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:39,代碼來源:GotoGotoReplacer.java

示例8: visitBranchInstruction

public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
{
    // Check if the instruction is an unconditional goto instruction that
    // isn't the target of a branch itself.
    byte opcode = branchInstruction.opcode;
    if ((opcode == InstructionConstants.OP_GOTO ||
         opcode == InstructionConstants.OP_GOTO_W) &&
        !branchTargetFinder.isBranchTarget(offset))
    {
        int branchOffset = branchInstruction.branchOffset;
        int targetOffset = offset + branchOffset;

        // Get the number of common bytes.
        int commonCount = commonByteCodeCount(codeAttribute, offset, targetOffset);

        if (commonCount > 0 &&
            !exceptionBoundary(codeAttribute, offset, targetOffset))
        {
            if (DEBUG)
            {
                System.out.println("GotoCommonCodeReplacer: "+clazz.getName()+"."+method.getName(clazz)+" (["+(offset-commonCount)+"] - "+branchInstruction.toString(offset)+" -> "+targetOffset+")");
            }

            // Delete the common instructions.
            for (int delta = 0; delta <= commonCount; delta++)
            {
                int deleteOffset = offset - delta;
                if (branchTargetFinder.isInstruction(deleteOffset))
                {
                    codeAttributeEditor.replaceInstruction(     deleteOffset, (Instruction)null);
                    codeAttributeEditor.insertBeforeInstruction(deleteOffset, (Instruction)null);
                    codeAttributeEditor.insertAfterInstruction( deleteOffset, (Instruction)null);

                    codeAttributeEditor.deleteInstruction(deleteOffset);
                }
            }

            // Redirect the goto instruction, if it is still necessary.
            int newBranchOffset = branchOffset - commonCount;
            if (newBranchOffset != branchInstruction.length(offset))
            {
                Instruction newGotoInstruction =
                     new BranchInstruction(opcode, newBranchOffset);
                codeAttributeEditor.replaceInstruction(offset,
                                                       newGotoInstruction);
            }

            // Visit the instruction, if required.
            if (extraInstructionVisitor != null)
            {
                extraInstructionVisitor.visitBranchInstruction(clazz, method, codeAttribute, offset, branchInstruction);
            }
        }
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:55,代碼來源:GotoCommonCodeReplacer.java


注:本文中的proguard.classfile.instruction.InstructionConstants.OP_GOTO_W屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。