diff options
author | Robert Griesemer <gri@golang.org> | 2021-06-30 13:26:11 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-07-01 22:17:50 +0000 |
commit | 30e5f266ed202740cfe0b7a9fde6117d6e1d6064 (patch) | |
tree | a9e72b80ccad4eee8d3927b3ddf6e3d8906f0624 /src/cmd/compile/internal/types2/array.go | |
parent | 9c1e7d9eff564df532c31114e2b833752519f0a2 (diff) | |
download | go-30e5f266ed202740cfe0b7a9fde6117d6e1d6064.tar.gz go-30e5f266ed202740cfe0b7a9fde6117d6e1d6064.zip |
[dev.typeparams] cmd/compile/internal/types2: move (remaining) type decls into their own files (cleanup)
This change moves the type declarations and associated methods for
each of the remaining Type types into their respective files. Except
for import and comment adjustments, and receiver name adjustments for
the Underlying and String methods, no functional changes are made.
Change-Id: I3b9ccab3c85abea4852bacd28c2e47cec05c0bac
Reviewed-on: https://go-review.googlesource.com/c/go/+/332093
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/array.go')
-rw-r--r-- | src/cmd/compile/internal/types2/array.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types2/array.go b/src/cmd/compile/internal/types2/array.go new file mode 100644 index 0000000000..502d49bc25 --- /dev/null +++ b/src/cmd/compile/internal/types2/array.go @@ -0,0 +1,25 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package types2 + +// An Array represents an array type. +type Array struct { + len int64 + elem Type +} + +// NewArray returns a new array type for the given element type and length. +// A negative length indicates an unknown length. +func NewArray(elem Type, len int64) *Array { return &Array{len: len, elem: elem} } + +// Len returns the length of array a. +// A negative result indicates an unknown length. +func (a *Array) Len() int64 { return a.len } + +// Elem returns element type of array a. +func (a *Array) Elem() Type { return a.elem } + +func (a *Array) Underlying() Type { return a } +func (a *Array) String() string { return TypeString(a, nil) } |