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
5package types2
6
7// BasicKind describes the kind of basic type.
8type BasicKind int
9
10const (
11	Invalid BasicKind = iota // type is invalid
12
13	// predeclared types
14	Bool
15	Int
16	Int8
17	Int16
18	Int32
19	Int64
20	Uint
21	Uint8
22	Uint16
23	Uint32
24	Uint64
25	Uintptr
26	Float32
27	Float64
28	Complex64
29	Complex128
30	String
31	UnsafePointer
32
33	// types for untyped values
34	UntypedBool
35	UntypedInt
36	UntypedRune
37	UntypedFloat
38	UntypedComplex
39	UntypedString
40	UntypedNil
41
42	// aliases
43	Byte = Uint8
44	Rune = Int32
45)
46
47// BasicInfo is a set of flags describing properties of a basic type.
48type BasicInfo int
49
50// Properties of basic types.
51const (
52	IsBoolean BasicInfo = 1 << iota
53	IsInteger
54	IsUnsigned
55	IsFloat
56	IsComplex
57	IsString
58	IsUntyped
59
60	IsOrdered   = IsInteger | IsFloat | IsString
61	IsNumeric   = IsInteger | IsFloat | IsComplex
62	IsConstType = IsBoolean | IsNumeric | IsString
63)
64
65// A Basic represents a basic type.
66type Basic struct {
67	kind BasicKind
68	info BasicInfo
69	name string
70}
71
72// Kind returns the kind of basic type b.
73func (b *Basic) Kind() BasicKind { return b.kind }
74
75// Info returns information about properties of basic type b.
76func (b *Basic) Info() BasicInfo { return b.info }
77
78// Name returns the name of basic type b.
79func (b *Basic) Name() string { return b.name }
80
81func (b *Basic) Underlying() Type { return b }
82func (b *Basic) String() string   { return TypeString(b, nil) }
83