github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/go/internal/gccgoimporter/importer.go (about)

     1  // Copyright 2013 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 gccgoimporter implements Import for gccgo-generated object files.
     6  package gccgoimporter
     7  
     8  import (
     9  	"github.com/shogo82148/std/go/types"
    10  	"github.com/shogo82148/std/io"
    11  )
    12  
    13  // A PackageInit describes an imported package that needs initialization.
    14  type PackageInit struct {
    15  	Name     string
    16  	InitFunc string
    17  	Priority int
    18  }
    19  
    20  // The gccgo-specific init data for a package.
    21  type InitData struct {
    22  	// Initialization priority of this package relative to other packages.
    23  	// This is based on the maximum depth of the package's dependency graph;
    24  	// it is guaranteed to be greater than that of its dependencies.
    25  	Priority int
    26  
    27  	// The list of packages which this package depends on to be initialized,
    28  	// including itself if needed. This is the subset of the transitive closure of
    29  	// the package's dependencies that need initialization.
    30  	Inits []PackageInit
    31  }
    32  
    33  // An Importer resolves import paths to Packages. The imports map records
    34  // packages already known, indexed by package path.
    35  // An importer must determine the canonical package path and check imports
    36  // to see if it is already present in the map. If so, the Importer can return
    37  // the map entry. Otherwise, the importer must load the package data for the
    38  // given path into a new *Package, record it in imports map, and return the
    39  // package.
    40  type Importer func(imports map[string]*types.Package, path, srcDir string, lookup func(string) (io.ReadCloser, error)) (*types.Package, error)
    41  
    42  func GetImporter(searchpaths []string, initmap map[*types.Package]InitData) Importer