1 module decs.dbg; 2 3 import core.stdc.stdio; 4 import core.stdc.stdarg; 5 import core.stdc.stdlib; 6 7 enum RESET = "\033[0m"; 8 enum RED = "\033[1;31m"; 9 enum GREEN = "\033[1;32m"; 10 enum YELLOW = "\033[1;33m"; 11 enum BLUE = "\033[1;34m"; 12 enum PINK = "\033[1;35m"; 13 enum CYAN = "\033[1;36m"; 14 enum WHITE = "\033[1;37m"; 15 16 pragma(printf) 17 extern(C) void panic(const char* fmt, ...) 18 { 19 printf(RED); 20 21 va_list args; 22 va_start(args, fmt); 23 24 vprintf(fmt, args); 25 va_end(args); 26 27 printf(RESET); 28 printf("\n"); 29 abort(); 30 } 31 32 pragma(inline) 33 { 34 bool is_nan(const ref float v) 35 { 36 //import core.stdc.math : isnan; 37 //return isnan(v) != 0; 38 return isNaN(v); 39 } 40 41 bool is_nan(const ref double v) 42 { 43 //import core.stdc.math : isnan; 44 //return isnan(v) != 0; 45 return isNaN(v); 46 } 47 48 // TODO: hmm ^^^^^^^^^^^^ 49 bool isNaN(X)(X x)if (__traits(isFloating, X)) 50 { 51 version (all) 52 { 53 return x != x; 54 } 55 else 56 { 57 panic("not supported"); 58 } 59 } 60 }