mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: refactor import reading
This CL restructures the gcimports importer to mmap the export data into memory as a string, and then pass that same string to both the typecheck and types2 importers. This is primarily motivated by preparation for unified IR; but it should also improve performance (fewer string copies) and reduces divergance between the two importers. Passes toolstash -cmp. Change-Id: I397f720693e9e6360bfcb5acb12609ab339d251f Reviewed-on: https://go-review.googlesource.com/c/go/+/325210 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
4e001a8d9e
commit
4c072c94dc
7 changed files with 173 additions and 155 deletions
|
|
@ -41,21 +41,15 @@ func (g *irgen) decls(decls []syntax.Decl) []ir.Node {
|
|||
}
|
||||
|
||||
func (g *irgen) importDecl(p *noder, decl *syntax.ImportDecl) {
|
||||
// TODO(mdempsky): Merge with gcimports so we don't have to import
|
||||
// packages twice.
|
||||
|
||||
g.pragmaFlags(decl.Pragma, 0)
|
||||
|
||||
// Get the imported package's path, as resolved already by types2
|
||||
// and gcimporter. This is the same path as would be computed by
|
||||
// parseImportPath.
|
||||
path := pkgNameOf(g.info, decl).Imported().Path()
|
||||
|
||||
ipkg := readImportFile(g.target, path)
|
||||
if ipkg == ir.Pkgs.Unsafe {
|
||||
switch pkgNameOf(g.info, decl).Imported().Path() {
|
||||
case "unsafe":
|
||||
p.importedUnsafe = true
|
||||
}
|
||||
if ipkg.Path == "embed" {
|
||||
case "embed":
|
||||
p.importedEmbed = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue