Exemple #1
0
        public override BlockWithLabels <Label> RecordInformationForNewBlock(Label currentLabel, BlockWithLabels <Label> previousBlock)
        {
            BlockWithLabels <Label> result     = null;
            Queue <Handler>         handlerEnd = GetHandlerEnd(currentLabel);

            if (handlerEnd != null)
            {
                foreach (Handler handler in handlerEnd)
                {
                    this.subroutine_stack.Head.Commit();
                    this.subroutine_stack = this.subroutine_stack.Tail;
                    previousBlock         = null;
                }
            }
            Queue <Handler> tryEnd = GetTryEnd(currentLabel);

            if (tryEnd != null)
            {
                foreach (Handler handler in tryEnd)
                {
                    if (!Equals(handler, CurrentProtectingHanlders.Head))
                    {
                        throw new InvalidOperationException("wrong handler");
                    }
                    CurrentProtectingHanlders = CurrentProtectingHanlders.Tail;
                }
            }
            Handler handler1;

            if (IsHandlerStart(currentLabel, out handler1))
            {
                if (IsFaultOrFinally(handler1))
                {
                    SubroutineWithHandlers <Label, Handler> sub = !CodeProvider.IsFaultHandler(handler1)
                                                                                        ? new FinallySubroutine <Label, Handler> (this.SubroutineFacade, currentLabel, this)
                                                                                        : (FaultFinallySubroutineBase <Label, Handler>) new FaultSubroutine <Label, Handler> (this.SubroutineFacade, currentLabel, this);
                    CurrentSubroutineWithHandlers.FaultFinallySubroutines.Add(handler1, sub);
                    this.subroutine_stack = this.subroutine_stack.Cons(sub);
                    previousBlock         = null;
                }
                else
                {
                    result = CurrentSubroutineWithHandlers.CreateCatchFilterHeader(handler1, currentLabel);
                }
            }
            if (result == null)
            {
                result = base.RecordInformationForNewBlock(currentLabel, previousBlock);
            }
            Stack <Handler> tryStart = GetTryStart(currentLabel);

            if (tryStart != null)
            {
                foreach (Handler handler in tryStart)
                {
                    CurrentProtectingHanlders = CurrentProtectingHanlders.Cons(handler);
                }
            }

            CurrentSubroutineWithHandlers.ProtectingHandlers.Add(result, CurrentProtectingHanlders);
            return(result);
        }
Exemple #2
0
        public CFGBlock BuildBlocks(Label entry, SubroutineWithHandlers <Label, Handler> subroutine)
        {
            this.subroutine_stack = Sequence <SubroutineWithHandlers <Label, Handler> > .Cons(subroutine, null);

            return(base.BuildBlocks(entry));
        }