module compiler const ( CommonCHeaders = ' #include // TODO remove all these includes, define all function signatures and types manually #include #include #include // for va_list #include // int64_t etc #include // memcpy #ifndef _WIN32 #include #include // tolower #include #include // sleep #endif #ifdef __APPLE__ #include // proc_pidpath #include // backtrace and backtrace_symbols_fd #endif #ifdef __linux__ #ifndef __BIONIC__ #include // backtrace and backtrace_symbols_fd #endif #pragma weak backtrace #pragma weak backtrace_symbols_fd #endif #ifdef __linux__ #include #include // os__wait uses wait on nix #endif #ifdef __FreeBSD__ #include #include // os__wait uses wait on nix #endif #ifdef __DragonFly__ #include #include // os__wait uses wait on nix #endif #ifdef __OpenBSD__ #include #include #include // os__wait uses wait on nix #endif #define EMPTY_STRUCT_DECLARATION #define EMPTY_STRUCT_INITIALIZATION 0 // Due to a tcc bug, the length of an array needs to be specified, but GCC crashes if it is... #define EMPTY_ARRAY_OF_ELEMS(x,n) (x[]) #define TCCSKIP(x) x #ifdef __TINYC__ #undef EMPTY_STRUCT_INITIALIZATION #define EMPTY_STRUCT_INITIALIZATION #undef EMPTY_ARRAY_OF_ELEMS #define EMPTY_ARRAY_OF_ELEMS(x,n) (x[n]) #undef TCCSKIP #define TCCSKIP(x) #endif #define OPTION_CAST(x) (x) #ifdef _WIN32 #define WINVER 0x0600 #define _WIN32_WINNT 0x0600 #define WIN32_LEAN_AND_MEAN #define _UNICODE #define UNICODE #include // must be included after #ifndef __TINYC__ #include #endif #include // _waccess #include // _O_U8TEXT #include // _wgetcwd //#include #ifdef _MSC_VER // On MSVC these are the same (as long as /volatile:ms is passed) #define _Atomic volatile // MSVC cannot parse some things properly #undef EMPTY_STRUCT_DECLARATION #undef OPTION_CAST #define EMPTY_STRUCT_DECLARATION int ____dummy_variable #define OPTION_CAST(x) #endif #else #include #endif //================================== TYPEDEFS ================================*/ typedef int64_t i64; typedef int16_t i16; typedef int8_t i8; typedef uint64_t u64; typedef uint32_t u32; typedef uint16_t u16; typedef uint8_t byte; typedef uint32_t rune; typedef float f32; typedef double f64; typedef unsigned char* byteptr; typedef int* intptr; typedef void* voidptr; typedef struct array array; typedef struct map map; typedef array array_string; typedef array array_int; typedef array array_byte; typedef array array_f32; typedef array array_f64; typedef map map_int; typedef map map_string; #ifndef bool typedef int bool; #define true 1 #define false 0 #endif //============================== HELPER C MACROS =============================*/ #define _PUSH(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array_push(arr, &tmp);} #define _PUSH_MANY(arr, val, tmp, tmp_typ) {tmp_typ tmp = (val); array_push_many(arr, tmp.data, tmp.len);} #define _IN(typ, val, arr) array_##typ##_contains(arr, val) #define _IN_MAP(val, m) map_exists(m, val) #define DEFAULT_EQUAL(a, b) (a == b) #define DEFAULT_NOT_EQUAL(a, b) (a != b) #define DEFAULT_LT(a, b) (a < b) #define DEFAULT_LE(a, b) (a <= b) #define DEFAULT_GT(a, b) (a > b) #define DEFAULT_GE(a, b) (a >= b) //================================== GLOBALS =================================*/ byteptr g_str_buf; int load_so(byteptr); void reload_so(); ' js_headers = ' var array_string = function() {} var array_byte = function() {} var array_int = function() {} var byte = function() {} var double = function() {} var int = function() {} var f64 = function() {} var f32 = function() {} var i64 = function() {} var i32 = function() {} var i16 = function() {} var u64 = function() {} var u32 = function() {} var u16 = function() {} var i8 = function() {} var u8 = function() {} var bool = function() {} var rune = function() {} var map_string = function() {} var map_int = function() {} ' )