cmd/compile: factor out Pkg, Sym, and Type into package types

- created new package cmd/compile/internal/types
- moved Pkg, Sym, Type to new package
- to break cycles, for now we need the (ugly) types/utils.go
  file which contains a handful of functions that must be installed
  early by the gc frontend
- to break cycles, for now we need two functions to convert between
  *gc.Node and *types.Node (the latter is a dummy type)
- adjusted the gc's code to use the new package and the conversion
  functions as needed
- made several Pkg, Sym, and Type methods functions as needed
- renamed constructors typ, typPtr, typArray, etc. to types.New,
  types.NewPtr, types.NewArray, etc.

Passes toolstash-check -all.

Change-Id: I8adfa5e85c731645d0a7fd2030375ed6ebf54b72
Reviewed-on: https://go-review.googlesource.com/39855
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2017-04-04 17:54:02 -07:00
parent 19bd145d07
commit f68f292820
48 changed files with 2433 additions and 2005 deletions

View file

@ -4,6 +4,8 @@
package gc
import "cmd/compile/internal/types"
// a function named init is a special case.
// it is called by the initialization before
// main is run. to make it unique within a
@ -12,7 +14,7 @@ package gc
var renameinit_initgen int
func renameinit() *Sym {
func renameinit() *types.Sym {
renameinit_initgen++
return lookupN("init.", renameinit_initgen)
}
@ -42,7 +44,7 @@ func anyinit(n []*Node) bool {
}
// are there any imported init functions
for _, s := range initSyms {
for _, s := range types.InitSyms {
if s.Def != nil {
return true
}
@ -81,7 +83,7 @@ func fninit(n []*Node) {
// (1)
gatevar := newname(lookup("initdone·"))
addvar(gatevar, Types[TUINT8], PEXTERN)
addvar(gatevar, types.Types[TUINT8], PEXTERN)
// (2)
fn := nod(ODCLFUNC, nil, nil)
@ -116,10 +118,10 @@ func fninit(n []*Node) {
r = append(r, a)
// (6)
for _, s := range initSyms {
for _, s := range types.InitSyms {
if s.Def != nil && s != initsym {
// could check that it is fn of no args/returns
a = nod(OCALL, s.Def, nil)
a = nod(OCALL, asNode(s.Def), nil)
r = append(r, a)
}
}
@ -134,7 +136,7 @@ func fninit(n []*Node) {
if s.Def == nil {
break
}
a = nod(OCALL, s.Def, nil)
a = nod(OCALL, asNode(s.Def), nil)
r = append(r, a)
}