Ejemplo n.º 1
0
            public LabelledExceptionHandler BeginHandler(ExceptionHandlerType type)
            {
                LabelledExceptionHandler prev = _Prev = _Handler;

                if (prev != null)
                {
                    EndHandler(prev);
                }

                IL.Emit(SRE.OpCodes.Leave, _SkipHandler = IL.DefineLabel());

                Label handlerStart = IL.DefineLabel();

                IL.MarkLabel(handlerStart);

                LabelledExceptionHandler next = _Handler = new LabelledExceptionHandler {
                    TryStart    = _Start,
                    TryEnd      = handlerStart,
                    HandlerType = type,
                    HandlerEnd  = _SkipHandler
                };

                if (type == ExceptionHandlerType.Filter)
                {
                    next.FilterStart = handlerStart;
                }
                else
                {
                    next.HandlerStart = handlerStart;
                }

                return(next);
            }
Ejemplo n.º 2
0
        public void EndHandler(ExceptionBlock block, LabelledExceptionHandler handler)
        {
            switch (handler.handlerType)
            {
            case ExceptionHandlerType.Filter:
                Emit(OpCodes.Endfilter);
                break;

            case ExceptionHandlerType.Finally:
                Emit(OpCodes.Endfinally);
                break;

            default:
                Emit(OpCodes.Leave, block.skip);
                break;
            }

            MarkLabel(block.skip);
            pendingExceptionHandlers.Add(block.cur);
        }
Ejemplo n.º 3
0
            public void EndHandler(LabelledExceptionHandler handler)
            {
                Label skip = _SkipHandler;

                switch (handler.HandlerType)
                {
                case ExceptionHandlerType.Filter:
                    IL.Emit(SRE.OpCodes.Endfilter);
                    break;

                case ExceptionHandlerType.Finally:
                    IL.Emit(SRE.OpCodes.Endfinally);
                    break;

                default:
                    IL.Emit(SRE.OpCodes.Leave, skip);
                    break;
                }

                IL.MarkLabel(skip);
                IL._ExceptionHandlersToMark.Add(handler);
            }
Ejemplo n.º 4
0
        public override void BeginCatchBlock(Type exceptionType)
        {
            LabelledExceptionHandler handler = _ExceptionHandlers.Peek().BeginHandler(ExceptionHandlerType.Catch);

            handler.ExceptionType = exceptionType == null ? null : _(exceptionType);
        }