diff options
author | Matthew Dempsky <mdempsky@google.com> | 2018-04-05 14:29:32 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2018-04-09 23:36:46 +0000 |
commit | 07029254a0f8991fb93f0838e469d2fcff514e0f (patch) | |
tree | df04a9a829dff02e2da0509d1b31d647f2c65b1a /src/cmd/compile/internal/types/pkg.go | |
parent | fe77a5413e64049af456b14ae911102681bee006 (diff) | |
download | go-07029254a0f8991fb93f0838e469d2fcff514e0f.tar.gz go-07029254a0f8991fb93f0838e469d2fcff514e0f.zip |
cmd/compile: add package height to export data
A package's height is defined as the length of the longest import path
between itself and a leaf package (i.e., package with no imports).
We can't rely on knowing the path of the package being compiled, so
package height is useful for defining a package ordering.
Updates #24693.
Change-Id: I965162c440b6c5397db91b621ea0be7fa63881f1
Reviewed-on: https://go-review.googlesource.com/105038
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types/pkg.go')
-rw-r--r-- | src/cmd/compile/internal/types/pkg.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/types/pkg.go b/src/cmd/compile/internal/types/pkg.go index 81bf72e972..e27c1fdba3 100644 --- a/src/cmd/compile/internal/types/pkg.go +++ b/src/cmd/compile/internal/types/pkg.go @@ -15,14 +15,24 @@ 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" - Pathsym *obj.LSym - Prefix string // escaped path for use in symbol table - Imported bool // export data of this package was parsed - Direct bool // imported directly - Syms map[string]*Sym + Path string // string literal used in import statement, e.g. "runtime/internal/sys" + Name string // package name, e.g. "sys" + Prefix string // escaped path for use in symbol table + 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 + + Imported bool // export data of this package was parsed + Direct bool // imported directly } // NewPkg returns a new Pkg for the given package path and name. |