[svn] r6337: nemerle/trunk/ncc: STATELESS-TODO
codedom/NemerleCodeCompiler.n completion/CodeCompletionEngi...
malekith
svnadmin at nemerle.org
Thu May 25 19:38:25 CEST 2006
Log:
Un-static Message state.
Author: malekith
Date: Thu May 25 19:38:23 2006
New Revision: 6337
Modified:
nemerle/trunk/ncc/STATELESS-TODO
nemerle/trunk/ncc/codedom/NemerleCodeCompiler.n
nemerle/trunk/ncc/completion/CodeCompletionEngine.n
nemerle/trunk/ncc/main.n
nemerle/trunk/ncc/parsing/Utility.n
nemerle/trunk/ncc/passes.n
nemerle/trunk/ncc/testsuite/test.n
Modified: nemerle/trunk/ncc/STATELESS-TODO
==============================================================================
--- nemerle/trunk/ncc/STATELESS-TODO (original)
+++ nemerle/trunk/ncc/STATELESS-TODO Thu May 25 19:38:23 2006
@@ -1,5 +1,4 @@
Modules:
-- Message
- Location_stack
- MacroColorizer
Modified: nemerle/trunk/ncc/codedom/NemerleCodeCompiler.n
==============================================================================
--- nemerle/trunk/ncc/codedom/NemerleCodeCompiler.n (original)
+++ nemerle/trunk/ncc/codedom/NemerleCodeCompiler.n Thu May 25 19:38:23 2006
@@ -119,16 +119,18 @@
ignore (results.Errors.Add (error));
}
- Message.ErrorOccured += fun (loc : Location, msg) {
+ def cOptions = CompilationOptions ();
+ def man = ManagerClass (cOptions);
+
+ man.ErrorOccured += fun (loc : Location, msg) {
err_event (false, loc, msg);
failed = true;
}
- Message.WarningOccured += fun (loc : Location, msg) {
+ man.WarningOccured += fun (loc : Location, msg) {
err_event (true, loc, msg);
}
mutable files = [];
- def cOptions = CompilationOptions ();
def opts = cOptions.GetCommonOptions () + [
Getopt.CliOption.NonOption (name = "",
help = "Specify file to compile",
@@ -138,7 +140,7 @@
List.FromArray (Regex.Split (options.CompilerOptions, @"\s")).Filter (fun (t) {t.Length > 0}));
def fullOutput = System.IO.StringWriter ();
- Message.InitOutput (fullOutput);
+ man.InitOutput (fullOutput);
cOptions.ProgressBar = false;
cOptions.IgnoreConfusion = true;
cOptions.ReferencedLibraries = [];
@@ -157,8 +159,7 @@
Message.Error ("need at least one file to compile");
else {
cOptions.Sources = files + List.FromArray (fileNames);
- def m = ManagerClass (cOptions);
- m.Run ();
+ man.Run ();
succeeded = !failed;
}
}
Modified: nemerle/trunk/ncc/completion/CodeCompletionEngine.n
==============================================================================
--- nemerle/trunk/ncc/completion/CodeCompletionEngine.n (original)
+++ nemerle/trunk/ncc/completion/CodeCompletionEngine.n Thu May 25 19:38:23 2006
@@ -215,16 +215,16 @@
this.ParsingPipeline = MainParser.Parse;
this.ScanningPipeline = ScanTypeHierarchy (this).ProcessDeclaration;
textWriter = null;
- Message.MessageOccured += Message.MessageEventHandler (process_error_message);
+ MessageOccured += process_error_message;
}
public Init() : void
{
Location.Init();
if (textWriter == null)
- Message.InitOutput (System.Console.Out);
+ InitOutput (System.Console.Out);
else
- Message.InitOutput (textWriter);
+ InitOutput (textWriter);
MacroColorizer.Clear ();
if (!Options.PersistentLibraries || this.NameTree == null)
this.NameTree = NamespaceTree (this);
Modified: nemerle/trunk/ncc/main.n
==============================================================================
--- nemerle/trunk/ncc/main.n (original)
+++ nemerle/trunk/ncc/main.n Thu May 25 19:38:23 2006
@@ -57,7 +57,10 @@
public Main () : void
{
- Options = parse_command_line ();
+ Options = CompilationOptions ();
+ Manager = ManagerClass (Options);
+ Manager.InitOutput (System.Console.Out);
+ parse_command_line ();
if (stack_kilos != 0 || needs_bigger_stack ()) {
when (stack_kilos == 0)
stack_kilos = 12 * 1024;
@@ -79,8 +82,6 @@
Options.LibraryPaths ::= System.IO.Path.GetDirectoryName
(System.Uri (typeof (MainClass).Assembly.CodeBase).LocalPath);
- Manager = ManagerClass (Options);
-
// run compilation with already created options
Manager.Run ()
} catch {
@@ -115,10 +116,9 @@
System.Environment.Exit (2);
}
- parse_command_line () : CompilationOptions
+ parse_command_line () : void
{
- def cOptions = CompilationOptions ();
- Message.InitOutput (System.Console.Out);
+ def cOptions = Options;
mutable files = [];
@@ -166,7 +166,6 @@
| _ =>
cOptions.Sources = files;
}
- cOptions
}
}
}
Modified: nemerle/trunk/ncc/parsing/Utility.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Utility.n (original)
+++ nemerle/trunk/ncc/parsing/Utility.n Thu May 25 19:38:23 2006
@@ -140,46 +140,24 @@
}
}
+ [ManagerAccess (ManagerClass.Instance)]
public module Message
{
- mutable error_cnt : int;
- mutable warning_cnt : int;
- mutable emitted_hints : Hashtable [string, int];
-
- mutable output : System.IO.TextWriter;
-
- public delegate MessageEventHandler (loc : Location, msg : string) : void;
- public event ErrorOccured : MessageEventHandler;
- public event WarningOccured : MessageEventHandler;
- public event MessageOccured : MessageEventHandler;
-
- public InitOutput (o : System.IO.TextWriter) : void
- {
- output = o;
- }
-
- public Init () : void {
- error_cnt = 0;
- warning_cnt = 0;
- unless (emitted_hints == null) emitted_hints.Clear ();
- }
-
public Error (loc : Location, m : string) : void
{
def loc =
if (loc == Location.Default) Location_stack.top()
else loc;
- when (ErrorOccured != null)
- ErrorOccured (loc, m);
+ Manager.RunErrorOccured (loc, m);
- Message.error_cnt = Message.error_cnt + 1;
- if (ManagerClass.Instance.Options.ColorMessages)
+ Message.Manager.Message_error_cnt++;
+ if (Manager.Options.ColorMessages)
Message.report (loc, "\e[01;31merror\e[0m: " + m)
else
Message.report (loc, "error: " + m);
- when (ManagerClass.Instance.Options.ThrowOnError)
+ when (Manager.Options.ThrowOnError)
throw BailOutException ();
}
@@ -202,14 +180,13 @@
else loc;
when (code == -1 || WarningOptions.IsEnabledAt (loc, code)) {
- when (WarningOccured != null)
- WarningOccured (loc, m);
+ Manager.RunWarningOccured (loc, m);
- Message.warning_cnt = Message.warning_cnt + 1;
+ Message.Manager.Message_warning_cnt++;
def m = if (code == -1) m else $"N$code: $m";
- if (ManagerClass.Instance.Options.ColorMessages)
+ if (Manager.Options.ColorMessages)
Message.report (loc, "\e[01;33mwarning\e[0m: " + m)
else
Message.report (loc, "warning: " + m);
@@ -224,7 +201,7 @@
public Hint (loc : Location, m : string) : void
{
- if (ManagerClass.Instance.Options.ColorMessages)
+ if (Manager.Options.ColorMessages)
Message.report (loc, "\e[01;32mhint\e[0m: " + m)
else
Message.report (loc, "hint: " + m);
@@ -236,14 +213,14 @@
}
public HintOnce (loc : Location, m : string) : void {
- when (emitted_hints == null)
- emitted_hints = Hashtable (20);
- unless (emitted_hints.Contains (m)) {
- if (ManagerClass.Instance.Options.ColorMessages)
+ when (Manager.Message_emitted_hints == null)
+ Manager.Message_emitted_hints = Hashtable (20);
+ unless (Manager.Message_emitted_hints.Contains (m)) {
+ if (Manager.Options.ColorMessages)
Message.report (loc, "\e[01;32mhint\e[0m: " + m)
else
Message.report (loc, "hint: " + m);
- emitted_hints.Add (m, 0)
+ Manager.Message_emitted_hints.Add (m, 0)
}
}
@@ -286,11 +263,11 @@
public MaybeBailout (fscked_up : bool) : void
{
- unless (ManagerClass.Instance.Options.IgnoreConfusion && fscked_up)
+ unless (Manager.Options.IgnoreConfusion && fscked_up)
when (SeenError) {
when (fscked_up)
printf ("confused by earlier errors bailing out\n");
- if (ManagerClass.Instance.Options.IgnoreConfusion)
+ if (Manager.Options.IgnoreConfusion)
throw Recovery ()
else
System.Environment.Exit (1)
@@ -299,12 +276,12 @@
public SeenError : bool
{
- get { error_cnt != 0 }
+ get { Manager.Message_error_cnt != 0 }
}
public ErrorCount : int
{
- get { error_cnt }
+ get { Manager.Message_error_cnt }
}
public MaybeBailout () : void
@@ -317,12 +294,12 @@
def l =
if (l == Location.Default) Location_stack.top()
else l;
- ManagerClass.Instance.KillProgressBar ();
+ Manager.KillProgressBar ();
def msg = l.ToString () + m;
- when (MessageOccured != null) MessageOccured (l, msg);
- when (output == null)
- output = System.Console.Out;
- fprintf (output, "%s\n", msg)
+ Manager.RunMessageOccured (l, msg);
+ when (Manager.Message_output == null)
+ Manager.Message_output = System.Console.Out;
+ fprintf (Manager.Message_output, "%s\n", msg)
}
}
Modified: nemerle/trunk/ncc/passes.n
==============================================================================
--- nemerle/trunk/ncc/passes.n (original)
+++ nemerle/trunk/ncc/passes.n Thu May 25 19:38:23 2006
@@ -57,6 +57,34 @@
mutable pb_killed : bool;
+ public delegate MessageEventHandler (loc : Location, msg : string) : void;
+ public event ErrorOccured : MessageEventHandler;
+ public event WarningOccured : MessageEventHandler;
+ public event MessageOccured : MessageEventHandler;
+
+ internal RunErrorOccured (loc : Location, msg : string) : void
+ {
+ when (ErrorOccured != null)
+ ErrorOccured (loc, msg)
+ }
+
+ internal RunWarningOccured (loc : Location, msg : string) : void
+ {
+ when (WarningOccured != null)
+ WarningOccured (loc, msg)
+ }
+
+ internal RunMessageOccured (loc : Location, msg : string) : void
+ {
+ when (MessageOccured != null)
+ MessageOccured (loc, msg)
+ }
+
+ public InitOutput (o : System.IO.TextWriter) : void
+ {
+ Message_output = o;
+ }
+
#region ,,static'' data from other modules
internal mutable StaticTyVarId : int;
internal mutable Typer_DT_Id : int;
@@ -70,6 +98,12 @@
internal mutable AttributeMacroExpansion_global_nr : int;
internal mutable Macros_in_pattern : bool;
+ internal mutable Message_error_cnt : int;
+ internal mutable Message_warning_cnt : int;
+ internal mutable Message_emitted_hints : Hashtable [string, int] = Hashtable ();
+
+ internal mutable Message_output : System.IO.TextWriter;
+
// won't be needed when we use this object only once
KillStatics () : void
{
@@ -84,12 +118,16 @@
Util_Id = 0;
AttributeMacroExpansion_global_nr = 0;
Macros_in_pattern = false;
+ Message_error_cnt = 0;
+ Message_warning_cnt = 0;
+ Message_emitted_hints.Clear ();
}
#endregion
/// initialize pipelines with default values
public this (options : CompilationOptions)
{
+ assert (options != null);
ParsingPipeline = MainParser.Parse;
def scanner = ScanTypeHierarchy (this);
ScanningPipeline = scanner.ProcessDeclaration;
@@ -181,7 +219,6 @@
internal InitCompiler () : void {
KillStatics ();
Stats.Reset ();
- Message.Init ();
MacroColorizer.Clear ();
Location.Init ();
if (shouldCreate (NameTree))
Modified: nemerle/trunk/ncc/testsuite/test.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/test.n (original)
+++ nemerle/trunk/ncc/testsuite/test.n Thu May 25 19:38:23 2006
@@ -51,7 +51,7 @@
{
public static mutable peverify : string = "";
- mutable Manager : ManagerClass = ManagerClass (null);
+ mutable Manager : ManagerClass = ManagerClass (CompilationOptions ());
private dnet_runtime : string;
private runtime_parms : list [string];
@@ -102,7 +102,7 @@
error_log = null;
log_file_created = false;
Init ("");
- Message.MessageOccured += fun (_, s) {
+ Manager.MessageOccured += fun (_, s) {
// FIXME, change + to :: and see
nem_output = NString.Split (s, array ['\n']) + nem_output;
};
@@ -305,7 +305,7 @@
Manager.Options = Options;
- Message.InitOutput (System.IO.TextWriter.Null);
+ Manager.InitOutput (System.IO.TextWriter.Null);
try {
Manager.Run ()
} catch {
More information about the svn
mailing list