Correctly apply fixup to switch macros. Addresses new issue in #862. Updates @pool.

This commit is contained in:
Christoffer Lerno
2023-07-19 11:38:18 +02:00
parent 5c2e82fc8b
commit 5aae9f3204
4 changed files with 816 additions and 5 deletions

View File

@@ -393,14 +393,13 @@ macro void @stack_pool(usz $size; @body) @builtin
};
}
macro void @pool(...; @body) @builtin
macro void @pool(TempAllocator* #other_temp = null; @body) @builtin
{
bool $has_arg = $vacount == 1;
assert($vacount <= 1);
TempAllocator* current = temp();
var $has_arg = !$checks(var $x = #other_temp);
$if $has_arg:
TempAllocator* original = current;
if (current == $vaarg(0)) current = temp_allocator_next();
if (current == #other_temp) current = temp_allocator_next();
$endif
usz mark = current.used;
defer