feat: stdlib daily APIs, macro tt/type paste, riscv64 cross smoke
ci / build (ubuntu) (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled

Sessions 83–87: grow Array/Map/String/Test ergonomics; delimiter-balanced
and juxta :tt macros plus $t:type fragments; expression-level $(…),* in
templates; selfhost slice lits; riscv64/aarch64 cross smoke helper and
freestanding docs. Null-safe CBE type names and String_StartsWith.
This commit is contained in:
2026-07-27 21:40:11 +03:00
parent a785747c37
commit d60ce2bc3f
23 changed files with 1263 additions and 86 deletions
+56
View File
@@ -71,6 +71,8 @@ module Std::String {
/// True if `s` begins with `prefix`.
func String_StartsWith(s: String, prefix: String) -> bool {
if s == null as String { return false; }
if prefix == null as String { return false; }
let s_len: uint = bux_strlen(s);
let p_len: uint = bux_strlen(prefix);
if p_len > s_len {
@@ -82,6 +84,8 @@ module Std::String {
/// True if `s` ends with `suffix`.
func String_EndsWith(s: String, suffix: String) -> bool {
if s == null as String { return false; }
if suffix == null as String { return false; }
let s_len: uint = bux_strlen(s);
let suf_len: uint = bux_strlen(suffix);
if suf_len > s_len {
@@ -294,4 +298,56 @@ module Std::String {
return bux_str_format(pattern, a0, a1, a2, "", "", "", "", "");
}
/// Lexicographic compare: `<0` if a<b, `0` if equal, `>0` if a>b (`strcmp`).
func String_Cmp(a: String, b: String) -> int {
return bux_strcmp(a, b);
}
/// Byte index of first `needle` in `s`, or `-1` if not found.
func String_IndexOf(s: String, needle: String) -> int {
let pos: String = bux_strstr(s, needle);
if String_IsNull(pos) {
return -1;
}
return String_Offset(pos, s) as int;
}
/// ASCII lower → upper (`a``z` only). Non-ASCII bytes unchanged.
func String_ToUpper(s: String) -> String {
let n: uint = bux_strlen(s);
var sb: StringBuilder = StringBuilder_NewCap(n + 1);
var i: uint = 0;
while i < n {
let c: int = s[i] as int;
if c >= 97 && c <= 122 {
StringBuilder_AppendChar(&sb, (c - 32) as char8);
} else {
StringBuilder_AppendChar(&sb, c as char8);
}
i = i + 1;
}
let result: String = StringBuilder_Build(&sb);
StringBuilder_Free(&sb);
return result;
}
/// ASCII upper → lower (`A``Z` only). Non-ASCII bytes unchanged.
func String_ToLower(s: String) -> String {
let n: uint = bux_strlen(s);
var sb: StringBuilder = StringBuilder_NewCap(n + 1);
var i: uint = 0;
while i < n {
let c: int = s[i] as int;
if c >= 65 && c <= 90 {
StringBuilder_AppendChar(&sb, (c + 32) as char8);
} else {
StringBuilder_AppendChar(&sb, c as char8);
}
i = i + 1;
}
let result: String = StringBuilder_Build(&sb);
StringBuilder_Free(&sb);
return result;
}
}