forked from AbleOS/ableos
migrating to new hblang syntax
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
f8523f5b3e
commit
f6bfb73bd7
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -213,25 +213,35 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
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]]
|
||||
name = "hblang"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#969ea57e3f677ae12b0b5031ad1da8711c71d634"
|
||||
dependencies = [
|
||||
"hashbrown",
|
||||
"hbbytecode",
|
||||
"hbvm",
|
||||
"hbbytecode 0.1.0",
|
||||
"hbvm 0.1.0",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hbvm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#969ea57e3f677ae12b0b5031ad1da8711c71d634"
|
||||
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]]
|
||||
|
@ -391,7 +401,7 @@ dependencies = [
|
|||
"crossbeam-queue",
|
||||
"derive_more",
|
||||
"hashbrown",
|
||||
"hbvm",
|
||||
"hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
||||
"ktest_macro",
|
||||
"limine",
|
||||
"log",
|
||||
|
|
|
@ -14,8 +14,8 @@ fatfs = { version = "0.3", default-features = false, features = [
|
|||
"alloc",
|
||||
] }
|
||||
toml = "0.8"
|
||||
hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
|
||||
#hblang.path = "../../holey-bytes/lang/"
|
||||
#hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
|
||||
hblang.path = "../../holey-bytes/lang/"
|
||||
log = "0.4"
|
||||
raw-cpuid = "11"
|
||||
ureq = { version = "2", default-features = false, features = ["tls"] }
|
||||
|
|
|
@ -29,7 +29,7 @@ create_window := fn(channel: int): ^render.Surface {
|
|||
x := 0
|
||||
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 {
|
||||
log.info("No messages\0")
|
||||
}
|
||||
|
@ -40,4 +40,4 @@ create_window := fn(channel: int): ^render.Surface {
|
|||
|
||||
return @as(^render.Surface, idk)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ from := fn(qoi: ^u8): ?Surface {
|
|||
}
|
||||
|
||||
surface := Surface.new(width, height)
|
||||
index := @as([Color; 64], idk)
|
||||
index := @as([64]Color, idk)
|
||||
|
||||
run := 0
|
||||
px := Color.(0, 0, 0, 255)
|
||||
|
@ -98,4 +98,4 @@ from := fn(qoi: ^u8): ?Surface {
|
|||
}
|
||||
|
||||
return surface
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,10 +47,10 @@ fmt_int := fn(v: @Any(), str: ^u8, radix: @TypeOf(v)): uint {
|
|||
|
||||
fmt_bool := fn(v: bool, str: ^u8): uint {
|
||||
if v {
|
||||
*@as(^[u8; 4], @bitcast(str)) = *@bitcast("true\0")
|
||||
*@as(^[4]u8, @bitcast(str)) = *@bitcast("true\0")
|
||||
return 4
|
||||
} else {
|
||||
*@as(^[u8; 5], @bitcast(str)) = *@bitcast("false\0")
|
||||
*@as(^[5]u8, @bitcast(str)) = *@bitcast("false\0")
|
||||
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 {
|
||||
T2 := @TypeOf(v)
|
||||
i := 0;
|
||||
*@as(^[u8; @len(@nameof(T2))], @bitcast(str)) = *@bitcast(@nameof(T2))
|
||||
len := @len(@nameof(T2));
|
||||
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0")
|
||||
*@as(^[@lenof(@nameof(T2))]u8, @bitcast(str)) = *@bitcast(@nameof(T2))
|
||||
len := @lenof(@nameof(T2));
|
||||
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(".(\0")
|
||||
len += 2
|
||||
$loop {
|
||||
v_sub := v[i]
|
||||
len += @inline(format, v_sub, str + len, opts)
|
||||
i += 1
|
||||
if i == @len(T2) break else {
|
||||
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(", \0")
|
||||
if i == @lenof(T2) break else {
|
||||
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(", \0")
|
||||
len += 2
|
||||
}
|
||||
};
|
||||
*@as(^[u8; 1], @bitcast(str + len)) = *@bitcast(")\0")
|
||||
*@as(^[1]u8, @bitcast(str + len)) = *@bitcast(")\0")
|
||||
len += 1
|
||||
return len
|
||||
}
|
||||
|
||||
fmt_nullable := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
||||
if v == null {
|
||||
*@as(^[u8; 4], @bitcast(str)) = *@bitcast("null\0")
|
||||
*@as(^[4]u8, @bitcast(str)) = *@bitcast("null\0")
|
||||
return 4
|
||||
} else {
|
||||
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 {
|
||||
T := @TypeOf(v)
|
||||
len := @len(@nameof(T));
|
||||
*@as(^[u8; @len(@nameof(T))], @bitcast(str)) = *@bitcast(@nameof(T));
|
||||
*@as(^[u8; 2], @bitcast(str + len)) = *@bitcast(".(\0")
|
||||
len := @lenof(@nameof(T));
|
||||
*@as(^[@lenof(@nameof(T))]u8, @bitcast(str)) = *@bitcast(@nameof(T));
|
||||
*@as(^[2]u8, @bitcast(str + len)) = *@bitcast(".(\0")
|
||||
len += 2
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -198,4 +198,4 @@ FormatOptions := struct {
|
|||
radix: uint = 10,
|
||||
// temporarily here, will change later maybe
|
||||
log: LogLevel = .Info,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ panic := fn(message: ?^u8): never {
|
|||
Kind := enum {
|
||||
Builtin,
|
||||
Struct,
|
||||
Tuple,
|
||||
Enum,
|
||||
Union,
|
||||
Pointer,
|
||||
|
@ -68,4 +69,4 @@ $bits := fn($T: type): usize(T) {
|
|||
|
||||
$bitmask := fn($T: type): usize(T) {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, log} := stn
|
||||
|
||||
VALID_JUMP_BYTES := [u8].(0xEB, 0x3C, 0x90)
|
||||
VALID_JUMP_BYTES := u8.[0xEB, 0x3C, 0x90]
|
||||
|
||||
OemIdent := struct {
|
||||
dos_version: [u8; 8],
|
||||
dos_version_name: [u8; 8],
|
||||
dos_version: [8]u8,
|
||||
dos_version_name: [8]u8,
|
||||
|
||||
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 {
|
||||
jump_bytes: [u8; 3],
|
||||
jump_bytes: [3]u8,
|
||||
oem_ident: OemIdent,
|
||||
bytes_per_sector: u16,
|
||||
sectors_per_cluster: u8,
|
||||
|
@ -53,16 +53,16 @@ FatVersionNumber := struct {
|
|||
minor_version: u8,
|
||||
}
|
||||
|
||||
FormatReservation := [u8; 12]
|
||||
FormatReservation := [12]u8
|
||||
|
||||
// Padded with spaces.
|
||||
VolumeName := [u8; 11]
|
||||
VolumeName := [11]u8
|
||||
|
||||
SystemIdentifierString := [u8; 8]
|
||||
VALID_SYSTEM_IDENTIFIER_STRING := [u8].(46, 41, 54, 33, 32, 20, 20, 20)
|
||||
SystemIdentifierString := [8]u8
|
||||
VALID_SYSTEM_IDENTIFIER_STRING := u8.[46, 41, 54, 33, 32, 20, 20, 20]
|
||||
BOOTABLE_PARTITION_SIGNATURE := @as(u32, 0xAA55)
|
||||
|
||||
BootCode := [u8; 420]
|
||||
BootCode := [420]u8
|
||||
|
||||
ExtendedBootRecord := struct {
|
||||
sectors_per_fat: u32,
|
||||
|
@ -104,10 +104,10 @@ ExtendedBootRecord := struct {
|
|||
}
|
||||
|
||||
new := fn(): ExtendedBootRecord {
|
||||
version := FatVersionNumber.(0, 0)
|
||||
fmt_res := FormatReservation.(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
vol_name := @as([u8; 11], idk)
|
||||
boot_code := @as([u8; 420], idk)
|
||||
version := u8.[0, 0]
|
||||
fmt_res := u8.[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
vol_name := @as([11]u8, idk)
|
||||
boot_code := @as([420]u8, idk)
|
||||
|
||||
return ExtendedBootRecord.(
|
||||
0,
|
||||
|
@ -135,11 +135,11 @@ VALID_TRAIL_FS_INFO := @as(u32, 0xAA550000)
|
|||
FSInfo := struct {
|
||||
// Must be 0x41615252 to indicate a valid FSInfo structure
|
||||
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)
|
||||
last_known_free_cluster_count: u32,
|
||||
last_known_avalible_cluster: u32,
|
||||
trail_reserved: [u8; 12],
|
||||
trail_reserved: [12]u8,
|
||||
trail_signature: u32,
|
||||
|
||||
sanity_check := fn(fs_info: FSInfo): uint {
|
||||
|
@ -165,8 +165,8 @@ FSInfo := struct {
|
|||
}
|
||||
|
||||
new := fn(): FSInfo {
|
||||
lead_reserved := @as([u8; 480], idk)
|
||||
trail_reserved := @as([u8; 12], idk)
|
||||
lead_reserved := @as([480]u8, idk)
|
||||
trail_reserved := @as([12]u8, idk)
|
||||
return FSInfo.(
|
||||
VALID_LEAD_FS_INFO,
|
||||
lead_reserved,
|
||||
|
@ -176,4 +176,4 @@ FSInfo := struct {
|
|||
VALID_TRAIL_FS_INFO,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
attributes := @use("attributes.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.
|
||||
FileEntry := struct {
|
||||
|
@ -18,4 +18,4 @@ FileEntry := struct {
|
|||
last_modification_date: datetime.date,
|
||||
low_cluster_number: u16,
|
||||
file_size: u32,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ $Reboot := State.(1)
|
|||
Port := packed struct {
|
||||
exists: bool,
|
||||
device: DeviceID,
|
||||
packet: [u8; 8],
|
||||
packet: [8]u8,
|
||||
packet_length: u8,
|
||||
can_hot_plug: bool,
|
||||
}
|
||||
|
@ -18,4 +18,4 @@ $PORT_AT_STARTUP := Port.(
|
|||
.(0, 0, 0, 0, 0, 0, 0, 0),
|
||||
0,
|
||||
true,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -24,10 +24,10 @@ test := fn(): uint {
|
|||
log.print(SubStructThingy.(-math.E, false), .{})
|
||||
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([u8].(1, 2, 3), .{})
|
||||
log.print(u8.[1, 2, 3], .{})
|
||||
log.print(&SubStructThingy.(0.0, true), .{})
|
||||
log.print(@as(?u32, null), .{})
|
||||
log.print(@as(?u32, 200), .{})
|
||||
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue