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

@ -7,6 +7,7 @@
package gc
import (
"cmd/compile/internal/types"
"reflect"
"testing"
"unsafe"
@ -26,20 +27,21 @@ func TestSizeof(t *testing.T) {
{Name{}, 36, 56},
{Param{}, 28, 56},
{Node{}, 84, 136},
{Sym{}, 60, 104},
{Type{}, 52, 88},
{MapType{}, 20, 40},
{ForwardType{}, 20, 32},
{FuncType{}, 28, 48},
{StructType{}, 12, 24},
{InterType{}, 4, 8},
{ChanType{}, 8, 16},
{ArrayType{}, 12, 16},
{DDDFieldType{}, 4, 8},
{FuncArgsType{}, 4, 8},
{ChanArgsType{}, 4, 8},
{PtrType{}, 4, 8},
{SliceType{}, 4, 8},
// TODO(gri) test the ones below in the types package
{types.Sym{}, 60, 104},
{types.Type{}, 52, 88},
{types.MapType{}, 20, 40},
{types.ForwardType{}, 20, 32},
{types.FuncType{}, 28, 48},
{types.StructType{}, 12, 24},
{types.InterType{}, 4, 8},
{types.ChanType{}, 8, 16},
{types.ArrayType{}, 12, 16},
{types.DDDFieldType{}, 4, 8},
{types.FuncArgsType{}, 4, 8},
{types.ChanArgsType{}, 4, 8},
{types.PtrType{}, 4, 8},
{types.SliceType{}, 4, 8},
}
for _, tt := range tests {