golang basic 代码
文件路径:/src/cmd/compile/internal/types2/basic.go
/ 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
/ BasicKind describes the kind of basic type.
type BasicKind int
const (
Invalid BasicKind = iota / type is invalid
/ predeclared types
Bool
Int
Int8
Int16
Int32
Int64
Uint
Uint8
Uint16
Uint32
Uint64
Uintptr
Float32
Float64
Complex64
Complex128
String
UnsafePointer
/ types for untyped values
UntypedBool
UntypedInt
UntypedRune
UntypedFloat
UntypedComplex
UntypedString
UntypedNil
/ aliases
Byte = Uint8
Rune = Int32
)
/ BasicInfo is a set of flags describing properties of a basic type.
type BasicInfo int
/ Properties of basic types.
const (
IsBoolean BasicInfo = 1 << iota
IsInteger
IsUnsigned
IsFloat
IsComplex
IsString
IsUntyped
IsOrdered = IsInteger | IsFloat | IsString
IsNumeric = IsInteger | IsFloat | IsComplex
IsConstType = IsBoolean | IsNumeric | IsString
)
/ A Basic represents a basic type.
type Basic struct {
kind BasicKind
info BasicInfo
name string
}
/ Kind returns the kind of basic type b.
func (b *Basic) Kind() BasicKind { return b.kind }
/ Info returns information about properties of basic type b.
func (b *Basic) Info() BasicInfo { return b.info }
/ Name returns the name of basic type b.
func (b *Basic) Name() string { return b.name }
func (b *Basic) Underlying() Type { return b }
func (b *Basic) String() string { return TypeString(b, nil) }