Ejemplo n.º 1
0
        protected internal override Statement VisitTryFault(TryFault inst)
        {
            var tryCatch = new TryCatchStatement();

            tryCatch.TryBlock = ConvertAsBlock(inst.TryBlock);
            var faultBlock = ConvertAsBlock(inst.FaultBlock);

            faultBlock.InsertChildAfter(null, new Comment("try-fault"), Roles.Comment);
            faultBlock.Add(new ThrowStatement());
            tryCatch.CatchClauses.Add(new CatchClause {
                Body = faultBlock
            });
            return(tryCatch);
        }
Ejemplo n.º 2
0
        protected internal override void VisitTryFault(TryFault inst)
        {
            DebugStartPoint(inst);
            // try-fault executes fault block if an exception occurs in try,
            // and always rethrows the exception at the end.
            State onException = HandleTryBlock(inst);
            State onSuccess   = state;

            state = onException;
            inst.FaultBlock.AcceptVisitor(this);
            PropagateStateOnException();             // rethrow the exception after the fault block

            // try-fault exits normally only if no exception occurred
            state = onSuccess;
            DebugEndPoint(inst);
        }