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>
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index 3e5f963..7180538 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -1715,9 +1715,7 @@
esc = ddd.Esc
}
- tslice := typ(TARRAY)
- tslice.Type = l.Type.Type
- tslice.Bound = -1
+ tslice := typSlice(l.Type.Type)
var n *Node
if len(lr0) == 0 {
@@ -2707,9 +2705,7 @@
// large numbers of strings are passed to the runtime as a slice.
fn = "concatstrings"
- t := typ(TARRAY)
- t.Type = Types[TSTRING]
- t.Bound = -1
+ t := typSlice(Types[TSTRING])
slice := Nod(OCOMPLIT, nil, typenod(t))
if prealloc[n] != nil {
prealloc[slice] = prealloc[n]