cmd/compile: refactor how declarations are imported

This CL moves all of the logic for wiring up imported declarations
into export.go, so that it can be reused by the indexed importer
code. While here, increase symmetry across routines.

Passes toolstash-check.

Change-Id: I1ccec5c3999522b010e4d04ed56b632fd4d712d9
Reviewed-on: https://go-review.googlesource.com/107621
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2018-04-17 14:40:56 -07:00
parent 514018c0aa
commit dd71e3fef4
3 changed files with 84 additions and 87 deletions

View file

@ -915,12 +915,9 @@ func loadsys() {
typ := typs[d.typ]
switch d.tag {
case funcTag:
importsym(Runtimepkg, sym, ONAME)
n := newfuncname(sym)
n.Type = typ
declare(n, PFUNC)
importfunc(Runtimepkg, src.NoXPos, sym, typ)
case varTag:
importvar(lineno, Runtimepkg, sym, typ)
importvar(Runtimepkg, src.NoXPos, sym, typ)
default:
Fatalf("unhandled declaration tag %v", d.tag)
}