Debian Codegraph @

go/internal/gccgoimporter/backdoor.go

raw symbols SCIP
1 // Copyright 2018 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 // This file opens a back door to the parser for golang.org/x/tools/go/gccgoexportdata.
6
7 package gccgoimporter
8
9 import (
10 "go/types"
11 "io"
12 )
13
14 // Parse reads and parses gccgo export data from in and constructs a
15 // Package, inserting it into the imports map.
16 func Parse(in io.Reader, imports map[string]*types.Package, path string) (_ *types.Package, err error) {
17 var p parser
18 p.init(path, in, imports)
19 defer func() {
20 switch x := recover().(type) {
21 case nil:
22 // success
23 case importError:
24 err = x
25 default:
26 panic(x) // resume unexpected panic
27 }
28 }()
29 pkg := p.parsePackage()
30 imports[path] = pkg
31 return pkg, err
32 }