1// Copyright 2015 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 typecheck
6
7import "cmd/compile/internal/types"
8
9// ----------------------------------------------------------------------------
10// Export format
11
12// Tags. Must be < 0.
13const (
14	// Objects
15	packageTag = -(iota + 1)
16	constTag
17	typeTag
18	varTag
19	funcTag
20	endTag
21
22	// Types
23	namedTag
24	arrayTag
25	sliceTag
26	dddTag
27	structTag
28	pointerTag
29	signatureTag
30	interfaceTag
31	mapTag
32	chanTag
33
34	// Values
35	falseTag
36	trueTag
37	int64Tag
38	floatTag
39	fractionTag // not used by gc
40	complexTag
41	stringTag
42	nilTag
43	unknownTag // not used by gc (only appears in packages with errors)
44
45	// Type aliases
46	aliasTag
47)
48
49var predecl []*types.Type // initialized lazily
50
51func predeclared() []*types.Type {
52	if predecl == nil {
53		// initialize lazily to be sure that all
54		// elements have been initialized before
55		predecl = []*types.Type{
56			// basic types
57			types.Types[types.TBOOL],
58			types.Types[types.TINT],
59			types.Types[types.TINT8],
60			types.Types[types.TINT16],
61			types.Types[types.TINT32],
62			types.Types[types.TINT64],
63			types.Types[types.TUINT],
64			types.Types[types.TUINT8],
65			types.Types[types.TUINT16],
66			types.Types[types.TUINT32],
67			types.Types[types.TUINT64],
68			types.Types[types.TUINTPTR],
69			types.Types[types.TFLOAT32],
70			types.Types[types.TFLOAT64],
71			types.Types[types.TCOMPLEX64],
72			types.Types[types.TCOMPLEX128],
73			types.Types[types.TSTRING],
74
75			// basic type aliases
76			types.ByteType,
77			types.RuneType,
78
79			// error
80			types.ErrorType,
81
82			// untyped types
83			types.UntypedBool,
84			types.UntypedInt,
85			types.UntypedRune,
86			types.UntypedFloat,
87			types.UntypedComplex,
88			types.UntypedString,
89			types.Types[types.TNIL],
90
91			// package unsafe
92			types.Types[types.TUNSAFEPTR],
93
94			// invalid type (package contains errors)
95			types.Types[types.Txxx],
96
97			// any type, for builtin export data
98			types.Types[types.TANY],
99
100			// comparable
101			types.ComparableType,
102
103			// any
104			types.AnyType,
105		}
106	}
107	return predecl
108}
109