Add code generation for array

This commit is contained in:
2025-05-04 23:26:03 +01:00
parent f444911452
commit 12f083edb0
18 changed files with 4466 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
u64 allocation_size = sizeof({ArrayType}) + sizeof({T}) * capacity;
{ArrayType} *array = NULL;
if (!allocator) {{
goto RETURN_{Tupper}_ARRAY_ALLOC;
}}
array = wapp_mem_allocator_alloc(allocator, allocation_size);
if (!array) {{
goto RETURN_{Tupper}_ARRAY_ALLOC;
}}
array->items = ({T} *)((u8 *)array + sizeof({ArrayType}));
array->count = 0;
array->capacity = capacity;
RETURN_{Tupper}_ARRAY_ALLOC:
return array;