コード例 #1
0
        private void LeaveBlock()
        {
            State.BlockJump.Push(BlockInfo.Leave(State.LeaveRequest));


            EHTryEntity finallyBlock = this.MethodDesc.EHTable.GetFinallyForLeaveInst(State.CurrInstIdx);

            // if  finallyBlock exists, it means that leave instruction is inside of try part of try-finally block
            // if not, then it is either the last instruction of try or the catch part of try-catch block
            if (finallyBlock != null)
            {
                //Do not touch leaving address, and jump control to finally block first
                State.BlockJump.Push(BlockInfo.Finally(finallyBlock.HandlerOffset));
            }

            State.FlowInterruption = FlowInterruption.Next;

            var blockInfo = State.BlockJump.Pop();

            JumpToBlock(blockInfo);
        }
コード例 #2
0
        public bool Resolve(MethodStateMachine methodSM)
        {
            var         exInfo       = methodSM.State.ExeptionInfo;
            var         currMethod   = methodSM;
            EHTryEntity catchHandler = null;

            do
            {
                catchHandler = currMethod.ThrowLogicForMethod(exInfo);
                if (catchHandler != null)
                {
                    break;
                }

                //Continue to search an appropriate catch handler in the method one hierarchy upper
                currMethod = currMethod.Caller;
            }while (currMethod != null);

            methodSM.State.ExecutionInterruption = ExecutionInterruption.None;
            methodSM.State.ExeptionInfo          = null;
            return(true);
        }
コード例 #3
0
        public EHTryEntity ThrowLogicForMethod(ExeptionInfo exeptionInfo)
        {
            EHTryEntity catchHandler = this.MethodDesc.EHTable.GetCatchIfExists(State.CurrInstIdx, exeptionInfo.Token);
            Int32       catchIndex   = 0;

            if (catchHandler != null)
            {
                State.BlockJump.Push(BlockInfo.Catch(catchHandler.HandlerOffset, exeptionInfo));
                catchIndex = catchHandler.Index;
            }
            else
            {
                State.MethodPendingFinallies = true;
            }

            AddFinalliesToStack(catchIndex);

            var blockInfo = State.BlockJump.Pop();

            JumpToBlock(blockInfo);

            return(catchHandler);
        }