Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Experiments / Attic / Rook / Castle.Rook.Compiler / Services / Default / ErrorReport.cs
blob4c053d305ba4c3aacebbfbd90f3b40aa52bd4a8c
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Rook.Compiler.Services.Default
17 using System;
18 using System.IO;
20 /// <summary>
21 /// Default Error Report outputs to Console
22 /// </summary>
23 public class ErrorReport : IErrorReport
25 private int errorCount, warningCount;
26 private int enableLevel = 0;
28 public ErrorReport()
32 #region IErrorReport Members
34 public void Enable()
36 enableLevel--;
39 public void Disable()
41 enableLevel++;
44 public void Error(String filename, LexicalPosition pos, String contents, params object[] args)
46 if (enableLevel > 0) return;
48 errorCount++;
50 if (pos.Column == 0)
52 ErrorWriter.Write("{0}:{1}\terror: ", filename, pos.Line);
54 else
56 ErrorWriter.Write("{0}:{1},{2}\terror: ", filename, pos.Line, pos.Column);
59 ErrorWriter.WriteLine(contents, args);
62 public void Error(String contents, params object[] args)
64 if (enableLevel > 0) return;
66 errorCount++;
68 ErrorWriter.Write("compiler error: ");
69 ErrorWriter.WriteLine(contents, args);
72 public void Warning(String filename, LexicalPosition pos, Severity severity, String contents, params object[] args)
74 if (enableLevel > 0) return;
76 warningCount++;
78 if (pos.Column == 0)
80 OutWriter.Write("{0}:{1}\twarning: ", filename, pos.Line);
82 else
84 OutWriter.Write("{0}:{1},{2}\twarning: ", filename, pos.Line, pos.Column);
87 OutWriter.WriteLine(contents, args);
90 public void Warning(String contents, params object[] args)
92 if (enableLevel > 0) return;
94 warningCount++;
96 OutWriter.Write("warning: ");
97 OutWriter.WriteLine(contents, args);
100 public bool HasErrors
102 get { return errorCount != 0; }
105 public bool HasWarnings
107 get { return warningCount != 0; }
110 #endregion
112 protected virtual TextWriter OutWriter
114 get { return Console.Out; }
117 protected virtual TextWriter ErrorWriter
119 get { return Console.Error; }