From 19bfcea51c0dc40fe28ac6b2cb0220604b0699c2 Mon Sep 17 00:00:00 2001 From: malekith Date: Sun, 25 Jan 2004 18:58:55 +0000 Subject: [PATCH] Print newline before print error messages (to kill progress bar). git-svn-id: https://nemerle.googlecode.com/svn/nemerle/trunk@1395 c8a6711f-211a-0410-a8d5-2f220496d6d1 --- ncc/main.n | 1 + ncc/passes.n | 34 ++++++++++++++++++++++++---------- ncc/util.n | 16 +++++++++------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/ncc/main.n b/ncc/main.n index 339e9e2c80..7ae20bec6c 100644 --- a/ncc/main.n +++ b/ncc/main.n @@ -67,6 +67,7 @@ namespace Nemerle.Compiler bomb (e : System.Exception, msg : string) : void { + Passes.KillProgressBar (); Message.maybe_bailout (true); print_string ("internal compiler error: " + msg + "\n" + e.StackTrace); System.Environment.Exit (2); diff --git a/ncc/passes.n b/ncc/passes.n index e6bd3f0b20..6db60d27de 100644 --- a/ncc/passes.n +++ b/ncc/passes.n @@ -38,22 +38,37 @@ namespace Nemerle.Compiler mutable current_tyinfo_count : int; mutable current_pb_stage : int; + + mutable pb_killed : bool; public MarkTyinfoCompiled () : void { current_tyinfo_count <- current_tyinfo_count + 1; - ProgressBar (10 + current_tyinfo_count * 85 / tyinfo_counter); + ProgressBar (10 + current_tyinfo_count * 90 / tyinfo_counter); } ProgressBar (stage : int) : void { - def max = 60; - def act = stage * max / 100; - def act = if (act > max) max else act; - when (Flags.progress_bar && current_pb_stage != act) - System.Console.Write ("\r" + System.String ('_', act) + - System.String ('.', max - act) + "\r"); - current_pb_stage <- act; + when (Flags.progress_bar) { + def max = 60; + def act = stage * max / 100; + def act = if (act > max) max else act; + def diff = act - current_pb_stage; + when ((pb_killed && diff > 10) || (!pb_killed && diff > 0)) { + System.Console.Write ("\r" + System.String ('_', act) + + System.String ('.', max - act) + "\r"); + current_pb_stage <- act; + pb_killed <- false; + } + } + } + + public KillProgressBar () : void + { + unless (pb_killed) { + System.Console.Write ("\n"); + pb_killed <- true; + } } /** @@ -87,8 +102,7 @@ namespace Nemerle.Compiler cgil.SaveAssembly (); Message.maybe_bailout(); - ProgressBar (100); - System.Console.Write ("\r" + System.String (' ', 60) + "\r"); + KillProgressBar (); } } } diff --git a/ncc/util.n b/ncc/util.n index 38696293b8..8f7fd51c17 100644 --- a/ncc/util.n +++ b/ncc/util.n @@ -117,7 +117,8 @@ namespace Nemerle.Compiler { mutable warning_cnt : int; mutable emitted_hints : Hashtable (string, int); - public location_to_string (l : Location) : string { + public location_to_string (l : Location) : string + { if (l == null) "(no location)" else @@ -126,12 +127,13 @@ namespace Nemerle.Compiler { } public report (l : Location, m : string) : void - { - def l' = - if (l == null) Location_stack.top() - else l; - print_endline (Message.location_to_string(l') + ": " + m); - } + { + def l' = + if (l == null) Location_stack.top() + else l; + Passes.KillProgressBar (); + print_endline (Message.location_to_string(l') + ": " + m); + } public error (l : Location, m : string) : void { Message.error_cnt <- Message.error_cnt + 1;