mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: change types2.Union API to accept a list of Terms
Instead of providing a list of tildes and types, use a list of Terms to create a Union, with suitable accessors. Define the (exported) notion of a Term representing a union term. This simplified various uses and also will be easier to extend should we want to add more information to a Term in the future. Change-Id: I52fd73938bfa11bac60adbf10580b6d0680df4f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/340250 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
09d82689ed
commit
0d7dc417ea
9 changed files with 52 additions and 53 deletions
|
|
@ -394,11 +394,11 @@ func (w *writer) structType(typ *types2.Struct) {
|
|||
}
|
||||
|
||||
func (w *writer) unionType(typ *types2.Union) {
|
||||
w.len(typ.NumTerms())
|
||||
for i := 0; i < typ.NumTerms(); i++ {
|
||||
term, tilde := typ.Term(i)
|
||||
w.typ(term)
|
||||
w.bool(tilde)
|
||||
w.len(typ.Len())
|
||||
for i := 0; i < typ.Len(); i++ {
|
||||
t := typ.Term(i)
|
||||
w.typ(t.Type())
|
||||
w.bool(t.Tilde())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue