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

     1  // Copyright 2017 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  import (
     8  	"github.com/shogo82148/std/cmd/internal/src"
     9  	"github.com/shogo82148/std/go/constant"
    10  )
    11  
    12  // Object represents an ir.Node, but without needing to import cmd/compile/internal/ir,
    13  // which would cause an import cycle. The uses in other packages must type assert
    14  // values of type Object to ir.Node or a more specific type.
    15  type Object interface {
    16  	Pos() src.XPos
    17  	Sym() *Sym
    18  	Type() *Type
    19  }
    20  
    21  // Kind describes a kind of type.
    22  type Kind uint8
    23  
    24  const (
    25  	Txxx Kind = iota
    26  
    27  	TINT8
    28  	TUINT8
    29  	TINT16
    30  	TUINT16
    31  	TINT32
    32  	TUINT32
    33  	TINT64
    34  	TUINT64
    35  	TINT
    36  	TUINT
    37  	TUINTPTR
    38  
    39  	TCOMPLEX64
    40  	TCOMPLEX128
    41  
    42  	TFLOAT32
    43  	TFLOAT64
    44  
    45  	TBOOL
    46  
    47  	TPTR
    48  	TFUNC
    49  	TSLICE
    50  	TARRAY
    51  	TSTRUCT
    52  	TCHAN
    53  	TMAP
    54  	TINTER
    55  	TFORW
    56  	TANY
    57  	TSTRING
    58  	TUNSAFEPTR
    59  
    60  	// pseudo-types for literals
    61  	TIDEAL
    62  	TNIL
    63  	TBLANK
    64  
    65  	// pseudo-types used temporarily only during frame layout (CalcSize())
    66  	TFUNCARGS
    67  	TCHANARGS
    68  
    69  	// SSA backend types
    70  	TSSA
    71  	TTUPLE
    72  	TRESULTS
    73  
    74  	NTYPE
    75  )
    76  
    77  // ChanDir is whether a channel can send, receive, or both.
    78  type ChanDir uint8
    79  
    80  func (c ChanDir) CanRecv() bool
    81  func (c ChanDir) CanSend() bool
    82  
    83  const (
    84  	// types of channel
    85  	// must match ../../../../reflect/type.go:/ChanDir
    86  	Crecv ChanDir = 1 << 0
    87  	Csend ChanDir = 1 << 1
    88  	Cboth ChanDir = Crecv | Csend
    89  )
    90  
    91  // Types stores pointers to predeclared named types.
    92  //
    93  // It also stores pointers to several special types:
    94  //   - Types[TANY] is the placeholder "any" type recognized by SubstArgTypes.
    95  //   - Types[TBLANK] represents the blank variable's type.
    96  //   - Types[TINTER] is the canonical "interface{}" type.
    97  //   - Types[TNIL] represents the predeclared "nil" value's type.
    98  //   - Types[TUNSAFEPTR] is package unsafe's Pointer type.
    99  var Types [NTYPE]*Type
   100  
   101  var (
   102  	// Predeclared alias types. These are actually created as distinct
   103  	// defined types for better error messages, but are then specially
   104  	// treated as identical to their respective underlying types.
   105  	AnyType  *Type
   106  	ByteType *Type
   107  	RuneType *Type
   108  
   109  	// Predeclared error interface type.
   110  	ErrorType *Type
   111  	// Predeclared comparable interface type.
   112  	ComparableType *Type
   113  
   114  	// Types to represent untyped string and boolean constants.
   115  	UntypedString = newType(TSTRING)
   116  	UntypedBool   = newType(TBOOL)
   117  
   118  	// Types to represent untyped numeric constants.
   119  	UntypedInt     = newType(TIDEAL)
   120  	UntypedRune    = newType(TIDEAL)
   121  	UntypedFloat   = newType(TIDEAL)
   122  	UntypedComplex = newType(TIDEAL)
   123  )
   124  
   125  // UntypedTypes maps from a constant.Kind to its untyped Type
   126  // representation.
   127  var UntypedTypes = [...]*Type{
   128  	constant.Bool:    UntypedBool,
   129  	constant.String:  UntypedString,
   130  	constant.Int:     UntypedInt,
   131  	constant.Float:   UntypedFloat,
   132  	constant.Complex: UntypedComplex,
   133  }
   134  
   135  // DefaultKinds maps from a constant.Kind to its default Kind.
   136  var DefaultKinds = [...]Kind{
   137  	constant.Bool:    TBOOL,
   138  	constant.String:  TSTRING,
   139  	constant.Int:     TINT,
   140  	constant.Float:   TFLOAT64,
   141  	constant.Complex: TCOMPLEX128,
   142  }
   143  
   144  // A Type represents a Go type.
   145  //
   146  // There may be multiple unnamed types with identical structure. However, there must
   147  // be a unique Type object for each unique named (defined) type. After noding, a
   148  // package-level type can be looked up by building its unique symbol sym (sym =
   149  // package.Lookup(name)) and checking sym.Def. If sym.Def is non-nil, the type
   150  // already exists at package scope and is available at sym.Def.(*ir.Name).Type().
   151  // Local types (which may have the same name as a package-level type) are
   152  // distinguished by their vargen, which is embedded in their symbol name.
   153  type Type struct {
   154  	// extra contains extra etype-specific fields.
   155  	// As an optimization, those etype-specific structs which contain exactly
   156  	// one pointer-shaped field are stored as values rather than pointers when possible.
   157  	//
   158  	// TMAP: *Map
   159  	// TFORW: *Forward
   160  	// TFUNC: *Func
   161  	// TSTRUCT: *Struct
   162  	// TINTER: *Interface
   163  	// TFUNCARGS: FuncArgs
   164  	// TCHANARGS: ChanArgs
   165  	// TCHAN: *Chan
   166  	// TPTR: Ptr
   167  	// TARRAY: *Array
   168  	// TSLICE: Slice
   169  	// TSSA: string
   170  	extra interface{}
   171  
   172  	// width is the width of this Type in bytes.
   173  	width int64
   174  
   175  	// list of base methods (excluding embedding)
   176  	methods fields
   177  	// list of all methods (including embedding)
   178  	allMethods fields
   179  
   180  	// canonical OTYPE node for a named type (should be an ir.Name node with same sym)
   181  	obj Object
   182  	// the underlying type (type literal or predeclared type) for a defined type
   183  	underlying *Type
   184  
   185  	// Cache of composite types, with this type being the element type.
   186  	cache struct {
   187  		ptr   *Type
   188  		slice *Type
   189  	}
   190  
   191  	kind  Kind
   192  	align uint8
   193  
   194  	intRegs, floatRegs uint8
   195  
   196  	flags bitset8
   197  	alg   AlgKind
   198  
   199  	// size of prefix of object that contains all pointers. valid if Align > 0.
   200  	// Note that for pointers, this is always PtrSize even if the element type
   201  	// is NotInHeap. See size.go:PtrDataSize for details.
   202  	ptrBytes int64
   203  
   204  	// For defined (named) generic types, a pointer to the list of type params
   205  	// (in order) of this type that need to be instantiated. For instantiated
   206  	// generic types, this is the targs used to instantiate them. These targs
   207  	// may be typeparams (for re-instantiated types such as Value[T2]) or
   208  	// concrete types (for fully instantiated types such as Value[int]).
   209  	// rparams is only set for named types that are generic or are fully
   210  	// instantiated from a generic type, and is otherwise set to nil.
   211  	// TODO(danscales): choose a better name.
   212  	rparams *[]*Type
   213  }
   214  
   215  // Registers returns the number of integer and floating-point
   216  // registers required to represent a parameter of this type under the
   217  // ABIInternal calling conventions.
   218  //
   219  // If t must be passed by memory, Registers returns (math.MaxUint8,
   220  // math.MaxUint8).
   221  func (t *Type) Registers() (uint8, uint8)
   222  
   223  func (*Type) CanBeAnSSAAux()
   224  
   225  func (t *Type) NotInHeap() bool
   226  func (t *Type) Noalg() bool
   227  func (t *Type) Deferwidth() bool
   228  func (t *Type) Recur() bool
   229  func (t *Type) IsShape() bool
   230  func (t *Type) HasShape() bool
   231  
   232  func (t *Type) SetNotInHeap(b bool)
   233  func (t *Type) SetNoalg(b bool)
   234  func (t *Type) SetDeferwidth(b bool)
   235  func (t *Type) SetRecur(b bool)
   236  
   237  // Should always do SetHasShape(true) when doing SetIsShape(true).
   238  func (t *Type) SetIsShape(b bool)
   239  func (t *Type) SetHasShape(b bool)
   240  
   241  // Kind returns the kind of type t.
   242  func (t *Type) Kind() Kind
   243  
   244  // Sym returns the name of type t.
   245  func (t *Type) Sym() *Sym
   246  
   247  // Underlying returns the underlying type of type t.
   248  func (t *Type) Underlying() *Type
   249  
   250  // Pos returns a position associated with t, if any.
   251  // This should only be used for diagnostics.
   252  func (t *Type) Pos() src.XPos
   253  
   254  func (t *Type) RParams() []*Type
   255  
   256  func (t *Type) SetRParams(rparams []*Type)
   257  
   258  // IsFullyInstantiated reports whether t is a fully instantiated generic type; i.e. an
   259  // instantiated generic type where all type arguments are non-generic or fully
   260  // instantiated generic types.
   261  func (t *Type) IsFullyInstantiated() bool
   262  
   263  // Map contains Type fields specific to maps.
   264  type Map struct {
   265  	Key  *Type
   266  	Elem *Type
   267  
   268  	Bucket *Type
   269  }
   270  
   271  // MapType returns t's extra map-specific fields.
   272  func (t *Type) MapType() *Map
   273  
   274  // Forward contains Type fields specific to forward types.
   275  type Forward struct {
   276  	Copyto      []*Type
   277  	Embedlineno src.XPos
   278  }
   279  
   280  // Func contains Type fields specific to func types.
   281  type Func struct {
   282  	allParams []*Field
   283  
   284  	startParams  int
   285  	startResults int
   286  
   287  	resultsTuple *Type
   288  
   289  	// Argwid is the total width of the function receiver, params, and results.
   290  	// It gets calculated via a temporary TFUNCARGS type.
   291  	// Note that TFUNC's Width is Widthptr.
   292  	Argwid int64
   293  }
   294  
   295  // StructType contains Type fields specific to struct types.
   296  type Struct struct {
   297  	fields fields
   298  
   299  	// Maps have three associated internal structs (see struct MapType).
   300  	// Map links such structs back to their map type.
   301  	Map *Type
   302  
   303  	ParamTuple bool
   304  }
   305  
   306  // StructType returns t's extra struct-specific fields.
   307  func (t *Type) StructType() *Struct
   308  
   309  // Interface contains Type fields specific to interface types.
   310  type Interface struct {
   311  }
   312  
   313  // Ptr contains Type fields specific to pointer types.
   314  type Ptr struct {
   315  	Elem *Type
   316  }
   317  
   318  // ChanArgs contains Type fields specific to TCHANARGS types.
   319  type ChanArgs struct {
   320  	T *Type
   321  }
   322  
   323  // // FuncArgs contains Type fields specific to TFUNCARGS types.
   324  type FuncArgs struct {
   325  	T *Type
   326  }
   327  
   328  // Chan contains Type fields specific to channel types.
   329  type Chan struct {
   330  	Elem *Type
   331  	Dir  ChanDir
   332  }
   333  
   334  type Tuple struct {
   335  	first  *Type
   336  	second *Type
   337  }
   338  
   339  // Results are the output from calls that will be late-expanded.
   340  type Results struct {
   341  	Types []*Type
   342  }
   343  
   344  // Array contains Type fields specific to array types.
   345  type Array struct {
   346  	Elem  *Type
   347  	Bound int64
   348  }
   349  
   350  // Slice contains Type fields specific to slice types.
   351  type Slice struct {
   352  	Elem *Type
   353  }
   354  
   355  // A Field is a (Sym, Type) pairing along with some other information, and,
   356  // depending on the context, is used to represent:
   357  //   - a field in a struct
   358  //   - a method in an interface or associated with a named type
   359  //   - a function parameter
   360  type Field struct {
   361  	flags bitset8
   362  
   363  	Embedded uint8
   364  
   365  	Pos src.XPos
   366  
   367  	// Name of field/method/parameter. Can be nil for interface fields embedded
   368  	// in interfaces and unnamed parameters.
   369  	Sym  *Sym
   370  	Type *Type
   371  	Note string
   372  
   373  	// For fields that represent function parameters, Nname points to the
   374  	// associated ONAME Node. For fields that represent methods, Nname points to
   375  	// the function name node.
   376  	Nname Object
   377  
   378  	// Offset in bytes of this field or method within its enclosing struct
   379  	// or interface Type. For parameters, this is BADWIDTH.
   380  	Offset int64
   381  }
   382  
   383  func (f *Field) IsDDD() bool
   384  func (f *Field) Nointerface() bool
   385  
   386  func (f *Field) SetIsDDD(b bool)
   387  func (f *Field) SetNointerface(b bool)
   388  
   389  // End returns the offset of the first byte immediately after this field.
   390  func (f *Field) End() int64
   391  
   392  // IsMethod reports whether f represents a method rather than a struct field.
   393  func (f *Field) IsMethod() bool
   394  
   395  // NewArray returns a new fixed-length array Type.
   396  func NewArray(elem *Type, bound int64) *Type
   397  
   398  // NewSlice returns the slice Type with element type elem.
   399  func NewSlice(elem *Type) *Type
   400  
   401  // NewChan returns a new chan Type with direction dir.
   402  func NewChan(elem *Type, dir ChanDir) *Type
   403  
   404  func NewTuple(t1, t2 *Type) *Type
   405  
   406  func NewResults(types []*Type) *Type
   407  
   408  // NewMap returns a new map Type with key type k and element (aka value) type v.
   409  func NewMap(k, v *Type) *Type
   410  
   411  // NewPtrCacheEnabled controls whether *T Types are cached in T.
   412  // Caching is disabled just before starting the backend.
   413  // This allows the backend to run concurrently.
   414  var NewPtrCacheEnabled = true
   415  
   416  // NewPtr returns the pointer type pointing to t.
   417  func NewPtr(elem *Type) *Type
   418  
   419  // NewChanArgs returns a new TCHANARGS type for channel type c.
   420  func NewChanArgs(c *Type) *Type
   421  
   422  // NewFuncArgs returns a new TFUNCARGS type for func type f.
   423  func NewFuncArgs(f *Type) *Type
   424  
   425  func NewField(pos src.XPos, sym *Sym, typ *Type) *Field
   426  
   427  // SubstAny walks t, replacing instances of "any" with successive
   428  // elements removed from types.  It returns the substituted type.
   429  func SubstAny(t *Type, types *[]*Type) *Type
   430  
   431  func (f *Field) Copy() *Field
   432  
   433  // ResultTuple returns the result type of signature type t as a tuple.
   434  // This can be used as the type of multi-valued call expressions.
   435  func (t *Type) ResultsTuple() *Type
   436  
   437  // Recvs returns a slice of receiver parameters of signature type t.
   438  // The returned slice always has length 0 or 1.
   439  func (t *Type) Recvs() []*Field
   440  
   441  // Params returns a slice of regular parameters of signature type t.
   442  func (t *Type) Params() []*Field
   443  
   444  // Results returns a slice of result parameters of signature type t.
   445  func (t *Type) Results() []*Field
   446  
   447  // RecvsParamsResults returns a slice containing all of the
   448  // signature's parameters in receiver (if any), (normal) parameters,
   449  // and then results.
   450  func (t *Type) RecvParamsResults() []*Field
   451  
   452  // RecvParams returns a slice containing the signature's receiver (if
   453  // any) followed by its (normal) parameters.
   454  func (t *Type) RecvParams() []*Field
   455  
   456  // ParamsResults returns a slice containing the signature's (normal)
   457  // parameters followed by its results.
   458  func (t *Type) ParamsResults() []*Field
   459  
   460  func (t *Type) NumRecvs() int
   461  func (t *Type) NumParams() int
   462  func (t *Type) NumResults() int
   463  
   464  // IsVariadic reports whether function type t is variadic.
   465  func (t *Type) IsVariadic() bool
   466  
   467  // Recv returns the receiver of function type t, if any.
   468  func (t *Type) Recv() *Field
   469  
   470  // Param returns the i'th parameter of signature type t.
   471  func (t *Type) Param(i int) *Field
   472  
   473  // Result returns the i'th result of signature type t.
   474  func (t *Type) Result(i int) *Field
   475  
   476  // Key returns the key type of map type t.
   477  func (t *Type) Key() *Type
   478  
   479  // Elem returns the type of elements of t.
   480  // Usable with pointers, channels, arrays, slices, and maps.
   481  func (t *Type) Elem() *Type
   482  
   483  // ChanArgs returns the channel type for TCHANARGS type t.
   484  func (t *Type) ChanArgs() *Type
   485  
   486  // FuncArgs returns the func type for TFUNCARGS type t.
   487  func (t *Type) FuncArgs() *Type
   488  
   489  // IsFuncArgStruct reports whether t is a struct representing function parameters or results.
   490  func (t *Type) IsFuncArgStruct() bool
   491  
   492  // Methods returns a pointer to the base methods (excluding embedding) for type t.
   493  // These can either be concrete methods (for non-interface types) or interface
   494  // methods (for interface types).
   495  func (t *Type) Methods() []*Field
   496  
   497  // AllMethods returns a pointer to all the methods (including embedding) for type t.
   498  // For an interface type, this is the set of methods that are typically iterated
   499  // over. For non-interface types, AllMethods() only returns a valid result after
   500  // CalcMethods() has been called at least once.
   501  func (t *Type) AllMethods() []*Field
   502  
   503  // SetMethods sets the direct method set for type t (i.e., *not*
   504  // including promoted methods from embedded types).
   505  func (t *Type) SetMethods(fs []*Field)
   506  
   507  // SetAllMethods sets the set of all methods for type t (i.e.,
   508  // including promoted methods from embedded types).
   509  func (t *Type) SetAllMethods(fs []*Field)
   510  
   511  // Field returns the i'th field of struct type t.
   512  func (t *Type) Field(i int) *Field
   513  
   514  // Fields returns a slice of containing all fields of
   515  // a struct type t.
   516  func (t *Type) Fields() []*Field
   517  
   518  // SetInterface sets the base methods of an interface type t.
   519  func (t *Type) SetInterface(methods []*Field)
   520  
   521  // ArgWidth returns the total aligned argument size for a function.
   522  // It includes the receiver, parameters, and results.
   523  func (t *Type) ArgWidth() int64
   524  
   525  func (t *Type) Size() int64
   526  
   527  func (t *Type) Alignment() int64
   528  
   529  func (t *Type) SimpleString() string
   530  
   531  // Cmp is a comparison between values a and b.
   532  //
   533  //	-1 if a < b
   534  //	 0 if a == b
   535  //	 1 if a > b
   536  type Cmp int8
   537  
   538  const (
   539  	CMPlt = Cmp(-1)
   540  	CMPeq = Cmp(0)
   541  	CMPgt = Cmp(1)
   542  )
   543  
   544  // Compare compares types for purposes of the SSA back
   545  // end, returning a Cmp (one of CMPlt, CMPeq, CMPgt).
   546  // The answers are correct for an optimizer
   547  // or code generator, but not necessarily typechecking.
   548  // The order chosen is arbitrary, only consistency and division
   549  // into equivalence classes (Types that compare CMPeq) matters.
   550  func (t *Type) Compare(x *Type) Cmp
   551  
   552  // IsKind reports whether t is a Type of the specified kind.
   553  func (t *Type) IsKind(et Kind) bool
   554  
   555  func (t *Type) IsBoolean() bool
   556  
   557  // ToUnsigned returns the unsigned equivalent of integer type t.
   558  func (t *Type) ToUnsigned() *Type
   559  
   560  func (t *Type) IsInteger() bool
   561  
   562  func (t *Type) IsSigned() bool
   563  
   564  func (t *Type) IsUnsigned() bool
   565  
   566  func (t *Type) IsFloat() bool
   567  
   568  func (t *Type) IsComplex() bool
   569  
   570  // IsPtr reports whether t is a regular Go pointer type.
   571  // This does not include unsafe.Pointer.
   572  func (t *Type) IsPtr() bool
   573  
   574  // IsPtrElem reports whether t is the element of a pointer (to t).
   575  func (t *Type) IsPtrElem() bool
   576  
   577  // IsUnsafePtr reports whether t is an unsafe pointer.
   578  func (t *Type) IsUnsafePtr() bool
   579  
   580  // IsUintptr reports whether t is a uintptr.
   581  func (t *Type) IsUintptr() bool
   582  
   583  // IsPtrShaped reports whether t is represented by a single machine pointer.
   584  // In addition to regular Go pointer types, this includes map, channel, and
   585  // function types and unsafe.Pointer. It does not include array or struct types
   586  // that consist of a single pointer shaped type.
   587  // TODO(mdempsky): Should it? See golang.org/issue/15028.
   588  func (t *Type) IsPtrShaped() bool
   589  
   590  // HasNil reports whether the set of values determined by t includes nil.
   591  func (t *Type) HasNil() bool
   592  
   593  func (t *Type) IsString() bool
   594  
   595  func (t *Type) IsMap() bool
   596  
   597  func (t *Type) IsChan() bool
   598  
   599  func (t *Type) IsSlice() bool
   600  
   601  func (t *Type) IsArray() bool
   602  
   603  func (t *Type) IsStruct() bool
   604  
   605  func (t *Type) IsInterface() bool
   606  
   607  // IsEmptyInterface reports whether t is an empty interface type.
   608  func (t *Type) IsEmptyInterface() bool
   609  
   610  // IsScalar reports whether 't' is a scalar Go type, e.g.
   611  // bool/int/float/complex. Note that struct and array types consisting
   612  // of a single scalar element are not considered scalar, likewise
   613  // pointer types are also not considered scalar.
   614  func (t *Type) IsScalar() bool
   615  
   616  func (t *Type) PtrTo() *Type
   617  
   618  func (t *Type) NumFields() int
   619  
   620  func (t *Type) FieldType(i int) *Type
   621  
   622  func (t *Type) FieldOff(i int) int64
   623  
   624  func (t *Type) FieldName(i int) string
   625  
   626  // OffsetOf reports the offset of the field of a struct.
   627  // The field is looked up by name.
   628  func (t *Type) OffsetOf(name string) int64
   629  
   630  func (t *Type) NumElem() int64
   631  
   632  const (
   633  	IgnoreBlankFields componentsIncludeBlankFields = false
   634  	CountBlankFields  componentsIncludeBlankFields = true
   635  )
   636  
   637  // NumComponents returns the number of primitive elements that compose t.
   638  // Struct and array types are flattened for the purpose of counting.
   639  // All other types (including string, slice, and interface types) count as one element.
   640  // If countBlank is IgnoreBlankFields, then blank struct fields
   641  // (and their comprised elements) are excluded from the count.
   642  // struct { x, y [3]int } has six components; [10]struct{ x, y string } has twenty.
   643  func (t *Type) NumComponents(countBlank componentsIncludeBlankFields) int64
   644  
   645  // SoleComponent returns the only primitive component in t,
   646  // if there is exactly one. Otherwise, it returns nil.
   647  // Components are counted as in NumComponents, including blank fields.
   648  // Keep in sync with cmd/compile/internal/walk/convert.go:soleComponent.
   649  func (t *Type) SoleComponent() *Type
   650  
   651  // ChanDir returns the direction of a channel type t.
   652  // The direction will be one of Crecv, Csend, or Cboth.
   653  func (t *Type) ChanDir() ChanDir
   654  
   655  func (t *Type) IsMemory() bool
   656  
   657  func (t *Type) IsFlags() bool
   658  func (t *Type) IsVoid() bool
   659  func (t *Type) IsTuple() bool
   660  func (t *Type) IsResults() bool
   661  
   662  // IsUntyped reports whether t is an untyped type.
   663  func (t *Type) IsUntyped() bool
   664  
   665  // HasPointers reports whether t contains a heap pointer.
   666  // Note that this function ignores pointers to not-in-heap types.
   667  func (t *Type) HasPointers() bool
   668  
   669  // FakeRecvType returns the singleton type used for interface method receivers.
   670  func FakeRecvType() *Type
   671  
   672  func FakeRecv() *Field
   673  
   674  var (
   675  	// TSSA types. HasPointers assumes these are pointer-free.
   676  	TypeInvalid   = newSSA("invalid")
   677  	TypeMem       = newSSA("mem")
   678  	TypeFlags     = newSSA("flags")
   679  	TypeVoid      = newSSA("void")
   680  	TypeInt128    = newSSA("int128")
   681  	TypeResultMem = newResults([]*Type{TypeMem})
   682  )
   683  
   684  // NewNamed returns a new named type for the given type name. obj should be an
   685  // ir.Name. The new type is incomplete (marked as TFORW kind), and the underlying
   686  // type should be set later via SetUnderlying(). References to the type are
   687  // maintained until the type is filled in, so those references can be updated when
   688  // the type is complete.
   689  func NewNamed(obj Object) *Type
   690  
   691  // Obj returns the canonical type name node for a named type t, nil for an unnamed type.
   692  func (t *Type) Obj() Object
   693  
   694  // SetUnderlying sets the underlying type of an incomplete type (i.e. type whose kind
   695  // is currently TFORW). SetUnderlying automatically updates any types that were waiting
   696  // for this type to be completed.
   697  func (t *Type) SetUnderlying(underlying *Type)
   698  
   699  // NewInterface returns a new interface for the given methods and
   700  // embedded types. Embedded types are specified as fields with no Sym.
   701  func NewInterface(methods []*Field) *Type
   702  
   703  // NewSignature returns a new function type for the given receiver,
   704  // parameters, and results, any of which may be nil.
   705  func NewSignature(recv *Field, params, results []*Field) *Type
   706  
   707  // NewStruct returns a new struct with the given fields.
   708  func NewStruct(fields []*Field) *Type
   709  
   710  var (
   711  	IsInt     [NTYPE]bool
   712  	IsFloat   [NTYPE]bool
   713  	IsComplex [NTYPE]bool
   714  	IsSimple  [NTYPE]bool
   715  )
   716  
   717  var IsOrdered [NTYPE]bool
   718  
   719  // IsReflexive reports whether t has a reflexive equality operator.
   720  // That is, if x==x for all x of type t.
   721  func IsReflexive(t *Type) bool
   722  
   723  // Can this type be stored directly in an interface word?
   724  // Yes, if the representation is a single pointer.
   725  func IsDirectIface(t *Type) bool
   726  
   727  // IsInterfaceMethod reports whether (field) m is
   728  // an interface method. Such methods have the
   729  // special receiver type types.FakeRecvType().
   730  func IsInterfaceMethod(f *Type) bool
   731  
   732  // IsMethodApplicable reports whether method m can be called on a
   733  // value of type t. This is necessary because we compute a single
   734  // method set for both T and *T, but some *T methods are not
   735  // applicable to T receivers.
   736  func IsMethodApplicable(t *Type, m *Field) bool
   737  
   738  // RuntimeSymName returns the name of s if it's in package "runtime"; otherwise
   739  // it returns "".
   740  func RuntimeSymName(s *Sym) string
   741  
   742  // ReflectSymName returns the name of s if it's in package "reflect"; otherwise
   743  // it returns "".
   744  func ReflectSymName(s *Sym) string
   745  
   746  // IsNoInstrumentPkg reports whether p is a package that
   747  // should not be instrumented.
   748  func IsNoInstrumentPkg(p *Pkg) bool
   749  
   750  // IsNoRacePkg reports whether p is a package that
   751  // should not be race instrumented.
   752  func IsNoRacePkg(p *Pkg) bool
   753  
   754  // ReceiverBaseType returns the underlying type, if any,
   755  // that owns methods with receiver parameter t.
   756  // The result is either a named type or an anonymous struct.
   757  func ReceiverBaseType(t *Type) *Type
   758  
   759  func FloatForComplex(t *Type) *Type
   760  
   761  func ComplexForFloat(t *Type) *Type
   762  
   763  func TypeSym(t *Type) *Sym
   764  
   765  func TypeSymLookup(name string) *Sym
   766  
   767  func TypeSymName(t *Type) string
   768  
   769  var SimType [NTYPE]Kind
   770  
   771  // Fake package for shape types (see typecheck.Shapify()).
   772  var ShapePkg = NewPkg("go.shape", "go.shape")