Example #1
0
        protected override Expression VisitChildren(ExpressionVisitor visitor)
        {
            // generate try block
            var tryBody = visitor.Visit(Wrap(Content.Body));

            tryBody = tryBody.AddPrologue(false, prologue);
            if (!(finallyLabel is null))
            {
                tryBody = tryBody.AddEpilogue(false, finallyLabel.Goto(), FaultLabel.LandingSite());
            }

            // generate exception handlers block
            var handlers = new LinkedList <Expression>();

            if (finallyLabel != null)
            {
                handlers.AddLast(new ExitGuardedCodeExpression(previousState, false));
                handlers.AddLast(new EnterGuardedCodeExpression(recoveryStateId));
                foreach (var handler in Content.Handlers)
                {
                    handlers.AddLast(visitor.Visit(new CatchStatement(handler, finallyLabel)));
                }
            }

            // generate finally block
            Expression fault = new FinallyStatement(Content.Finally ?? Content.Fault, previousState, finallyLabel ?? FaultLabel);

            fault = visitor.Visit(fault);
            return(tryBody.AddEpilogue(false, handlers).AddEpilogue(false, fault));
        }
Example #2
0
        protected override Expression VisitChildren(ExpressionVisitor visitor)
        {
            var filter = visitor.Visit(this.filter);

            if (ExpressionAttributes.Get(filter)?.ContainsAwait ?? false)
            {
                throw new NotSupportedException(ExceptionMessages.FilterHasAwait);
            }
            var handler = visitor.Visit(Content);

            handler = handler.AddPrologue(false, prologue).AddEpilogue(false, epilogue).AddEpilogue(false, FaultLabel.Goto());
            return(IfThen(filter, handler));
        }