internal static void Print(Stmt stmt, string name, bool verbose)
 {
     if (verbose)
     {
         if (name != null && name.StartsWith("Visitor"))
         {
             name = name.Substring(7);
         }
         Console.WriteLine(" --- AST Transform Step {0}{1} ---", stmt.Ctx.step++, name == null ? "" : (" '" + name + "'"));
         Console.WriteLine(ShowVisitor.V(stmt));
         Console.WriteLine();
     }
 }
        internal static Stmt DoStep(Func <Stmt, Stmt> fnStep, Stmt stmt, string name, bool verbose)
        {
            var s1 = fnStep(stmt);

            if (s1 != stmt)
            {
                Print(s1, name, verbose);
                var dupStmts = VisitorFindDuplicateStmts.Find(s1);
                if (dupStmts.Any())
                {
                    Console.WriteLine("*** ERROR *** {0} DUPLICATE STMT(S) ***", dupStmts.Count());
                    foreach (var dup in dupStmts)
                    {
                        Console.WriteLine();
                        Console.WriteLine(ShowVisitor.V(dup));
                    }
                    throw new InvalidOperationException("Duplicate stmt(s) found");
                }
            }
            return(s1);
        }