From 528b1fc66ce71c5627a96b93f319235f5125d6c7 Mon Sep 17 00:00:00 2001 From: Able Date: Fri, 19 Jul 2024 08:53:45 -0500 Subject: [PATCH] formatted code --- Cargo.lock | 6 +- sysdata/libraries/stn/src/buffer.hb | 23 ++++--- sysdata/libraries/stn/src/lib.hb | 8 +-- sysdata/libraries/stn/src/log.hb | 21 +++---- sysdata/libraries/stn/src/memory.hb | 24 ++++---- sysdata/libraries/stn/src/string.hb | 78 ++++++++++++------------ sysdata/programs/fb_driver/src/main.hb | 14 ++--- sysdata/programs/tests/src/main.hb | 46 ++++++-------- sysdata/programs/time_driver/src/main.hb | 36 +++++------ 9 files changed, 122 insertions(+), 134 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4638a89..5c7e1ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -429,7 +429,7 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#654b7eb7af94c191a6ac9071e7efd56833966ad5" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#5555b9865a3ae9d512bc338c1f370aeca9975c60" [[package]] name = "hbbytecode" @@ -439,7 +439,7 @@ source = "git+https://git.ablecorp.us/ableos/holey-bytes#e494785f93dad2722ebd9e5 [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#654b7eb7af94c191a6ac9071e7efd56833966ad5" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#5555b9865a3ae9d512bc338c1f370aeca9975c60" dependencies = [ "hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] @@ -447,7 +447,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#654b7eb7af94c191a6ac9071e7efd56833966ad5" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#5555b9865a3ae9d512bc338c1f370aeca9975c60" dependencies = [ "hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)", ] diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index 1fd18ba..b29bf3f 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -1,20 +1,19 @@ -string := @use("rel:string.hb"); +string := @use("rel:string.hb") receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u8 { - return @eca(^u8, 4, buffer_id, memory_map_location, length); + return @eca(^u8, 4, buffer_id, memory_map_location, length) } send_message := fn(buffer_id: int): void { - message := "Hello there\0"; - message_length := string.length(message); - - @eca(i32, 3, buffer_id, message, message_length); - return; + message := "Hello there\0" + message_length := string.length(message) + @eca(i32, 3, buffer_id, message, message_length) + return } create := fn(): int { - msg := "\{01}Number\0"; - msg_length := string.length(msg); - *msg = 0; - return @eca(int, 1, 0, msg, msg_length); -} \ No newline at end of file + msg := "\{01}Number\0" + msg_length := string.length(msg); + *msg = 0 + return @eca(int, 1, 0, msg, msg_length) +} diff --git a/sysdata/libraries/stn/src/lib.hb b/sysdata/libraries/stn/src/lib.hb index fe530ec..fd27a71 100644 --- a/sysdata/libraries/stn/src/lib.hb +++ b/sysdata/libraries/stn/src/lib.hb @@ -1,4 +1,4 @@ -string := @use("rel:string.hb"); -log := @use("rel:log.hb"); -memory := @use("rel:memory.hb"); -buffer := @use("rel:buffer.hb"); \ No newline at end of file +string := @use("rel:string.hb") +log := @use("rel:log.hb") +memory := @use("rel:memory.hb") +buffer := @use("rel:buffer.hb") diff --git a/sysdata/libraries/stn/src/log.hb b/sysdata/libraries/stn/src/log.hb index 7028346..ebf3e8a 100644 --- a/sysdata/libraries/stn/src/log.hb +++ b/sysdata/libraries/stn/src/log.hb @@ -1,15 +1,14 @@ -string := @use("rel:string.hb"); +string := @use("rel:string.hb") log := fn(message: ^u8, level: u8): void { - message_length := string.length(message); - *(message + message_length) = level; - - @eca(i32, 3, 1, message, message_length + 1); - return; + message_length := string.length(message); + *(message + message_length) = level + @eca(i32, 3, 1, message, message_length + 1) + return } -error:= fn(message: ^u8):void return log(message, 0); -warn:= fn(message: ^u8):void return log(message, 1); -info:= fn(message: ^u8):void return log(message, 2); -debug:= fn(message: ^u8):void return log(message, 3); -trace:= fn(message: ^u8):void return log(message, 4); \ No newline at end of file +error := fn(message: ^u8): void return log(message, 0) +warn := fn(message: ^u8): void return log(message, 1) +info := fn(message: ^u8): void return log(message, 2) +debug := fn(message: ^u8): void return log(message, 3) +trace := fn(message: ^u8): void return log(message, 4) diff --git a/sysdata/libraries/stn/src/memory.hb b/sysdata/libraries/stn/src/memory.hb index 1357cf8..76b3484 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -1,18 +1,18 @@ request_page := fn(page_count: u8): ^u8 { - msg := "\{00}\{01}xxxxxxxx\0"; - msg_page_count := msg + 1; - *msg_page_count = page_count; - return @eca(^u8, 3, 2, msg, 12); + msg := "\{00}\{01}xxxxxxxx\0" + msg_page_count := msg + 1; + *msg_page_count = page_count + return @eca(^u8, 3, 2, msg, 12) } release_page := fn(ptr: ^u8, page_count: u8): void { - msg := "\{01}\{00}xxxxxxxx\0"; - - msg_page_count := msg + 1; - *msg_page_count = page_count; + msg := "\{01}\{00}xxxxxxxx\0" - msg_ptr := @as(^^u8, @bitcast(msg+2)); - *msg_ptr = ptr; + msg_page_count := msg + 1; + *msg_page_count = page_count - return @eca(void, 3, 2, msg, 12); -} \ No newline at end of file + msg_ptr := @as(^^u8, @bitcast(msg + 2)); + *msg_ptr = ptr + + return @eca(void, 3, 2, msg, 12) +} diff --git a/sysdata/libraries/stn/src/string.hb b/sysdata/libraries/stn/src/string.hb index 52145ab..d23f3bd 100644 --- a/sysdata/libraries/stn/src/string.hb +++ b/sysdata/libraries/stn/src/string.hb @@ -1,51 +1,51 @@ length := fn(ptr: ^u8): int { - len := 0; - loop if *ptr == 0 break else { - len += 1; - ptr += 1; + len := 0 + loop if *ptr == 0 break else { + len += 1 + ptr += 1 } - return len; + return len } display_int := fn(num: int, p: ^u8): ^u8 { - i := 0; - if num == 0 { - set(p, 48); - return p; - } - loop { - if num == 0 break; - set(p + i, num % 10 + 48); - num /= 10; - i += 1; - } - reverse(p); - //null terminate - set(p + i, 0); - return p; + i := 0 + if num == 0 { + set(p, 48) + return p + } + loop { + if num == 0 break + set(p + i, num % 10 + 48) + num /= 10 + i += 1 + } + reverse(p) + //null terminate + set(p + i, 0) + return p } reverse := fn(s: ^u8): void { - //reverse a string, don't remove digits - len := 0; - loop { - if *(s + len) == 0 break; - len += 1; - } - i := 0; - j := len - 1; - loop { - if i >= j break; - temp := *(s + i); - *(s + i) = *(s + j); - *(s + j) = temp; - i += 1; - j -= 1; - } - return; + //reverse a string, don't remove digits + len := 0 + loop { + if *(s + len) == 0 break + len += 1 + } + i := 0 + j := len - 1 + loop { + if i >= j break + temp := *(s + i); + *(s + i) = *(s + j); + *(s + j) = temp + i += 1 + j -= 1 + } + return } set := fn(change: ^u8, new: int): void { - *(change) = new; - return; + *change = new + return } diff --git a/sysdata/programs/fb_driver/src/main.hb b/sysdata/programs/fb_driver/src/main.hb index 783cd94..306a3c9 100644 --- a/sysdata/programs/fb_driver/src/main.hb +++ b/sysdata/programs/fb_driver/src/main.hb @@ -1,15 +1,15 @@ -frame_buffer := @as(^u8, @bitcast(18446603339442421760)); +frame_buffer := @as(^u8, @bitcast(18446603339442421760)) main := fn(): int { - color := 17; + color := 17 loop { - len := (786432 * 4)+1; + len := 786432 * 4 + 1 loop if len == 0 break else { fb := frame_buffer + len; - *fb = color; - len = len - 1; - color += len; + *fb = color + len -= 1 + color += len } } - return 0; + return 0 } diff --git a/sysdata/programs/tests/src/main.hb b/sysdata/programs/tests/src/main.hb index 49da3f1..4c34d32 100644 --- a/sysdata/programs/tests/src/main.hb +++ b/sysdata/programs/tests/src/main.hb @@ -1,8 +1,8 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -log := stn.log; -string := stn.string; -memory := stn.memory; -buffer := stn.buffer; +stn := @use("../../../libraries/stn/src/lib.hb") +log := stn.log +string := stn.string +memory := stn.memory +buffer := stn.buffer /* service_search := fn(): void { @@ -12,28 +12,18 @@ service_search := fn(): void { } */ - - main := fn(): int { - // Create a buffer - - buffer_id := buffer.create(); - buffer.send_message(buffer_id); - - memory_pages := memory.request_page(3); - buffer.receive_message(buffer_id, memory_pages, 4096*3); + // Create a buffer + num := 2 + buffer_id := buffer.create() + buffer.send_message(buffer_id) + memory_pages := memory.request_page(3) + buffer.receive_message(buffer_id, memory_pages, 4096 * 3) + log.info("abc\0") + memory.release_page(memory_pages, 3) - log.info("abc\0"); - - memory.release_page(memory_pages, 3); - - - - // todo: abstract this out - port_str := "\0\{70}\0"; - a := @eca(u8, 3, 3, port_str, 2); - - - - return 0; -} \ No newline at end of file + // todo: abstract this out + port_str := "\0\{70}\0" + a := @eca(u8, 3, 3, port_str, 2) + return 0 +} diff --git a/sysdata/programs/time_driver/src/main.hb b/sysdata/programs/time_driver/src/main.hb index e8eb06d..6b2c482 100644 --- a/sysdata/programs/time_driver/src/main.hb +++ b/sysdata/programs/time_driver/src/main.hb @@ -1,21 +1,21 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -log := stn.log; -mem := stn.memory; -s := stn.string; -page := 0; +stn := @use("../../../libraries/stn/src/lib.hb") +log := stn.log +mem := stn.memory +s := stn.string +page := 0 main := fn(): void { - page += mem.request_page(1); - port_str := "\0\{47}\0"; - a := @eca(u8, 3, 3, port_str, 2); - - n := 5000000; - loop { - if n == 0 break; - n -= 1; - stack_reclamation_edge_case := 0; - } - td := s.display_int(a, page); - log.debug(td); - return; + page += mem.request_page(1) + port_str := "\0\{47}\0" + a := @eca(u8, 3, 3, port_str, 2) + + n := 5000000 + loop { + if n == 0 break + n -= 1 + stack_reclamation_edge_case := 0 + } + td := s.display_int(a, page) + log.debug(td) + return }