Source file src/cmd/compile/internal/types2/array.go

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package types2
     6  
     7  // An Array represents an array type.
     8  type Array struct {
     9  	len  int64
    10  	elem Type
    11  }
    12  
    13  // NewArray returns a new array type for the given element type and length.
    14  // A negative length indicates an unknown length.
    15  func NewArray(elem Type, len int64) *Array { return &Array{len: len, elem: elem} }
    16  
    17  // Len returns the length of array a.
    18  // A negative result indicates an unknown length.
    19  func (a *Array) Len() int64 { return a.len }
    20  
    21  // Elem returns element type of array a.
    22  func (a *Array) Elem() Type { return a.elem }
    23  
    24  func (a *Array) Underlying() Type { return a }
    25  func (a *Array) String() string   { return TypeString(a, nil) }
    26  

View as plain text