types.LocalPkg = types.NewPkg(base.Ctxt.Pkgpath, "")
- // We won't know localpkg's height until after import
- // processing. In the mean time, set to MaxPkgHeight to ensure
- // height comparisons at least work until then.
- types.LocalPkg.Height = types.MaxPkgHeight
-
// pseudo-package, for scoping
types.BuiltinPkg = types.NewPkg("go.builtin", "") // TODO(gri) name this package go.builtin?
types.BuiltinPkg.Prefix = "go.builtin" // not go%2ebuiltin
func (g *irgen) generate(noders []*noder) {
types.LocalPkg.Name = g.self.Name()
- types.LocalPkg.Height = g.self.Height()
typecheck.TypecheckAllowed = true
// Prevent size calculations until we set the underlying type
}
name := r.String()
- height := r.Len()
+ _ = r.Len() // was package height, but not necessary anymore.
pkg := types.NewPkg(path, "")
base.Assertf(pkg.Name == name, "package %q has name %q, but want %q", pkg.Path, pkg.Name, name)
}
- if pkg.Height == 0 {
- pkg.Height = height
- } else {
- base.Assertf(pkg.Height == height, "package %q has height %v, but want %v", pkg.Path, pkg.Height, height)
- }
-
return pkg
}
base.Flag.Lang = fmt.Sprintf("go1.%d", goversion.Version)
types.ParseLangFlag()
- types.LocalPkg.Height = 0 // reset so pkgReader.pkgIdx doesn't complain
target := typecheck.Target
typecheck.TypecheckAllowed = true
base.Assertf(path != "builtin" && path != "unsafe", "unexpected path for user-defined package: %q", path)
w.String(path)
w.String(pkg.Name())
- w.Len(pkg.Height())
+ w.Len(0) // was package height, but not necessary anymore.
w.Len(len(pkg.Imports()))
for _, imp := range pkg.Imports() {
w.string(exportPath(pkg))
if mainIndex {
w.string(pkg.Name)
- w.uint64(uint64(pkg.Height))
+ w.uint64(0) // was package height, but not necessary anymore.
}
// Sort symbols within a package by name.
for nPkgs := ird.uint64(); nPkgs > 0; nPkgs-- {
pkg := p.pkgAt(ird.uint64())
pkgName := p.stringAt(ird.uint64())
- pkgHeight := int(ird.uint64())
+ _ = int(ird.uint64()) // was package height, but not necessary anymore.
if pkg.Name == "" {
pkg.Name = pkgName
- pkg.Height = pkgHeight
types.NumImport[pkgName]++
// TODO(mdempsky): This belongs somewhere else.
if pkg.Name != pkgName {
base.Fatalf("conflicting package names %v and %v for path %q", pkg.Name, pkgName, pkg.Path)
}
- if pkg.Height != pkgHeight {
- base.Fatalf("conflicting package heights %v and %v for path %q", pkg.Height, pkgHeight, pkg.Path)
- }
}
for nSyms := ird.uint64(); nSyms > 0; nSyms-- {
// 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"
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
}