GoPLS Viewer

Home|gopls/internal/pkgbits/codes.go
1// Copyright 2021 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 pkgbits
6
7// A Code is an enum value that can be encoded into bitstreams.
8//
9// Code types are preferable for enum types, because they allow
10// Decoder to detect desyncs.
11type Code interface {
12    // Marker returns the SyncMarker for the Code's dynamic type.
13    Marker() SyncMarker
14
15    // Value returns the Code's ordinal value.
16    Value() int
17}
18
19// A CodeVal distinguishes among go/constant.Value encodings.
20type CodeVal int
21
22func (c CodeValMarker() SyncMarker { return SyncVal }
23func (c CodeValValue() int         { return int(c) }
24
25// Note: These values are public and cannot be changed without
26// updating the go/types importers.
27
28const (
29    ValBool CodeVal = iota
30    ValString
31    ValInt64
32    ValBigInt
33    ValBigRat
34    ValBigFloat
35)
36
37// A CodeType distinguishes among go/types.Type encodings.
38type CodeType int
39
40func (c CodeTypeMarker() SyncMarker { return SyncType }
41func (c CodeTypeValue() int         { return int(c) }
42
43// Note: These values are public and cannot be changed without
44// updating the go/types importers.
45
46const (
47    TypeBasic CodeType = iota
48    TypeNamed
49    TypePointer
50    TypeSlice
51    TypeArray
52    TypeChan
53    TypeMap
54    TypeSignature
55    TypeStruct
56    TypeInterface
57    TypeUnion
58    TypeTypeParam
59)
60
61// A CodeObj distinguishes among go/types.Object encodings.
62type CodeObj int
63
64func (c CodeObjMarker() SyncMarker { return SyncCodeObj }
65func (c CodeObjValue() int         { return int(c) }
66
67// Note: These values are public and cannot be changed without
68// updating the go/types importers.
69
70const (
71    ObjAlias CodeObj = iota
72    ObjConst
73    ObjType
74    ObjFunc
75    ObjVar
76    ObjStub
77)
78
MembersX
CodeObj.Marker.c
CodeObj.Value
CodeVal
CodeVal.Marker.c
CodeType.Marker
CodeType.Value.c
CodeType.Value
CodeVal.Marker
CodeVal.Value
ValBool
CodeType.Marker.c
CodeObj.Value.c
CodeVal.Value.c
CodeType
TypeBasic
ObjAlias
Code
CodeObj
CodeObj.Marker
Members
X