aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/bexport.go
blob: cc7f91f9372af4665131f801bf459cde47dd0aac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2015 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 typecheck

import "cmd/compile/internal/types"

// ----------------------------------------------------------------------------
// Export format

// Tags. Must be < 0.
const (
	// Objects
	packageTag = -(iota + 1)
	constTag
	typeTag
	varTag
	funcTag
	endTag

	// Types
	namedTag
	arrayTag
	sliceTag
	dddTag
	structTag
	pointerTag
	signatureTag
	interfaceTag
	mapTag
	chanTag

	// Values
	falseTag
	trueTag
	int64Tag
	floatTag
	fractionTag // not used by gc
	complexTag
	stringTag
	nilTag
	unknownTag // not used by gc (only appears in packages with errors)

	// Type aliases
	aliasTag
)

var predecl []*types.Type // initialized lazily

func predeclared() []*types.Type {
	if predecl == nil {
		// initialize lazily to be sure that all
		// elements have been initialized before
		predecl = []*types.Type{
			// basic types
			types.Types[types.TBOOL],
			types.Types[types.TINT],
			types.Types[types.TINT8],
			types.Types[types.TINT16],
			types.Types[types.TINT32],
			types.Types[types.TINT64],
			types.Types[types.TUINT],
			types.Types[types.TUINT8],
			types.Types[types.TUINT16],
			types.Types[types.TUINT32],
			types.Types[types.TUINT64],
			types.Types[types.TUINTPTR],
			types.Types[types.TFLOAT32],
			types.Types[types.TFLOAT64],
			types.Types[types.TCOMPLEX64],
			types.Types[types.TCOMPLEX128],
			types.Types[types.TSTRING],

			// basic type aliases
			types.ByteType,
			types.RuneType,

			// error
			types.ErrorType,

			// untyped types
			types.UntypedBool,
			types.UntypedInt,
			types.UntypedRune,
			types.UntypedFloat,
			types.UntypedComplex,
			types.UntypedString,
			types.Types[types.TNIL],

			// package unsafe
			types.Types[types.TUNSAFEPTR],

			// invalid type (package contains errors)
			types.Types[types.Txxx],

			// any type, for builtin export data
			types.Types[types.TANY],

			// comparable
			types.ComparableType,
		}
	}
	return predecl
}