Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support type instruction #895

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions cl/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,11 @@ func preloadFile(p *gox.Package, parent *pkgCtx, file string, f *ast.File, targe
log.Println("==> Load > NewType", name)
}
decl := ctx.pkg.NewType(name)
if t.Doc != nil {
decl.SetComments(t.Doc)
} else if d.Doc != nil {
decl.SetComments(d.Doc)
}
ld.typInit = func() { // decycle
if debugLoad {
log.Println("==> Load > InitType", name)
Expand Down
15 changes: 14 additions & 1 deletion cl/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3212,7 +3212,7 @@ func main() {
`)
}

func TestGoInstr(t *testing.T) {
func TestGoFuncInstr(t *testing.T) {
gopClTest(t, `package main

//go:noinline
Expand All @@ -3225,3 +3225,16 @@ func test(s string, p uintptr, q uintptr, rest ...uintptr) int {
}
`)
}

func TestGoTypeInstr(t *testing.T) {
gopClTest(t, `package main

//go:notinheap
type S struct{ x int }
`, `package main
//go:notinheap
type S struct {
x int
}
`)
}
1 change: 0 additions & 1 deletion cmd/goptestgo/goptestgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ var (
"issue18149.go": {},
"issue22662.go": {},
"issue27201.go": {},
"issue40954.go": {}, // type instruction
"nilptr_aix.go": {},
"inline_literal.go": {},
"returntype.go": {}, // not a problem
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/goplus/gop
go 1.16

require (
github.com/goplus/gox v1.7.14
github.com/goplus/gox v1.7.15
github.com/qiniu/x v1.11.5
golang.org/x/mod v0.5.1
golang.org/x/tools v0.1.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/goplus/gox v1.7.14 h1:Y1SRmPm+Xlv8DZkf7Q0d9umvVtGcC6m0K6w8GvSC+Kg=
github.com/goplus/gox v1.7.14/go.mod h1:orZ6Mr9qqB4BVaVCMp/cypMtkn0Fp5XUE7e5uqjZATA=
github.com/goplus/gox v1.7.15 h1:su5OVmfKPTj4kXrATMBB2n2zuIYoPPR2pDv6k9/Qt3A=
github.com/goplus/gox v1.7.15/go.mod h1:orZ6Mr9qqB4BVaVCMp/cypMtkn0Fp5XUE7e5uqjZATA=
github.com/qiniu/x v1.11.5 h1:TYr5cl4g2yoHAZeDK4MTjKF6CMoG+IHlCDvvM5qym6U=
github.com/qiniu/x v1.11.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
Expand Down