internal/abi.Map: IndirectKey/IndirectElem
This commit is contained in:
5
c/c.go
5
c/c.go
@@ -46,7 +46,7 @@ type integer interface {
|
||||
func Str(string) *Char
|
||||
|
||||
// llgo:link Advance llgo.advance
|
||||
func Advance[PtrT any](ptr PtrT, offset int) PtrT { return ptr }
|
||||
func Advance[PtrT any, I integer](ptr PtrT, offset I) PtrT { return ptr }
|
||||
|
||||
// llgo:link Index llgo.index
|
||||
func Index[T any, I integer](ptr *T, offset I) T { return *ptr }
|
||||
@@ -66,6 +66,9 @@ func Free(ptr Pointer)
|
||||
//go:linkname Memcpy C.memcpy
|
||||
func Memcpy(dst, src Pointer, n uintptr) Pointer
|
||||
|
||||
//go:linkname Memmove C.memmove
|
||||
func Memmove(dst, src Pointer, n uintptr) Pointer
|
||||
|
||||
//go:linkname Memset C.memset
|
||||
func Memset(s Pointer, c Int, n uintptr) Pointer
|
||||
|
||||
|
||||
@@ -170,6 +170,24 @@ type MapType struct {
|
||||
Flags uint32
|
||||
}
|
||||
|
||||
// Note: flag values must match those used in the TMAP case
|
||||
// in ../cmd/compile/internal/reflectdata/reflect.go:writeType.
|
||||
func (mt *MapType) IndirectKey() bool { // store ptr to key instead of key itself
|
||||
return mt.Flags&1 != 0
|
||||
}
|
||||
func (mt *MapType) IndirectElem() bool { // store ptr to elem instead of elem itself
|
||||
return mt.Flags&2 != 0
|
||||
}
|
||||
func (mt *MapType) ReflexiveKey() bool { // true if k==k for all keys
|
||||
return mt.Flags&4 != 0
|
||||
}
|
||||
func (mt *MapType) NeedKeyUpdate() bool { // true if we need to update key on an overwrite
|
||||
return mt.Flags&8 != 0
|
||||
}
|
||||
func (mt *MapType) HashMightPanic() bool { // true if hash function might panic
|
||||
return mt.Flags&16 != 0
|
||||
}
|
||||
|
||||
type PtrType struct {
|
||||
Type
|
||||
Elem *Type // pointer element (pointed at) type
|
||||
|
||||
@@ -19,10 +19,10 @@ To run the demos in directory `_demo`, you need to set the `LLGO_LIB_PYTHON` env
|
||||
export LLGO_LIB_PYTHON=/foo/bar/python3.12
|
||||
```
|
||||
|
||||
For example, `/opt/homebrew/Frameworks/Python.framework/Versions/3.12/libpython3.12.dylib` is a typical python lib location under macOS. So we should set it like this:
|
||||
For example, `/opt/homebrew/Frameworks/Python.framework/Versions/3.12/lib/libpython3.12.dylib` is a typical python lib location under macOS. So we should set it like this:
|
||||
|
||||
```sh
|
||||
export LLGO_LIB_PYTHON=/opt/homebrew/Frameworks/Python.framework/Versions/3.12/python3.12
|
||||
export LLGO_LIB_PYTHON=/opt/homebrew/Frameworks/Python.framework/Versions/3.12/lib/python3.12
|
||||
```
|
||||
|
||||
Then you can run the demos in directory `_demo`:
|
||||
|
||||
Reference in New Issue
Block a user