Skip to content

Commit

Permalink
cl: fnType.load use gox.CheckFuncEx
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Dec 21, 2023
1 parent f76c89d commit e068592
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions cl/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,37 +492,41 @@ func (p *fnType) initTypeType(t *gox.TypeType) {
p.size = 1
}

func checkOverload(sig *types.Signature) (base int, funcs []types.Object, ok bool) {
if typ, ok := gox.CheckFuncEx(sig); ok {
switch t := typ.(type) {
case *gox.TyOverloadFunc:
return 0, t.Funcs, true
case *gox.TyOverloadMethod:
return 0, t.Methods, true
case *gox.TyTemplateRecvMethod:
if tsig, ok := t.Func.Type().(*types.Signature); ok {
if ex, ok := gox.CheckFuncEx(tsig); ok {
if t, ok := ex.(*gox.TyOverloadFunc); ok {
return 1, t.Funcs, true
}
}
}
return 1, []types.Object{t.Func}, true
}
}
return
}

func (p *fnType) load(fnt types.Type) {
switch v := fnt.(type) {
case *gox.TypeType:
p.initTypeType(v)
case *types.Signature:
if recv := v.Recv(); recv != nil {
switch t := recv.Type().(type) {
case *gox.TyOverloadFunc:
p.initFuncs(0, t.Funcs...)
return
case *gox.TyOverloadMethod:
p.initFuncs(0, t.Methods...)
return
case *gox.TyTemplateRecvMethod:
if tsig, ok := t.Func.Type().(*types.Signature); ok {
if trecv := tsig.Recv(); trecv != nil {
if t, ok := trecv.Type().(*gox.TyOverloadFunc); ok {
p.initFuncs(1, t.Funcs...)
return
}
}
}
p.initFuncs(1, t.Func)
return
}
if base, funcs, ok := checkOverload(v); ok {
p.initFuncs(base, funcs)
} else {
p.init(0, v)
}
p.init(0, v)
}
}

func (p *fnType) initFuncs(base int, funcs ...types.Object) {
func (p *fnType) initFuncs(base int, funcs []types.Object) {
for i, obj := range funcs {
if sig, ok := obj.Type().(*types.Signature); ok {
if i == 0 {
Expand Down

0 comments on commit e068592

Please sign in to comment.