llgo/ssa,runtime: Slice
This commit is contained in:
@@ -23,8 +23,8 @@ const (
|
||||
LLGoPackage = "decl"
|
||||
)
|
||||
|
||||
//go:linkname String llgo.cstr
|
||||
func String(string) *int8
|
||||
//go:linkname Str llgo.cstr
|
||||
func Str(string) *int8
|
||||
|
||||
//go:linkname Alloca llgo.alloca
|
||||
func Alloca(size uintptr) unsafe.Pointer
|
||||
|
||||
@@ -24,9 +24,9 @@ import (
|
||||
|
||||
// Slice is the runtime representation of a slice.
|
||||
type Slice struct {
|
||||
array unsafe.Pointer
|
||||
len int
|
||||
cap int
|
||||
data unsafe.Pointer
|
||||
len int
|
||||
cap int
|
||||
}
|
||||
|
||||
// NilSlice returns a nil slice.
|
||||
@@ -34,4 +34,14 @@ func NilSlice() Slice {
|
||||
return Slice{nil, 0, 0}
|
||||
}
|
||||
|
||||
// NewSlice creates a new slice.
|
||||
func NewSlice(data unsafe.Pointer, len, cap int) Slice {
|
||||
return Slice{data, len, cap}
|
||||
}
|
||||
|
||||
// SliceLen returns the length of a slice.
|
||||
func SliceLen(s Slice) int {
|
||||
return s.len
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user