Package com.strobel.assembler.ir

Examples of com.strobel.assembler.ir.InstructionBlock


        _blockIndex = blockIndex;
        _exceptionHandler = VerifyArgument.notNull(exceptionHandler, "exceptionHandler");
        _nodeType = exceptionHandler.isFinally() ? ControlFlowNodeType.FinallyHandler : ControlFlowNodeType.CatchHandler;
        _endFinallyNode = endFinallyNode;

        final InstructionBlock handlerBlock = exceptionHandler.getHandlerBlock();

//        _start = handlerBlock.getFirstInstruction();
//        _end = handlerBlock.getLastInstruction();
        _start = null;
        _end = null;
        _offset = handlerBlock.getFirstInstruction().getOffset(); //_start.getOffset();
    }
View Full Code Here


    private ExceptionHandler findInnermostExceptionHandler(final int offsetInTryBlock) {
        ExceptionHandler result = null;

        for (final ExceptionHandler handler : _exceptionHandlers) {
            final InstructionBlock tryBlock = handler.getTryBlock();

            if (tryBlock.getFirstInstruction().getOffset() <= offsetInTryBlock &&
                offsetInTryBlock < tryBlock.getLastInstruction().getEndOffset() &&
                (result == null || isNarrower(handler, result))) {

                result = handler;
            }
        }
View Full Code Here

        for (final ExceptionHandler handler : _exceptionHandlers) {
            if (!handler.isFinally()) {
                continue;
            }

            final InstructionBlock tryBlock = handler.getTryBlock();

            if (tryBlock.getFirstInstruction().getOffset() <= offsetInTryBlock &&
                offsetInTryBlock < tryBlock.getLastInstruction().getEndOffset() &&
                (result == null || isNarrower(handler, result))) {

                result = handler;
            }
        }
View Full Code Here

        return findInnermostHandlerBlock(instructionOffset, true);
    }

    private ControlFlowNode findInnermostHandlerBlock(final int instructionOffset, final boolean finallyOnly) {
        ExceptionHandler result = null;
        InstructionBlock resultBlock = null;

        for (final ExceptionHandler handler : _exceptionHandlers) {
            if (finallyOnly && handler.isCatch()) {
                continue;
            }

            final InstructionBlock handlerBlock = handler.getHandlerBlock();

            if (handlerBlock.getFirstInstruction().getOffset() <= instructionOffset &&
                instructionOffset < handlerBlock.getLastInstruction().getEndOffset() &&
                (resultBlock == null || isNarrower(handler.getHandlerBlock(), resultBlock))) {

                result = handler;
                resultBlock = handlerBlock;
            }
        }

        final ControlFlowNode innerMost = finallyOnly ? findInnermostExceptionHandlerNode(instructionOffset)
                                                      : findInnermostFinallyHandlerNode(instructionOffset);

        final ExceptionHandler innerHandler = innerMost.getExceptionHandler();
        final InstructionBlock innerBlock = innerHandler != null ? innerHandler.getTryBlock() : null;

        if (innerBlock != null && (resultBlock == null || isNarrower(innerBlock, resultBlock))) {
            result = innerHandler;
        }
View Full Code Here

                }
            }

            final Instruction lastInstruction = instructions.get(instructions.size() - 1);

            final InstructionBlock tryBlock;

            if (entry.getEndOffset() == lastInstruction.getEndOffset()) {
                tryBlock = new InstructionBlock(
                    instructions.atOffset(entry.getStartOffset()),
                    lastInstruction
                );
            }
            else {
                tryBlock = new InstructionBlock(
                    instructions.atOffset(entry.getStartOffset()),
                    instructions.atOffset(entry.getEndOffset()).getPrevious()
                );
            }

            if (entry.getCatchType() == null) {
                handlers.add(
                    ExceptionHandler.createFinally(
                        tryBlock,
                        new InstructionBlock(handlerStart.getStart(), lastOrDefault(dominatedNodes).getEnd())
                    )
                );
            }
            else {
                handlers.add(
                    ExceptionHandler.createCatch(
                        tryBlock,
                        new InstructionBlock(handlerStart.getStart(), lastOrDefault(dominatedNodes).getEnd()),
                        entry.getCatchType()
                    )
                );
            }
        }
View Full Code Here

            if (handler == null) {
                break;
            }

            final InstructionBlock tryBlock = handler.getTryBlock();

            if (tryBlock.getFirstInstruction().getOffset() <= offsetInTryBlock &&
                offsetInTryBlock < tryBlock.getLastInstruction().getEndOffset() &&
                isNarrower(handler, result)) {

                result = handler;
                resultNode = node;
            }
View Full Code Here

    private ExceptionHandler findInnermostExceptionHandler(final int offsetInTryBlock) {
        ExceptionHandler result = null;

        for (final ExceptionHandler handler : _handlerPlaceholders) {
            final InstructionBlock tryBlock = handler.getTryBlock();

            if (tryBlock.getFirstInstruction().getOffset() <= offsetInTryBlock &&
                offsetInTryBlock < tryBlock.getLastInstruction().getEndOffset() &&
                (result == null || isNarrower(handler, result))) {

                result = handler;
            }
        }
View Full Code Here

            final ExceptionHandler handler;
            final Instruction afterTry = _instructions.tryGetAtOffset(entry.getEndOffset());

            if (entry.getCatchType() == null) {
                handler = ExceptionHandler.createFinally(
                    new InstructionBlock(
                        _instructions.atOffset(entry.getStartOffset()),
                        afterTry != null ? afterTry.getPrevious() : last(_instructions)
                    ),
                    new InstructionBlock(
                        _instructions.atOffset(entry.getHandlerOffset()),
                        _instructions.atOffset(entry.getHandlerOffset())
                    )
                );
            }
            else {
                handler = ExceptionHandler.createCatch(
                    new InstructionBlock(
                        _instructions.atOffset(entry.getStartOffset()),
                        afterTry != null ? afterTry.getPrevious() : last(_instructions)
                    ),
                    new InstructionBlock(
                        _instructions.atOffset(entry.getHandlerOffset()),
                        _instructions.atOffset(entry.getHandlerOffset())
                    ),
                    entry.getCatchType()
                );
View Full Code Here

        if (catchType != null) {
            output.write(' ');
            writeType(output, catchType);
        }

        final InstructionBlock handlerBlock = handler.getHandlerBlock();

        output.write(' ');
        writeOffsetReference(output, handlerBlock.getFirstInstruction());

        if (handlerBlock.getLastInstruction() != null) {
            output.write(" - ");
            writeEndOffsetReference(output, handlerBlock.getLastInstruction());
        }
    }
View Full Code Here

TOP

Related Classes of com.strobel.assembler.ir.InstructionBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.