2002, 2023, 2029,
3005, 3012, 3018, 3019, 3021, 3022, 3023, 3026, 3027,
#if GMCS_SOURCE
- 402, 414, 693, 1058, 1700, 3024
+ 402, 414, 458, 693, 1058, 1700, 3024
#endif
};
msg.Append (" ");
}
msg.AppendFormat ("{0} CS{1:0000}: {2}", MessageType, code, message);
- Stderr.WriteLine (msg.ToString ());
+
+ //
+ //
+ if (Stderr == Console.Error)
+ Stderr.WriteLine (ColorFormat (msg.ToString ()));
+ else
+ Stderr.WriteLine (msg.ToString ());
if (extra_info != null) {
foreach (string s in extra_info)
Check (code);
}
+
+ public virtual string ColorFormat (string s)
+ {
+ return s;
+ }
}
sealed class WarningMessage : AbstractMessage
}
}
+ static int NameToCode (string s)
+ {
+ switch (s){
+ case "black":
+ return 0;
+ case "red":
+ return 1;
+ case "green":
+ return 2;
+ case "yellow":
+ return 3;
+ case "blue":
+ return 4;
+ case "magenta":
+ return 5;
+ case "cyan":
+ return 6;
+ case "grey":
+ case "white":
+ return 7;
+ }
+ return 7;
+ }
+
+ //
+ // maps a color name to its xterm color code
+ //
+ static string GetForeground (string s)
+ {
+ string highcode;
+
+ if (s.StartsWith ("bright")){
+ highcode = "1;";
+ s = s.Substring (6);
+ } else
+ highcode = "";
+
+ return "\x001b[" + highcode + (30 + NameToCode (s)).ToString () + "m";
+ }
+
+ static string GetBackground (string s)
+ {
+ return "\x001b[" + (40 + NameToCode (s)).ToString () + "m";
+ }
+
sealed class ErrorMessage : AbstractMessage
{
+ static string prefix, postfix;
+
+ static ErrorMessage ()
+ {
+ string term = Environment.GetEnvironmentVariable ("TERM");
+ bool xterm_colors = false;
+
+ switch (term){
+ case "xterm":
+ case "rxvt":
+ case "rxvt-unicode":
+ if (Environment.GetEnvironmentVariable ("COLORTERM") != null){
+ xterm_colors = true;
+ }
+ break;
+
+ case "xterm-color":
+ xterm_colors = true;
+ break;
+ }
+ string config = Environment.GetEnvironmentVariable ("MCS_COLORS");
+ if (config == null){
+ config = "errors=red";
+ //config = "brightwhite,red";
+ }
+
+ if (config == "disable")
+ return;
+
+ if (!config.StartsWith ("errors="))
+ return;
+
+ config = config.Substring (7);
+
+ if (!xterm_colors)
+ return;
+
+ int p = config.IndexOf (",");
+ if (p == -1)
+ prefix = GetForeground (config);
+ else
+ prefix = GetBackground (config.Substring (p+1)) + GetForeground (config.Substring (0, p));
+ postfix = "\x001b[0m";
+ }
+
public ErrorMessage (int code, Location loc, string message, ArrayList extraInfo)
: base (code, loc, message, extraInfo)
{
{
}
+ public override string ColorFormat (string s)
+ {
+ if (prefix != null)
+ return prefix + s + postfix;
+ return s;
+ }
+
public override void Print()
{
Errors++;
public static void FeatureIsNotAvailable (Location loc, string feature)
{
string version;
- if (RootContext.Version == LanguageVersion.ISO_1)
+ switch (RootContext.Version) {
+ case LanguageVersion.ISO_1:
version = "1.0";
- else if (RootContext.Version == LanguageVersion.ISO_2)
+ break;
+ case LanguageVersion.ISO_2:
version = "2.0";
- else
+ break;
+ case LanguageVersion.Default_MCS:
+ Report.Error (1644, loc, "Feature `{0}' is not available in Mono mcs compiler. Consider using Mono gmcs compiler instead",
+ feature);
+ return;
+ default:
throw new InternalErrorException ("Invalid feature version", RootContext.Version);
+ }
Report.Error (1644, loc,
"Feature `{0}' cannot be used because it is not part of the C# {1} language specification",
return;
Type dt = TypeManager.DropGenericTypeArguments (mi.DeclaringType);
+ if (TypeManager.IsDelegateType (dt)) {
+ SymbolRelatedToPreviousError (dt);
+ return;
+ }
+
DeclSpace temp_ds = TypeManager.LookupDeclSpace (dt);
if (temp_ds == null) {
SymbolRelatedToPreviousError (dt.Assembly.Location, TypeManager.GetFullNameSignature (mi));