aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/main.go
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2020-11-24 18:09:00 -0500
committerAlexander Rakoczy <alex@golang.org>2020-12-14 11:43:39 -0500
commit2b76429eb01ec1752f7622e3011babd7140ab870 (patch)
tree071856776dce5cd88135336c16a0e9a3f5ae583c /src/cmd/compile/internal/gc/main.go
parent9c5241e52020cf77683cd260a5fa3f3f029ed80c (diff)
downloadgo-2b76429eb01ec1752f7622e3011babd7140ab870.tar.gz
go-2b76429eb01ec1752f7622e3011babd7140ab870.zip
[dev.regabi] cmd/compile: refactor type initialization code into helper
Create a helper routine for initializing the types package, so as make it easier to use in unit testing (in a follow-on patch). Change-Id: I0f937788dfd34ac6641a4f28c16e47008aa08116 Reviewed-on: https://go-review.googlesource.com/c/go/+/273010 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Than McIntosh <thanm@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/gc/main.go')
-rw-r--r--src/cmd/compile/internal/gc/main.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go
index 503dc449d3..368fe1fcab 100644
--- a/src/cmd/compile/internal/gc/main.go
+++ b/src/cmd/compile/internal/gc/main.go
@@ -210,13 +210,7 @@ func Main(archInit func(*Arch)) {
// initialize types package
// (we need to do this to break dependencies that otherwise
// would lead to import cycles)
- types.Widthptr = Widthptr
- types.Dowidth = dowidth
- types.TypeLinkSym = func(t *types.Type) *obj.LSym {
- return typenamesym(t).Linksym()
- }
-
- initUniverse()
+ initializeTypesPackage()
dclcontext = ir.PEXTERN
@@ -1125,3 +1119,13 @@ func parseLang(s string) (lang, error) {
}
return lang{major: major, minor: minor}, nil
}
+
+func initializeTypesPackage() {
+ types.Widthptr = Widthptr
+ types.Dowidth = dowidth
+ types.TypeLinkSym = func(t *types.Type) *obj.LSym {
+ return typenamesym(t).Linksym()
+ }
+
+ initUniverse()
+}