MCPcopy Create free account
hub / github.com/nsf/gocode / parse_export

Method parse_export

package_bin.go:82–150  ·  view source on GitHub ↗
(callback func(string, ast.Decl))

Source from the content-addressed store, hash-verified

80}
81
82func (p *gc_bin_parser) parse_export(callback func(string, ast.Decl)) {
83 p.callback = callback
84
85 // read version info
86 var versionstr string
87 if b := p.rawByte(); b == 'c' || b == 'd' {
88 // Go1.7 encoding; first byte encodes low-level
89 // encoding format (compact vs debug).
90 // For backward-compatibility only (avoid problems with
91 // old installed packages). Newly compiled packages use
92 // the extensible format string.
93 // TODO(gri) Remove this support eventually; after Go1.8.
94 if b == 'd' {
95 p.debugFormat = true
96 }
97 p.trackAllTypes = p.rawByte() == 'a'
98 p.posInfoFormat = p.int() != 0
99 versionstr = p.string()
100 if versionstr == "v1" {
101 p.version = 0
102 }
103 } else {
104 // Go1.8 extensible encoding
105 // read version string and extract version number (ignore anything after the version number)
106 versionstr = p.rawStringln(b)
107 if s := strings.SplitN(versionstr, " ", 3); len(s) >= 2 && s[0] == "version" {
108 if v, err := strconv.Atoi(s[1]); err == nil && v > 0 {
109 p.version = v
110 }
111 }
112 }
113
114 // read version specific flags - extend as necessary
115 switch p.version {
116 case 6, 5, 4, 3, 2, 1:
117 p.debugFormat = p.rawStringln(p.rawByte()) == "debug"
118 p.trackAllTypes = p.int() != 0
119 p.posInfoFormat = p.int() != 0
120 case 0:
121 // Go1.7 encoding format - nothing to do here
122 default:
123 panic(fmt.Errorf("unknown export format version %d (%q)", p.version, versionstr))
124 }
125
126 // --- generic export data ---
127
128 // populate typList with predeclared "known" types
129 p.typList = append(p.typList, predeclared...)
130
131 // read package data
132 pkgName := p.pkg()
133 p.pfc.defalias = pkgName[strings.LastIndex(pkgName, "!")+1:]
134
135 // read objects of phase 1 only (see cmd/compiler/internal/gc/bexport.go)
136 objcount := 0
137 for {
138 tag := p.tagOrIndex()
139 if tag == endTag {

Callers

nothing calls this directly

Calls 7

rawByteMethod · 0.95
intMethod · 0.95
stringMethod · 0.95
rawStringlnMethod · 0.95
pkgMethod · 0.95
tagOrIndexMethod · 0.95
objMethod · 0.95

Tested by

no test coverage detected