Skip to content

Commit

Permalink
Merge pull request #1690 from xushiwei/class
Browse files Browse the repository at this point in the history
TestGopxNoFunc
  • Loading branch information
xushiwei authored Jan 30, 2024
2 parents bfdd089 + 22904ba commit 309b8b7
Show file tree
Hide file tree
Showing 9 changed files with 818 additions and 810 deletions.
9 changes: 5 additions & 4 deletions cl/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,6 @@ func isOverloadFunc(name string) bool {
return n > 3 && name[n-3:n-1] == "__"
}

//go:linkname initThisGopPkg github.com/goplus/gox.initThisGopPkg
func initThisGopPkg(pkg *types.Package)

func initGopPkg(ctx *pkgCtx, pkg *gox.Package, gopSyms map[string]bool) {
for name, f := range ctx.syms {
if gopSyms[name] {
Expand All @@ -654,7 +651,7 @@ func initGopPkg(ctx *pkgCtx, pkg *gox.Package, gopSyms map[string]bool) {
if pkg.Types.Scope().Lookup(gopPackage) == nil {
pkg.Types.Scope().Insert(types.NewConst(token.NoPos, pkg.Types, gopPackage, types.Typ[types.UntypedBool], constant.MakeBool(true)))
}
initThisGopPkg(pkg.Types)
gox.InitThisGopPkg(pkg.Types)
}

func getEntrypoint(f *ast.File) string {
Expand Down Expand Up @@ -832,6 +829,10 @@ func preloadGopFile(p *gox.Package, ctx *blockCtx, file string, f *ast.File, con
}
parent.tylds = append(parent.tylds, ld)
}

// bugfix: see TestGopxNoFunc
parent.lbinames = append(parent.lbinames, classType)

ctx.classRecv = &ast.FieldList{List: []*ast.Field{{
Names: []*ast.Ident{
{Name: "this"},
Expand Down
Loading

0 comments on commit 309b8b7

Please sign in to comment.