예제 #1
0
            private void Analyze()
            {
                Instruction[] instructions = _interpreter.Instructions.Instructions;

                foreach (Instruction instruction in instructions)
                {
                    var enterTryCatchFinally = instruction as EnterTryCatchFinallyInstruction;
                    if (enterTryCatchFinally != null)
                    {
                        TryCatchFinallyHandler handler = enterTryCatchFinally.Handler;

                        AddTryStart(handler.TryStartIndex);
                        AddHandlerExit(handler.TryEndIndex + 1 /* include Goto instruction that acts as a "leave" */);

                        if (handler.IsFinallyBlockExist)
                        {
                            _handlerEnter.Add(handler.FinallyStartIndex, "finally");
                            AddHandlerExit(handler.FinallyEndIndex);
                        }

                        if (handler.IsCatchBlockExist)
                        {
                            foreach (ExceptionHandler catchHandler in handler.Handlers)
                            {
                                _handlerEnter.Add(catchHandler.HandlerStartIndex - 1 /* include EnterExceptionHandler instruction */, catchHandler.ToString());
                                AddHandlerExit(catchHandler.HandlerEndIndex);

                                ExceptionFilter filter = catchHandler.Filter;
                                if (filter != null)
                                {
                                    _handlerEnter.Add(filter.StartIndex - 1 /* include EnterExceptionFilter instruction */, "filter");
                                    AddHandlerExit(filter.EndIndex);
                                }
                            }
                        }
                    }

                    var enterTryFault = instruction as EnterTryFaultInstruction;
                    if (enterTryFault != null)
                    {
                        TryFaultHandler handler = enterTryFault.Handler;

                        AddTryStart(handler.TryStartIndex);
                        AddHandlerExit(handler.TryEndIndex + 1 /* include Goto instruction that acts as a "leave" */);

                        _handlerEnter.Add(handler.FinallyStartIndex, "fault");
                        AddHandlerExit(handler.FinallyEndIndex);
                    }
                }
            }
예제 #2
0
 internal void SetTryHandler(TryCatchFinallyHandler tryHandler)
 {
     Debug.Assert(_tryHandler == null && tryHandler != null, "the tryHandler can be set only once");
     _tryHandler = tryHandler;
 }
예제 #3
0
 internal void SetTryHandler(TryCatchFinallyHandler tryHandler)
 {
     Handler = tryHandler;
 }