Skip to content

Commit

Permalink
Print newline before print error messages (to kill progress bar).
Browse files Browse the repository at this point in the history
git-svn-id: https://nemerle.googlecode.com/svn/nemerle/trunk@1395 c8a6711f-211a-0410-a8d5-2f220496d6d1
  • Loading branch information
malekith committed Jan 25, 2004
1 parent 447fc3c commit 19bfcea
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
1 change: 1 addition & 0 deletions ncc/main.n
Expand Up @@ -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);
Expand Down
34 changes: 24 additions & 10 deletions ncc/passes.n
Expand Up @@ -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;
}
}

/**
Expand Down Expand Up @@ -87,8 +102,7 @@ namespace Nemerle.Compiler
cgil.SaveAssembly ();
Message.maybe_bailout();

ProgressBar (100);
System.Console.Write ("\r" + System.String (' ', 60) + "\r");
KillProgressBar ();
}
}
}
Expand Down
16 changes: 9 additions & 7 deletions ncc/util.n
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 19bfcea

Please sign in to comment.