Fix foreach body copy. Moved deref / addr into special functions. Cleaned up access. Remove .sizeof .alignof .qnameof .nameof, create $qnameof $nameof

This commit is contained in:
Christoffer Lerno
2021-07-25 23:01:54 +02:00
committed by Christoffer Lerno
parent 2815a6d02e
commit 9f42ddb68d
18 changed files with 296 additions and 122 deletions

View File

@@ -40,7 +40,7 @@ private func void LinkedList.linkFirst(LinkedList *list, Type value)
private func void LinkedList.linkLast(LinkedList *list, Type value)
{
Node *last = list.last;
Node *new_node = mem::alloc(Node.sizeof);
Node *new_node = mem::alloc($sizeof(Node));
*new_node = { .prev = last, .value = value };
list.last = new_node;
if (!last)

View File

@@ -13,7 +13,7 @@ private func void List.ensureCapacity(List *list) @inline
if (list.capacity == list.size)
{
list.capacity = list.capacity ? 2 * list.capacity : 16;
list.entries = mem::realloc(list.entries, Type.sizeof * list.capacity);
list.entries = mem::realloc(list.entries, $sizeof(Type) * list.capacity);
}
}

View File

@@ -114,7 +114,7 @@ Allocator main_allocator = { &system_malloc_function, null };
macro malloc($Type)
{
return ($Type*)(mem::alloc($Type.sizeof));
return ($Type*)(mem::alloc($sizeof($Type)));
}
func void* alloc(usize size, usize elements = 1) @inline