cuelang.org/go@v0.10.1/internal/golangorgx/tools/pkgbits/sync.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 import ( 8 "fmt" 9 "strings" 10 ) 11 12 // fmtFrames formats a backtrace for reporting reader/writer desyncs. 13 func fmtFrames(pcs ...uintptr) []string { 14 res := make([]string, 0, len(pcs)) 15 walkFrames(pcs, func(file string, line int, name string, offset uintptr) { 16 // Trim package from function name. It's just redundant noise. 17 name = strings.TrimPrefix(name, "cmd/compile/internal/noder.") 18 19 res = append(res, fmt.Sprintf("%s:%v: %s +0x%v", file, line, name, offset)) 20 }) 21 return res 22 } 23 24 type frameVisitor func(file string, line int, name string, offset uintptr) 25 26 // SyncMarker is an enum type that represents markers that may be 27 // written to export data to ensure the reader and writer stay 28 // synchronized. 29 type SyncMarker int 30 31 const ( 32 _ SyncMarker = iota 33 34 // Public markers (known to go/types importers). 35 36 // Low-level coding markers. 37 SyncEOF 38 SyncBool 39 SyncInt64 40 SyncUint64 41 SyncString 42 SyncValue 43 SyncVal 44 SyncRelocs 45 SyncReloc 46 SyncUseReloc 47 48 // Higher-level object and type markers. 49 SyncPublic 50 SyncPos 51 SyncPosBase 52 SyncObject 53 SyncObject1 54 SyncPkg 55 SyncPkgDef 56 SyncMethod 57 SyncType 58 SyncTypeIdx 59 SyncTypeParamNames 60 SyncSignature 61 SyncParams 62 SyncParam 63 SyncCodeObj 64 SyncSym 65 SyncLocalIdent 66 SyncSelector 67 68 // Private markers (only known to cmd/compile). 69 SyncPrivate 70 71 SyncFuncExt 72 SyncVarExt 73 SyncTypeExt 74 SyncPragma 75 76 SyncExprList 77 SyncExprs 78 SyncExpr 79 SyncExprType 80 SyncAssign 81 SyncOp 82 SyncFuncLit 83 SyncCompLit 84 85 SyncDecl 86 SyncFuncBody 87 SyncOpenScope 88 SyncCloseScope 89 SyncCloseAnotherScope 90 SyncDeclNames 91 SyncDeclName 92 93 SyncStmts 94 SyncBlockStmt 95 SyncIfStmt 96 SyncForStmt 97 SyncSwitchStmt 98 SyncRangeStmt 99 SyncCaseClause 100 SyncCommClause 101 SyncSelectStmt 102 SyncDecls 103 SyncLabeledStmt 104 SyncUseObjLocal 105 SyncAddLocal 106 SyncLinkname 107 SyncStmt1 108 SyncStmtsEnd 109 SyncLabel 110 SyncOptLabel 111 )