github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/tools/cmd/godex/gccgo14.go (about) 1 // Copyright 2014 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 // +build !go1.5 6 7 // This file implements access to gccgo-generated export data. 8 9 package main 10 11 import ( 12 "golang.org/x/tools/go/gccgoimporter" 13 "golang.org/x/tools/go/types" 14 ) 15 16 var ( 17 initmap = make(map[*types.Package]gccgoimporter.InitData) 18 ) 19 20 func init() { 21 incpaths := []string{"/"} 22 23 // importer for default gccgo 24 var inst gccgoimporter.GccgoInstallation 25 inst.InitFromDriver("gccgo") 26 register("gccgo", inst.GetImporter(incpaths, initmap)) 27 } 28 29 // Print the extra gccgo compiler data for this package, if it exists. 30 func (p *printer) printGccgoExtra(pkg *types.Package) { 31 if initdata, ok := initmap[pkg]; ok { 32 p.printf("/*\npriority %d\n", initdata.Priority) 33 34 p.printDecl("init", len(initdata.Inits), func() { 35 for _, init := range initdata.Inits { 36 p.printf("%s %s %d\n", init.Name, init.InitFunc, init.Priority) 37 } 38 }) 39 40 p.print("*/\n") 41 } 42 }