Boo.Lang.Compiler.Steps.RemoveDeadCode.DetectUnreachableCode C# (CSharp) Метод

DetectUnreachableCode() приватный Метод

private DetectUnreachableCode ( Block block, Statement limit ) : int
block Boo.Lang.Compiler.Ast.Block
limit Boo.Lang.Compiler.Ast.Statement
Результат int
        private int DetectUnreachableCode(Block block, Statement limit)
        {
            bool unreachable = false;
            int idx = 0;
            foreach (Statement stmt in block.Statements)
            {
                //HACK: __switch__ builtin function is hard to detect/handle
                //		within this context, let's ignore whatever is after __switch__
                if (stmt is ExpressionStatement)
                {
                    MethodInvocationExpression mie = (stmt as ExpressionStatement).Expression as MethodInvocationExpression;
                    if (null != mie && TypeSystem.BuiltinFunction.Switch == mie.Target.Entity)
                        return -1;//ignore followings
                }

                if (unreachable && stmt is LabelStatement)
                    return -1;

                if (stmt == limit)
                {
                    unreachable = true;
                }
                else if (unreachable)
                {
                    Warnings.Add(
                        CompilerWarningFactory.UnreachableCodeDetected(stmt) );
                    return idx;
                }
                idx++;
            }
            return -1;
        }