- $foreach "()" replaced by trailing ":" $foreach ($x, $y : $foo) -> $foreach $x, $y : $foo:

- `$for` "()" replaced by trailing ":" `$for (var $x = 0; $x < FOO; $x++)` -> `$for var $x = 0; $x < FOO; $x++:`
- `$switch` "()" replaced by trailing ":" `$switch ($Type)` -> `$switch $Type:`
- Empty `$switch` requires trailing ":" `$switch` -> `$switch:`
This commit is contained in:
Christoffer Lerno
2025-03-04 16:13:06 +01:00
parent 46b52ec9ce
commit 2439405e70
65 changed files with 149 additions and 149 deletions

View File

@@ -25,7 +25,7 @@ macro usz binarysearch(list, x, cmp = EMPTY_MACRO_SLOT, context = EMPTY_MACRO_SL
}
$else
$switch
$switch:
$case $defined(cmp(list[0], list[0], context)):
int res = cmp(list[half], x, context);
$case $defined(cmp(list[0], list[0])):

View File

@@ -65,7 +65,7 @@ fn void csort(Type list, usz low, usz high, KeyFn key_fn, uint byte_idx)
for (usz i = low; i < high; i++)
{
$switch
$switch:
$case NO_KEY_FN:
KeyFnReturnType k = list[i];
$case KEY_BY_VALUE:
@@ -129,7 +129,7 @@ fn void csort(Type list, usz low, usz high, KeyFn key_fn, uint byte_idx)
sorted_count += (e - s);
for (; s < e; s++)
{
$switch
$switch:
$case NO_KEY_FN:
KeyFnReturnType k = list[low + s];
$case KEY_BY_VALUE:

View File

@@ -35,7 +35,7 @@ fn void isort(Type list, usz low, usz high, CmpFn comp, Context context)
$if $has_get_ref:
ElementType *rhs = &list[j];
ElementType *lhs = &list[--j];
$switch
$switch:
$case $cmp_by_value && $has_context:
if (comp(*rhs, *lhs, context) >= 0) break;
$case $cmp_by_value:
@@ -51,7 +51,7 @@ fn void isort(Type list, usz low, usz high, CmpFn comp, Context context)
$else
usz r = j;
--j;
$switch
$switch:
$case $cmp_by_value && $has_context:
if (comp(list[r], list[j], context) >= 0) break;
$case $cmp_by_value:

View File

@@ -120,7 +120,7 @@ macro @partition(Type list, isz l, isz h, CmpFn cmp, Context context)
ElementType pivot = list[l];
while (l < h)
{
$switch
$switch:
$case $cmp_by_value && $has_context:
while (cmp(list[h], pivot, context) >= 0 && l < h) h--;
if (l < h) list[l++] = list[h];

View File

@@ -11,7 +11,7 @@ macro usz len_from_list(list)
macro bool @is_sortable(#list)
{
$switch
$switch:
$case !$defined(#list[0]):
return false;
$case !$defined(#list.len):
@@ -34,7 +34,7 @@ macro bool @is_valid_cmp_fn(#cmp, #list, #context)
{
var $Type = $typeof(#cmp);
var $no_context = @is_empty_macro_slot(#context);
$switch
$switch:
$case @is_empty_macro_slot(#cmp): return true;
$case $Type.kindof != FUNC ||| $Type.returns.kindof != SIGNED_INT: return false;
$case $defined(#cmp(#list[0], #list[0], #context)): return true;
@@ -47,7 +47,7 @@ macro bool @is_valid_cmp_fn(#cmp, #list, #context)
macro bool @is_cmp_key_fn(#key_fn, #list)
{
$switch
$switch:
$case @is_empty_macro_slot(#key_fn): return true;
$case $typeof(#key_fn).kindof != FUNC: return false;
$case $typeof(#key_fn).returns.kindof != UNSIGNED_INT: return false;

View File

@@ -44,7 +44,7 @@ macro int @sort_cmp(list, pos, cmp, ctx) @local
var a = list[pos];
var b = list[pos+1];
$switch
$switch:
$case $cmp_by_value && $has_context:
return cmp(a, b);
$case $cmp_by_value: