scriggo

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: BSD-3-Clause Imports: 9 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(env runtime.Env, format string, a ...interface{}) error

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

func IsLimitExceeded(err error) bool

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

func PrintFunc

func PrintFunc(w io.Writer) runtime.PrintFunc

PrintFunc returns a function that print its argument to the writer w with the same format used by the builtin print to print to the standard error. The returned function can be used for the PrintFunc option.

Types

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

type CompilerError interface {
	error
	Position() ast.Position
	Path() string
	Message() string
}

CompilerError represents an error returned by the compiler.

type Declarations

type Declarations map[string]interface{}

Declarations.

type LoadOptions

type LoadOptions struct {
	OutOfSpec struct {
		AllowShebangLine bool         // allow shebang line; only for package-less programs.
		DisallowGoStmt   bool         // disallow "go" statement.
		PackageLess      bool         // enable the package-less syntax.
		Builtins         Declarations // builtins.
	}
}

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

type MapStringLoader map[string]string

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

type PackageLoader interface {
	Load(path string) (interface{}, error)
}

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

type Packages map[string]Package

Packages is a Loader that load packages from a map where the key is a package path and the value is a *Package value.

func (Packages) Load

func (pp Packages) Load(path string) (interface{}, error)

type Program

type Program struct {
	// contains filtered or unexported fields
}

func Load

func Load(src io.Reader, loader PackageLoader, options *LoadOptions) (*Program, error)

Load loads a Go program with the given options, loading the imported packages from loader.

func (*Program) Disassemble

func (p *Program) Disassemble(w io.Writer, pkgPath string) (int64, error)

Disassemble disassembles the package with the given path. 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.

func (*Program) Run

func (p *Program) Run(options *RunOptions) (int, error)

Run starts the program and waits for it to complete.

type RunOptions

type RunOptions struct {
	Context   context.Context
	PrintFunc runtime.PrintFunc
	OutOfSpec struct {
		Builtins map[string]interface{}
	}
}

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.
test module

Jump to

Keyboard shortcuts

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