internal/lib/reflect: type.Field FieldByIndex FieldByName
This commit is contained in:
@@ -321,8 +321,11 @@ func (b *Builder) structHash(t *types.Struct) (ret []byte, private bool) {
|
||||
if f.Embedded() {
|
||||
name = "-"
|
||||
}
|
||||
ft, _ := b.TypeName(f.Type())
|
||||
ft, pub := b.TypeName(f.Type())
|
||||
fmt.Fprintln(h, name, ft)
|
||||
if !pub {
|
||||
private = true
|
||||
}
|
||||
}
|
||||
ret = h.Sum(b.buf[:0])
|
||||
return
|
||||
|
||||
@@ -204,17 +204,13 @@ func (b Builder) abiNamedOf(t *types.Named) func() Expr {
|
||||
}
|
||||
|
||||
func (b Builder) abiNamed(t *types.Named) Expr {
|
||||
if expr, ok := b.Pkg.named[t]; ok {
|
||||
return expr
|
||||
}
|
||||
pkg := b.Pkg
|
||||
tunder := t.Underlying()
|
||||
kind := int(abi.UnderlyingKind(tunder))
|
||||
size := b.sizeof(tunder)
|
||||
numMethods, numPtrMethods := b.abiMethods(t)
|
||||
newNamed := pkg.rtFunc("NewNamed")
|
||||
expr := b.Call(newNamed, b.Prog.Val(kind), b.Prog.IntVal(uint64(size), b.Prog.Uintptr()), b.Prog.Val(numMethods), b.Prog.Val(numPtrMethods))
|
||||
b.Pkg.named[t] = expr
|
||||
expr := b.Call(newNamed, b.Str(t.String()), b.Prog.Val(kind), b.Prog.IntVal(uint64(size), b.Prog.Uintptr()), b.Prog.Val(numMethods), b.Prog.Val(numPtrMethods))
|
||||
return expr
|
||||
}
|
||||
|
||||
|
||||
@@ -346,14 +346,13 @@ func (p Program) NewPackage(name, pkgPath string) Package {
|
||||
pyobjs := make(map[string]PyObjRef)
|
||||
pymods := make(map[string]Global)
|
||||
strs := make(map[string]llvm.Value)
|
||||
named := make(map[types.Type]Expr)
|
||||
glbDbgVars := make(map[Expr]bool)
|
||||
p.NeedRuntime = false
|
||||
// Don't need reset p.needPyInit here
|
||||
// p.needPyInit = false
|
||||
ret := &aPackage{
|
||||
mod: mod, vars: gbls, fns: fns, stubs: stubs,
|
||||
pyobjs: pyobjs, pymods: pymods, strs: strs, named: named, Prog: p,
|
||||
pyobjs: pyobjs, pymods: pymods, strs: strs, Prog: p,
|
||||
di: nil, cu: nil, glbDbgVars: glbDbgVars,
|
||||
}
|
||||
ret.abi.Init(pkgPath)
|
||||
@@ -603,7 +602,6 @@ type aPackage struct {
|
||||
pyobjs map[string]PyObjRef
|
||||
pymods map[string]Global
|
||||
strs map[string]llvm.Value
|
||||
named map[types.Type]Expr
|
||||
afterb unsafe.Pointer
|
||||
patch func(types.Type) types.Type
|
||||
fnlink func(string) string
|
||||
|
||||
Reference in New Issue
Block a user