Change syntax of $if, $assert, $include, $echo. Introduces $error

This commit is contained in:
Christoffer Lerno
2023-05-06 12:18:00 +02:00
parent 3dd6675e1b
commit 172d561f07
104 changed files with 338 additions and 336 deletions

View File

@@ -36,7 +36,7 @@ def EnumSet = distinct EnumSetType;
fn void EnumSet.add(EnumSet* this, Enum v)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
(*this)[v / 8] |= (char)(1u << (v % 8));
$else
*this = (EnumSet)((EnumSetType)*this | 1u << (EnumSetType)v);
@@ -45,7 +45,7 @@ $endif
fn void EnumSet.clear(EnumSet* this)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
*this = {};
$else
*this = 0;
@@ -54,7 +54,7 @@ $endif
fn bool EnumSet.remove(EnumSet* this, Enum v)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
if (!this.has(v) @inline) return false;
(*this)[v / 8] &= (char)~(1 << (v % 8));
return true;
@@ -68,7 +68,7 @@ $endif
fn bool EnumSet.has(EnumSet* this, Enum v)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
return (bool)(((*this)[v / 8] << (v % 8)) & 0x01);
$else
return ((EnumSetType)*this & (1u << (EnumSetType)v)) != 0;
@@ -77,7 +77,7 @@ $endif
fn void EnumSet.add_all(EnumSet* this, EnumSet s)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
foreach (i, c : s) (*this)[i] |= c;
$else
*this = (EnumSet)((EnumSetType)*this | (EnumSetType)s);
@@ -86,7 +86,7 @@ $endif
fn void EnumSet.retain_all(EnumSet* this, EnumSet s)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
foreach (i, c : s) (*this)[i] &= c;
$else
*this = (EnumSet)((EnumSetType)*this & (EnumSetType)s);
@@ -95,7 +95,7 @@ $endif
fn void EnumSet.remove_all(EnumSet* this, EnumSet s)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
foreach (i, c : s) (*this)[i] &= ~c;
$else
*this = (EnumSet)((EnumSetType)*this & ~(EnumSetType)s);
@@ -104,7 +104,7 @@ $endif
fn EnumSet EnumSet.and_of(EnumSet* this, EnumSet s)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
EnumSet copy = *this;
copy.retain_all(s);
return copy;
@@ -115,7 +115,7 @@ $endif
fn EnumSet EnumSet.or_of(EnumSet* this, EnumSet s)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
EnumSet copy = *this;
copy.add_all(s);
return copy;
@@ -127,7 +127,7 @@ $endif
fn EnumSet EnumSet.diff_of(EnumSet* this, EnumSet s)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
EnumSet copy = *this;
copy.remove_all(s);
return copy;
@@ -138,7 +138,7 @@ $endif
fn EnumSet EnumSet.xor_of(EnumSet* this, EnumSet s)
{
$if (IS_CHAR_ARRAY)
$if IS_CHAR_ARRAY:
EnumSet copy = *this;
foreach (i, c : s) copy[i] ^= c;
return copy;

View File

@@ -281,7 +281,7 @@ fn void List.ensure_capacity(List* list, usz added = 1) @inline @private
// Functions for equatable types
$if (types::is_equatable_type(Type))
$if types::is_equatable_type(Type):
fn usz! List.index_of(List* list, Type type)
{
@@ -357,7 +357,7 @@ fn void List.remove_all(List* list, List* other_list)
$endif
$if (Type.kindof == POINTER)
$if Type.kindof == POINTER:
/**
* @param [&in] list

View File

@@ -205,7 +205,7 @@ fn Value[] HashMap.value_list(HashMap* map, Allocator* using = mem::heap())
return list;
}
$if (types::is_equatable(Value))
$if types::is_equatable(Value):
fn bool HashMap.has_value(HashMap* map, Value v)
{
if (!map.count) return false;

View File

@@ -230,7 +230,7 @@ $switch
$case $checks(String s = value):
return new_string(value);
$default:
$assert(false, "Unsupported object type.");
$error "Unsupported object type.";
$endswitch
}
@@ -315,7 +315,7 @@ macro get_integer_value(Object* value, $Type)
}
if (value.is_string())
{
$if ($Type.kindof == TypeKind.SIGNED_INT)
$if $Type.kindof == TypeKind.SIGNED_INT:
return ($Type)value.s.to_int128();
$else
return ($Type)value.s.to_uint128();

View File

@@ -37,7 +37,7 @@ struct AlignedBlock
macro void*! @aligned_alloc(#alloc_fn, usz bytes, usz alignment, usz offset)
{
usz header = mem::aligned_offset(AlignedBlock.sizeof + offset, alignment) - offset;
$if ($checks(#alloc_fn(bytes)!))
$if $checks(#alloc_fn(bytes)!):
void* data = #alloc_fn(header + bytes)!;
$else
void* data = #alloc_fn(header + bytes);
@@ -56,7 +56,7 @@ macro void*! @aligned_alloc(#alloc_fn, usz bytes, usz alignment, usz offset)
macro void*! @aligned_calloc(#calloc_fn, usz bytes, usz alignment, usz offset)
{
usz header = mem::aligned_offset(AlignedBlock.sizeof + offset, alignment) - offset;
$if ($checks(#calloc_fn(bytes)!))
$if $checks(#calloc_fn(bytes)!):
void* data = #calloc_fn(header + bytes)!;
$else
void* data = #calloc_fn(header + bytes);
@@ -78,7 +78,7 @@ macro void*! @aligned_realloc(#calloc_fn, #free_fn, void* old_pointer, usz bytes
void* data_start = desc.start;
void* new_data = @aligned_calloc(#calloc_fn, bytes, alignment, offset)!;
mem::copy(new_data, old_pointer, desc.len > bytes ? desc.len : bytes, mem::DEFAULT_MEM_ALIGNMENT, mem::DEFAULT_MEM_ALIGNMENT);
$if ($checks(#free_fn(data_start)!))
$if $checks(#free_fn(data_start)!):
#free_fn(data_start)!;
$else
#free_fn(data_start);
@@ -89,7 +89,7 @@ macro void*! @aligned_realloc(#calloc_fn, #free_fn, void* old_pointer, usz bytes
macro void! @aligned_free(#free_fn, void* old_pointer)
{
AlignedBlock* desc = (AlignedBlock*)old_pointer - 1;
$if ($checks(#free_fn(desc.start)!))
$if $checks(#free_fn(desc.start)!):
#free_fn(desc.start)!;
$else
#free_fn(desc.start);

View File

@@ -78,7 +78,7 @@ struct CallstackElement
fn void default_panic(String message, String file, String function, uint line)
{
CallstackElement* stack = $$stacktrace();
$if ($defined(io::stderr) && $defined(File.printf))
$if $defined(io::stderr) && $defined(File.printf):
if (stack) stack = stack.prev;
if (stack)
@@ -181,7 +181,7 @@ macro enum_by_name($Type, String enum_name) @builtin
**/
macro bool @likely(bool #value, $probability = 1.0) @builtin
{
$if ($probability == 1.0)
$if $probability == 1.0:
return $$expect(#value, true);
$else
return $$expect_with_probability(#value, true, $probability);
@@ -197,7 +197,7 @@ $endif
**/
macro bool @unlikely(bool #value, $probability = 1.0) @builtin
{
$if ($probability == 1.0)
$if $probability == 1.0:
return $$expect(#value, false);
$else
return $$expect_with_probability(#value, false, $probability);
@@ -211,7 +211,7 @@ $endif
**/
macro @expect(#value, expected, $probability = 1.0) @builtin
{
$if ($probability == 1.0)
$if $probability == 1.0:
return $$expect(#value, ($typeof(#value))expected);
$else
return $$expect_with_probability(#value, expected, $probability);

View File

@@ -82,7 +82,7 @@ $endswitch
macro min(x, ...) @builtin
{
$if ($vacount == 1)
$if $vacount == 1:
return less(x, $vaarg(0)) ? x : $vaarg(0);
$else
var result = x;
@@ -98,7 +98,7 @@ macro min(x, ...) @builtin
macro max(x, ...) @builtin
{
$if ($vacount == 1)
$if $vacount == 1:
return greater(x, $vaarg(0)) ? x : $vaarg(0);
$else
var result = x;

View File

@@ -8,13 +8,13 @@ const C_LONG_SIZE = $$C_LONG_SIZE;
const C_SHORT_SIZE = $$C_SHORT_SIZE;
const C_LONG_LONG_SIZE = $$C_LONG_LONG_SIZE;
$assert (C_SHORT_SIZE < 32);
$assert (C_INT_SIZE < 128);
$assert (C_LONG_SIZE < 128);
$assert (C_LONG_LONG_SIZE <= 128);
$assert (C_SHORT_SIZE <= C_INT_SIZE);
$assert (C_INT_SIZE <= C_LONG_SIZE);
$assert (C_LONG_SIZE <= C_LONG_LONG_SIZE);
$assert C_SHORT_SIZE < 32;
$assert C_INT_SIZE < 128;
$assert C_LONG_SIZE < 128;
$assert C_LONG_LONG_SIZE <= 128;
$assert C_SHORT_SIZE <= C_INT_SIZE;
$assert C_INT_SIZE <= C_LONG_SIZE;
$assert C_LONG_SIZE <= C_LONG_LONG_SIZE;
$switch ($$C_INT_SIZE)
$case 64:
@@ -27,7 +27,7 @@ $case 16:
typedef CInt = short;
typedef CUInt = ushort;
$default:
$assert(false, "Invalid C int size");
$error "Invalid C int size";
$endswitch
$switch ($$C_LONG_SIZE)
@@ -41,7 +41,7 @@ $case 16:
typedef CLong = short;
typedef CULong = ushort;
$default:
$assert(false, "Invalid C long size");
$error "Invalid C long size";
$endswitch
$switch ($$C_SHORT_SIZE)
@@ -55,7 +55,7 @@ $case 8:
typedef CShort = ichar;
typedef CUShort = char;
$default:
$assert(false, "Invalid C short size");
$error "Invalid C short size";
$endswitch
$switch ($$C_LONG_LONG_SIZE)
@@ -72,7 +72,7 @@ $case 16:
typedef CLongLong = short;
typedef CULongLong = ushort;
$default:
$assert(false, "Invalid C long long size");
$error "Invalid C long long size";
$endswitch
@@ -80,7 +80,7 @@ $endswitch
typedef CSChar = ichar;
typedef CUChar = char;
$if ($$C_CHAR_IS_SIGNED)
$if $$C_CHAR_IS_SIGNED:
typedef CChar = ichar;
$else
typedef CChar = char;

View File

@@ -308,7 +308,7 @@ macro void DString.append(DString* str, value)
$case @convertible(value, String):
str.append_chars(value);
$default:
$assert(false, "Unsupported type for append use printf instead.");
$error "Unsupported type for append use printf instead.";
$endswitch
$endswitch
}

View File

@@ -177,7 +177,7 @@ macro bool os_is_posix()
**/
fn String! get_var(String name)
{
$if (COMPILER_LIBC_AVAILABLE && !os_is_win32())
$if COMPILER_LIBC_AVAILABLE && !os_is_win32():
@pool()
{
ZString val = libc::getenv(name.zstr_tcopy());
@@ -196,7 +196,7 @@ $endif
**/
fn void set_var(String name, String value, bool overwrite = true)
{
$if (COMPILER_LIBC_AVAILABLE && !os_is_win32())
$if COMPILER_LIBC_AVAILABLE && !os_is_win32():
@pool()
{
if (libc::setenv(name.zstr_tcopy(), value.zstr_copy(), (int)overwrite))
@@ -213,7 +213,7 @@ $endif
**/
fn void clear_var(String name)
{
$if (COMPILER_LIBC_AVAILABLE && !os_is_win32())
$if COMPILER_LIBC_AVAILABLE && !os_is_win32():
@pool()
{
if (libc::unsetenv(name.zstr_tcopy()))

View File

@@ -91,7 +91,7 @@ fn bool ptr_is_aligned(void* ptr, usz alignment) @inline
macro void clear(void* dst, usz len, usz $dst_align = 0, bool $is_volatile = false, bool $inlined = false)
{
$if ($inlined)
$if $inlined:
$$memset_inline(dst, (char)0, len, $is_volatile, $dst_align);
$else
$$memset(dst, (char)0, len, $is_volatile, $dst_align);
@@ -100,7 +100,7 @@ macro void clear(void* dst, usz len, usz $dst_align = 0, bool $is_volatile = fal
macro void copy(void* dst, void* src, usz len, usz $dst_align = 0, usz $src_align = 0, bool $is_volatile = false, bool $inlined = false)
{
$if ($inlined)
$if $inlined:
$$memcpy_inline(dst, src, len, $is_volatile, $dst_align, $src_align);
$else
$$memcpy(dst, src, len, $is_volatile, $dst_align, $src_align);
@@ -114,7 +114,7 @@ macro void move(void* dst, void* src, usz len, usz $dst_align = 0, usz $src_alig
macro void set(void* dst, char val, usz len, usz $dst_align = 0, bool $is_volatile = false, bool $inlined = false)
{
$if ($inlined)
$if $inlined:
$$memset_inline(dst, val, len, $is_volatile, $dst_align);
$else
$$memset(dst, val, len, $is_volatile, $dst_align);
@@ -130,12 +130,12 @@ macro void set(void* dst, char val, usz len, usz $dst_align = 0, bool $is_volati
**/
macro bool equals(a, b, isz len = -1, usz $align = 0)
{
$if (!$align)
$if !$align:
$align = $typeof(a[0]).alignof;
$endif
void* x @noinit;
void* y @noinit;
$if (values::@inner_kind(a) == TypeKind.SUBARRAY)
$if values::@inner_kind(a) == TypeKind.SUBARRAY:
len = a.len;
if (len != b.len) return false;
x = a.ptr;
@@ -206,10 +206,10 @@ macro malloc(..., Allocator* using = mem::heap(), usz end_padding = 0) @builtin
**/
macro malloc_checked(..., Allocator* using = mem::heap(), usz end_padding = 0) @builtin
{
$if ($checks($vatype(0).sizeof))
$if $checks($vatype(0).sizeof):
var $Type = $vatype(0);
$assert(!type_alloc_must_be_aligned($vatype(0)), "Type must be allocated with malloc_aligned");
$if ($vacount == 2)
$assert !type_alloc_must_be_aligned($vatype(0)) : "Type must be allocated with malloc_aligned";
$if $vacount == 2:
usz size = $vaarg(1);
return (($Type*)using.alloc($Type.sizeof * size + end_padding))[:size];
$else
@@ -228,9 +228,9 @@ macro malloc_checked(..., Allocator* using = mem::heap(), usz end_padding = 0) @
**/
macro malloc_aligned(..., usz alignment = 0, usz end_padding = 0, Allocator* using = mem::heap()) @builtin
{
$if ($checks($vatype(0).sizeof))
$if $checks($vatype(0).sizeof):
var $Type = $vatype(0);
$if ($vacount == 2)
$if $vacount == 2:
usz size = $vaarg(1);
return (($Type*)using.alloc_aligned($Type.sizeof * size + end_padding, alignment))[:size];
$else
@@ -256,10 +256,10 @@ macro calloc(..., Allocator* using = mem::heap(), usz end_padding = 0) @builtin
**/
macro calloc_checked(..., Allocator* using = mem::heap(), usz end_padding = 0) @builtin
{
$if ($checks($vatype(0).sizeof))
$if $checks($vatype(0).sizeof):
var $Type = $vatype(0);
$assert(!type_alloc_must_be_aligned($vatype(0)), "Type must be allocated with calloc_aligned");
$if ($vacount == 2)
$assert !type_alloc_must_be_aligned($vatype(0)) : "Type must be allocated with calloc_aligned";
$if $vacount == 2:
usz size = $vaarg(1);
return (($Type*)using.calloc($Type.sizeof * size + end_padding))[:size];
$else
@@ -278,9 +278,9 @@ macro calloc_checked(..., Allocator* using = mem::heap(), usz end_padding = 0) @
**/
macro calloc_aligned(..., usz alignment = 0, Allocator* using = mem::heap(), usz end_padding = 0) @builtin
{
$if ($checks($vatype(0).sizeof))
$if $checks($vatype(0).sizeof):
var $Type = $vatype(0);
$if ($vacount == 2)
$if $vacount == 2:
usz size = $vaarg(1);
return (($Type*)using.calloc_aligned($Type.sizeof * size + end_padding, alignment))[:size];
$else
@@ -331,9 +331,9 @@ macro void @scoped(Allocator* using; @body())
**/
macro tmalloc(..., usz end_padding = 0, usz alignment = DEFAULT_MEM_ALIGNMENT) @builtin
{
$if ($checks($vatype(0).sizeof))
$if $checks($vatype(0).sizeof):
var $Type = $vatype(0);
$if ($vacount == 2)
$if $vacount == 2:
usz size = $vaarg(1);
return (($Type*)temp().alloc_aligned($Type.sizeof * size + end_padding, alignment))[:size]!!;
$else
@@ -350,9 +350,9 @@ macro tmalloc(..., usz end_padding = 0, usz alignment = DEFAULT_MEM_ALIGNMENT) @
**/
macro tcalloc(..., usz end_padding = 0, usz alignment = mem::DEFAULT_MEM_ALIGNMENT) @builtin
{
$if ($checks($vatype(0).sizeof))
$if $checks($vatype(0).sizeof):
var $Type = $vatype(0);
$if ($vacount == 2)
$if $vacount == 2:
usz size = $vaarg(1);
return (($Type*)temp().calloc_aligned($Type.sizeof * size + end_padding, alignment))[:size]!!;
$else
@@ -411,7 +411,7 @@ macro TempAllocator* temp()
macro Allocator* current_allocator() => thread_allocator;
macro Allocator* heap() => thread_allocator;
$if (!env::COMPILER_LIBC_AVAILABLE && env::ARCH_TYPE == ArchType.WASM32 || env::ARCH_TYPE == ArchType.WASM64)
$if !env::COMPILER_LIBC_AVAILABLE && env::ARCH_TYPE == ArchType.WASM32 || env::ARCH_TYPE == ArchType.WASM64:
SimpleHeapAllocator wasm_allocator @private;

View File

@@ -55,7 +55,7 @@ macro int @main_to_void_main_args(#m, int argc, char** argv)
return 0;
}
$if (env::os_is_win32())
$if env::os_is_win32():
extern fn Char16** _win_command_line_to_argv_w(ushort* cmd_line, int* argc_ptr) @extern("CommandLineToArgvW");

View File

@@ -88,7 +88,7 @@ fn bool __run_default_test_runner()
return test_runner_create().run();
}
$if (!env::COMPILER_LIBC_AVAILABLE && env::ARCH_TYPE == ArchType.WASM32 || env::ARCH_TYPE == ArchType.WASM64)
$if !env::COMPILER_LIBC_AVAILABLE && env::ARCH_TYPE == ArchType.WASM32 || env::ARCH_TYPE == ArchType.WASM64:
extern fn void __wasm_call_ctors();
fn void wasm_initialize() @extern("_initialize") @wasm

View File

@@ -460,9 +460,9 @@ macro String.to_real(String chars, $Type) @private
const int BITS = math::DOUBLE_MANT_DIG;
const int EMIN = math::DOUBLE_MIN_EXP - BITS;
$case float128:
$assert(false, "Not yet supported");
$error "Not yet supported";
$default:
$assert(false, "Unexpected type");
$error "Unexpected type";
$endswitch
while (chars.len && chars[0] == ' ') chars = chars[1..];

View File

@@ -77,7 +77,7 @@ macro any_to_int(any v, $Type)
macro bool is_numerical($Type)
{
var $kind = $Type.kindof;
$if ($kind == TypeKind.DISTINCT)
$if $kind == TypeKind.DISTINCT:
return is_numerical($Type.inner);
$else
return $kind == TypeKind.SIGNED_INT || $kind == TypeKind.UNSIGNED_INT || $kind == TypeKind.FLOAT
@@ -98,7 +98,7 @@ macro bool is_indexable($Type)
macro bool is_comparable($Type)
{
var $kind = $Type.kindof;
$if ($kind == TypeKind.DISTINCT)
$if $kind == TypeKind.DISTINCT:
return is_comparable($Type.inner);
$else
return $kind == TypeKind.SIGNED_INT || $kind == TypeKind.UNSIGNED_INT || $kind == TypeKind.FLOAT
@@ -162,7 +162,7 @@ macro bool is_vector($Type)
macro TypeKind inner_kind($Type)
{
$if ($Type.kindof == TypeKind.DISTINCT)
$if $Type.kindof == TypeKind.DISTINCT:
return inner_kind($typefrom($Type.inner));
$else
return $Type.kindof;
@@ -182,11 +182,11 @@ macro bool is_same($TypeA, $TypeB)
macro bool @has_same(#a, #b, ...)
{
var $type_a = $typeof(#a).typeid;
$if ($type_a != $typeof(#b).typeid)
$if $type_a != $typeof(#b).typeid:
return false;
$endif
$for (var $i = 0; $i < $vacount; $i++)
$if ($typeof($vaexpr($i)).typeid != $type_a)
$if $typeof($vaexpr($i)).typeid != $type_a:
return false;
$endif
$endfor
@@ -213,7 +213,7 @@ macro bool is_promotable_to_float($Type) => types::is_float($Type) || types::is_
macro bool is_same_vector_type($Type1, $Type2)
{
$if ($Type1.kindof != TypeKind.VECTOR)
$if $Type1.kindof != TypeKind.VECTOR:
return $Type2.kindof != TypeKind.VECTOR;
$else
return $Type1.inner == $Type2.inner && $Type1.len == $Type2.len;
@@ -222,7 +222,7 @@ macro bool is_same_vector_type($Type1, $Type2)
macro bool is_equatable_type($Type)
{
$if ($defined($Type.less) || $defined($Type.compare_to) || $defined($Type.equals))
$if $defined($Type.less) || $defined($Type.compare_to) || $defined($Type.equals):
return true;
$else
return is_equatable($Type);
@@ -236,7 +236,7 @@ macro bool is_equatable_value(value)
macro bool is_comparable_value(value)
{
$if ($defined(value.less) || $defined(value.compare_to))
$if $defined(value.less) || $defined(value.compare_to):
return true;
$else
return is_comparable($typeof(value));

View File

@@ -12,7 +12,7 @@ macro bool @is_promotable_to_float(#value) => types::is_promotable_to_float($typ
macro bool @is_same_vector_type(#value1, #value2) => types::is_same_vector_type($typeof(#value1), $typeof(#value2));
macro promote_int(x)
{
$if (@is_int(x))
$if @is_int(x):
return (double)x;
$else
return x;

View File

@@ -96,7 +96,7 @@ macro @blk(&block, i) @local
macro @blk0(&block, i) @local
{
$if (env::BIG_ENDIAN)
$if env::BIG_ENDIAN:
return block.l[i];
$else
return block.l[i] = (block.l[i].rotl(24) & 0xFF00FF00)

View File

@@ -63,7 +63,7 @@ macro void print(x)
$case DString:
(void)stdout().print(x.str());
$default:
$if (@convertible(x, String))
$if @convertible(x, String):
(void)stdout().print((String)x);
$else
(void)stdout().printf("%s", x);
@@ -82,7 +82,7 @@ macro void printn(x = "")
$case DString:
(void)stdout().printn(x.str());
$default:
$if (@convertible(x, String))
$if @convertible(x, String):
(void)stdout().printn((String)x);
$else
(void)stdout().printfn("%s", x);

View File

@@ -69,10 +69,10 @@ fn uint128! int_from_any(any arg, bool *is_neg) @private
fn FloatType! float_from_any(any arg) @private
{
$if (env::F128_SUPPORT)
$if env::F128_SUPPORT:
if (arg.type == float128.typeid) return (FloatType)*((float128*)arg.ptr);
$endif
$if (env::F16_SUPPORT)
$if env::F16_SUPPORT:
if (arg.type == float16.typeid) return *((float16*)arg.ptr);
$endif
if (arg.type.kindof == TypeKind.DISTINCT)

View File

@@ -109,7 +109,7 @@ fn void Formatter.init(Formatter* this, OutputFn out_fn, void* data = null)
*/
macro void formatter_register_type($Type)
{
$if ($checks($Type a, a.to_format(&&Formatter {})))
$if $checks($Type a, a.to_format(&&Formatter {})):
if (!toformat_functions.table.len)
{
toformat_functions.init(64);

View File

@@ -9,25 +9,25 @@ typedef FtellFn = fn usz!(void*);
typedef FwriteFn = fn usz!(void*, char[] buffer);
typedef FreadFn = fn usz!(void*, char[] buffer);
$if (!$defined(native_fopen_fn))
$if !$defined(native_fopen_fn):
FopenFn native_fopen_fn @weak;
$endif
$if (!$defined(native_fclose_fn))
$if !$defined(native_fclose_fn):
FcloseFn native_fclose_fn @weak;
$endif
$if (!$defined(native_freopen_fn))
$if !$defined(native_freopen_fn):
FreopenFn native_freopen_fn @weak;
$endif
$if (!$defined(native_fseek_fn))
$if !$defined(native_fseek_fn):
FseekFn native_fseek_fn @weak;
$endif
$if (!$defined(native_ftell_fn))
$if !$defined(native_ftell_fn):
FtellFn native_ftell_fn @weak;
$endif
$if (!$defined(native_fwrite_fn))
$if !$defined(native_fwrite_fn):
FwriteFn native_fwrite_fn @weak;
$endif
$if (!$defined(native_fread_fn))
$if !$defined(native_fread_fn):
FreadFn native_fread_fn @weak;
$endif
@@ -38,13 +38,13 @@ $endif
**/
fn void*! native_fopen(String filename, String mode) @inline
{
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
if (native_fopen_fn) return native_fopen_fn(filename, mode);
unreachable("Tried to call fopen without support.");
$else
@pool()
{
$if (env::os_is_win32())
$if env::os_is_win32():
void* file = (CFile)_wfopen(filename.to_temp_utf16(), filename.to_temp_utf16())!;
$else
void* file = libc::fopen(filename.zstr_tcopy(), mode.zstr_tcopy());
@@ -60,13 +60,13 @@ $endif
**/
fn void*! native_freopen(void* file, String filename, String mode) @inline
{
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
if (native_freopen_fn) return native_freopen_fn(file, filename, mode);
unreachable("Tried to call freopen without support.");
$else
@pool()
{
$if (env::os_is_win32())
$if env::os_is_win32():
file = _wfreopen(filename.to_temp_utf16(), mode.to_temp_utf16(), file)!;
$else
file = libc::freopen(filename.zstr_tcopy(), mode.zstr_tcopy(), file);
@@ -78,11 +78,11 @@ $endif
fn void! native_fseek(void* file, isz offset, Seek seek_mode) @inline
{
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
if (native_fseek_fn) return native_fseek_fn(file, offset, seek_mode);
unreachable("Tried to call fseek without support.");
$else
$if (env::os_is_win32())
$if env::os_is_win32():
bool success = _fseeki64(file, (long)offset, (int)seek_mode) == 0;
$else
bool success = libc::fseek(file, (SeekIndex)offset, (CInt)seek_mode) == 0;
@@ -93,11 +93,11 @@ $endif
fn usz! native_ftell(CFile file) @inline
{
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
if (native_ftell_fn) return native_ftell_fn(file);
unreachable("Tried to call ftell without support.");
$else
$if (env::os_is_win32())
$if env::os_is_win32():
long index = _ftelli64(file);
return index >= 0 ? index : file_seek_errno()?;
$else
@@ -109,7 +109,7 @@ $endif
fn usz! native_fwrite(CFile file, char[] buffer) @inline
{
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
if (native_fwrite_fn) return native_fwrite_fn(file, buffer);
unreachable("Tried to call fwrite without support.");
$else
@@ -119,7 +119,7 @@ $endif
fn usz! native_fread(CFile file, char[] buffer) @inline
{
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
if (native_fread_fn) return native_fread_fn(file, buffer);
unreachable("Tried to call fread without support.");
$else
@@ -175,13 +175,13 @@ macro anyfault file_seek_errno() @local
}
// Win functions
$if (env::os_is_win32())
$if env::os_is_win32():
extern fn void* _wfopen(Char16*, Char16*) @local;
extern fn void* _wfreopen(Char16*, Char16*, CFile) @local;
extern fn int _fseeki64(CFile, long, int) @local;
extern fn long _ftelli64(CFile) @local;
$endif
$if (env::os_is_posix())
$if env::os_is_posix():
extern fn CInt access(ZString path, CInt mode);
$endif

View File

@@ -1,8 +1,7 @@
module std::io::file::os;
import libc;
$if (env::os_is_darwin())
$if env::os_is_darwin():
struct DarwinTimespec @private
{

View File

@@ -1,7 +1,7 @@
module std::io::file::os;
// native_temp_directory, for non Win32
$if (!env::os_is_win32())
$if !env::os_is_win32():
fn Path! native_temp_directory(Allocator* using = mem::heap())
{
@@ -13,7 +13,7 @@ fn Path! native_temp_directory(Allocator* using = mem::heap())
return path::new("/tmp", using);
}
$if (env::COMPILER_LIBC_AVAILABLE)
$if env::COMPILER_LIBC_AVAILABLE:
extern fn void* opendir(ZString);
extern fn void closedir(void*);
@@ -84,7 +84,7 @@ $endif
$endif
$if (!env::os_is_darwin() && !env::os_is_win32())
$if !env::os_is_darwin() && !env::os_is_win32():
fn usz! native_file_size(String path)
{
@@ -93,7 +93,7 @@ fn usz! native_file_size(String path)
return f.seek(0, Seek.END)!;
}
$if (env::os_is_posix() && env::COMPILER_LIBC_AVAILABLE)
$if env::os_is_posix() && env::COMPILER_LIBC_AVAILABLE:
fn bool native_file_or_dir_exists(String path)
{
@@ -142,7 +142,7 @@ $case MACOS:
$case TVOS:
$case WATCHOS:
$if (env::ARCH_TYPE == X86_64)
$if env::ARCH_TYPE == X86_64:
extern fn NativeDirentry* readdir(void*) @extern("readdir$INODE64");
$else
extern fn NativeDirentry* readdir(void*) @extern("readdir");

View File

@@ -1,7 +1,7 @@
module std::io::file::os;
import std::os::win32;
$if (env::os_is_win32())
$if env::os_is_win32():
const Win32_DWORD FILE_ATTRIBUTE_READONLY = 0x01;
const Win32_DWORD FILE_ATTRIBUTE_HIDDEN = 0x02;

View File

@@ -96,7 +96,7 @@ fn bool! rmdir(Path path)
fn void! rmtree(Path path)
{
if (!path.path_string.len) return PathResult.INVALID_PATH?;
$if ($defined(os::native_rmtree))
$if $defined(os::native_rmtree):
return os::native_rmtree(path);
$else
assert(false, "rmtree is not available");

View File

@@ -35,7 +35,7 @@ typedef TerminateFunction = fn void();
typedef CompareFunction = fn int(void*, void*);
typedef JmpBuf = uptr[$$JMP_BUF_SIZE];
$if (env::COMPILER_LIBC_AVAILABLE)
$if env::COMPILER_LIBC_AVAILABLE:
extern fn double atof(char* str);
extern fn int atoi(char* str);
@@ -59,7 +59,7 @@ extern fn int rand();
extern fn void srand(uint seed);
extern fn void longjmp(JmpBuf* buffer, CInt value);
$if (env::os_is_win32())
$if env::os_is_win32():
// TODO win32 aarch64
extern fn CInt _setjmp(void* frameptr, JmpBuf* buffer);
macro CInt setjmp(JmpBuf* buffer) => _setjmp($$frameaddress(), buffer);
@@ -205,7 +205,7 @@ const int FILENAME_MAX = 1024;
typedef Errno = distinct CInt;
typedef SeekIndex = CLong;
$if (env::COMPILER_LIBC_AVAILABLE)
$if env::COMPILER_LIBC_AVAILABLE:
extern fn int fclose(CFile stream);
extern fn void clearerr(CFile stream);
@@ -370,7 +370,7 @@ struct Tm
$endswitch
$if (env::os_is_win32())
$if env::os_is_win32():
struct TimeSpec
{
@@ -411,7 +411,7 @@ extern fn Tm* gmtime(Time_t *timer);
extern fn Tm* localtime(Time_t *timer);
$if (env::os_is_win32())
$if env::os_is_win32():
extern fn Tm* _gmtime64_s(Tm* buf, Time_t *timer);
extern fn Tm* _localtime64_s(Tm* buf, Time_t *timer);
extern fn void _get_timezone(CLong *timezone);
@@ -451,7 +451,7 @@ const Errno ENOEXEC = 8; // Exec format error
const Errno EBADF = 9; // Bad file number
const Errno ECHILD = 10; // No child processes
$if (env::OS_TYPE == MACOS)
$if env::os_is_darwin():
const Errno EAGAIN = 35; // Try again Macos
$else
const Errno EAGAIN = 11; // Try again

View File

@@ -120,7 +120,7 @@ macro abs(x) => $$abs(x);
macro sign(x)
{
var $Type = $typeof(x);
$if ($Type.kindof == TypeKind.UNSIGNED_INT)
$if $Type.kindof == TypeKind.UNSIGNED_INT:
return ($Type)(x > 0);
$else
return ($Type)(x > 0) - ($Type)(x < 0);
@@ -134,7 +134,7 @@ macro sign(x)
**/
macro atan2(x, y)
{
$if (@typeis(x, float) && @typeis(y, float))
$if @typeis(x, float) && @typeis(y, float):
return _atan2f(x, y);
$else
return _atan2(x, y);
@@ -148,7 +148,7 @@ macro atan2(x, y)
**/
macro @sincos(x, y)
{
$if ($typeof(y[0]).typeid == float.typeid)
$if $typeof(y[0]).typeid == float.typeid:
return _sincosf(x, y);
$else
return _sincos(x, y);
@@ -161,7 +161,7 @@ macro @sincos(x, y)
**/
macro atan(x)
{
$if ($typeof(x).typeid == float.typeid)
$if $typeof(x).typeid == float.typeid:
return _atanf(x);
$else
return _atan(x);
@@ -276,7 +276,7 @@ macro log10(x) => $$log10(values::promote_int(x));
**/
macro max(x, y, ...)
{
$if ($vacount == 0)
$if $vacount == 0:
return $$max(x, y);
$else
var m = $$max(x, y);
@@ -293,7 +293,7 @@ macro max(x, y, ...)
**/
macro min(x, y, ...)
{
$if ($vacount == 0)
$if $vacount == 0:
return $$min(x, y);
$else
var m = $$min(x, y);
@@ -321,7 +321,7 @@ macro nearbyint(x) => $$nearbyint(x);
**/
macro pow(x, exp)
{
$if (types::is_floatlike($typeof(exp)))
$if types::is_floatlike($typeof(exp)):
return $$pow(x, ($typeof(x))exp);
$else
return $$pow_int(x, exp);
@@ -333,7 +333,7 @@ macro pow(x, exp)
**/
macro frexp(x, int* e)
{
$switch($typeof(x))
$switch ($typeof(x))
$case float:
$case float16:
return _frexpf((float)x, e);
@@ -347,7 +347,7 @@ macro frexp(x, int* e)
**/
macro int signbit(x)
{
$switch($typeof(x))
$switch ($typeof(x))
$case float:
$case float16:
return bitcast((float)x, uint) >> 31;
@@ -422,7 +422,7 @@ $endswitch
**/
macro bool is_finite(x)
{
$switch($typeof(x))
$switch ($typeof(x))
$case float:
$case float16:
return bitcast((float)x, uint) & 0x7fffffff < 0x7f800000;

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/k_cos.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/k_cosf.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/k_sin.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/k_sinf.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/k_tan.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/k_tanf.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc::atan;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
const double[*] ATANHI @private = {
4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
fn double _ceil(double x) @weak @extern("ceil") @nostrip
{

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
fn float _cosf(float x) @extern("cosf") @weak @nostrip
{

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
macro uint _top12f(float x) @private => bitcast(x, uint) >> 20;

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
fn double _floor(double x) @weak @extern("floor") @nostrip
{

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
fn float powf_broken(float x, float f) @extern("powf") @weak @nostrip
{

View File

@@ -1,7 +1,7 @@
module std::math::nolibc;
import std::math;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/e_rem_pio2f.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
fn double _round(double x) @extern("round") @weak @nostrip
{

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
fn double _scalbn(double x, int n) @weak @extern("scalbn") @nostrip
{

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
/* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */
/*

View File

@@ -1,6 +1,6 @@
module std::math::nolibc::trig;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
fn double sincos_broken(double x) @extern("sincos") @weak @nostrip
{

View File

@@ -1,6 +1,6 @@
module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE)
$if !env::COMPILER_LIBC_AVAILABLE:
fn double _trunc(double x) @weak @extern("trunc") @nostrip
{

View File

@@ -217,7 +217,7 @@ return v;
var view_proj = m1.mul(m2);
var invert = view_proj.invert();
// Create quaternion from source point
$if ($typeof(v[0]).typeid == float.typeid)
$if $typeof(v[0]).typeid == float.typeid:
Quaternionf quat = { v.x, v.y, v.z, 1 };
$else
Quaternion quat = { v.x, v.y, v.z, 1 };

View File

@@ -1,8 +1,8 @@
module std::net::os;
$if ($defined(PLATFORM_AF_INET))
$if $defined(PLATFORM_AF_INET):
$if (!$defined(PLATFORM_O_NONBLOCK))
$if !$defined(PLATFORM_O_NONBLOCK):
const PLATFORM_O_NONBLOCK = 0;
$endif

View File

@@ -1,7 +1,7 @@
module std::net::os;
import libc;
$if (env::os_is_darwin())
$if env::os_is_darwin():
const AI_NUMERICSERV = 0x1000;
const AI_ALL = 0x100;

View File

@@ -1,7 +1,7 @@
module std::net::os;
import libc;
$if (env::OS_TYPE == LINUX)
$if env::OS_TYPE == LINUX:
struct AddrInfo
{

View File

@@ -1,7 +1,7 @@
module std::net::os;
import libc;
$if (env::os_is_win32() && $defined(AddrInfo))
$if env::os_is_win32() && $defined(AddrInfo):
const int F_GETFL = 3;
const int F_SETFL = 4;

View File

@@ -1,6 +1,6 @@
module std::net::os;
$if (env::os_is_win32())
$if env::os_is_win32():
const int PLATFORM_AF_INET = 1;
const int PLATFORM_AF_IPX = 6;

View File

@@ -1,6 +1,6 @@
module std::os::macos::cf;
$if (env::os_is_darwin())
$if env::os_is_darwin():
typedef CFAllocatorRef = distinct void*;
typedef CFAllocatorContextRef = distinct void*;

View File

@@ -1,6 +1,6 @@
module std::os::macos::cf;
$if (env::os_is_darwin())
$if env::os_is_darwin():
typedef CFArrayRef = distinct void*;
typedef CFArrayCallBacksRef = distinct void*;

View File

@@ -1,6 +1,6 @@
module std::os::macos::cf;
$if (env::os_is_darwin())
$if env::os_is_darwin():
typedef CFTypeRef = distinct void*;
typedef CFIndex = isz;

View File

@@ -1,6 +1,6 @@
module std::os::macos::objc;
$if (env::os_is_darwin())
$if env::os_is_darwin():
typedef Class = distinct void*;
typedef Method = distinct void*;

View File

@@ -1,6 +1,6 @@
module std::os::posix;
$if (env::os_is_posix() && env::COMPILER_LIBC_AVAILABLE)
$if env::os_is_posix() && env::COMPILER_LIBC_AVAILABLE:
extern fn int rmdir(ZString);
extern fn int mkdir(ZString, ushort mode_t);

View File

@@ -1,6 +1,6 @@
module std::os::win32;
$if (env::os_is_win32())
$if env::os_is_win32():
enum Win32_GET_FILEEX_INFO_LEVELS
{

View File

@@ -1,6 +1,6 @@
module std::os::win32;
$if (env::os_is_win32())
$if env::os_is_win32():
extern fn Win32_DWORD win32_GetLastError() @extern("GetLastError");

View File

@@ -1,6 +1,6 @@
module std::os::win32;
$if (env::os_is_win32())
$if env::os_is_win32():
extern fn bool win32_CreateProcessW(
Win32_LPCWSTR lpApplicationName,

View File

@@ -2,7 +2,7 @@ module std::os::win32;
typedef WSAError = distinct int;
$if (env::os_is_win32())
$if env::os_is_win32():
extern fn WSAError win32_WSAGetLastError() @extern("WSAGetLastError");
extern fn void win32_WSASetLastError(WSAError error) @extern("WSASetLastError");
@@ -10,7 +10,7 @@ $endif
module std::os::win32::wsa;
$if (env::os_is_win32())
$if env::os_is_win32():
const WSAError INVALID_HANDLE = 6;
const WSAError NOT_ENOUGHT_MEMORY = 8;
const WSAError INVALID_PARAMETER = 87;

View File

@@ -1,7 +1,7 @@
module std::thread::os;
import libc;
$if (thread::THREAD_MODEL == ThreadModel.POSIX)
$if thread::THREAD_MODEL == ThreadModel.POSIX:
const PTHREAD_MUTEX_NORMAL = 0;
const PTHREAD_MUTEX_ERRORCHECK = 1;
@@ -14,7 +14,7 @@ typedef NativeOnceFlag = PthreadOnce;
typedef Pthread = distinct void*;
$if (env::OS_TYPE == LINUX)
$if env::OS_TYPE == LINUX:
typedef PthreadMutex = distinct ulong[5];
typedef PthreadAttribute = distinct ulong[7];
typedef PthreadMutexAttribute = distinct uint;

View File

@@ -1,6 +1,6 @@
module std::thread::os;
$if (thread::THREAD_MODEL == ThreadModel.WIN32)
$if thread::THREAD_MODEL == ThreadModel.WIN32:
typedef NativeThread = Win32_HANDLE;

View File

@@ -2,7 +2,7 @@ module std::time::clock;
fn Clock now()
{
$if ($defined(native_clock))
$if $defined(native_clock):
return os::native_clock();
$else
return 0;

View File

@@ -36,10 +36,10 @@ fn TzDateTime DateTime.to_local(DateTime* this)
dt.weekday = !tm.tm_wday ? Weekday.SUNDAY : (Weekday)tm.tm_wday + 1;
dt.year_day = (ushort)tm.tm_yday;
dt.time = this.time;
$if ($defined(tm.tm_gmtoff))
$if $defined(tm.tm_gmtoff):
dt.gmt_offset = (int)tm.tm_gmtoff;
$else
$assert($defined(libc::_get_timezone));
$assert $defined(libc::_get_timezone);
CLong timezone;
libc::_get_timezone(&timezone);
dt.gmt_offset = (int)-timezone;

View File

@@ -1,6 +1,6 @@
module std::time::os;
$if (env::os_is_darwin())
$if env::os_is_darwin():
struct Darwin_mach_timebase_info
{

View File

@@ -1,7 +1,7 @@
module std::time::os;
import libc;
$if (env::os_is_posix() && env::COMPILER_LIBC_AVAILABLE)
$if env::os_is_posix() && env::COMPILER_LIBC_AVAILABLE:
$switch (env::OS_TYPE)
$case OPENBSD:
@@ -76,7 +76,7 @@ fn Time native_timestamp()
return (Time)(ts.s * 1_000_000i64 + ts.ns / 1_000i64);
}
$if (!env::os_is_darwin())
$if !env::os_is_darwin():
fn Clock native_clock()
{
TimeSpec ts;

View File

@@ -1,7 +1,7 @@
module std::time::os;
import std::os::win32;
$if (env::os_is_win32() && env::COMPILER_LIBC_AVAILABLE)
$if env::os_is_win32() && env::COMPILER_LIBC_AVAILABLE:
extern fn void win32_GetSystemTimeAsFileTime(Win32_FILETIME* time) @extern("GetSystemTimeAsFileTime");
extern fn Win32_BOOL win32_QueryPerformanceFrequency(Win32_LARGE_INTEGER* lpFrequency) @extern("QueryPerformanceFrequency");

View File

@@ -61,7 +61,7 @@ enum Month : char
fn Time now()
{
$if ($defined(native_timestamp))
$if $defined(native_timestamp):
return os::native_timestamp();
$else
return 0;