builtin: llgo.advance

This commit is contained in:
xushiwei
2024-05-01 23:57:19 +08:00
parent cf02f4a34f
commit df1e4708f5
6 changed files with 85 additions and 25 deletions

View File

@@ -56,14 +56,19 @@ func StringData(s String) unsafe.Pointer {
}
// StringCat concatenates strings.
func StringCat(args ...String) String {
func StringCat(args ...String) (ret String) {
n := 0
for _, v := range args {
n += v.len
}
ret := Alloc(uintptr(n))
_ = ret
panic("todo")
dest := Alloc(uintptr(n))
ret.data = dest
ret.len = n
for _, v := range args {
c.Memcpy(dest, v.data, uintptr(v.len))
dest = c.Advance(dest, v.len)
}
return
}
// -----------------------------------------------------------------------------