github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/pkgbits/codes.go (about) 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 5 package 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. 11 type Code interface { 12 Marker() SyncMarker 13 14 Value() int 15 } 16 17 // A CodeVal distinguishes among go/constant.Value encodings. 18 type CodeVal int 19 20 func (c CodeVal) Marker() SyncMarker 21 func (c CodeVal) Value() int 22 23 const ( 24 ValBool CodeVal = iota 25 ValString 26 ValInt64 27 ValBigInt 28 ValBigRat 29 ValBigFloat 30 ) 31 32 // A CodeType distinguishes among go/types.Type encodings. 33 type CodeType int 34 35 func (c CodeType) Marker() SyncMarker 36 func (c CodeType) Value() int 37 38 const ( 39 TypeBasic CodeType = iota 40 TypeNamed 41 TypePointer 42 TypeSlice 43 TypeArray 44 TypeChan 45 TypeMap 46 TypeSignature 47 TypeStruct 48 TypeInterface 49 TypeUnion 50 TypeTypeParam 51 ) 52 53 // A CodeObj distinguishes among go/types.Object encodings. 54 type CodeObj int 55 56 func (c CodeObj) Marker() SyncMarker 57 func (c CodeObj) Value() int 58 59 const ( 60 ObjAlias CodeObj = iota 61 ObjConst 62 ObjType 63 ObjFunc 64 ObjVar 65 ObjStub 66 )