forked from AbleOS/ableos
printf, various syntax updates, better string manipulation miscellaneous changes
This commit is contained in:
parent
59cf6ef4d7
commit
1ec9d0fd46
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -213,12 +213,12 @@ 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#4b3b6af70eb84d513b9fa926dd8c36e1dba88713"
|
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#418fd0039eda7fd4052c8086373b1e1257d573c8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hblang"
|
name = "hblang"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"hbbytecode",
|
"hbbytecode",
|
||||||
|
@ -229,7 +229,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hbvm"
|
name = "hbvm"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"hbbytecode",
|
"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 {
|
fmt_int := fn(v: @Any(), str: ^u8, radix: @TypeOf(v)): uint {
|
||||||
is_negative := signed_int(@TypeOf(v)) & v < 0
|
is_negative := signed_int(@TypeOf(v)) & v < 0
|
||||||
|
@ -199,7 +199,14 @@ FormatOptions := struct {
|
||||||
format := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
format := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
||||||
T := @TypeOf(v)
|
T := @TypeOf(v)
|
||||||
match Kind.of(T) {
|
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 => {
|
.Builtin => {
|
||||||
if integer(T) {
|
if integer(T) {
|
||||||
return @inline(fmt_int, v, str, @intcast(opts.radix))
|
return @inline(fmt_int, v, str, @intcast(opts.radix))
|
||||||
|
@ -216,4 +223,57 @@ format := fn(v: @Any(), str: ^u8, opts: FormatOptions): uint {
|
||||||
.Slice => return @inline(fmt_container, v, str, opts),
|
.Slice => return @inline(fmt_container, v, str, opts),
|
||||||
_ => @error("Type: \"\0", T, "\" is not supported.\0"),
|
_ => @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
|
$ARBITRARY7 := 0x3F84D5B5B5470917
|
||||||
$ARBITRARY8 := 0x9216D5D98979FB1B
|
$ARBITRARY8 := 0x9216D5D98979FB1B
|
||||||
$ARBITRARY9 := 0xD1310BA698DFB5AC
|
$ARBITRARY9 := 0xD1310BA698DFB5AC
|
||||||
$FIXED_GLOBAL_SEED := [uint].(ARBITRARY4, ARBITRARY5, ARBITRARY6, ARBITRARY7)
|
$FIXED_GLOBAL_SEED := uint.[ARBITRARY4, ARBITRARY5, ARBITRARY6, ARBITRARY7]
|
||||||
|
|
||||||
global_seed := 0
|
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 {
|
if remainder > 0 {
|
||||||
remainder_start := bytes + len - math.max(uint, remainder, 16)
|
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
|
return s0 ^ s1
|
||||||
|
@ -159,17 +159,9 @@ FoldHasher := struct {
|
||||||
}
|
}
|
||||||
self.accumulator = folded_multiply(s0, s1)
|
self.accumulator = folded_multiply(s0, s1)
|
||||||
} else if len < 256 {
|
} 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 {
|
} else {
|
||||||
self.accumulator = hash_bytes_long(
|
self.accumulator = @inline(hash_bytes_long, bytes, len, s0, s1, self.expand_seed2, self.expand_seed3, self.fold_seed)
|
||||||
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")
|
process := @use("process.hb")
|
||||||
sleep := @use("sleep.hb")
|
sleep := @use("sleep.hb")
|
||||||
|
|
||||||
// todo: replace with comptime message (for zero cost)
|
|
||||||
panic := fn(message: ?^u8): never {
|
panic := fn(message: ?^u8): never {
|
||||||
log.error("Error: Panic Called, Message:\0")
|
log.printf("HBLang Panic: {}\0", message, .{log: .Error})
|
||||||
if message == null {
|
|
||||||
log.error("None\0")
|
|
||||||
} else {
|
|
||||||
log.error(message)
|
|
||||||
}
|
|
||||||
die
|
die
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,4 +63,4 @@ $bits := fn($T: type): usize(T) {
|
||||||
|
|
||||||
$bitmask := fn($T: type): usize(T) {
|
$bitmask := fn($T: type): usize(T) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
|
@ -23,14 +23,19 @@ trace := fn(message: ^u8): void return @inline(log, LogLevel.Trace, message)
|
||||||
print_buffer := memory.dangling(u8)
|
print_buffer := memory.dangling(u8)
|
||||||
|
|
||||||
print := fn(v: @Any(), opts: fmt.FormatOptions): void {
|
print := fn(v: @Any(), opts: fmt.FormatOptions): void {
|
||||||
if @TypeOf(v) == ^u8 {
|
|
||||||
@inline(log, opts.log, v)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if print_buffer == memory.dangling(u8) {
|
if print_buffer == memory.dangling(u8) {
|
||||||
print_buffer = memory.request_page(1)
|
print_buffer = memory.request_page(1)
|
||||||
}
|
}
|
||||||
len := @inline(fmt.format, v, print_buffer, opts)
|
len := @inline(fmt.format, v, print_buffer, opts)
|
||||||
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
||||||
memory.set(u8, &0, print_buffer, memory.PAGE_SIZE)
|
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 {
|
length := fn(ptr: ^u8): uint {
|
||||||
len := 0
|
len := 0
|
||||||
loop if *(ptr + len) == 0 return len else len += 1
|
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 {
|
reverse := fn(s: ^u8): void {
|
||||||
j := s + @inline(length, s) - 1
|
j := s + @inline(length, s) - 1
|
||||||
temp := @as(u8, 0)
|
temp := @as(u8, 0)
|
||||||
|
@ -69,132 +38,109 @@ clear := fn(ptr: ^u8): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
split_once := fn(haystack: ^u8, needle: u8): ?^u8 {
|
split_buffer := memory.dangling(u8)
|
||||||
loop if *haystack == needle return haystack else if *haystack == 0 return null else haystack += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
split_once_str := fn(haystack: ^u8, needle: ^u8): ?^u8 {
|
split_once := fn(haystack: ^u8, needle: @Any()): ?^u8 {
|
||||||
if *needle == 0 return null
|
T := @TypeOf(needle)
|
||||||
|
if T == ^u8 {
|
||||||
|
if *needle == 0 return null
|
||||||
|
|
||||||
loop if *haystack == 0 return null else {
|
loop if *haystack == 0 return null else {
|
||||||
if *haystack == *needle {
|
if *haystack == *needle {
|
||||||
h := haystack
|
h := haystack
|
||||||
n := needle
|
n := needle
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
n += 1
|
n += 1
|
||||||
h += 1
|
h += 1
|
||||||
if *n == 0 {
|
if *n == 0 {
|
||||||
return haystack
|
return haystack
|
||||||
} else if *h == 0 | *h != *n {
|
} else if *h == 0 | *h != *n {
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
haystack += 1
|
||||||
}
|
}
|
||||||
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 {
|
||||||
str: ^u8,
|
return struct {
|
||||||
needle: u8,
|
str: ^u8,
|
||||||
done: bool,
|
needle: T,
|
||||||
}
|
done: bool,
|
||||||
|
|
||||||
split := fn(iter: ^u8, needle: u8): Split {
|
next := fn(self: ^Self): ?^u8 {
|
||||||
return .(
|
if self.done | *self.str == 0 {
|
||||||
iter,
|
return null
|
||||||
needle,
|
}
|
||||||
false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
iter_split := fn(iter: ^Split): ?^u8 {
|
next0 := split_once(self.str, self.needle)
|
||||||
if iter.done | *iter.str == 0 {
|
|
||||||
return null
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
next := split_once(iter.str + 1, iter.needle)
|
split := fn(iter: ^u8, needle: @Any()): SplitIter(@TypeOf(needle)) {
|
||||||
|
T := @TypeOf(needle)
|
||||||
if next == null {
|
if T != ^u8 & T != u8 {
|
||||||
iter.done = true
|
@error("Type of needle must be string or char.\0")
|
||||||
return iter.str
|
|
||||||
}
|
}
|
||||||
s := iter.str
|
return .(iter, needle, false)
|
||||||
iter.str = next + 1
|
|
||||||
|
|
||||||
return s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SplitStr := struct {
|
find_once := fn(haystack: ^u8, needle: @Any()): ?uint {
|
||||||
str: ^u8,
|
|
||||||
needle: ^u8,
|
|
||||||
done: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
split_str := fn(iter: ^u8, needle: ^u8): SplitStr {
|
|
||||||
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 {
|
|
||||||
return @bitcast(@inline(split_once, haystack, needle) - haystack)
|
return @bitcast(@inline(split_once, haystack, needle) - haystack)
|
||||||
}
|
}
|
||||||
|
|
||||||
find_once_str := fn(haystack: ^u8, needle: ^u8): ?uint {
|
count := fn(haystack: ^u8, needle: @Any()): uint {
|
||||||
return @bitcast(@inline(split_once_str, haystack, needle) - haystack)
|
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
|
c := 0
|
||||||
loop if *haystack == needle {
|
if T == u8 {
|
||||||
c += 1
|
loop if *haystack == needle {
|
||||||
haystack += 1
|
c += 1
|
||||||
} else if *haystack == 0 return c else haystack += 1
|
haystack += 1
|
||||||
}
|
} else if *haystack == 0 return c else haystack += 1
|
||||||
|
} else if T == ^u8 {
|
||||||
|
if *needle == 0 return 0
|
||||||
|
loop if *haystack == 0 return c else {
|
||||||
|
if *haystack == *needle {
|
||||||
|
h := haystack
|
||||||
|
n := needle
|
||||||
|
|
||||||
count_str := fn(haystack: ^u8, needle: ^u8): uint {
|
loop {
|
||||||
if *needle == 0 return 0
|
n += 1
|
||||||
c := 0
|
h += 1
|
||||||
loop if *haystack == 0 return c else {
|
if *n == 0 {
|
||||||
if *haystack == *needle {
|
c += 1
|
||||||
h := haystack
|
break
|
||||||
n := needle
|
} else if *h == 0 | *h != *n {
|
||||||
|
break
|
||||||
loop {
|
}
|
||||||
n += 1
|
|
||||||
h += 1
|
|
||||||
if *n == 0 {
|
|
||||||
c += 1
|
|
||||||
break
|
|
||||||
} else if *h == 0 | *h != *n {
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
haystack += 1
|
||||||
}
|
}
|
||||||
haystack += 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ devices := @use("devices.hb")
|
||||||
controller := @use("controller.hb");
|
controller := @use("controller.hb");
|
||||||
.{Info, Port} := controller
|
.{Info, Port} := controller
|
||||||
mouse := @use("mouse.hb")
|
mouse := @use("mouse.hb")
|
||||||
format_page := memory.dangling(u8)
|
|
||||||
|
|
||||||
mouse_buffer := 0
|
mouse_buffer := 0
|
||||||
keyboard_buffer := 0
|
keyboard_buffer := 0
|
||||||
|
@ -73,7 +72,7 @@ process := fn(port: ^controller.Port): void {
|
||||||
enable_streaming(port)
|
enable_streaming(port)
|
||||||
}
|
}
|
||||||
log.info("Identified device!\0")
|
log.info("Identified device!\0")
|
||||||
log.info(string.display_int(port.device.value, format_page, 16))
|
log.print(port.device.value, .{radix: 16})
|
||||||
} else {
|
} else {
|
||||||
log.info("KEY PRESSED\0")
|
log.info("KEY PRESSED\0")
|
||||||
}
|
}
|
||||||
|
@ -109,7 +108,6 @@ check_complete := fn(port: ^controller.Port): bool {
|
||||||
|
|
||||||
main := fn(): void {
|
main := fn(): void {
|
||||||
mouse_buffer = buffer.create("PS/2 Mouse\0")
|
mouse_buffer = buffer.create("PS/2 Mouse\0")
|
||||||
format_page = memory.alloc(u8, 1024)
|
|
||||||
|
|
||||||
controller.init()
|
controller.init()
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ Port := packed struct {
|
||||||
$PORT_AT_STARTUP := Port.(
|
$PORT_AT_STARTUP := Port.(
|
||||||
true,
|
true,
|
||||||
NO_DEVICE,
|
NO_DEVICE,
|
||||||
.(0, 0, 0, 0, 0, 0, 0, 0),
|
.[0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
|
@ -240,4 +240,4 @@ map_keys := fn(scancode: u8): u8 {
|
||||||
}
|
}
|
||||||
return ps2_table[scancode]
|
return ps2_table[scancode]
|
||||||
}
|
}
|
||||||
ps2_table :=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 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 {
|
main := fn(): uint {
|
||||||
// return serial_driver.test()
|
// 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 {
|
test := fn(): uint {
|
||||||
buffer := memory.request_page(1)
|
log.print(dt.get(int, "framebuffer/fb0/width\0"), .{})
|
||||||
|
log.print(dt.get(int, "framebuffer/fb0/height\0"), .{})
|
||||||
log.info(string.display_int(dt.get(int, "framebuffer/fb0/width\0"), buffer, 10))
|
log.print(dt.get(^uint, "framebuffer/fb0/ptr\0"), .{})
|
||||||
string.clear(buffer)
|
log.print(dt.get(int, "cpu/cpu0/architecture\0"), .{})
|
||||||
|
|
||||||
log.info(string.display_int(dt.get(int, "cpu/cpu0/architecture\0"), buffer, 10))
|
|
||||||
string.clear(buffer)
|
|
||||||
|
|
||||||
// 0 -> memory mapped
|
// 0 -> memory mapped
|
||||||
// 1 -> port 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
|
return 0
|
||||||
}
|
}
|
|
@ -30,6 +30,7 @@ test := fn(): uint {
|
||||||
log.print(@as(?u32, null), .{})
|
log.print(@as(?u32, null), .{})
|
||||||
log.print(@as(?u32, 200), .{})
|
log.print(@as(?u32, 200), .{})
|
||||||
log.print(.(@as(?u32, null), 200, 3.14), .{})
|
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
|
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 {
|
test := fn(): uint {
|
||||||
buffer := memory.request_page(1)
|
|
||||||
target := "abcdefghijklmnop\0"
|
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)
|
len := @sizeof(@TypeOf(strings)) / @sizeof(^u8)
|
||||||
strlen := string.length(target)
|
strlen := string.length(target)
|
||||||
|
|
||||||
|
@ -12,21 +11,16 @@ test := fn(): uint {
|
||||||
hasher.write(target, strlen)
|
hasher.write(target, strlen)
|
||||||
correct := hasher.finish()
|
correct := hasher.finish()
|
||||||
|
|
||||||
log.warn("target:\0")
|
log.printf("target string: {}, target hash: {}\0", .(target, correct), .{radix: 16})
|
||||||
log.warn(target)
|
|
||||||
|
|
||||||
i := 0
|
i := 0
|
||||||
loop if i == len break else {
|
loop if i == len break else {
|
||||||
defer i += 1
|
defer i += 1
|
||||||
|
|
||||||
hasher.reset()
|
hasher.reset()
|
||||||
hasher.write(strings[i], strlen)
|
hasher.write(strings[i], strlen)
|
||||||
d := hasher.finish()
|
d := hasher.finish()
|
||||||
if d == correct {
|
log.printf("matches: {}, string: {}, hash: {}\0", .(d == correct, strings[i], d), .{radix: 16})
|
||||||
log.warn("match found\0")
|
|
||||||
}
|
|
||||||
log.info(strings[i])
|
|
||||||
log.debug(string.display_int(@bitcast(d), buffer, 16))
|
|
||||||
string.clear(buffer)
|
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -1,22 +1,16 @@
|
||||||
stn := @use("stn");
|
stn := @use("stn");
|
||||||
|
|
||||||
.{log} := stn;
|
.{string, buffer, log} := stn;
|
||||||
.{info} := log;
|
.{info} := log
|
||||||
|
|
||||||
.{string} := stn;
|
|
||||||
.{split_str, iter_split_str} := string;
|
|
||||||
.{split, iter_split} := string;
|
|
||||||
|
|
||||||
.{buffer} := stn
|
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
log.info("VFSaur starting.\0")
|
log.info("VFSaur starting.\0")
|
||||||
vfs_buff := buffer.create("VFS\0")
|
vfs_buff := buffer.create("VFS\0")
|
||||||
|
|
||||||
full_path := "acs:/path/to/a/file\0"
|
full_path := "acs:/path/to/a/file\0"
|
||||||
splt := split(full_path, ':')
|
split := string.split(full_path, '/')
|
||||||
root := iter_split(&splt)
|
root := split.next()
|
||||||
path := iter_split(&splt)
|
path := split.next()
|
||||||
|
|
||||||
if root == null {
|
if root == null {
|
||||||
return 1
|
return 1
|
||||||
|
@ -29,4 +23,4 @@ main := fn(): int {
|
||||||
log.info(path)
|
log.info(path)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -23,15 +23,14 @@ resolution = "1024x768x24"
|
||||||
|
|
||||||
[boot.limine.ableos.modules]
|
[boot.limine.ableos.modules]
|
||||||
|
|
||||||
|
# [boot.limine.ableos.modules.render_example]
|
||||||
|
# path = "boot:///render_example.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.render_example]
|
# [boot.limine.ableos.modules.sunset_server]
|
||||||
path = "boot:///render_example.hbf"
|
# path = "boot:///sunset_server.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.sunset_server]
|
# [boot.limine.ableos.modules.ps2_mouse_driver]
|
||||||
path = "boot:///sunset_server.hbf"
|
# 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]
|
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||||
|
@ -51,9 +50,8 @@ path = "boot:///ps2_mouse_driver.hbf"
|
||||||
# [boot.limine.ableos.modules.angels_halo]
|
# [boot.limine.ableos.modules.angels_halo]
|
||||||
# path = "boot:///angels_halo.hbf"
|
# path = "boot:///angels_halo.hbf"
|
||||||
|
|
||||||
|
[boot.limine.ableos.modules.test]
|
||||||
|
path = "boot:///test.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.test]
|
# [boot.limine.ableos.modules.vfsaur]
|
||||||
# path = "boot:///test.hbf"
|
# path = "boot:///vfsaur.hbf"
|
||||||
#
|
|
||||||
[boot.limine.ableos.modules.vfsaur]
|
|
||||||
path = "boot:///vfsaur.hbf"
|
|
||||||
|
|
Loading…
Reference in a new issue