Browse Source

Added a pretty simple diagnostic system so we can provide improved diagnostics to clients.

pull/1/head
triton 13 years ago
parent
commit
3800ccf996
  1. 32
      src/Generator/Diagnostics.cs
  2. 3
      src/Generator/Driver.cs

32
src/Generator/Diagnostics.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
using System;
namespace Cxxi
{
public enum DiagnosticKind
{
Message,
Warning,
Error
}
public struct DiagnosticInfo
{
public string Message;
public string File;
public int Line;
public int Column;
}
public interface IDiagnosticConsumer
{
void Emit(DiagnosticKind kind, DiagnosticInfo info);
}
public class TextDiagnosticPrinter : IDiagnosticConsumer
{
public void Emit(DiagnosticKind kind, DiagnosticInfo info)
{
Console.WriteLine(info.Message);
}
}
}

3
src/Generator/Driver.cs

@ -10,6 +10,7 @@ namespace Cxxi @@ -10,6 +10,7 @@ namespace Cxxi
{
private readonly Options options;
private readonly ILibrary transform;
private readonly IDiagnosticConsumer diagnostics;
private readonly TypeMapDatabase typeDatabase;
private Library library;
@ -17,6 +18,8 @@ namespace Cxxi @@ -17,6 +18,8 @@ namespace Cxxi
{
this.options = options;
this.transform = transform;
this.diagnostics = new TextDiagnosticPrinter();
typeDatabase = new TypeMapDatabase();
typeDatabase.SetupTypeMaps();
}

Loading…
Cancel
Save