github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/types/alg.go (about)

     1  // Copyright 2016 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 types
     6  
     7  // AlgKind describes the kind of algorithms used for comparing and
     8  // hashing a Type.
     9  type AlgKind int8
    10  
    11  const (
    12  	AUNK   AlgKind = iota
    13  	ANOEQ
    14  	ANOALG
    15  	AMEM
    16  	AMEM0
    17  	AMEM8
    18  	AMEM16
    19  	AMEM32
    20  	AMEM64
    21  	AMEM128
    22  	ASTRING
    23  	AINTER
    24  	ANILINTER
    25  	AFLOAT32
    26  	AFLOAT64
    27  	ACPLX64
    28  	ACPLX128
    29  	ASPECIAL
    30  )
    31  
    32  // AlgType returns the AlgKind used for comparing and hashing Type t.
    33  func AlgType(t *Type) AlgKind
    34  
    35  // TypeHasNoAlg reports whether t does not have any associated hash/eq
    36  // algorithms because t, or some component of t, is marked Noalg.
    37  func TypeHasNoAlg(t *Type) bool
    38  
    39  // IsComparable reports whether t is a comparable type.
    40  func IsComparable(t *Type) bool
    41  
    42  // IncomparableField returns an incomparable Field of struct Type t, if any.
    43  func IncomparableField(t *Type) *Field
    44  
    45  // IsPaddedField reports whether the i'th field of struct type t is followed
    46  // by padding.
    47  func IsPaddedField(t *Type, i int) bool