mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add typArray, typSlice, and typDDDArray
These are the first of several convenience constructors for types. They are part of type field encapsulation. This removes most external writes to TARRAY Type and Bound fields. substAny still directly fiddles with the .Type field. substAny generally needs access to Type internals. It will be moved to type.go in a future CL. bimport still directly writes the .Type field. This is hard to change. Also of note: * inl.go contains an (apparently irrelevant) bug fix: as.Right was given the wrong type. vararrtype was previously unused. * I believe that aindex (subr.go) never creates slices, but it is safer to keep existing behavior. The removal of -1 as a constant there is part of hiding that implementation detail. Future CLs will finish that job. Passes toolstash -cmp. Change-Id: If09bf001a874d7dba08e9ad0bcd6722860af4b91 Reviewed-on: https://go-review.googlesource.com/21249 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
f32161daf8
commit
eb98e51563
10 changed files with 62 additions and 73 deletions
|
|
@ -433,10 +433,8 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
|
|||
initplan(r)
|
||||
if Isslice(r.Type) {
|
||||
// Init slice.
|
||||
ta := typ(TARRAY)
|
||||
|
||||
ta.Type = r.Type.Type
|
||||
ta.Bound = r.Right.Val().U.(*Mpint).Int64()
|
||||
bound := r.Right.Val().U.(*Mpint).Int64()
|
||||
ta := typArray(r.Type.Type, bound)
|
||||
a := staticname(ta, 1)
|
||||
inittemps[r] = a
|
||||
n := *l
|
||||
|
|
@ -876,9 +874,7 @@ func maplit(ctxt int, n *Node, var_ *Node, init *Nodes) {
|
|||
tstruct := typ(TSTRUCT)
|
||||
tstruct.SetFields(fields[:])
|
||||
|
||||
tarr := typ(TARRAY)
|
||||
tarr.Bound = int64(b)
|
||||
tarr.Type = tstruct
|
||||
tarr := typArray(tstruct, int64(b))
|
||||
|
||||
// TODO(josharian): suppress alg generation for these types?
|
||||
dowidth(tarr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue