Documentation ¶
Index ¶
- type Errors
- type ImportCycleError
- type Package
- type Program
- func (p *Program) Import(path, srcDir string, pos token.Position) (*Package, error)
- func (p *Program) ImportFile(path string) (*Package, error)
- func (p *Program) LoadSSA() *ssa.Program
- func (p *Program) Parse(compileTestBinary bool) error
- func (p *Program) Sorted() []*Package
- func (p *Program) SwapTestMain() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Errors ¶
Errors contains a list of parser errors or a list of typechecker errors for the given package.
type ImportCycleError ¶
ImportCycleErrors is returned when encountering an import cycle. The list of packages is a list from the root package to the leaf package that imports one of the packages in the list.
func (*ImportCycleError) Error ¶
func (e *ImportCycleError) Error() string
type Package ¶
type Package struct { *Program *build.Package Imports map[string]*Package Importing bool Files []*ast.File Pkg *types.Package types.Info }
Package holds a loaded package, its imports, and its parsed files.
func (*Package) Check ¶
Check runs the package through the typechecker. The package must already be loaded and all dependencies must have been checked already.
Idempotent.
type Program ¶
type Program struct { Build *build.Context OverlayBuild *build.Context OverlayPath func(path string) string Packages map[string]*Package TypeChecker types.Config Dir string // current working directory (for error reporting) TINYGOROOT string // root of the TinyGo installation or root of the source code CFlags []string ClangHeaders string // contains filtered or unexported fields }
Program holds all packages and some metadata about the program as a whole.
func (*Program) Import ¶
Import loads the given package relative to srcDir (for the vendor directory). It only loads the current package without recursion.
func (*Program) ImportFile ¶
ImportFile loads and parses the import statements in the given path and creates a pseudo-package out of it.
func (*Program) LoadSSA ¶
LoadSSA constructs the SSA form of the loaded packages.
The program must already be parsed and type-checked with the .Parse() method.
func (*Program) Parse ¶
Parse recursively imports all packages, parses them, and typechecks them.
The returned error may be an Errors error, which contains a list of errors.
Idempotent.
func (*Program) Sorted ¶
Sorted returns a list of all packages, sorted in a way that no packages come before the packages they depend upon.