ableos/sysdata/libraries/stn/src/lib.hb
Jakub Doka f6bfb73bd7
migrating to new hblang syntax
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
2024-12-20 11:37:06 +01:00

73 lines
1.3 KiB
Plaintext

acs := @use("acs.hb")
allocators := @use("alloc/lib.hb")
fmt := @use("fmt.hb")
hashers := @use("hash/lib.hb")
string := @use("string.hb")
log := @use("log.hb")
memory := @use("memory.hb")
buffer := @use("buffer.hb")
math := @use("math.hb")
random := @use("random.hb")
file := @use("file_io.hb")
dt := @use("dt.hb")
process := @use("process.hb")
sleep := @use("sleep.hb")
// todo: replace with comptime message (for zero cost)
panic := fn(message: ?^u8): never {
log.error("Error: Panic Called, Message:\0")
if message == null {
log.error("None\0")
} else {
log.error(message)
}
die
}
Kind := enum {
Builtin,
Struct,
Tuple,
Enum,
Union,
Pointer,
Slice,
Opt,
Function,
Template,
Global,
Const,
Module,
$of := fn($T: type): Self {
return @bitcast(@kindof(T))
}
}
$unsigned_int := fn($T: type): bool {
return T == uint | T == u8 | T == u16 | T == u32
}
$signed_int := fn($T: type): bool {
return T == int | T == i8 | T == i16 | T == i32
}
$integer := fn($T: type): bool {
return unsigned_int(T) | signed_int(T)
}
$float := fn($T: type): bool {
return T == f32 | T == f64
}
$usize := fn($T: type): type {
if @sizeof(T) == 1 return u8 else if @sizeof(T) == 2 return u16 else if @sizeof(T) == 4 return u32 else return uint
}
$bits := fn($T: type): usize(T) {
return @sizeof(T) << 3
}
$bitmask := fn($T: type): usize(T) {
return -1
}