build: separate compiler and libs
This commit is contained in:
71
compiler/cl/_testrt/eface/in.go
Normal file
71
compiler/cl/_testrt/eface/in.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/compiler/internal/abi"
|
||||
)
|
||||
|
||||
type T string
|
||||
|
||||
func (t *T) Invoke() {
|
||||
println("invoke")
|
||||
}
|
||||
|
||||
type eface struct {
|
||||
_type *abi.Type
|
||||
data unsafe.Pointer
|
||||
}
|
||||
|
||||
func main() {
|
||||
dump(true)
|
||||
dump(0)
|
||||
dump(int8(0))
|
||||
dump(int16(0))
|
||||
dump(int32(0))
|
||||
dump(int64(0))
|
||||
dump(uint(0))
|
||||
dump(uint8(0))
|
||||
dump(uint16(0))
|
||||
dump(uint32(0))
|
||||
dump(uint64(0))
|
||||
dump(uintptr(0))
|
||||
dump(float32(0))
|
||||
dump(float64(0))
|
||||
dump([10]int{})
|
||||
dump(func() {})
|
||||
dump((*int)(nil))
|
||||
dump([]int{})
|
||||
dump("hello")
|
||||
dump(struct {
|
||||
x int8
|
||||
y int
|
||||
z int
|
||||
}{})
|
||||
var t T
|
||||
dump(t)
|
||||
}
|
||||
|
||||
func dump(v any) {
|
||||
e := (*eface)(unsafe.Pointer(&v))
|
||||
dumpTyp(e._type, "")
|
||||
}
|
||||
|
||||
func dumpTyp(t *abi.Type, sep string) {
|
||||
print(sep)
|
||||
println(t.String(), t.Kind(), t.Size_, t.PtrBytes, t.Hash, t.TFlag, t.Align_, t.PtrToThis_, t.Uncommon())
|
||||
if t.Elem() != nil {
|
||||
dumpTyp(t.Elem(), sep+"\telem: ")
|
||||
}
|
||||
if t.Uncommon() != nil {
|
||||
dumpUncommon(t.Uncommon(), sep+"\tuncomm: ")
|
||||
if t.PtrToThis_ != nil {
|
||||
dumpUncommon(t.PtrToThis_.Uncommon(), sep+"\tuncomm: ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func dumpUncommon(u *abi.UncommonType, sep string) {
|
||||
print(sep)
|
||||
println(u.PkgPath_, u.Mcount, u.Xcount)
|
||||
}
|
||||
Reference in New Issue
Block a user