Documentation
¶
Index ¶
- func Errorf(env runtime.Env, format string, a ...interface{}) error
- func IsLimitExceeded(err error) bool
- func PrintFunc(w io.Writer) runtime.PrintFunc
- type BuildOptions
- type CombinedLoader
- type CombinedPackage
- type CompilerError
- type MapPackage
- type MapStringLoader
- type Package
- type PackageLoader
- type Packages
- type Program
- type RunOptions
- type UntypedBooleanConst
- type UntypedNumericConst
- type UntypedStringConst
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
Errorf formats according to a format specifier, and returns the string as a value that satisfies error.
Unlike the function fmt.Errorf, Errorf does not recognize the %w verb in format.
func IsLimitExceeded ¶
IsLimitExceeded reports whether the error is a limit exceeded compiler error.
These limitations have been arbitrarily added to Scriggo to enhance performances:
- 127 registers of a given type (integer, floating point, string or general) per function
- 256 function literal declarations plus unique functions calls per function
- 256 types available per function
- 256 unique predefined functions per function
- 256 integer values per function
- 256 string values per function
- 256 floating-point values per function
- 256 general values per function
Types ¶
type BuildOptions ¶ added in v0.31.0
type BuildOptions struct {
DisallowGoStmt bool // disallow "go" statement.
}
type CombinedLoader ¶
type CombinedLoader []PackageLoader
CombinedLoader combines more loaders in one loader. Load calls in order the Load methods of each loader and returns as soon as a loader returns a package.
func (CombinedLoader) Load ¶
func (loaders CombinedLoader) Load(path string) (interface{}, error)
type CombinedPackage ¶
type CombinedPackage []Package
CombinedPackage combines more packages in one package with name the name of the first package and declarations the declarations of all the packages.
Lookup method calls in order the Lookup methods of each package and returns as soon as a package returns a declaration.
func (CombinedPackage) DeclarationNames ¶
func (packages CombinedPackage) DeclarationNames() []string
func (CombinedPackage) Lookup ¶
func (packages CombinedPackage) Lookup(declName string) interface{}
func (CombinedPackage) Name ¶
func (packages CombinedPackage) Name() string
type CompilerError ¶
CompilerError represents an error returned by the compiler.
type MapPackage ¶
type MapPackage struct {
// Package name.
PkgName string
// Package declarations.
Declarations map[string]interface{}
}
func (MapPackage) DeclarationNames ¶
func (p MapPackage) DeclarationNames() []string
func (MapPackage) Lookup ¶
func (p MapPackage) Lookup(declName string) interface{}
func (MapPackage) Name ¶
func (p MapPackage) Name() string
type MapStringLoader ¶
MapStringLoader implements PackageLoader that returns the source of a package. Package paths and sources are respectively the keys and the values of the map.
func (MapStringLoader) Load ¶
func (r MapStringLoader) Load(path string) (interface{}, error)
type Package ¶
type Package interface {
// Name returns the package's name.
Name() string
// Lookup searches for an exported declaration, named declName, in the
// package. If the declaration does not exist, it returns nil.
//
// For a variable returns a pointer to the variable, for a function
// returns the function, for a type returns the reflect.Type and for a
// constant returns its value or a Constant.
Lookup(declName string) interface{}
// DeclarationNames returns the exported declaration names in the package.
DeclarationNames() []string
}
Package represents a predefined package.
type PackageLoader ¶
PackageLoader is implemented by package loaders. Given a package path, Load returns a *Package value or a package source as io.Reader.
If the package does not exist it returns nil and nil. If the package exists but there was an error while loading the package, it returns nil and the error.
If Load returns an io.Reader that implements io.Closer, the Close method will be called after a Read returns either EOF or an error.
func Loaders ¶
func Loaders(loaders ...PackageLoader) PackageLoader
Loaders returns a CombinedLoader that combine loaders.
type Packages ¶
Packages is a PackageLoader that load packages from a map where the key is a package path and the value is a Package value.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
func Build ¶ added in v0.31.0
func Build(src io.Reader, packages PackageLoader, options *BuildOptions) (*Program, error)
Build builds a Go program with the given options, loading the imported packages from packages.
func (*Program) Disassemble ¶
Disassemble disassembles the package with the given path and returns its assembly code. Predefined packages can not be disassembled.
func (*Program) MustRun ¶
func (p *Program) MustRun(options *RunOptions) int
MustRun is like Run but panics if the run fails.
type UntypedBooleanConst ¶
type UntypedBooleanConst = compiler.UntypedBooleanConst
UntypedBooleanConst represents an untyped boolean constant.
type UntypedNumericConst ¶
type UntypedNumericConst = compiler.UntypedNumericConst
UntypedNumericConst represents an untyped numeric constant.
type UntypedStringConst ¶
type UntypedStringConst = compiler.UntypedStringConst
UntypedStringConst represents an untyped string constant.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package compiler implements parsing, type checking and emitting of sources.
|
Package compiler implements parsing, type checking and emitting of sources. |
|
ast
Package ast declares the types used to define the template trees.
|
Package ast declares the types used to define the template trees. |
|
ast/astutil
Package astutil implements methods to walk and dump a tree.
|
Package astutil implements methods to walk and dump a tree. |
|
types
package types implements functions and types to represent and work with Scriggo types.
|
package types implements functions and types to represent and work with Scriggo types. |
|
Package fs defines basic interfaces to a file system.
|
Package fs defines basic interfaces to a file system. |
|
test
module
|