rt: move slice append helpers from lib/slices/ into libwwrt.a
This commit is contained in:
@@ -244,24 +244,10 @@ static const struct row rows[] = {
|
||||
" x *= 2; x <<= 1; x >>= 2;\n"
|
||||
" return x;\n"
|
||||
"};", 96 },
|
||||
/* user-defined slice append via *[]u8: stdlib slices.appendu8.
|
||||
* Demonstrates allocator + ptr-to-slice fields + scaled index write. */
|
||||
{ "use os;\n"
|
||||
"use slices;\n"
|
||||
"fn main() i32 = {\n"
|
||||
" let s: []u8;\n"
|
||||
" s.ptr = nil; s.len = 0; s.cap = 0;\n"
|
||||
" slices.appendu8(&s, 65u8);\n"
|
||||
" slices.appendu8(&s, 66u8);\n"
|
||||
" slices.appendu8(&s, 67u8);\n"
|
||||
" os.write(1, s.ptr, s.len: u64);\n"
|
||||
" os.write(1, \"\\n\".ptr, 1u64);\n"
|
||||
" return s.len;\n"
|
||||
"};", 3 },
|
||||
/* Hare-style builtins: append(s, v) and len(s). The compiler
|
||||
* lowers these to slices.appendu8 / s.len access. */
|
||||
* lowers append to a CALL into libwwrt.a's appendu8 / appendi64
|
||||
* by element size — no `use rt;` or `use slices;` required. */
|
||||
{ "use os;\n"
|
||||
"use slices;\n"
|
||||
"fn main() i32 = {\n"
|
||||
" let s: []u8;\n"
|
||||
" s.ptr = nil; s.len = 0; s.cap = 0;\n"
|
||||
@@ -281,7 +267,6 @@ static const struct row rows[] = {
|
||||
"};", 12 },
|
||||
/* variadic append + static qualifier (Hare idiom) */
|
||||
{ "use os;\n"
|
||||
"use slices;\n"
|
||||
"fn main() i32 = {\n"
|
||||
" let s: []u8;\n"
|
||||
" s.ptr = nil; s.len = 0; s.cap = 0;\n"
|
||||
@@ -298,7 +283,6 @@ static const struct row rows[] = {
|
||||
"};", 25 },
|
||||
/* Hare-style range loop: for (let x .. slice) iterates elements */
|
||||
{ "use os;\n"
|
||||
"use slices;\n"
|
||||
"fn main() i32 = {\n"
|
||||
" let s: []u8;\n"
|
||||
" s.ptr = nil; s.len = 0; s.cap = 0;\n"
|
||||
@@ -309,7 +293,6 @@ static const struct row rows[] = {
|
||||
"};", 100 },
|
||||
/* alloc([], n): fresh empty slice with cap n */
|
||||
{ "use os;\n"
|
||||
"use slices;\n"
|
||||
"fn main() i32 = {\n"
|
||||
" let s: []u8 = alloc([], 16);\n"
|
||||
" append(s, 72u8, 105u8);\n"
|
||||
@@ -317,7 +300,6 @@ static const struct row rows[] = {
|
||||
"};", 16 },
|
||||
/* variadic spread: append(dst, src...) iterates src */
|
||||
{ "use os;\n"
|
||||
"use slices;\n"
|
||||
"fn main() i32 = {\n"
|
||||
" let src: []u8;\n"
|
||||
" src.ptr = nil; src.len = 0; src.cap = 0;\n"
|
||||
|
||||
@@ -28,7 +28,6 @@ static const char *modules[] = {
|
||||
"lib/bufio/bufio.ww",
|
||||
"lib/fmt/fmt.ww",
|
||||
"lib/net/net.ww",
|
||||
"lib/slices/slices.ww",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -210,7 +210,6 @@ probe_dump_diff(const char *bin)
|
||||
"lib/types/types.ww",
|
||||
"lib/sort/sort.ww",
|
||||
"lib/path/path.ww",
|
||||
"lib/slices/slices.ww",
|
||||
"lib/net/net.ww",
|
||||
"lib/encoding/utf8/utf8.ww",
|
||||
"lib/encoding/hex/hex.ww",
|
||||
|
||||
Reference in New Issue
Block a user