diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afa6ffdf6..f23d79bd5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -184,7 +184,7 @@ jobs: fail-fast: false matrix: build_type: [Release, Debug] - llvm_version: [15, 16] + llvm_version: [16] steps: - uses: actions/checkout@v3 diff --git a/lib/std/core/allocators/dynamic_arena.c3 b/lib/std/core/allocators/dynamic_arena.c3 index 8804d18cd..e880ada38 100644 --- a/lib/std/core/allocators/dynamic_arena.c3 +++ b/lib/std/core/allocators/dynamic_arena.c3 @@ -17,19 +17,19 @@ struct DynamicArenaAllocator * @require page_size >= 128 * @require this != null **/ -fn void DynamicArenaAllocator.init(DynamicArenaAllocator* this, usz page_size, Allocator* backing_allocator = mem::heap()) +fn void DynamicArenaAllocator.init(DynamicArenaAllocator* this, usz page_size, Allocator* using = mem::heap()) { this.function = &dynamic_arena_allocator_function; this.page = null; this.unused_page = null; this.page_size = page_size; - this.backing_allocator = backing_allocator; + this.backing_allocator = using; } /** * @require this != null **/ -fn void DynamicArenaAllocator.destroy(DynamicArenaAllocator* this) +fn void DynamicArenaAllocator.free(DynamicArenaAllocator* this) { DynamicArenaPage* page = this.page; while (page) @@ -67,7 +67,7 @@ struct DynamicArenaChunk @local * @require ptr && this * @require this.page `tried to free pointer on invalid allocator` */ -fn void DynamicArenaAllocator.free(DynamicArenaAllocator* this, void* ptr) @private +fn void DynamicArenaAllocator.free_ptr(DynamicArenaAllocator* this, void* ptr) @private { DynamicArenaPage* current_page = this.page; if (ptr == current_page.last_ptr) @@ -226,7 +226,7 @@ fn void*! dynamic_arena_allocator_function(Allocator* data, usz size, usz alignm if (!size) { if (!old_pointer) return null; - allocator.free(old_pointer); + allocator.free_ptr(old_pointer); return null; } if (!old_pointer) return allocator._alloc(size, alignment, offset); @@ -235,7 +235,7 @@ fn void*! dynamic_arena_allocator_function(Allocator* data, usz size, usz alignm case ALIGNED_FREE: case FREE: if (!old_pointer) return null; - allocator.free(old_pointer); + allocator.free_ptr(old_pointer); return null; case MARK: unreachable("Tried to mark a dynamic arena"); diff --git a/lib/std/core/allocators/temp_allocator.c3 b/lib/std/core/allocators/temp_allocator.c3 index 4a0a26af8..58a5b4ff4 100644 --- a/lib/std/core/allocators/temp_allocator.c3 +++ b/lib/std/core/allocators/temp_allocator.c3 @@ -37,12 +37,12 @@ macro bool TempAllocatorPage.is_aligned(TempAllocatorPage* page) => page.size & /** * @require size >= 16 **/ -fn TempAllocator*! new_temp(usz size, Allocator* backing_allocator) +fn TempAllocator*! new_temp(usz size, Allocator* using) { - TempAllocator* allocator = malloc_checked(TempAllocator, .using = backing_allocator, .end_padding = size)!; + TempAllocator* allocator = malloc_checked(TempAllocator, .using = using, .end_padding = size)!; allocator.last_page = null; allocator.function = &temp_allocator_function; - allocator.backing_allocator = backing_allocator; + allocator.backing_allocator = using; allocator.used = 0; allocator.capacity = size; return allocator; diff --git a/lib/std/core/allocators/tracking_allocator.c3 b/lib/std/core/allocators/tracking_allocator.c3 index 22176955b..8efc5beab 100644 --- a/lib/std/core/allocators/tracking_allocator.c3 +++ b/lib/std/core/allocators/tracking_allocator.c3 @@ -24,10 +24,10 @@ struct TrackingAllocator * * @require this != null **/ -fn void TrackingAllocator.init(TrackingAllocator* this, Allocator* allocator) +fn void TrackingAllocator.init(TrackingAllocator* this, Allocator* using) { - *this = { .inner_allocator = allocator, .allocator.function = &tracking_allocator_fn }; - this.map.init(.using = allocator); + *this = { .inner_allocator = using, .allocator.function = &tracking_allocator_fn }; + this.map.init(.using = using); } fn void TrackingAllocator.free(TrackingAllocator* this) diff --git a/lib/std/io/io_file.c3 b/lib/std/io/io_file.c3 index 22bb9545e..2298c1930 100644 --- a/lib/std/io/io_file.c3 +++ b/lib/std/io/io_file.c3 @@ -109,7 +109,7 @@ fn usz! File.write(File file, char[] buffer) * @param [&in] file * @require file.file `File must be initialized` */ -fn usz! File.printn(File file, String string) +fn usz! File.printn(File file, String string = "") { usz len = file.print(string)!; if (!libc::putc('\n', file.file)) return IoError.UNKNOWN_ERROR?; diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index f435bfadc..67244b377 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -329,7 +329,7 @@ struct Type_ void *backend_debug_type; union { - // Error, Struct, Union, Typedef, Member + // Error, Struct, Union, Typedef, Member, Bitstruct Decl *decl; // int, float, bool TypeBuiltin builtin; @@ -341,8 +341,6 @@ struct Type_ Type *pointer; // Optional Type *optional; - // Bitstruct - Type *bitstruct; }; }; diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 4903282a8..6fd4adb48 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -1162,6 +1162,9 @@ static bool cast_from_array(SemaContext *context, Expr *expr, Type *from, Type * // Len must be checked. if (to->array.len != from->array.len) return sema_error_cannot_convert(expr, to_type, false, silent); break; + case TYPE_BITSTRUCT: + if (to->decl->bitstruct.base_type->type->canonical == from) return cast_with_optional(expr, to_type, add_optional); + FALLTHROUGH; default: // No other conversions are allowed. return sema_error_cannot_convert(expr, to_type, false, silent); @@ -1891,6 +1894,11 @@ static bool cast_inner(Expr *expr, Type *from_type, Type *to, Type *to_type) return false; case TYPE_ARRAY: if (to->type_kind == TYPE_VECTOR) return array_to_vector(expr, to_type); + if (to->type_kind == TYPE_BITSTRUCT) + { + expr->type = to_type; + return true; + } FALLTHROUGH; case TYPE_STRUCT: case TYPE_UNION: diff --git a/src/version.h b/src/version.h index 0a403ab1b..038f60e30 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.507" \ No newline at end of file +#define COMPILER_VERSION "0.4.508" \ No newline at end of file