update ssa.Slice

This commit is contained in:
visualfc
2024-05-03 10:30:07 +08:00
parent 85da86a4f1
commit d444123062
8 changed files with 276 additions and 26 deletions

View File

@@ -80,4 +80,14 @@ func CStrDup(s String) *int8 {
return CStrCopy(dest, s)
}
func NewStringSlice(base String, i, j int) String {
if i < 0 || j < i || j > base.len {
panic("string slice index out of bounds")
}
if i < base.len {
return String{c.Advance(base.data, i), j - i}
}
return String{nil, 0}
}
// -----------------------------------------------------------------------------