Imports #
"bytes"
"crypto/sha256"
"encoding/binary"
"go/constant"
"io"
"math/big"
"runtime"
"strings"
"fmt"
"fmt"
"runtime"
"strings"
"strconv"
"encoding/binary"
"errors"
"fmt"
"go/constant"
"go/token"
"io"
"math/big"
"os"
"runtime"
"strings"
"bytes"
"crypto/sha256"
"encoding/binary"
"go/constant"
"io"
"math/big"
"runtime"
"strings"
"fmt"
"fmt"
"runtime"
"strings"
"strconv"
"encoding/binary"
"errors"
"fmt"
"go/constant"
"go/token"
"io"
"math/big"
"os"
"runtime"
"strings"
ObjAlias has a list of TypeParamNames.
const AliasTypeParamNames
Deprecated: DerivedFuncInstance was a bool indicating whether an object was a function instance.
const DerivedFuncInstance
Deprecated: DerivedInfoNeeded was a bool indicating whether a type was a derived type.
const DerivedInfoNeeded
Flags in a uint32 in the header of a bitstream that is used to indicate whether optional features are enabled.
const Flags Field = iota
Deprecated: HasInit was a bool indicating whether a package has any init functions.
const HasInit
const ObjAlias CodeObj = iota
const ObjConst
const ObjFunc
const ObjStub
const ObjType
const ObjVar
Reserved indices within the meta relocation section.
const PrivateRootIdx Index = 1
Reserved indices within the meta relocation section.
const PublicRootIdx Index = 0
const RelocBody
const RelocMeta
const RelocName
const RelocObj
const RelocObjDict
const RelocObjExt
const RelocPkg
const RelocPosBase
const RelocString RelocKind = iota
const RelocType
const SyncAddLocal
const SyncAssign
const SyncBlockStmt
const SyncBool
const SyncCaseClause
const SyncCloseAnotherScope
const SyncCloseScope
const SyncCodeObj
const SyncCommClause
const SyncCompLit
const SyncConvRTTI
const SyncDecl
const SyncDeclName
const SyncDeclNames
const SyncDecls
Low-level coding markers.
const SyncEOF
const SyncExpr
const SyncExprList
const SyncExprType
const SyncExprs
const SyncForStmt
const SyncFuncBody
const SyncFuncExt
const SyncFuncLit
const SyncIfStmt
const SyncInt64
const SyncLabel
const SyncLabeledStmt
const SyncLinkname
const SyncLocalIdent
const SyncMethod
const SyncMultiExpr
const SyncObject
const SyncObject1
const SyncOp
const SyncOpenScope
const SyncOptLabel
const SyncParam
const SyncParams
const SyncPkg
const SyncPkgDef
const SyncPos
const SyncPosBase
const SyncPragma
Private markers (only known to cmd/compile).
const SyncPrivate
Higher-level object and type markers.
const SyncPublic
const SyncRType
const SyncRangeStmt
const SyncReloc
const SyncRelocs
const SyncSelectStmt
const SyncSelector
const SyncSignature
const SyncStmt1
const SyncStmts
const SyncStmtsEnd
const SyncString
const SyncSwitchStmt
const SyncSym
const SyncType
const SyncTypeExt
const SyncTypeIdx
const SyncTypeParamNames
const SyncUint64
const SyncUseObjLocal
const SyncUseReloc
const SyncVal
const SyncValue
const SyncVarExt
const TypeArray
const TypeBasic CodeType = iota
const TypeChan
const TypeInterface
const TypeMap
const TypeNamed
const TypePointer
const TypeSignature
const TypeSlice
const TypeStruct
const TypeTypeParam
const TypeUnion
V0: initial prototype. All data that is not assigned a Field is in version V0 and has not been deprecated.
const V0 Version = iota
V1: adds the Flags uint32 word
const V1
V2: removes unused legacy fields and supports type parameters for aliases. - remove the legacy "has init" bool from the public root - remove obj's "derived func instance" bool - add a TypeParamNames field to ObjAlias - remove derived info "needed" bool
const V2
const ValBigFloat
const ValBigInt
const ValBigRat
const ValBool CodeVal = iota
const ValInt64
const ValString
const _ SyncMarker = iota
var _SyncMarker_index = [...]uint16{...}
const _SyncMarker_name = "EOFBoolInt64Uint64StringValueValRelocsRelocUseRelocPublicPosPosBaseObjectObject1PkgPkgDefMethodTypeTypeIdxTypeParamNamesSignatureParamsParamCodeObjSymLocalIdentSelectorPrivateFuncExtVarExtTypeExtPragmaExprListExprsExprExprTypeAssignOpFuncLitCompLitDeclFuncBodyOpenScopeCloseScopeCloseAnotherScopeDeclNamesDeclNameStmtsBlockStmtIfStmtForStmtSwitchStmtRangeStmtCaseClauseCommClauseSelectStmtDeclsLabeledStmtUseObjLocalAddLocalLinknameStmt1StmtsEndLabelOptLabelMultiExprRTypeConvRTTI"
const flagSyncMarkers = *ast.BinaryExpr
introduced is the version a field was added.
var introduced = [numFields]Version{...}
const numFields = iota
const numRelocs = iota
const numVersions = iota
var overflow = *ast.CallExpr
removed is the version a field was removed in or 0 for fields that have not yet been deprecated. (So removed[f]-1 is the last version it is included in.)
var removed = [numFields]Version{...}
A CodeObj distinguishes among go/types.Object encodings.
type CodeObj int
A CodeType distinguishes among go/types.Type encodings.
type CodeType int
A CodeVal distinguishes among go/constant.Value encodings.
type CodeVal int
Field denotes a unit of data in the serialized unified IR bitstream. It is conceptually a like field in a structure. We only really need Fields when the data may or may not be present in a stream based on the Version of the bitstream. Unlike much of pkgbits, Fields are not serialized and can change values as needed.
type Field int
An Index represents a bitstream element index within a particular section.
type Index int32
A RelocKind indicates a particular section within a unified IR export.
type RelocKind int32
SyncMarker is an enum type that represents markers that may be written to export data to ensure the reader and writer stay synchronized.
type SyncMarker int
Version indicates a version of a unified IR bitstream. Each Version indicates the addition, removal, or change of new data in the bitstream. These are serialized to disk and the interpretation remains fixed.
type Version uint32
type frameVisitor func(file string, line int, name string, offset uintptr)
A Code is an enum value that can be encoded into bitstreams. Code types are preferable for enum types, because they allow Decoder to detect desyncs.
type Code interface {
Marker() SyncMarker
Value() int
}
A Decoder provides methods for decoding an individual element's bitstream data.
type Decoder struct {
common *PkgDecoder
Relocs []RelocEnt
Data strings.Reader
k RelocKind
Idx Index
}
An Encoder provides methods for encoding an individual element's bitstream data.
type Encoder struct {
p *PkgEncoder
Relocs []RelocEnt
RelocMap map[RelocEnt]uint32
Data bytes.Buffer
encodingRelocHeader bool
k RelocKind
Idx Index
}
A PkgDecoder provides methods for decoding a package's Unified IR export data.
type PkgDecoder struct {
version Version
sync bool
pkgPath string
elemData string
elemEnds []uint32
elemEndsEnds [numRelocs]uint32
scratchRelocEnt []RelocEnt
}
A PkgEncoder provides methods for encoding a package's Unified IR export data.
type PkgEncoder struct {
version Version
elems [numRelocs][]string
stringsIdx map[string]Index
syncFrames int
}
A relocEnt (relocation entry) is an entry in an element's local reference table. TODO(mdempsky): Rename this too.
type RelocEnt struct {
Kind RelocKind
Idx Index
}
AbsIdx returns the absolute index for the given (section, index) pair.
func (pr *PkgDecoder) AbsIdx(k RelocKind, idx Index) int
Bool decodes and returns a bool value from the element bitstream.
func (r *Decoder) Bool() bool
Bool encodes and writes a bool value into the element bitstream, and then returns the bool value. For simple, 2-alternative encodings, the idiomatic way to call Bool is something like: if w.Bool(x != 0) { // alternative #1 } else { // alternative #2 } For multi-alternative encodings, use Code instead.
func (w *Encoder) Bool(b bool) bool
Code encodes and writes a Code value into the element bitstream.
func (w *Encoder) Code(c Code)
Code decodes a Code value from the element bitstream and returns its ordinal value. It's the caller's responsibility to convert the result to an appropriate Code type. TODO(mdempsky): Ideally this method would have signature "Code[T Code] T" instead, but we don't allow generic methods and the compiler can't depend on generics yet anyway.
func (r *Decoder) Code(mark SyncMarker) int
DataIdx returns the raw element bitstream for the given (section, index) pair.
func (pr *PkgDecoder) DataIdx(k RelocKind, idx Index) string
DumpTo writes the package's encoded data to out0 and returns the package fingerprint.
func (pw *PkgEncoder) DumpTo(out0 io.Writer) (fingerprint [8]byte)
Fingerprint returns the package fingerprint.
func (pr *PkgDecoder) Fingerprint() [8]byte
Flush finalizes the element's bitstream and returns its Index.
func (w *Encoder) Flush() Index
Has reports whether field f is present in a bitstream at version v.
func (v Version) Has(f Field) bool
Int decodes and returns an int value from the element bitstream.
func (r *Decoder) Int() int
Int encodes and writes an int value into the element bitstream.
func (w *Encoder) Int(x int)
Int64 decodes and returns an int64 value from the element bitstream.
func (r *Decoder) Int64() int64
Int64 encodes and writes an int64 value into the element bitstream.
func (w *Encoder) Int64(x int64)
Len encodes and writes a non-negative int value into the element bitstream.
func (w *Encoder) Len(x int)
Len decodes and returns a non-negative int value from the element bitstream.
func (r *Decoder) Len() int
func (c CodeObj) Marker() SyncMarker
func (c CodeVal) Marker() SyncMarker
func (c CodeType) Marker() SyncMarker
NewDecoder returns a Decoder for the given (section, index) pair, and decodes the given SyncMarker from the element bitstream.
func (pr *PkgDecoder) NewDecoder(k RelocKind, idx Index, marker SyncMarker) Decoder
NewDecoderRaw returns a Decoder for the given (section, index) pair. Most callers should use NewDecoder instead.
func (pr *PkgDecoder) NewDecoderRaw(k RelocKind, idx Index) Decoder
NewEncoder returns an Encoder for a new element within the given section, and encodes the given SyncMarker as the start of the element bitstream.
func (pw *PkgEncoder) NewEncoder(k RelocKind, marker SyncMarker) Encoder
NewEncoderRaw returns an Encoder for a new element within the given section. Most callers should use NewEncoder instead.
func (pw *PkgEncoder) NewEncoderRaw(k RelocKind) Encoder
NewPkgDecoder returns a PkgDecoder initialized to read the Unified IR export data from input. pkgPath is the package path for the compilation unit that produced the export data.
func NewPkgDecoder(pkgPath string, input string) PkgDecoder
NewPkgEncoder returns an initialized PkgEncoder. syncFrames is the number of caller frames that should be serialized at Sync points. Serializing additional frames results in larger export data files, but can help diagnosing desync errors in higher-level Unified IR reader/writer code. If syncFrames is negative, then sync markers are omitted entirely.
func NewPkgEncoder(version Version, syncFrames int) PkgEncoder
NumElems returns the number of elements in section k.
func (pr *PkgDecoder) NumElems(k RelocKind) int
PeekObj returns the package path, object name, and CodeObj for the specified object index.
func (pr *PkgDecoder) PeekObj(idx Index) (string, string, CodeObj)
PeekPkgPath returns the package path for the specified package index.
func (pr *PkgDecoder) PeekPkgPath(idx Index) string
PkgPath returns the package path for the package TODO(mdempsky): Remove; unneeded since CL 391014.
func (pr *PkgDecoder) PkgPath() string
Reloc encodes and writes a relocation for the given (section, index) pair into the element bitstream. Note: Only the index is formally written into the element bitstream, so bitstream decoders must know from context which section an encoded relocation refers to.
func (w *Encoder) Reloc(r RelocKind, idx Index)
Reloc decodes a relocation of expected section k from the element bitstream and returns an index to the referenced element.
func (r *Decoder) Reloc(k RelocKind) Index
func (pr *PkgDecoder) RetireDecoder(d *Decoder)
String encodes and writes a string value into the element bitstream. Internally, strings are deduplicated by adding them to the strings section (if not already present), and then writing a relocation into the element bitstream.
func (w *Encoder) String(s string)
func (i SyncMarker) String() string
String decodes and returns a string value from the element bitstream.
func (r *Decoder) String() string
StringIdx returns the string value for the given string index.
func (pr *PkgDecoder) StringIdx(idx Index) string
StringIdx adds a string value to the strings section, if not already present, and returns its index.
func (pw *PkgEncoder) StringIdx(s string) Index
StringRef writes a reference to the given index, which must be a previously encoded string value.
func (w *Encoder) StringRef(idx Index)
Strings encodes and writes a variable-length slice of strings into the element bitstream.
func (w *Encoder) Strings(ss []string)
Strings decodes and returns a variable-length slice of strings from the element bitstream.
func (r *Decoder) Strings() []string
Sync decodes a sync marker from the element bitstream and asserts that it matches the expected marker. If EnableSync is false, then Sync is a no-op.
func (r *Decoder) Sync(mWant SyncMarker)
func (w *Encoder) Sync(m SyncMarker)
SyncMarkers reports whether pr uses sync markers.
func (pr *PkgDecoder) SyncMarkers() bool
SyncMarkers reports whether pw uses sync markers.
func (pw *PkgEncoder) SyncMarkers() bool
TempDecoder returns a Decoder for the given (section, index) pair, and decodes the given SyncMarker from the element bitstream. If possible the Decoder should be RetireDecoder'd when it is no longer needed, this will avoid heap allocations.
func (pr *PkgDecoder) TempDecoder(k RelocKind, idx Index, marker SyncMarker) Decoder
func (pr *PkgDecoder) TempDecoderRaw(k RelocKind, idx Index) Decoder
TotalElems returns the total number of elements across all sections.
func (pr *PkgDecoder) TotalElems() int
Uint encodes and writes a uint value into the element bitstream.
func (w *Encoder) Uint(x uint)
Uint decodes and returns a uint value from the element bitstream.
func (r *Decoder) Uint() uint
Uint64 encodes and writes a uint64 value into the element bitstream.
func (w *Encoder) Uint64(x uint64)
Uint64 decodes and returns a uint64 value from the element bitstream.
func (r *Decoder) Uint64() uint64
Value decodes and returns a constant.Value from the element bitstream.
func (r *Decoder) Value() constant.Value
Value encodes and writes a constant.Value into the element bitstream.
func (w *Encoder) Value(val constant.Value)
func (c CodeObj) Value() int
func (c CodeType) Value() int
func (c CodeVal) Value() int
Version reports the version of the bitstream.
func (w *Decoder) Version() Version
Version reports the version of the bitstream.
func (w *Encoder) Version() Version
func _()
func assert(b bool)
func (r *Decoder) bigFloat() *big.Float
func (w *Encoder) bigFloat(v *big.Float)
func (r *Decoder) bigInt() *big.Int
func (w *Encoder) bigInt(v *big.Int)
func (r *Decoder) checkErr(err error)
func (w *Encoder) checkErr(err error)
fmtFrames formats a backtrace for reporting reader/writer desyncs.
func fmtFrames(pcs ...uintptr) []string
func panicf(format string, args ...any)
func (w *Encoder) rawReloc(r RelocKind, idx Index) int
func (r *Decoder) rawReloc(k RelocKind, idx int) Index
func (r *Decoder) rawUvarint() uint64
func (w *Encoder) rawUvarint(x uint64)
func (r *Decoder) rawVarint() int64
func (w *Encoder) rawVarint(x int64)
readUvarint is a type-specialized copy of encoding/binary.ReadUvarint. This avoids the interface conversion and thus has better escape properties, which flows up the stack.
func readUvarint(r *strings.Reader) (uint64, error)
func (w *Encoder) scalar(val constant.Value)
func (r *Decoder) scalar() constant.Value
walkFrames calls visit for each call frame represented by pcs. pcs should be a slice of PCs, as returned by runtime.Callers.
func walkFrames(pcs []uintptr, visit frameVisitor)
Generated with Arrow