build: fix unsafe.Sizeof for llgo:type C
This commit is contained in:
@@ -110,7 +110,9 @@ type Cached struct {
|
||||
}
|
||||
|
||||
type aDeduper struct {
|
||||
cache sync.Map
|
||||
cache sync.Map
|
||||
setpath func(path string, name string) string
|
||||
preload func(pkg *types.Package, syntax []*ast.File)
|
||||
}
|
||||
|
||||
type Deduper = *aDeduper
|
||||
@@ -119,6 +121,14 @@ func NewDeduper() Deduper {
|
||||
return &aDeduper{}
|
||||
}
|
||||
|
||||
func (p Deduper) SetPreload(fn func(pkg *types.Package, syntax []*ast.File)) {
|
||||
p.preload = fn
|
||||
}
|
||||
|
||||
func (p Deduper) SetPkgPath(fn func(path, name string) string) {
|
||||
p.setpath = fn
|
||||
}
|
||||
|
||||
func (p Deduper) Check(pkgPath string) *Cached {
|
||||
if v, ok := p.cache.Load(pkgPath); ok {
|
||||
return v.(*Cached)
|
||||
@@ -186,6 +196,9 @@ func loadPackageEx(dedup Deduper, ld *loader, lpkg *loaderPackage) {
|
||||
})
|
||||
}
|
||||
}()
|
||||
if dedup.setpath != nil {
|
||||
lpkg.PkgPath = dedup.setpath(lpkg.PkgPath, lpkg.Name)
|
||||
}
|
||||
}
|
||||
|
||||
// Call NewPackage directly with explicit name.
|
||||
@@ -369,6 +382,10 @@ func loadPackageEx(dedup Deduper, ld *loader, lpkg *loaderPackage) {
|
||||
panic("unreachable")
|
||||
})
|
||||
|
||||
if dedup != nil && dedup.preload != nil {
|
||||
dedup.preload(lpkg.Types, lpkg.Syntax)
|
||||
}
|
||||
|
||||
// type-check
|
||||
tc := &types.Config{
|
||||
Importer: importer,
|
||||
|
||||
Reference in New Issue
Block a user