]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/compile/internal/types/pkg.go
cmd/compile/internal/types: remove dead function
[gostls13.git] / src / cmd / compile / internal / types / pkg.go
index 4bf39a5e9dfff675890d4bd66fcc0efe28311874..c6ce7889afbb7bd7abc4d32a30e53278bda7b44f 100644 (file)
@@ -8,7 +8,6 @@ import (
        "cmd/internal/obj"
        "cmd/internal/objabi"
        "fmt"
-       "sort"
        "strconv"
        "sync"
 )
@@ -16,9 +15,6 @@ import (
 // pkgMap maps a package path to a package.
 var pkgMap = make(map[string]*Pkg)
 
-// MaxPkgHeight is a height greater than any likely package height.
-const MaxPkgHeight = 1e9
-
 type Pkg struct {
        Path    string // string literal used in import statement, e.g. "runtime/internal/sys"
        Name    string // package name, e.g. "sys"
@@ -26,12 +22,6 @@ type Pkg struct {
        Syms    map[string]*Sym
        Pathsym *obj.LSym
 
-       // Height is the package's height in the import graph. Leaf
-       // packages (i.e., packages with no imports) have height 0,
-       // and all other packages have height 1 plus the maximum
-       // height of their imported packages.
-       Height int
-
        Direct bool // imported directly
 }
 
@@ -64,25 +54,10 @@ func NewPkg(path, name string) *Pkg {
        return p
 }
 
-// ImportedPkgList returns the list of directly imported packages.
-// The list is sorted by package path.
-func ImportedPkgList() []*Pkg {
-       var list []*Pkg
-       for _, p := range pkgMap {
-               if p.Direct {
-                       list = append(list, p)
-               }
-       }
-       sort.Sort(byPath(list))
-       return list
+func PkgMap() map[string]*Pkg {
+       return pkgMap
 }
 
-type byPath []*Pkg
-
-func (a byPath) Len() int           { return len(a) }
-func (a byPath) Less(i, j int) bool { return a[i].Path < a[j].Path }
-func (a byPath) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
-
 var nopkg = &Pkg{
        Syms: make(map[string]*Sym),
 }
@@ -131,6 +106,14 @@ func (pkg *Pkg) LookupNum(prefix string, n int) *Sym {
        return pkg.LookupBytes(b)
 }
 
+// Selector looks up a selector identifier.
+func (pkg *Pkg) Selector(name string) *Sym {
+       if IsExported(name) {
+               pkg = LocalPkg
+       }
+       return pkg.Lookup(name)
+}
+
 var (
        internedStringsmu sync.Mutex // protects internedStrings
        internedStrings   = map[string]string{}
@@ -146,12 +129,3 @@ func InternString(b []byte) string {
        internedStringsmu.Unlock()
        return s
 }
-
-// CleanroomDo invokes f in an environment with no preexisting packages.
-// For testing of import/export only.
-func CleanroomDo(f func()) {
-       saved := pkgMap
-       pkgMap = make(map[string]*Pkg)
-       f()
-       pkgMap = saved
-}