Пример #1
0
            protected override Expression VisitGoto(GotoExpression @goto)
            {
                if (@goto.Kind != GotoExpressionKind.Goto)
                {
                    return(base.VisitGoto(@goto));
                }

                var currentBlockFinalExpression = _blocks.Peek()?.Expressions.Last();

                if (currentBlockFinalExpression?.NodeType == ExpressionType.Label)
                {
                    var returnLabel = (LabelExpression)currentBlockFinalExpression;

                    if (@goto.Target == returnLabel.Target)
                    {
                        GotoReturnGotos.Add(@goto);

                        return(base.VisitGoto(@goto));
                    }
                }

                NamedLabelTargets.Add(@goto.Target);

                return(base.VisitGoto(@goto));
            }
Пример #2
0
        private void Visit(GotoExpression @goto)
        {
            if (@goto.Kind != GotoExpressionKind.Goto)
            {
                goto VisitValue;
            }

            var currentBlockFinalExpression = _blocks.Peek()?.Expressions.Last();

            if (currentBlockFinalExpression?.NodeType == ExpressionType.Label)
            {
                var returnLabel = (LabelExpression)currentBlockFinalExpression;

                if (@goto.Target == returnLabel.Target)
                {
                    GotoReturnGotos.Add(@goto);
                    goto VisitValue;
                }
            }

            NamedLabelTargets.Add(@goto.Target);

VisitValue:
            Visit(@goto.Value);
        }