Fixes to lib7, added parallel test structure.

This commit is contained in:
Christoffer Lerno
2025-02-23 13:53:04 +01:00
parent 3a1aa8bdf0
commit 4f72bc4be9
1228 changed files with 63192 additions and 56 deletions

View File

@@ -160,28 +160,12 @@ fn void ElasticArray.add_array(&self, Type[] array)
<*
IMPORTANT The returned array must be freed using free_aligned.
*>
fn Type[] ElasticArray.to_new_aligned_array(&self)
{
return list_common::list_to_new_aligned_array(Type, self, allocator::heap());
}
<* <*
IMPORTANT The returned array must be freed using free_aligned. IMPORTANT The returned array must be freed using free_aligned.
*> *>
fn Type[] ElasticArray.to_aligned_array(&self, Allocator allocator) fn Type[] ElasticArray.to_aligned_array(&self, Allocator allocator)
{ {
return list_common::list_to_new_aligned_array(Type, self, allocator); return list_common::list_to_aligned_array(Type, self, allocator);
}
<*
@require !type_is_overaligned() : "This function is not available on overaligned types"
*>
macro Type[] ElasticArray.to_new_array(&self)
{
return list_common::list_to_array(Type, self, allocator::heap());
} }
<* <*
@@ -189,7 +173,7 @@ macro Type[] ElasticArray.to_new_array(&self)
*> *>
macro Type[] ElasticArray.to_array(&self, Allocator allocator) macro Type[] ElasticArray.to_array(&self, Allocator allocator)
{ {
return list_common::list_to_new_array(Type, self, allocator); return list_common::list_to_array(Type, self, allocator);
} }
fn Type[] ElasticArray.to_tarray(&self) fn Type[] ElasticArray.to_tarray(&self)

View File

@@ -23,8 +23,8 @@
module std::collections::priorityqueue{Type}; module std::collections::priorityqueue{Type};
import std::collections::priorityqueue::private; import std::collections::priorityqueue::private;
distinct PriorityQueue = inline List{Type}; distinct PriorityQueue = inline PrivatePriorityQueue{Type, false};
distinct PriorityQueueMax = inline List{Type}; distinct PriorityQueueMax = inline PrivatePriorityQueue{Type, true};
module std::collections::priorityqueue::private{Type, MAX}; module std::collections::priorityqueue::private{Type, MAX};
import std::collections::list, std::io; import std::collections::list, std::io;
@@ -68,13 +68,13 @@ fn void PrivatePriorityQueue.push(&self, Type element)
} }
<* <*
@require index < self.len : "Index out of range" @require index < self.len() : "Index out of range"
*> *>
fn void PrivatePriorityQueue.remove_at(&self, usz index) fn void PrivatePriorityQueue.remove_at(&self, usz index)
{ {
if (index == 0) if (index == 0)
{ {
self.heap.remove_last(); self.pop()!!;
return; return;
} }
self.heap.remove_at(index); self.heap.remove_at(index);

View File

@@ -4,6 +4,31 @@
module std::core::builtin; module std::core::builtin;
import libc, std::hash, std::io, std::os::backtrace; import libc, std::hash, std::io, std::os::backtrace;
<*
EMPTY_MACRO_SLOT is a value used for implementing optional arguments for macros in an efficient
way. It relies on the fact that distinct types are not implicitly convertable.
You can use `@is_empty_macro_slot()` and `@is_valid_macro_slot()` to figure out whether
the argument has been used or not.
An example:
```c3
macro foo(a, #b = EMPTY_MACRO_SLOT)
{
$if @is_valid_macro_slot(#b):
return invoke_foo2(a, #b);
$else
return invoke_foo1(a);
$endif
}
*>
const EmptySlot EMPTY_MACRO_SLOT @builtin = null;
distinct EmptySlot = void*;
macro @is_empty_macro_slot(#arg) @const @builtin => @typeis(#arg, EmptySlot);
macro @is_valid_macro_slot(#arg) @const @builtin => !@typeis(#arg, EmptySlot);
/* /*
Use `IteratorResult` when reading the end of an iterator, or accessing a result out of bounds. Use `IteratorResult` when reading the end of an iterator, or accessing a result out of bounds.
*/ */
@@ -67,7 +92,7 @@ fn bool print_backtrace(String message, int backtraces_to_ignore) @if(env::NATIV
void*[256] buffer; void*[256] buffer;
void*[] backtraces = backtrace::capture_current(&buffer); void*[] backtraces = backtrace::capture_current(&buffer);
backtraces_to_ignore++; backtraces_to_ignore++;
BacktraceList! backtrace = backtrace::symbolize_backtrace(allocator::temp(), backtraces); BacktraceList! backtrace = backtrace::symbolize_backtrace(tmem(), backtraces);
if (catch backtrace) return false; if (catch backtrace) return false;
if (backtrace.len() <= backtraces_to_ignore) return false; if (backtrace.len() <= backtraces_to_ignore) return false;
io::eprint("\nERROR: '"); io::eprint("\nERROR: '");
@@ -413,10 +438,6 @@ macro uint String.hash(String c) => (uint)fnv32a::encode(c);
macro uint char[].hash(char[] c) => (uint)fnv32a::encode(c); macro uint char[].hash(char[] c) => (uint)fnv32a::encode(c);
macro uint void*.hash(void* ptr) => @generic_hash(((ulong)(uptr)ptr)); macro uint void*.hash(void* ptr) => @generic_hash(((ulong)(uptr)ptr));
distinct EmptySlot = void*;
const EmptySlot EMPTY_MACRO_SLOT @builtin = null;
macro @is_empty_macro_slot(#arg) @builtin => @typeis(#arg, EmptySlot);
macro @is_valid_macro_slot(#arg) @builtin => !@typeis(#arg, EmptySlot);
const MAX_FRAMEADDRESS = 128; const MAX_FRAMEADDRESS = 128;
<* <*

View File

@@ -27,7 +27,7 @@ import std::time, std::os, std::io;
fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Allocator allocator) fn PathList! native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Allocator allocator)
{ {
PathList list; PathList list;
list.new_init(allocator: allocator); list.init(allocator);
@pool(allocator) @pool(allocator)
{ {

Some files were not shown because too many files have changed in this diff Show More