Skip to content

Commit

Permalink
cmd/compile: move typepkg to package types
Browse files Browse the repository at this point in the history
Response to code review feedback on CL 40693.

It is now only accessible by types.TypePkgLookup.

Passes toolstash-check.

Change-Id: I0c422c1a271f97467ae38de53af9dc33f4b31bdb
Reviewed-on: https://go-review.googlesource.com/41304
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
  • Loading branch information
josharian committed Apr 21, 2017
1 parent 0d50a49 commit 24c52ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/cmd/compile/internal/gc/go.go
Expand Up @@ -114,8 +114,6 @@ var racepkg *types.Pkg // package runtime/race

var msanpkg *types.Pkg // package runtime/msan

var typepkg *types.Pkg // fake package for runtime type info (headers)

var unsafepkg *types.Pkg // package unsafe

var trackpkg *types.Pkg // fake package for field tracking
Expand Down
2 changes: 0 additions & 2 deletions src/cmd/compile/internal/gc/main.go
Expand Up @@ -150,8 +150,6 @@ func Main(archInit func(*Arch)) {
trackpkg = types.NewPkg("go.track", "go.track")
trackpkg.Prefix = "go.track" // not go%2etrack

typepkg = types.NewPkg("type", "type")

// pseudo-package used for map zero values
mappkg = types.NewPkg("go.map", "go.map")
mappkg.Prefix = "go.map"
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/compile/internal/gc/reflect.go
Expand Up @@ -908,7 +908,7 @@ func typesymname(t *types.Type) string {
}

func typesym(t *types.Type) *types.Sym {
return typepkg.Lookup(typesymname(t))
return types.TypePkgLookup(typesymname(t))
}

// tracksym returns the symbol for tracking use of field/method f, assumed
Expand All @@ -919,7 +919,7 @@ func tracksym(t *types.Type, f *types.Field) *types.Sym {

func typesymprefix(prefix string, t *types.Type) *types.Sym {
p := prefix + "." + t.ShortString()
s := typepkg.Lookup(p)
s := types.TypePkgLookup(p)

//print("algsym: %s -> %+S\n", p, s);

Expand Down Expand Up @@ -1561,7 +1561,7 @@ func dalgsym(t *types.Type) *types.Sym {
// we use one algorithm table for all AMEM types of a given size
p := fmt.Sprintf(".alg%d", t.Width)

s = typepkg.Lookup(p)
s = types.TypePkgLookup(p)

if s.AlgGen() {
return s
Expand All @@ -1571,7 +1571,7 @@ func dalgsym(t *types.Type) *types.Sym {
// make hash closure
p = fmt.Sprintf(".hashfunc%d", t.Width)

hashfunc = typepkg.Lookup(p)
hashfunc = types.TypePkgLookup(p)

ot := 0
ot = dsymptr(hashfunc, ot, Runtimepkg.Lookup("memhash_varlen"), 0)
Expand All @@ -1581,7 +1581,7 @@ func dalgsym(t *types.Type) *types.Sym {
// make equality closure
p = fmt.Sprintf(".eqfunc%d", t.Width)

eqfunc = typepkg.Lookup(p)
eqfunc = types.TypePkgLookup(p)

ot = 0
ot = dsymptr(eqfunc, ot, Runtimepkg.Lookup("memequal_varlen"), 0)
Expand Down
7 changes: 7 additions & 0 deletions src/cmd/compile/internal/types/pkg.go
Expand Up @@ -68,6 +68,13 @@ var nopkg = &Pkg{
Syms: make(map[string]*Sym),
}

// fake package for runtime type info (headers)
var typepkg = NewPkg("type", "type")

func TypePkgLookup(name string) *Sym {
return typepkg.Lookup(name)
}

func (pkg *Pkg) Lookup(name string) *Sym {
s, _ := pkg.LookupOK(name)
return s
Expand Down

0 comments on commit 24c52ee

Please sign in to comment.