forked from AbleOS/ableos
printf, various syntax updates, better string manipulation miscellaneous changes
This commit is contained in:
parent
c9601fae4a
commit
96dc726c35
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -213,12 +213,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4b3b6af70eb84d513b9fa926dd8c36e1dba88713"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#418fd0039eda7fd4052c8086373b1e1257d573c8"
|
||||
|
||||
[[package]]
|
||||
name = "hblang"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4b3b6af70eb84d513b9fa926dd8c36e1dba88713"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#418fd0039eda7fd4052c8086373b1e1257d573c8"
|
||||
dependencies = [
|
||||
"hashbrown",
|
||||
"hbbytecode",
|
||||
|
@ -229,7 +229,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbvm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#4b3b6af70eb84d513b9fa926dd8c36e1dba88713"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#418fd0039eda7fd4052c8086373b1e1257d573c8"
|
||||
dependencies = [
|
||||
"hbbytecode",
|
||||
]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.{Kind, usize, string, signed_int, float, integer, memory, panic, log: .{LogLevel}} := @use("stn")
|
||||
.{Kind, usize, string, signed_int, panic, float, integer, memory, log: .{LogLevel}} := @use("stn")
|
||||
|
||||
fmt_int := fn(v: @Any(), str: ^u8, radix: @TypeOf(v)): uint {
|
||||
is_negative := signed_int(@TypeOf(v)) & v < 0
|
||||
|
@ -199,7 +199,14 @@ FormatOptions := struct {
|
|||
format := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
||||
T := @TypeOf(v)
|
||||
match Kind.of(T) {
|
||||
.Pointer => return @inline(fmt_int, @as(uint, @bitcast(v)), str, 16),
|
||||
.Pointer => if T != ^u8 return @inline(fmt_int, @as(uint, @bitcast(v)), str, 16) else {
|
||||
i := 0
|
||||
loop if *(v + i) == '\0' break else {
|
||||
*(str + i) = *(v + i)
|
||||
i += 1
|
||||
}
|
||||
return i
|
||||
},
|
||||
.Builtin => {
|
||||
if integer(T) {
|
||||
return @inline(fmt_int, v, str, @intcast(opts.radix))
|
||||
|
@ -217,3 +224,56 @@ format := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
|||
_ => @error("Type: \"\0", T, "\" is not supported.\0"),
|
||||
}
|
||||
}
|
||||
|
||||
format_with_str := fn(v: @Any(), read: ^u8, write: ^u8, opts: FormatOptions): uint {
|
||||
T := @TypeOf(v)
|
||||
n := string.count(read, '{')
|
||||
if n != string.count(read, '}') panic("Missing closing '}' in format string.\0")
|
||||
if Kind.of(T) == .Tuple {
|
||||
if @lenof(T) != n panic("Format string has different number of '{}' than args given.\0")
|
||||
m := 0
|
||||
i := 0
|
||||
j := 0
|
||||
$loop if m > @lenof(T) break else {
|
||||
if m == @lenof(T) {
|
||||
loop if *(read + i) == '\0' break else {
|
||||
*(write + j) = *(read + i)
|
||||
i += 1
|
||||
j += 1
|
||||
}
|
||||
m += 1
|
||||
} else {
|
||||
v2 := v[m]
|
||||
loop if *(read + i) == '\0' break else {
|
||||
if *(read + i) == '{' & *(read + i + 1) == '}' {
|
||||
j += format(v2, write + j, opts) + 1
|
||||
i += 2
|
||||
break
|
||||
} else {
|
||||
*(write + j) = *(read + i)
|
||||
i += 1
|
||||
j += 1
|
||||
}
|
||||
}
|
||||
m += 1
|
||||
}
|
||||
}
|
||||
return j
|
||||
} else if n > 1 {
|
||||
panic("Format string has multiple '{}' but value provided is not a tuple.\0")
|
||||
} else {
|
||||
i := 0
|
||||
j := 0
|
||||
loop if *(read + i) == '\0' break else {
|
||||
if *(read + i) == '{' & *(read + i + 1) == '}' {
|
||||
j += format(v, write + j, opts) + 1
|
||||
i += 2
|
||||
} else {
|
||||
*(write + j) = *(read + i)
|
||||
i += 1
|
||||
j += 1
|
||||
}
|
||||
}
|
||||
return j
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ $ARBITRARY6 := 0xC0AC29B7C97C50DD
|
|||
$ARBITRARY7 := 0x3F84D5B5B5470917
|
||||
$ARBITRARY8 := 0x9216D5D98979FB1B
|
||||
$ARBITRARY9 := 0xD1310BA698DFB5AC
|
||||
$FIXED_GLOBAL_SEED := [uint].(ARBITRARY4, ARBITRARY5, ARBITRARY6, ARBITRARY7)
|
||||
$FIXED_GLOBAL_SEED := uint.[ARBITRARY4, ARBITRARY5, ARBITRARY6, ARBITRARY7]
|
||||
|
||||
global_seed := 0
|
||||
|
||||
|
@ -103,7 +103,7 @@ hash_bytes_long := fn(bytes: ^u8, len: uint, s0: uint, s1: uint, s2: uint, s3: u
|
|||
|
||||
if remainder > 0 {
|
||||
remainder_start := bytes + len - math.max(uint, remainder, 16)
|
||||
return hash_bytes_medium(remainder_start, math.max(uint, remainder, 16), s0, s1, fold_seed)
|
||||
return @inline(hash_bytes_medium, remainder_start, math.max(uint, remainder, 16), s0, s1, fold_seed)
|
||||
}
|
||||
|
||||
return s0 ^ s1
|
||||
|
@ -159,17 +159,9 @@ FoldHasher := struct {
|
|||
}
|
||||
self.accumulator = folded_multiply(s0, s1)
|
||||
} else if len < 256 {
|
||||
self.accumulator = hash_bytes_medium(bytes, len, s0, s1, self.fold_seed)
|
||||
self.accumulator = @inline(hash_bytes_medium, bytes, len, s0, s1, self.fold_seed)
|
||||
} else {
|
||||
self.accumulator = hash_bytes_long(
|
||||
bytes,
|
||||
len,
|
||||
s0,
|
||||
s1,
|
||||
self.expand_seed2,
|
||||
self.expand_seed3,
|
||||
self.fold_seed,
|
||||
)
|
||||
self.accumulator = @inline(hash_bytes_long, bytes, len, s0, s1, self.expand_seed2, self.expand_seed3, self.fold_seed)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,8 @@ 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)
|
||||
}
|
||||
log.printf("HBLang Panic: {}\0", message, .{log: .Error})
|
||||
die
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,6 @@ trace := fn(message: ^u8): void return @inline(log, LogLevel.Trace, message)
|
|||
print_buffer := memory.dangling(u8)
|
||||
|
||||
print := fn(v: @Any(), opts: fmt.FormatOptions): void {
|
||||
if @TypeOf(v) == ^u8 {
|
||||
@inline(log, opts.log, v)
|
||||
return
|
||||
}
|
||||
if print_buffer == memory.dangling(u8) {
|
||||
print_buffer = memory.request_page(1)
|
||||
}
|
||||
|
@ -34,3 +30,12 @@ print := fn(v: @Any(), opts: fmt.FormatOptions): void {
|
|||
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
||||
memory.set(u8, &0, print_buffer, memory.PAGE_SIZE)
|
||||
}
|
||||
|
||||
printf := fn(str: ^u8, v: @Any(), opts: fmt.FormatOptions): void {
|
||||
if print_buffer == memory.dangling(u8) {
|
||||
print_buffer = memory.request_page(1)
|
||||
}
|
||||
len := @inline(fmt.format_with_str, v, str, print_buffer, opts)
|
||||
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
||||
memory.set(u8, &0, print_buffer, memory.PAGE_SIZE)
|
||||
}
|
|
@ -1,41 +1,10 @@
|
|||
.{log, memory} := @use("stn")
|
||||
|
||||
length := fn(ptr: ^u8): uint {
|
||||
len := 0
|
||||
loop if *(ptr + len) == 0 return len else len += 1
|
||||
}
|
||||
|
||||
display_int := fn(num: int, p: ^u8, radix: uint): ^u8 {
|
||||
is_negative := num < 0
|
||||
if is_negative num = -num
|
||||
|
||||
ptr := p
|
||||
|
||||
if num == 0 {
|
||||
*ptr = 0x30;
|
||||
*(ptr + 1) = 0
|
||||
return p
|
||||
}
|
||||
|
||||
loop if num == 0 break else {
|
||||
remainder := num % @bitcast(radix)
|
||||
num /= @bitcast(radix);
|
||||
*ptr = @intcast(remainder + 0x30)
|
||||
if remainder > 9 {
|
||||
*ptr = @intcast(remainder - 10 + 0x41)
|
||||
}
|
||||
ptr += 1
|
||||
}
|
||||
|
||||
if is_negative {
|
||||
*ptr = 0x2D
|
||||
ptr += 1
|
||||
}
|
||||
// ! it gets broked when you do this ??
|
||||
// *ptr = 0
|
||||
|
||||
@inline(reverse, p)
|
||||
return p
|
||||
}
|
||||
|
||||
reverse := fn(s: ^u8): void {
|
||||
j := s + @inline(length, s) - 1
|
||||
temp := @as(u8, 0)
|
||||
|
@ -69,11 +38,11 @@ clear := fn(ptr: ^u8): void {
|
|||
}
|
||||
}
|
||||
|
||||
split_once := fn(haystack: ^u8, needle: u8): ?^u8 {
|
||||
loop if *haystack == needle return haystack else if *haystack == 0 return null else haystack += 1
|
||||
}
|
||||
split_buffer := memory.dangling(u8)
|
||||
|
||||
split_once_str := fn(haystack: ^u8, needle: ^u8): ?^u8 {
|
||||
split_once := fn(haystack: ^u8, needle: @Any()): ?^u8 {
|
||||
T := @TypeOf(needle)
|
||||
if T == ^u8 {
|
||||
if *needle == 0 return null
|
||||
|
||||
loop if *haystack == 0 return null else {
|
||||
|
@ -93,91 +62,67 @@ split_once_str := fn(haystack: ^u8, needle: ^u8): ?^u8 {
|
|||
}
|
||||
haystack += 1
|
||||
}
|
||||
} else if T == u8 {
|
||||
loop if *haystack == needle return haystack else if *haystack == 0 return null else haystack += 1
|
||||
} else {
|
||||
@error("Type of needle must be string or char.\0")
|
||||
}
|
||||
}
|
||||
|
||||
Split := struct {
|
||||
SplitIter := fn($T: type): type {
|
||||
return struct {
|
||||
str: ^u8,
|
||||
needle: u8,
|
||||
needle: T,
|
||||
done: bool,
|
||||
}
|
||||
|
||||
split := fn(iter: ^u8, needle: u8): Split {
|
||||
return .(
|
||||
iter,
|
||||
needle,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
iter_split := fn(iter: ^Split): ?^u8 {
|
||||
if iter.done | *iter.str == 0 {
|
||||
next := fn(self: ^Self): ?^u8 {
|
||||
if self.done | *self.str == 0 {
|
||||
return null
|
||||
}
|
||||
|
||||
next := split_once(iter.str + 1, iter.needle)
|
||||
next0 := split_once(self.str, self.needle)
|
||||
|
||||
if next == null {
|
||||
iter.done = true
|
||||
return iter.str
|
||||
if next0 == null {
|
||||
self.done = true
|
||||
return self.str
|
||||
}
|
||||
s := self.str
|
||||
if T == ^u8 {
|
||||
self.str = next0 + length(self.needle)
|
||||
} else if T == u8 {
|
||||
self.str = next0 + 1
|
||||
}
|
||||
s := iter.str
|
||||
iter.str = next + 1
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
SplitStr := struct {
|
||||
str: ^u8,
|
||||
needle: ^u8,
|
||||
done: bool,
|
||||
}
|
||||
}
|
||||
|
||||
split_str := fn(iter: ^u8, needle: ^u8): SplitStr {
|
||||
return .(
|
||||
iter,
|
||||
needle,
|
||||
false,
|
||||
)
|
||||
split := fn(iter: ^u8, needle: @Any()): SplitIter(@TypeOf(needle)) {
|
||||
T := @TypeOf(needle)
|
||||
if T != ^u8 & T != u8 {
|
||||
@error("Type of needle must be string or char.\0")
|
||||
}
|
||||
return .(iter, needle, false)
|
||||
}
|
||||
|
||||
iter_split_str := fn(iter: ^SplitStr): ?^u8 {
|
||||
if iter.done | *iter.str == 0 {
|
||||
return null
|
||||
}
|
||||
|
||||
next := split_once_str(iter.str, iter.needle)
|
||||
|
||||
if next == null {
|
||||
iter.done = true
|
||||
return iter.str
|
||||
}
|
||||
|
||||
s := iter.str
|
||||
|
||||
iter.str = next + length(iter.needle)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
find_once := fn(haystack: ^u8, needle: u8): ?uint {
|
||||
find_once := fn(haystack: ^u8, needle: @Any()): ?uint {
|
||||
return @bitcast(@inline(split_once, haystack, needle) - haystack)
|
||||
}
|
||||
|
||||
find_once_str := fn(haystack: ^u8, needle: ^u8): ?uint {
|
||||
return @bitcast(@inline(split_once_str, haystack, needle) - haystack)
|
||||
count := fn(haystack: ^u8, needle: @Any()): uint {
|
||||
T := @TypeOf(needle)
|
||||
if T != ^u8 & T != u8 {
|
||||
@error("Type of needle must be string or char.\0")
|
||||
}
|
||||
|
||||
count := fn(haystack: ^u8, needle: ^u8): uint {
|
||||
c := 0
|
||||
if T == u8 {
|
||||
loop if *haystack == needle {
|
||||
c += 1
|
||||
haystack += 1
|
||||
} else if *haystack == 0 return c else haystack += 1
|
||||
}
|
||||
|
||||
count_str := fn(haystack: ^u8, needle: ^u8): uint {
|
||||
} else if T == ^u8 {
|
||||
if *needle == 0 return 0
|
||||
c := 0
|
||||
loop if *haystack == 0 return c else {
|
||||
if *haystack == *needle {
|
||||
h := haystack
|
||||
|
@ -197,6 +142,7 @@ count_str := fn(haystack: ^u8, needle: ^u8): uint {
|
|||
haystack += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
left_trim := fn(str: ^u8, sub: ^u8): ^u8 {
|
||||
original := str
|
||||
|
|
|
@ -5,7 +5,6 @@ devices := @use("devices.hb")
|
|||
controller := @use("controller.hb");
|
||||
.{Info, Port} := controller
|
||||
mouse := @use("mouse.hb")
|
||||
format_page := memory.dangling(u8)
|
||||
|
||||
mouse_buffer := 0
|
||||
keyboard_buffer := 0
|
||||
|
@ -73,7 +72,7 @@ process := fn(port: ^controller.Port): void {
|
|||
enable_streaming(port)
|
||||
}
|
||||
log.info("Identified device!\0")
|
||||
log.info(string.display_int(port.device.value, format_page, 16))
|
||||
log.print(port.device.value, .{radix: 16})
|
||||
} else {
|
||||
log.info("KEY PRESSED\0")
|
||||
}
|
||||
|
@ -109,7 +108,6 @@ check_complete := fn(port: ^controller.Port): bool {
|
|||
|
||||
main := fn(): void {
|
||||
mouse_buffer = buffer.create("PS/2 Mouse\0")
|
||||
format_page = memory.alloc(u8, 1024)
|
||||
|
||||
controller.init()
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ Port := packed struct {
|
|||
$PORT_AT_STARTUP := Port.(
|
||||
true,
|
||||
NO_DEVICE,
|
||||
.(0, 0, 0, 0, 0, 0, 0, 0),
|
||||
.[0, 0, 0, 0, 0, 0, 0, 0],
|
||||
0,
|
||||
true,
|
||||
)
|
|
@ -240,4 +240,4 @@ map_keys := fn(scancode: u8): u8 {
|
|||
}
|
||||
return ps2_table[scancode]
|
||||
}
|
||||
ps2_table := [u8].(0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
ps2_table := u8.[0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
@ -3,5 +3,5 @@ serial_driver := @use("./tests/serial_driver.hb")
|
|||
|
||||
main := fn(): uint {
|
||||
// return serial_driver.test()
|
||||
return stn.fmt.test()
|
||||
return stn.hashers.test()
|
||||
}
|
|
@ -1,18 +1,15 @@
|
|||
.{dt, memory, string, log} := @use("../../../../../libraries/stn/src/lib.hb")
|
||||
.{dt, log} := @use("stn")
|
||||
|
||||
test := fn(): uint {
|
||||
buffer := memory.request_page(1)
|
||||
|
||||
log.info(string.display_int(dt.get(int, "framebuffer/fb0/width\0"), buffer, 10))
|
||||
string.clear(buffer)
|
||||
|
||||
log.info(string.display_int(dt.get(int, "cpu/cpu0/architecture\0"), buffer, 10))
|
||||
string.clear(buffer)
|
||||
log.print(dt.get(int, "framebuffer/fb0/width\0"), .{})
|
||||
log.print(dt.get(int, "framebuffer/fb0/height\0"), .{})
|
||||
log.print(dt.get(^uint, "framebuffer/fb0/ptr\0"), .{})
|
||||
log.print(dt.get(int, "cpu/cpu0/architecture\0"), .{})
|
||||
|
||||
// 0 -> memory mapped
|
||||
// 1 -> port mapped
|
||||
|
||||
log.info(string.display_int(dt.get(int, "serial_ports/sp0/mapping\0"), buffer, 10))
|
||||
log.print(dt.get(int, "serial_ports/sp0/mapping\0"), .{})
|
||||
|
||||
return 0
|
||||
}
|
|
@ -30,6 +30,7 @@ test := fn(): uint {
|
|||
log.print(@as(?u32, null), .{})
|
||||
log.print(@as(?u32, 200), .{})
|
||||
log.print(.(@as(?u32, null), 200, 3.14), .{})
|
||||
log.printf("{}, {}, {}\0", .("Hello\0", math.PI, Color.{r: 101, g: 102, b: 103, a: 104}), .{})
|
||||
|
||||
return 0
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
.{hashers, log, memory, string} := @use("../../../../../libraries/stn/src/lib.hb")
|
||||
.{hashers, log, memory, string} := @use("stn")
|
||||
|
||||
test := fn(): uint {
|
||||
buffer := memory.request_page(1)
|
||||
target := "abcdefghijklmnop\0"
|
||||
strings := [^u8].("abcdefshijklmnop\0", "abcdefghijklnnop\0", "abcdefshijklmnop\0", "abcdefghijklmnop\0", "abcdefghijflmnop\0", "dbcdefghijklmnop\0", "abcdefghijklmnop\0")
|
||||
strings := .["abcdefshijklmnop\0", "abcdefghijklnnop\0", "abcdefshijklmnop\0", "abcdefghijklmnop\0", "abcdefghijflmnop\0", "dbcdefghijklmnop\0", "abcdefghijklmnop\0"]
|
||||
len := @sizeof(@TypeOf(strings)) / @sizeof(^u8)
|
||||
strlen := string.length(target)
|
||||
|
||||
|
@ -12,21 +11,16 @@ test := fn(): uint {
|
|||
hasher.write(target, strlen)
|
||||
correct := hasher.finish()
|
||||
|
||||
log.warn("target:\0")
|
||||
log.warn(target)
|
||||
log.printf("target string: {}, target hash: {}\0", .(target, correct), .{radix: 16})
|
||||
|
||||
i := 0
|
||||
loop if i == len break else {
|
||||
defer i += 1
|
||||
|
||||
hasher.reset()
|
||||
hasher.write(strings[i], strlen)
|
||||
d := hasher.finish()
|
||||
if d == correct {
|
||||
log.warn("match found\0")
|
||||
}
|
||||
log.info(strings[i])
|
||||
log.debug(string.display_int(@bitcast(d), buffer, 16))
|
||||
string.clear(buffer)
|
||||
log.printf("matches: {}, string: {}, hash: {}\0", .(d == correct, strings[i], d), .{radix: 16})
|
||||
}
|
||||
return 0
|
||||
}
|
|
@ -1,22 +1,16 @@
|
|||
stn := @use("stn");
|
||||
|
||||
.{log} := stn;
|
||||
.{info} := log;
|
||||
|
||||
.{string} := stn;
|
||||
.{split_str, iter_split_str} := string;
|
||||
.{split, iter_split} := string;
|
||||
|
||||
.{buffer} := stn
|
||||
.{string, buffer, log} := stn;
|
||||
.{info} := log
|
||||
|
||||
main := fn(): int {
|
||||
log.info("VFSaur starting.\0")
|
||||
vfs_buff := buffer.create("VFS\0")
|
||||
|
||||
full_path := "acs:/path/to/a/file\0"
|
||||
splt := split(full_path, ':')
|
||||
root := iter_split(&splt)
|
||||
path := iter_split(&splt)
|
||||
split := string.split(full_path, '/')
|
||||
root := split.next()
|
||||
path := split.next()
|
||||
|
||||
if root == null {
|
||||
return 1
|
||||
|
|
|
@ -23,15 +23,14 @@ resolution = "1024x768x24"
|
|||
|
||||
[boot.limine.ableos.modules]
|
||||
|
||||
# [boot.limine.ableos.modules.render_example]
|
||||
# path = "boot:///render_example.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.render_example]
|
||||
path = "boot:///render_example.hbf"
|
||||
# [boot.limine.ableos.modules.sunset_server]
|
||||
# path = "boot:///sunset_server.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.sunset_server]
|
||||
path = "boot:///sunset_server.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.ps2_mouse_driver]
|
||||
path = "boot:///ps2_mouse_driver.hbf"
|
||||
# [boot.limine.ableos.modules.ps2_mouse_driver]
|
||||
# path = "boot:///ps2_mouse_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||
|
@ -51,9 +50,8 @@ path = "boot:///ps2_driver.hbf"
|
|||
# [boot.limine.ableos.modules.angels_halo]
|
||||
# path = "boot:///angels_halo.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.test]
|
||||
path = "boot:///test.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.test]
|
||||
# path = "boot:///test.hbf"
|
||||
#
|
||||
[boot.limine.ableos.modules.vfsaur]
|
||||
path = "boot:///vfsaur.hbf"
|
||||
# [boot.limine.ableos.modules.vfsaur]
|
||||
# path = "boot:///vfsaur.hbf"
|
||||
|
|
Loading…
Reference in a new issue