diff options
author | Matthew Dempsky <mdempsky@google.com> | 2018-04-02 15:38:57 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2018-04-02 23:12:53 +0000 |
commit | ce1252a6109ad81840ba7c0c69138175b093d107 (patch) | |
tree | 8dbbe36edcfcc7b68c2d90933e8d2bd472d051ea /src/cmd/compile/internal/types/sym.go | |
parent | 096d96779aca3baaa14644f64313abf03ff3d49f (diff) | |
download | go-ce1252a6109ad81840ba7c0c69138175b093d107.tar.gz go-ce1252a6109ad81840ba7c0c69138175b093d107.zip |
cmd/compile: simplify exportsym flags and logic
We used to have three Sym flags for dealing with export/reexport:
Export, Package, and Exported.
Export and Package were used to distinguish whether a symbol is
exported or package-scope (i.e., mutually exclusive), except that for
local declarations Export served double-duty as tracking whether the
symbol had been added to exportlist.
Meanwhile, imported declarations that needed reexporting could be
added to exportlist multiple times, necessitating a flag to track
whether they'd already been written out by exporter.
Simplify all of these into a single OnExportList flag so that we can
ensure symbols on exportlist are present exactly once. Merge
reexportsym into exportsym so there's a single place where we append
to exportlist.
Code that used to set Exported to prevent a symbol from being exported
can now just set OnExportList before calling declare to prevent it
from even appearing on exportlist.
Lastly, drop the IsAlias check in exportsym: we call exportsym too
early for local symbols to detect if they're an alias, and we never
reexport aliases.
Passes toolstash-check.
Change-Id: Icdea3719105dc169fcd7651606589cd08b0a80ff
Reviewed-on: https://go-review.googlesource.com/103865
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types/sym.go')
-rw-r--r-- | src/cmd/compile/internal/types/sym.go | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/cmd/compile/internal/types/sym.go b/src/cmd/compile/internal/types/sym.go index 1b9d01dab5..00328fa44f 100644 --- a/src/cmd/compile/internal/types/sym.go +++ b/src/cmd/compile/internal/types/sym.go @@ -35,30 +35,24 @@ type Sym struct { } const ( - symExport = 1 << iota // added to exportlist (no need to add again) - symPackage - symExported // already written out by export + symOnExportList = 1 << iota // added to exportlist (no need to add again) symUniq symSiggen symAsm symAlgGen ) -func (sym *Sym) Export() bool { return sym.flags&symExport != 0 } -func (sym *Sym) Package() bool { return sym.flags&symPackage != 0 } -func (sym *Sym) Exported() bool { return sym.flags&symExported != 0 } -func (sym *Sym) Uniq() bool { return sym.flags&symUniq != 0 } -func (sym *Sym) Siggen() bool { return sym.flags&symSiggen != 0 } -func (sym *Sym) Asm() bool { return sym.flags&symAsm != 0 } -func (sym *Sym) AlgGen() bool { return sym.flags&symAlgGen != 0 } +func (sym *Sym) OnExportList() bool { return sym.flags&symOnExportList != 0 } +func (sym *Sym) Uniq() bool { return sym.flags&symUniq != 0 } +func (sym *Sym) Siggen() bool { return sym.flags&symSiggen != 0 } +func (sym *Sym) Asm() bool { return sym.flags&symAsm != 0 } +func (sym *Sym) AlgGen() bool { return sym.flags&symAlgGen != 0 } -func (sym *Sym) SetExport(b bool) { sym.flags.set(symExport, b) } -func (sym *Sym) SetPackage(b bool) { sym.flags.set(symPackage, b) } -func (sym *Sym) SetExported(b bool) { sym.flags.set(symExported, b) } -func (sym *Sym) SetUniq(b bool) { sym.flags.set(symUniq, b) } -func (sym *Sym) SetSiggen(b bool) { sym.flags.set(symSiggen, b) } -func (sym *Sym) SetAsm(b bool) { sym.flags.set(symAsm, b) } -func (sym *Sym) SetAlgGen(b bool) { sym.flags.set(symAlgGen, b) } +func (sym *Sym) SetOnExportList(b bool) { sym.flags.set(symOnExportList, b) } +func (sym *Sym) SetUniq(b bool) { sym.flags.set(symUniq, b) } +func (sym *Sym) SetSiggen(b bool) { sym.flags.set(symSiggen, b) } +func (sym *Sym) SetAsm(b bool) { sym.flags.set(symAsm, b) } +func (sym *Sym) SetAlgGen(b bool) { sym.flags.set(symAlgGen, b) } func (sym *Sym) IsBlank() bool { return sym != nil && sym.Name == "_" |