|
@@ -7,6 +7,8 @@ namespace Invercargill {
|
|
private const string COLOUR_PROGRAM = "\x1b[97m";
|
|
private const string COLOUR_PROGRAM = "\x1b[97m";
|
|
private const string COLOUR_CLASS = "\x1b[92m";
|
|
private const string COLOUR_CLASS = "\x1b[92m";
|
|
private const string COLOUR_CATEGORY = "\x1b[96m";
|
|
private const string COLOUR_CATEGORY = "\x1b[96m";
|
|
|
|
+ private const string COLOUR_NUMBER = "\x1b[93m";
|
|
|
|
+ private const string COLOUR_INTERFACE = "\x1b[95m";
|
|
|
|
|
|
private static string format_colour(string colour, string message) {
|
|
private static string format_colour(string colour, string message) {
|
|
return colour + message + COLOUR_RESET;
|
|
return colour + message + COLOUR_RESET;
|
|
@@ -57,10 +59,10 @@ namespace Invercargill {
|
|
output(format_colour(COLOUR_DEBUG, "Trace registered, output will be printed when the enumerable is iterated.\n"));
|
|
output(format_colour(COLOUR_DEBUG, "Trace registered, output will be printed when the enumerable is iterated.\n"));
|
|
}
|
|
}
|
|
|
|
|
|
- public static void print_trace(string message, string additional_message = "", DebugOutputDelegate? output_func = null, bool formatting = true) {
|
|
|
|
|
|
+ public static void print_trace(uint count, string message, string additional_message = "", DebugOutputDelegate? output_func = null, bool formatting = true) {
|
|
var output = get_delegate(output_func, formatting);
|
|
var output = get_delegate(output_func, formatting);
|
|
- var seperator = (additional_message != null && additional_message.length > 0) ? ": " : "";
|
|
|
|
- output(format_colour(COLOUR_DEBUG, "[TRACE] ") + format_colour(COLOUR_PROGRAM, additional_message) + format_colour(COLOUR_DEBUG, seperator) + format_colour(COLOUR_PROGRAM, message) + "\n");
|
|
|
|
|
|
+ var formatted_additional = additional_message.length > 0 ? additional_message + " " : "";
|
|
|
|
+ output(format_colour(COLOUR_DEBUG, "[TRACE] ") + format_colour(COLOUR_PROGRAM, formatted_additional) + format_colour(COLOUR_NUMBER, @"$count") + format_colour(COLOUR_DEBUG, ":\t") + format_colour(COLOUR_PROGRAM, message) + "\n");
|
|
}
|
|
}
|
|
|
|
|
|
public static void print_trace_debug_message(string message, string additional_message = "", DebugOutputDelegate? output_func = null, bool formatting = true) {
|
|
public static void print_trace_debug_message(string message, string additional_message = "", DebugOutputDelegate? output_func = null, bool formatting = true) {
|
|
@@ -76,16 +78,19 @@ namespace Invercargill {
|
|
for(int i = 0; i < indents; i++) indent += " ";
|
|
for(int i = 0; i < indents; i++) indent += " ";
|
|
var has_sources = info.sources.any();
|
|
var has_sources = info.sources.any();
|
|
var known_count = info.count != null;
|
|
var known_count = info.count != null;
|
|
|
|
+ var interfaces = notable_interfaces(info.enumerable_type);
|
|
output(
|
|
output(
|
|
format_colour(COLOUR_DEBUG, indent) +
|
|
format_colour(COLOUR_DEBUG, indent) +
|
|
format_colour(COLOUR_CATEGORY, info.category.to_string()) +
|
|
format_colour(COLOUR_CATEGORY, info.category.to_string()) +
|
|
format_colour(COLOUR_DEBUG, " Enumerable ") +
|
|
format_colour(COLOUR_DEBUG, " Enumerable ") +
|
|
format_colour(COLOUR_CLASS, info.enumerable_type.name()) +
|
|
format_colour(COLOUR_CLASS, info.enumerable_type.name()) +
|
|
format_colour(COLOUR_DEBUG, " with ") +
|
|
format_colour(COLOUR_DEBUG, " with ") +
|
|
- (known_count ? format_colour(COLOUR_PROGRAM, @"$(info.count) ") : "") +
|
|
|
|
|
|
+ (known_count ? format_colour(COLOUR_NUMBER, @"$(info.count) ") : "") +
|
|
format_colour(COLOUR_CLASS, info.element_type.name() ?? "UNKNOWN") +
|
|
format_colour(COLOUR_CLASS, info.element_type.name() ?? "UNKNOWN") +
|
|
format_colour(COLOUR_DEBUG, info.count == 1 ? " element" : " elements") +
|
|
format_colour(COLOUR_DEBUG, info.count == 1 ? " element" : " elements") +
|
|
- (has_sources ? format_colour(COLOUR_DEBUG, ", sources from:") : ".") +
|
|
|
|
|
|
+ (interfaces.any() ? format_colour(COLOUR_DEBUG, " conforms to ") : "") +
|
|
|
|
+ interfaces.to_string(s => format_colour(COLOUR_INTERFACE, s), format_colour(COLOUR_DEBUG, ", ")) +
|
|
|
|
+ (has_sources ? format_colour(COLOUR_DEBUG, ", sources from:") : format_colour(COLOUR_DEBUG, ".")) +
|
|
"\n"
|
|
"\n"
|
|
);
|
|
);
|
|
|
|
|
|
@@ -94,6 +99,36 @@ namespace Invercargill {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static Enumerable<string> notable_interfaces(Type type) {
|
|
|
|
+ var names = new DataStructures.Vector<string>();
|
|
|
|
+ if(type.is_a(typeof(Lot))) {
|
|
|
|
+ names.add("Lot");
|
|
|
|
+ }
|
|
|
|
+ if(type.is_a(typeof(ReadOnlyAddressable))) {
|
|
|
|
+ names.add("Addressable");
|
|
|
|
+ }
|
|
|
|
+ if(type.is_a(typeof(ReadOnlyAssociative))) {
|
|
|
|
+ names.add("Associative");
|
|
|
|
+ }
|
|
|
|
+ if(type.is_a(typeof(ReadOnlyCollection))) {
|
|
|
|
+ names.add("Collection");
|
|
|
|
+ }
|
|
|
|
+ if(type.is_a(typeof(ReadOnlySet))) {
|
|
|
|
+ names.add("Collection");
|
|
|
|
+ }
|
|
|
|
+ if(type.is_a(typeof(Elements))) {
|
|
|
|
+ names.add("Elements");
|
|
|
|
+ }
|
|
|
|
+ if(type.is_a(typeof(Properties))) {
|
|
|
|
+ names.add("Elements");
|
|
|
|
+ }
|
|
|
|
+ if(type.is_a(typeof(Promotion))) {
|
|
|
|
+ names.add("Promotion");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return names;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
internal class TraceEnumerable<T> : Enumerable<T> {
|
|
internal class TraceEnumerable<T> : Enumerable<T> {
|
|
@@ -102,6 +137,7 @@ namespace Invercargill {
|
|
private string additional_message;
|
|
private string additional_message;
|
|
private DebugOutputDelegate? output_func;
|
|
private DebugOutputDelegate? output_func;
|
|
private bool formatting;
|
|
private bool formatting;
|
|
|
|
+ private uint counter = 0;
|
|
|
|
|
|
public TraceEnumerable(owned Enumerable<T> input, EnumerableInfo info, owned TransformDelegate<T, string> stringifier, string additional_message = "", owned DebugOutputDelegate? output_func, bool formatting) {
|
|
public TraceEnumerable(owned Enumerable<T> input, EnumerableInfo info, owned TransformDelegate<T, string> stringifier, string additional_message = "", owned DebugOutputDelegate? output_func, bool formatting) {
|
|
this.input = (owned)input;
|
|
this.input = (owned)input;
|
|
@@ -130,7 +166,8 @@ namespace Invercargill {
|
|
() => tracker.has_next(),
|
|
() => tracker.has_next(),
|
|
() => {
|
|
() => {
|
|
var item = tracker.get_next();
|
|
var item = tracker.get_next();
|
|
- DebugPrinter.print_trace(stringifier(item), additional_message, output_func, formatting);
|
|
|
|
|
|
+ DebugPrinter.print_trace(counter, stringifier(item), additional_message, output_func, formatting);
|
|
|
|
+ counter++;
|
|
return item;
|
|
return item;
|
|
}
|
|
}
|
|
);
|
|
);
|