Documentation
¶
Overview ¶
Package builtin defines interfaces and helper methods to provide builtin functions.
Index ¶
- func Build(bld *builder.Builder, impl *impl.Stdlib, pkgBuilder PackageBuilder) (builder.Package, error)
- func IRFuncBuiltin[T builtinFuncImpl](name string, fnBuiltin interp.FuncBuiltin, pkg *ir.Package) *ir.FuncBuiltin
- type Builder
- func BuildConst(f ConstBuilder) Builder
- func BuildFunc(f FuncBuilder) Builder
- func BuildMethod(name string, f MethodBuilder) Builder
- func BuildType(f TypeBuilder) Builder
- func ImplementBuiltin(name string, fn interp.FuncBuiltin) Builder
- func ImplementGraphFunc(name string, slotFn interp.FuncBuiltin) Builder
- func ImplementStubFunc(name string, slotFn func(impl *impl.Stdlib) interp.FuncBuiltin) Builder
- func ParseSource(fs *embed.FS, names ...string) Builder
- func RegisterMacro(name string, impl cpevelements.MacroImpl) Builder
- type ConstBuilder
- type Func
- type FuncBuilder
- type MethodBuilder
- type PackageBuilder
- type TypeBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(bld *builder.Builder, impl *impl.Stdlib, pkgBuilder PackageBuilder) (builder.Package, error)
Build a package from its description.
func IRFuncBuiltin ¶
func IRFuncBuiltin[T builtinFuncImpl](name string, fnBuiltin interp.FuncBuiltin, pkg *ir.Package) *ir.FuncBuiltin
IRFuncBuiltin returns an *ir.FuncBuiltin for a function with the given name, implementation (contained in type T), interpreter slot, and package. Satisfies FuncBuilder.BuildFuncIR.
The type of the function is computed at compile time from the call to the function.
Types ¶
type Builder ¶
type Builder interface { // Name of the builder (for debugging purpose only). Name() string // Build the given package. Build(*builder.Builder, *impl.Stdlib, *builder.FilePackage) error }
Builder a builtin package.
func BuildConst ¶
func BuildConst(f ConstBuilder) Builder
BuildConst builds a function in a package.
func BuildMethod ¶
func BuildMethod(name string, f MethodBuilder) Builder
BuildMethod builds a method for a named type in a package.
func ImplementBuiltin ¶
func ImplementBuiltin(name string, fn interp.FuncBuiltin) Builder
ImplementBuiltin provides the implementation of a builtin function.
func ImplementGraphFunc ¶
func ImplementGraphFunc(name string, slotFn interp.FuncBuiltin) Builder
ImplementGraphFunc sets the implementation in a function declaration. The function declared type does not change.
func ImplementStubFunc ¶
ImplementStubFunc replaces a function declaration with a stdlib-provided implementation, while keeping the function's declared type.
func ParseSource ¶
ParseSource builds a package by parsing source files. If names is empty, all files at the top-level will parsed.
func RegisterMacro ¶
func RegisterMacro(name string, impl cpevelements.MacroImpl) Builder
RegisterMacro registers the implementation of a meta function.
type ConstBuilder ¶
ConstBuilder builds a type for a package.
type Func ¶
type Func struct { Func *ir.FuncBuiltin Impl interp.FuncBuiltin }
Func is a standard library builtin function.
func (Func) Implementation ¶
Implementation of the builtin function.
type FuncBuilder ¶
FuncBuilder builds a function for a package.
type MethodBuilder ¶
type MethodBuilder interface {
BuildMethodIR(*impl.Stdlib, builder.Package, *ir.NamedType) (*ir.FuncBuiltin, error)
}
MethodBuilder builds a method for a package given its named type.
type PackageBuilder ¶
type PackageBuilder struct { // FullPath is the full path to the package, including its path and its name. FullPath string // Builders are the steps required to build the package. Builders []Builder }
PackageBuilder builds a builtin package, that is a package composed of GX and Go code.