1
0
Fork 0
forked from AbleOS/ableos

migrating to new hblang syntax

Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
Jakub Doka 2024-12-20 11:37:06 +01:00
parent f8523f5b3e
commit f6bfb73bd7
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
10 changed files with 64 additions and 53 deletions

24
Cargo.lock generated
View file

@ -213,25 +213,35 @@ dependencies = [
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#969ea57e3f677ae12b0b5031ad1da8711c71d634"
[[package]]
name = "hbbytecode"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#8ad58ee6b626736d7660713a5a29f590463b0e41"
[[package]] [[package]]
name = "hblang" name = "hblang"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#969ea57e3f677ae12b0b5031ad1da8711c71d634"
dependencies = [ dependencies = [
"hashbrown", "hashbrown",
"hbbytecode", "hbbytecode 0.1.0",
"hbvm", "hbvm 0.1.0",
"log", "log",
] ]
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#969ea57e3f677ae12b0b5031ad1da8711c71d634"
dependencies = [ dependencies = [
"hbbytecode", "hbbytecode 0.1.0",
]
[[package]]
name = "hbvm"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#8ad58ee6b626736d7660713a5a29f590463b0e41"
dependencies = [
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
] ]
[[package]] [[package]]
@ -391,7 +401,7 @@ dependencies = [
"crossbeam-queue", "crossbeam-queue",
"derive_more", "derive_more",
"hashbrown", "hashbrown",
"hbvm", "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
"ktest_macro", "ktest_macro",
"limine", "limine",
"log", "log",

View file

@ -14,8 +14,8 @@ fatfs = { version = "0.3", default-features = false, features = [
"alloc", "alloc",
] } ] }
toml = "0.8" toml = "0.8"
hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git" #hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
#hblang.path = "../../holey-bytes/lang/" hblang.path = "../../holey-bytes/lang/"
log = "0.4" log = "0.4"
raw-cpuid = "11" raw-cpuid = "11"
ureq = { version = "2", default-features = false, features = ["tls"] } ureq = { version = "2", default-features = false, features = ["tls"] }

View file

@ -29,7 +29,7 @@ create_window := fn(channel: int): ^render.Surface {
x := 0 x := 0
loop if x > 1000 break else x += 1 loop if x > 1000 break else x += 1
ret := buffer.recv([u8; 4096], windowing_system_buffer, mem_buf) ret := buffer.recv([4096]u8, windowing_system_buffer, mem_buf)
if ret == null { if ret == null {
log.info("No messages\0") log.info("No messages\0")
} }
@ -40,4 +40,4 @@ create_window := fn(channel: int): ^render.Surface {
return @as(^render.Surface, idk) return @as(^render.Surface, idk)
} }
} }

View file

@ -45,7 +45,7 @@ from := fn(qoi: ^u8): ?Surface {
} }
surface := Surface.new(width, height) surface := Surface.new(width, height)
index := @as([Color; 64], idk) index := @as([64]Color, idk)
run := 0 run := 0
px := Color.(0, 0, 0, 255) px := Color.(0, 0, 0, 255)
@ -98,4 +98,4 @@ from := fn(qoi: ^u8): ?Surface {
} }
return surface return surface
} }

View file

@ -47,10 +47,10 @@ fmt_int := fn(v: @Any(), str: ^u8, radix: @TypeOf(v)): uint {
fmt_bool := fn(v: bool, str: ^u8): uint { fmt_bool := fn(v: bool, str: ^u8): uint {
if v { if v {
*@as(^[u8; 4], @bitcast(str)) = *@bitcast("true\0") *@as(^[4]u8, @bitcast(str)) = *@bitcast("true\0")
return 4 return 4
} else { } else {
*@as(^[u8; 5], @bitcast(str)) = *@bitcast("false\0") *@as(^[5]u8, @bitcast(str)) = *@bitcast("false\0")
return 5 return 5
} }
} }
@ -120,27 +120,27 @@ fmt_float := fn(v: @Any(), str: ^u8, precision: uint, radix: int): uint {
fmt_container := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint { fmt_container := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
T2 := @TypeOf(v) T2 := @TypeOf(v)
i := 0; i := 0;
*@as(^[u8; @len(@nameof(T2))], @bitcast(str)) = *@bitcast(@nameof(T2)) *@as(^[@lenof(@nameof(T2))]u8, @bitcast(str)) = *@bitcast(@nameof(T2))
len := @len(@nameof(T2)); len := @lenof(@nameof(T2));
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0") *@as(^[2]u8, @bitcast(str + len)) = *@bitcast(".(\0")
len += 2 len += 2
$loop { $loop {
v_sub := v[i] v_sub := v[i]
len += @inline(format, v_sub, str + len, opts) len += @inline(format, v_sub, str + len, opts)
i += 1 i += 1
if i == @len(T2) break else { if i == @lenof(T2) break else {
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(", \0") *@as(^[2]u8, @bitcast(str + len)) = *@bitcast(", \0")
len += 2 len += 2
} }
}; };
*@as(^[u8; 1], @bitcast(str + len)) = *@bitcast(")\0") *@as(^[1]u8, @bitcast(str + len)) = *@bitcast(")\0")
len += 1 len += 1
return len return len
} }
fmt_nullable := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint { fmt_nullable := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
if v == null { if v == null {
*@as(^[u8; 4], @bitcast(str)) = *@bitcast("null\0") *@as(^[4]u8, @bitcast(str)) = *@bitcast("null\0")
return 4 return 4
} else { } else {
return @inline(format, @as(@ChildOf(@TypeOf(v)), v), str, opts) return @inline(format, @as(@ChildOf(@TypeOf(v)), v), str, opts)
@ -149,12 +149,12 @@ fmt_nullable := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
fmt_enum := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint { fmt_enum := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
T := @TypeOf(v) T := @TypeOf(v)
len := @len(@nameof(T)); len := @lenof(@nameof(T));
*@as(^[u8; @len(@nameof(T))], @bitcast(str)) = *@bitcast(@nameof(T)); *@as(^[@lenof(@nameof(T))]u8, @bitcast(str)) = *@bitcast(@nameof(T));
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0") *@as(^[2]u8, @bitcast(str + len)) = *@bitcast(".(\0")
len += 2 len += 2
len += @inline(fmt_int, @as(usize(T), @bitcast(v)), str + len, 10); len += @inline(fmt_int, @as(usize(T), @bitcast(v)), str + len, 10);
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(")\0") *@as(^[2]u8, @bitcast(str + len)) = *@bitcast(")\0")
return len + 2 return len + 2
} }
@ -198,4 +198,4 @@ FormatOptions := struct {
radix: uint = 10, radix: uint = 10,
// temporarily here, will change later maybe // temporarily here, will change later maybe
log: LogLevel = .Info, log: LogLevel = .Info,
} }

View file

@ -27,6 +27,7 @@ panic := fn(message: ?^u8): never {
Kind := enum { Kind := enum {
Builtin, Builtin,
Struct, Struct,
Tuple,
Enum, Enum,
Union, Union,
Pointer, Pointer,
@ -68,4 +69,4 @@ $bits := fn($T: type): usize(T) {
$bitmask := fn($T: type): usize(T) { $bitmask := fn($T: type): usize(T) {
return -1 return -1
} }

View file

@ -1,19 +1,19 @@
stn := @use("../../../libraries/stn/src/lib.hb"); stn := @use("../../../libraries/stn/src/lib.hb");
.{string, memory, buffer, log} := stn .{string, memory, buffer, log} := stn
VALID_JUMP_BYTES := [u8].(0xEB, 0x3C, 0x90) VALID_JUMP_BYTES := u8.[0xEB, 0x3C, 0x90]
OemIdent := struct { OemIdent := struct {
dos_version: [u8; 8], dos_version: [8]u8,
dos_version_name: [u8; 8], dos_version_name: [8]u8,
new := fn(major: int, minor: int): OemIdent { new := fn(major: int, minor: int): OemIdent {
return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0)) return .(.[0, 0, 0, 0, 0, 0, 0, 0], .[0, 0, 0, 0, 0, 0, 0, 0])
} }
} }
BiosParameterBlock := struct { BiosParameterBlock := struct {
jump_bytes: [u8; 3], jump_bytes: [3]u8,
oem_ident: OemIdent, oem_ident: OemIdent,
bytes_per_sector: u16, bytes_per_sector: u16,
sectors_per_cluster: u8, sectors_per_cluster: u8,
@ -53,16 +53,16 @@ FatVersionNumber := struct {
minor_version: u8, minor_version: u8,
} }
FormatReservation := [u8; 12] FormatReservation := [12]u8
// Padded with spaces. // Padded with spaces.
VolumeName := [u8; 11] VolumeName := [11]u8
SystemIdentifierString := [u8; 8] SystemIdentifierString := [8]u8
VALID_SYSTEM_IDENTIFIER_STRING := [u8].(46, 41, 54, 33, 32, 20, 20, 20) VALID_SYSTEM_IDENTIFIER_STRING := u8.[46, 41, 54, 33, 32, 20, 20, 20]
BOOTABLE_PARTITION_SIGNATURE := @as(u32, 0xAA55) BOOTABLE_PARTITION_SIGNATURE := @as(u32, 0xAA55)
BootCode := [u8; 420] BootCode := [420]u8
ExtendedBootRecord := struct { ExtendedBootRecord := struct {
sectors_per_fat: u32, sectors_per_fat: u32,
@ -104,10 +104,10 @@ ExtendedBootRecord := struct {
} }
new := fn(): ExtendedBootRecord { new := fn(): ExtendedBootRecord {
version := FatVersionNumber.(0, 0) version := u8.[0, 0]
fmt_res := FormatReservation.(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) fmt_res := u8.[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
vol_name := @as([u8; 11], idk) vol_name := @as([11]u8, idk)
boot_code := @as([u8; 420], idk) boot_code := @as([420]u8, idk)
return ExtendedBootRecord.( return ExtendedBootRecord.(
0, 0,
@ -135,11 +135,11 @@ VALID_TRAIL_FS_INFO := @as(u32, 0xAA550000)
FSInfo := struct { FSInfo := struct {
// Must be 0x41615252 to indicate a valid FSInfo structure // Must be 0x41615252 to indicate a valid FSInfo structure
lead_signature: u32, lead_signature: u32,
lead_reserved: [u8; 480], lead_reserved: [480]u8,
// If the value is 0xFFFFFFFF, then the free count is unknown and must be computed. However, this value might be incorrect and should at least be range checked (<= volume cluster count) // If the value is 0xFFFFFFFF, then the free count is unknown and must be computed. However, this value might be incorrect and should at least be range checked (<= volume cluster count)
last_known_free_cluster_count: u32, last_known_free_cluster_count: u32,
last_known_avalible_cluster: u32, last_known_avalible_cluster: u32,
trail_reserved: [u8; 12], trail_reserved: [12]u8,
trail_signature: u32, trail_signature: u32,
sanity_check := fn(fs_info: FSInfo): uint { sanity_check := fn(fs_info: FSInfo): uint {
@ -165,8 +165,8 @@ FSInfo := struct {
} }
new := fn(): FSInfo { new := fn(): FSInfo {
lead_reserved := @as([u8; 480], idk) lead_reserved := @as([480]u8, idk)
trail_reserved := @as([u8; 12], idk) trail_reserved := @as([12]u8, idk)
return FSInfo.( return FSInfo.(
VALID_LEAD_FS_INFO, VALID_LEAD_FS_INFO,
lead_reserved, lead_reserved,
@ -176,4 +176,4 @@ FSInfo := struct {
VALID_TRAIL_FS_INFO, VALID_TRAIL_FS_INFO,
) )
} }
} }

View file

@ -1,7 +1,7 @@
attributes := @use("attributes.hb") attributes := @use("attributes.hb")
datetime := @use("datetime.hb") datetime := @use("datetime.hb")
FileName := [u8; 11] FileName := [11]u8
// This is the File Allocation Table entry that tells us where on disk the File is. // This is the File Allocation Table entry that tells us where on disk the File is.
FileEntry := struct { FileEntry := struct {
@ -18,4 +18,4 @@ FileEntry := struct {
last_modification_date: datetime.date, last_modification_date: datetime.date,
low_cluster_number: u16, low_cluster_number: u16,
file_size: u32, file_size: u32,
} }

View file

@ -7,7 +7,7 @@ $Reboot := State.(1)
Port := packed struct { Port := packed struct {
exists: bool, exists: bool,
device: DeviceID, device: DeviceID,
packet: [u8; 8], packet: [8]u8,
packet_length: u8, packet_length: u8,
can_hot_plug: bool, can_hot_plug: bool,
} }
@ -18,4 +18,4 @@ $PORT_AT_STARTUP := Port.(
.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0),
0, 0,
true, true,
) )

View file

@ -24,10 +24,10 @@ test := fn(): uint {
log.print(SubStructThingy.(-math.E, false), .{}) log.print(SubStructThingy.(-math.E, false), .{})
log.print(Color.{r: 255, g: 254, b: 253, a: 252}, .{radix: 2}) log.print(Color.{r: 255, g: 254, b: 253, a: 252}, .{radix: 2})
log.print(@as(f64, math.LN_2), .{radix: 16, decimal_digits: 1 << 32}) log.print(@as(f64, math.LN_2), .{radix: 16, decimal_digits: 1 << 32})
log.print([u8].(1, 2, 3), .{}) log.print(u8.[1, 2, 3], .{})
log.print(&SubStructThingy.(0.0, true), .{}) log.print(&SubStructThingy.(0.0, true), .{})
log.print(@as(?u32, null), .{}) log.print(@as(?u32, null), .{})
log.print(@as(?u32, 200), .{}) log.print(@as(?u32, 200), .{})
return 0 return 0
} }