cl: fix package patching

This commit is contained in:
Li Jie
2024-11-25 11:17:06 +08:00
parent 2f5c033f09
commit e732e5158e
3 changed files with 35 additions and 18 deletions

View File

@@ -105,6 +105,8 @@ type aProgram struct {
sizes types.Sizes // provided by Go compiler
gocvt goTypes
patchType func(types.Type) types.Type
rt *types.Package
rtget func() *types.Package
@@ -233,6 +235,17 @@ func NewProgram(target *Target) Program {
}
}
func (p Program) SetPatch(patchType func(types.Type) types.Type) {
p.patchType = patchType
}
func (p Program) patch(typ types.Type) types.Type {
if p.patchType != nil {
return p.patchType(typ)
}
return typ
}
// SetRuntime sets the runtime.
// Its type can be *types.Package or func() *types.Package.
func (p Program) SetRuntime(runtime any) {