basic.go raw

   1  // Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
   2  // Source: ../../cmd/compile/internal/types2/basic.go
   3  
   4  // Copyright 2011 The Go Authors. All rights reserved.
   5  // Use of this source code is governed by a BSD-style
   6  // license that can be found in the LICENSE file.
   7  
   8  package types
   9  
  10  // BasicKind describes the kind of basic type.
  11  type BasicKind int
  12  
  13  const (
  14  	Invalid BasicKind = iota // type is invalid
  15  
  16  	// predeclared types
  17  	Bool
  18  	Int
  19  	Int8
  20  	Int16
  21  	Int32
  22  	Int64
  23  	Uint
  24  	Uint8
  25  	Uint16
  26  	Uint32
  27  	Uint64
  28  	Uintptr
  29  	Float32
  30  	Float64
  31  	Complex64
  32  	Complex128
  33  	String
  34  	UnsafePointer
  35  
  36  	// types for untyped values
  37  	UntypedBool
  38  	UntypedInt
  39  	UntypedRune
  40  	UntypedFloat
  41  	UntypedComplex
  42  	UntypedString
  43  	UntypedNil
  44  
  45  	// aliases
  46  	Byte = Uint8
  47  	Rune = Int32
  48  )
  49  
  50  // BasicInfo is a set of flags describing properties of a basic type.
  51  type BasicInfo int
  52  
  53  // Properties of basic types.
  54  const (
  55  	IsBoolean BasicInfo = 1 << iota
  56  	IsInteger
  57  	IsUnsigned
  58  	IsFloat
  59  	IsComplex
  60  	IsString
  61  	IsUntyped
  62  
  63  	IsOrdered   = IsInteger | IsFloat | IsString
  64  	IsNumeric   = IsInteger | IsFloat | IsComplex
  65  	IsConstType = IsBoolean | IsNumeric | IsString
  66  )
  67  
  68  // A Basic represents a basic type.
  69  type Basic struct {
  70  	kind BasicKind
  71  	info BasicInfo
  72  	name string
  73  }
  74  
  75  // Kind returns the kind of basic type b.
  76  func (b *Basic) Kind() BasicKind { return b.kind }
  77  
  78  // Info returns information about properties of basic type b.
  79  func (b *Basic) Info() BasicInfo { return b.info }
  80  
  81  // Name returns the name of basic type b.
  82  func (b *Basic) Name() string { return b.name }
  83  
  84  func (b *Basic) Underlying() Type { return b }
  85  func (b *Basic) String() string   { return TypeString(b, nil) }
  86