update hblang

This commit is contained in:
koniifer 2025-03-09 17:25:31 +00:00
parent c7bb6be547
commit b63583af53
3 changed files with 6 additions and 6 deletions

2
build
View file

@ -8,7 +8,7 @@ readonly LILY_TEST_DIR="${LILY_TEST_DIR:-$LILY_SCRIPT_DIR/test}"
readonly LILY_BUILD_DIR="${LILY_BUILD_DIR:-$LILY_SCRIPT_DIR/out}"
readonly HBLANG_GIT="https://git.ablecorp.us/mlokis/hblang"
readonly HBLANG_COMMIT="925fe0e0340bf5154cb1fa075a562d8826031526"
readonly HBLANG_COMMIT="092e75aca33fc3ca8a4ab2f9affddad9b803eed9"
readonly HBLANG_CFLAGS="--path-projection lily $LILY_SRC_DIR/lib.hb ${HBLANG_CFLAGS:-}"
die() { error "$2" && exit "$1"; }

View file

@ -9,11 +9,11 @@ main := fn(): void {
// i := 0
// loop if i == 5 break else {
// // 24 = @size_of(AllocationHeader)
// if alloc.Arena.alloc(&arena, u8, target.page_len() - 24) == null die
// if arena.alloc(u8, target.page_len() - 24) == null die
// i += 1
// }
b = alloc.Arena.alloc_zeroed(&arena, u8, 1000).?
b = arena.alloc_zeroed(u8, 1000).?
mem.bytes(mem.reverse("Hello, World!")[1..]).take(5).for_each(fn(x: u8): void {
len := fmt.fmt_int(b, x, 16)

View file

@ -56,8 +56,7 @@ Arena := struct {
return @as(^T, @bit_cast(@as(^u8, @bit_cast(header + 1)) + header.len - size))[0..count]
}
$alloc_zeroed := fn(self: ^Self, $T: type, count: uint): ?[]T {
// todo: change back after struct method fix
slice := Self.alloc(self, T, count)
self.alloc(T, count)
if slice == null return null
mem.set(slice.?.ptr, 0, slice.?.len)
return slice
@ -66,7 +65,8 @@ Arena := struct {
@error("todo: ", Self.realloc)
return null
}
$dealloc := fn(self: ^Self, $T: type, ptr: ^T): void {}
$dealloc := fn(self: ^Self, $T: type, ptr: ^T): void {
}
deinit := fn(self: ^Self): void {
if self.allocation == null {
lily.log.error("fixme: double free arena. can't fix due to compiler.")