aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2016-04-04 15:41:56 -0700
committerMatthew Dempsky <mdempsky@google.com>2016-04-04 23:47:25 +0000
commit0c71e293b57b0b2fbfa63d0fbf364b1771b6ee6e (patch)
tree43b221cef8ee2916df6613a64573cfd0f7763d2c /src
parent86e7a5b92a8cda6809d7677689fad557b2d15544 (diff)
downloadgo-0c71e293b57b0b2fbfa63d0fbf364b1771b6ee6e.tar.xz
cmd/compile: minor cleanup to import loading
Briefly document what the importfoo functions do. Get rid of importsym's unused result parameter. Get rid of the redundant calls to importsym(s, OTYPE) after we've already called pkgtype(s). Passes toolstash -cmp. Change-Id: I4c057358144044f5356e4dec68907ec85f1fe806 Reviewed-on: https://go-review.googlesource.com/21498 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/bimport.go1
-rw-r--r--src/cmd/compile/internal/gc/export.go13
-rw-r--r--src/cmd/compile/internal/gc/parser.go7
3 files changed, 7 insertions, 14 deletions
diff --git a/src/cmd/compile/internal/gc/bimport.go b/src/cmd/compile/internal/gc/bimport.go
index 103a0b354b..8c53372b80 100644
--- a/src/cmd/compile/internal/gc/bimport.go
+++ b/src/cmd/compile/internal/gc/bimport.go
@@ -290,7 +290,6 @@ func (p *importer) typ() *Type {
// parser.go:hidden_pkgtype
t = pkgtype(tsym)
- importsym(tsym, OTYPE)
p.typList = append(p.typList, t)
// read underlying type
diff --git a/src/cmd/compile/internal/gc/export.go b/src/cmd/compile/internal/gc/export.go
index 17681d0700..9fc6e56275 100644
--- a/src/cmd/compile/internal/gc/export.go
+++ b/src/cmd/compile/internal/gc/export.go
@@ -445,10 +445,8 @@ func dumpexport() {
}
}
-// import
-
-// return the sym for ss, which should match lexical
-func importsym(s *Sym, op Op) *Sym {
+// importsym declares symbol s as an imported object representable by op.
+func importsym(s *Sym, op Op) {
if s.Def != nil && s.Def.Op != op {
pkgstr := fmt.Sprintf("during import %q", importpkg.Path)
redeclare(s, pkgstr)
@@ -462,11 +460,10 @@ func importsym(s *Sym, op Op) *Sym {
s.Flags |= SymPackage // package scope
}
}
-
- return s
}
-// return the type pkg.name, forward declaring if needed
+// pkgtype returns the named type declared by symbol s.
+// If no such type has been declared yet, a forward declaration is returned.
func pkgtype(s *Sym) *Type {
importsym(s, OTYPE)
if s.Def == nil || s.Def.Op != OTYPE {
@@ -506,6 +503,7 @@ func importimport(s *Sym, path string) {
}
}
+// importconst declares symbol s as an imported constant with type t and value n.
func importconst(s *Sym, t *Type, n *Node) {
importsym(s, OLITERAL)
n = convlit(n, t)
@@ -533,6 +531,7 @@ func importconst(s *Sym, t *Type, n *Node) {
}
}
+// importvar declares symbol s as an imported variable with type t.
func importvar(s *Sym, t *Type) {
importsym(s, ONAME)
if s.Def != nil && s.Def.Op == ONAME {
diff --git a/src/cmd/compile/internal/gc/parser.go b/src/cmd/compile/internal/gc/parser.go
index aecd0361be..6538877e68 100644
--- a/src/cmd/compile/internal/gc/parser.go
+++ b/src/cmd/compile/internal/gc/parser.go
@@ -2931,12 +2931,7 @@ func (p *parser) hidden_pkgtype() *Type {
defer p.trace("hidden_pkgtype")()
}
- s1 := p.hidden_pkg_importsym()
-
- ss := pkgtype(s1)
- importsym(s1, OTYPE)
-
- return ss
+ return pkgtype(p.hidden_pkg_importsym())
}
// ----------------------------------------------------------------------------