Documentation
¶
Overview ¶
Package builder builds a GX intermediate representation (IR). First, the GX source code is parsed to build a go/ast tree.
This package then builds an internal tree from the go/ast tree to resolve types and references. The root of the internal tree is a package. Each node in the tree refers to an external IR node that will be the output of the compilation.
The output IR tree is build from multiple passes of the internal tree:
- internal nodes and their matching external GIR node are created
- all types are resolved.
- the external IR tree is filled.
Errors are accumulated during these phases to report to the user. The output tree is available even if some errors occurred.
Index ¶
- type Builder
- func (b *Builder) Build(path string) (Package, error)
- func (b *Builder) BuildFiles(packagePath, packageName string, fs fs.FS, filenames []string) (Package, error)
- func (b *Builder) Import(path string) (*ir.Package, error)
- func (b *Builder) Loader() Loader
- func (b *Builder) NewIncrementalPackage(fullname string) *IncrementalPackage
- func (b *Builder) NewPackage(path, name string) (*FilePackage, error)
- type FilePackage
- type IncrementalPackage
- type Loader
- type Package
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder represents a build session from text to the intermediate representation.
func (*Builder) BuildFiles ¶
func (b *Builder) BuildFiles(packagePath, packageName string, fs fs.FS, filenames []string) (Package, error)
BuildFiles builds a package from a list of files. Note that the package is not registered by the builder.
func (*Builder) NewIncrementalPackage ¶
func (b *Builder) NewIncrementalPackage(fullname string) *IncrementalPackage
NewIncrementalPackage creates a new incremental package.
func (*Builder) NewPackage ¶
func (b *Builder) NewPackage(path, name string) (*FilePackage, error)
NewPackage returns a new builder package given the path of the package and its name.
type FilePackage ¶
type FilePackage struct {
// contains filtered or unexported fields
}
FilePackage builds GX package from GX source files or programmatically build IR.
func (*FilePackage) BuildFiles ¶
func (pkg *FilePackage) BuildFiles(fs fs.FS, filenames []string) (err error)
BuildFiles complete the package definitions from a list of source files.
func (*FilePackage) IR ¶
func (pkg *FilePackage) IR() *ir.Package
IR returns the package GX intermediate representation.
func (*FilePackage) ImportIR ¶
func (pkg *FilePackage) ImportIR(decls *ir.Declarations) error
ImportIR imports package definitions from a GX intermediate representation.
type IncrementalPackage ¶
type IncrementalPackage struct {
// contains filtered or unexported fields
}
IncrementalPackage builds GX package from an AST. It uses a single file in which everything is defined. Any name in the package can be reassigned without triggering an error. The main use case is for GX in a notebook.
func (*IncrementalPackage) Build ¶
func (pkg *IncrementalPackage) Build(src string) error
Build a AST source file. Definitions are added to the package or replace existing definitions.
func (*IncrementalPackage) BuildExpr ¶
func (pkg *IncrementalPackage) BuildExpr(src string) (ir.Expr, error)
BuildExpr builds an expression.
func (*IncrementalPackage) IR ¶
func (pkg *IncrementalPackage) IR() *ir.Package
IR returns the package GX intermediate representation.
Source Files
¶
- annotations.go
- arraytype.go
- assign.go
- axis.go
- basiclit.go
- binary.go
- builder.go
- call.go
- composite.go
- const.go
- decls.go
- directives.go
- einsum.go
- expr.go
- fields.go
- file.go
- func.go
- ident.go
- if.go
- import.go
- index.go
- interface.go
- ir.go
- irimporters.go
- macro.go
- meta.go
- namedtype.go
- number.go
- package.go
- paren.go
- pscope.go
- range.go
- rank.go
- return.go
- rscope.go
- scope.go
- select.go
- slice.go
- stmt.go
- struct.go
- typeassert.go
- unary.go
- var.go
Directories
¶
Path | Synopsis |
---|---|
Package builtins provides builtins for the compiler.
|
Package builtins provides builtins for the compiler. |
Package irb keeps track of IRs being built and how to add them to the package declarations.
|
Package irb keeps track of IRs being built and how to add them to the package declarations. |
Package testbuild provides helper functions to test the build step in GX.
|
Package testbuild provides helper functions to test the build step in GX. |