Skip to content

Commit

Permalink
cl: Go+ overload func support pos
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Apr 25, 2024
1 parent 892db82 commit 8f00c8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion cl/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ type pkgCtx struct {
*nodeInterp
projs map[string]*gmxProject // .gmx => project
classes map[*ast.File]*gmxClass
overpos map[string]token.Pos // overload => pos
fset *token.FileSet
cpkgs *cpackages.Importer
syms map[string]loader
Expand Down Expand Up @@ -493,6 +494,7 @@ func NewPackage(pkgPath string, pkg *ast.Package, conf *Config) (p *gogen.Packag
nodeInterp: interp,
projs: make(map[string]*gmxProject),
classes: make(map[*ast.File]*gmxClass),
overpos: make(map[string]token.Pos),
syms: make(map[string]loader),
generics: make(map[string]bool),
}
Expand Down Expand Up @@ -663,7 +665,7 @@ func initGopPkg(ctx *pkgCtx, pkg *gogen.Package, gopSyms map[string]bool) {
ctx.loadType(lbi.(*ast.Ident).Name)
}
}
gogen.InitThisGopPkg(pkg.Types)
gogen.InitThisGopPkgEx(pkg.Types, ctx.overpos)
}

func loadFile(ctx *pkgCtx, f *ast.File) {
Expand Down Expand Up @@ -1153,6 +1155,11 @@ func preloadFile(p *gogen.Package, ctx *blockCtx, f *ast.File, goFile string, ge
ctx.handleErrorf(name.NamePos, "%v", err)
break
}
if recv != nil {
ctx.overpos[recv.Name+"."+name.Name] = name.NamePos
} else {
ctx.overpos[name.Name] = name.NamePos
}
oval := strings.Join(onames, ",")
preloadConst(&ast.GenDecl{
Doc: d.Doc,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/fsnotify/fsnotify v1.7.0
github.com/goplus/c2go v0.7.26
github.com/goplus/gogen v1.15.2
github.com/goplus/gogen v1.15.3-0.20240424153048-0d40138c65a5
github.com/goplus/mod v0.13.10
github.com/qiniu/x v1.13.10
golang.org/x/tools v0.19.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyT
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/goplus/c2go v0.7.26 h1:YmihhrbUC6+5RmdRqYzul4igfsyofwj4mM2iwkTTOuc=
github.com/goplus/c2go v0.7.26/go.mod h1:ePAStubV/ls8mmdPGQo6VfADTVd46rKuBemE4zzBDnA=
github.com/goplus/gogen v1.15.2 h1:Q6XaSx/Zi5tWnjfAziYsQI6Jv6MgODRpFtOYqNkiiqM=
github.com/goplus/gogen v1.15.2/go.mod h1:92qEzVgv7y8JEFICWG9GvYI5IzfEkxYdsA1DbmnTkqk=
github.com/goplus/gogen v1.15.3-0.20240424153048-0d40138c65a5 h1:OpVAkQH6VJaP4ooZgqeETcgW1Ac9wxLXej0Jl+PlxCs=
github.com/goplus/gogen v1.15.3-0.20240424153048-0d40138c65a5/go.mod h1:92qEzVgv7y8JEFICWG9GvYI5IzfEkxYdsA1DbmnTkqk=
github.com/goplus/mod v0.13.10 h1:5Om6KOvo31daN7N30kWU1vC5zhsJPM+uPbcEN/FnlzE=
github.com/goplus/mod v0.13.10/go.mod h1:HDuPZgpWiaTp3PUolFgsiX+Q77cbUWB/mikVHfYND3c=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down

0 comments on commit 8f00c8a

Please sign in to comment.