From 8f00c8a73eee24c9cee01fcc2e996302342dad4c Mon Sep 17 00:00:00 2001 From: visualfc Date: Thu, 25 Apr 2024 07:48:06 +0800 Subject: [PATCH 1/2] cl: Go+ overload func support pos --- cl/compile.go | 9 ++++++++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cl/compile.go b/cl/compile.go index cab47ce12..43894f725 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -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 @@ -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), } @@ -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) { @@ -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, diff --git a/go.mod b/go.mod index cfc589662..3aa2165fb 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index d36cd4cc8..38b7648e9 100644 --- a/go.sum +++ b/go.sum @@ -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= From f97bb348de1b6fec63b28da1475f80a468616175 Mon Sep 17 00:00:00 2001 From: visualfc Date: Thu, 25 Apr 2024 08:28:59 +0800 Subject: [PATCH 2/2] workflows: update go.yml --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f3e4bc2b2..4aab1c49c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -38,7 +38,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go: ${{ matrix.go }} + go-version: ${{ matrix.go }} - name: Test Go+ installer run: |