loader

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2021 License: BSD-3-Clause Imports: 25 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCachedGoroot added in v0.14.0

func GetCachedGoroot(config *compileopts.Config) (string, error)

GetCachedGoroot creates a new GOROOT by merging both the standard GOROOT and the GOROOT from TinyGo using lots of symbolic links.

func List added in v0.15.0

func List(config *compileopts.Config, extraArgs, pkgs []string) (*exec.Cmd, error)

List returns a ready-to-run *exec.Cmd for running the `go list` command with the configuration used for TinyGo.

Types

type Error added in v0.15.0

type Error struct {
	ImportStack []string
	Err         scanner.Error
}

Error is a regular error but with an added import stack. This is especially useful for debugging import cycle errors.

func (Error) Error added in v0.15.0

func (e Error) Error() string

type Errors

type Errors struct {
	Pkg  *Package
	Errs []error
}

Errors contains a list of parser errors or a list of typechecker errors for the given package.

func (Errors) Error

func (e Errors) Error() string

type NoTestFilesError added in v0.18.0

type NoTestFilesError struct {
	ImportPath string
}

Error returned when loading a *Program for a test binary but no test files are present.

func (NoTestFilesError) Error added in v0.18.0

func (e NoTestFilesError) Error() string

type Package

type Package struct {
	PackageJSON

	Files      []*ast.File
	FileHashes map[string][]byte
	CFlags     []string // CFlags used during CGo preprocessing (only set if CGo is used)
	Pkg        *types.Package
	// contains filtered or unexported fields
}

Package holds a loaded package, its imports, and its parsed files.

func (*Package) Check

func (p *Package) Check() error

Check runs the package through the typechecker. The package must already be loaded and all dependencies must have been checked already.

Idempotent.

func (*Package) Import

func (p *Package) Import(to string) (*types.Package, error)

Import implements types.Importer. It loads and parses packages it encounters along the way, if needed.

func (*Package) LoadSSA added in v0.17.0

func (p *Package) LoadSSA() *ssa.Package

LoadSSA constructs the SSA form of this package.

The program must already be parsed and type-checked with the .Parse() method.

func (*Package) Parse

func (p *Package) Parse() error

Parse parses and typechecks this package.

Idempotent.

type PackageJSON added in v0.15.0

type PackageJSON struct {
	Dir        string
	ImportPath string
	Name       string
	ForTest    string

	// Source files
	GoFiles  []string
	CgoFiles []string
	CFiles   []string

	// Dependency information
	Imports   []string
	ImportMap map[string]string

	// Error information
	Error *struct {
		ImportStack []string
		Pos         string
		Err         string
	}
}

PackageJSON is a subset of the JSON struct returned from `go list`.

type Program

type Program struct {
	Packages map[string]*Package

	// Information obtained during parsing.
	LDFlags []string
	// contains filtered or unexported fields
}

Program holds all packages and some metadata about the program as a whole.

func Load added in v0.15.0

func Load(config *compileopts.Config, inputPkgs []string, clangHeaders string, typeChecker types.Config) (*Program, error)

Load loads the given package with all dependencies (including the runtime package). Call .Parse() afterwards to parse all Go files (including CGo processing, if necessary).

func (*Program) LoadSSA

func (p *Program) LoadSSA() *ssa.Program

LoadSSA constructs the SSA form of the loaded packages.

The program must already be parsed and type-checked with the .Parse() method.

func (*Program) MainPkg added in v0.14.0

func (p *Program) MainPkg() *Package

MainPkg returns the last package in the Sorted() slice. This is the main package of the program.

func (*Program) Parse

func (p *Program) Parse() error

Parse parses all packages and typechecks them.

The returned error may be an Errors error, which contains a list of errors.

Idempotent.

func (*Program) Sorted

func (p *Program) Sorted() []*Package

Sorted returns a list of all packages, sorted in a way that no packages come before the packages they depend upon.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL