runtime

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SharedRuntime = &Runtime{index: sharedIndex}

Functions

func RegisterBuiltin

func RegisterBuiltin(importPath string, f PackageFunc)

Types

type Compiler added in v0.6.0

type Compiler interface {
	// Compile creates an adt.Expr (usually a builtin) for the
	// given external named resource (usually a function). name
	// is the name of the resource to compile, taken from altName
	// in `@extern(name=altName)`, or from the field name if that's
	// not defined. Scope is the struct that contains the field.
	// Other than "name", the fields in a are implementation
	// specific.
	Compile(name string, scope adt.Value, a *internal.Attr) (adt.Expr, errors.Error)
}

A Compiler fills in an adt.Expr for fields marked with `@extern(kind)`.

type Config added in v0.4.0

type Config struct {
	Runtime    *Runtime
	Filename   string
	ImportPath string

	Counts *stats.Counts

	compile.Config
}

type Interpreter added in v0.6.0

type Interpreter interface {
	// NewCompiler creates a compiler for b and reports any errors.
	NewCompiler(b *build.Instance, r *Runtime) (Compiler, errors.Error)

	// Kind returns the string to be used in the file-level @extern attribute.
	Kind() string
}

Interpreter defines an entrypoint for creating per-package interpreters.

type PackageFunc

type PackageFunc func(ctx adt.Runtime) (*adt.Vertex, errors.Error)

type Runtime

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

A Runtime maintains data structures for indexing and reuse for evaluation.

func New

func New() *Runtime

New is a wrapper for NewVersioned(internal.DefaultVersion).

func NewVersioned added in v0.8.0

func NewVersioned(v internal.EvaluatorVersion) *Runtime

NewVersioned creates a new Runtime using the given runtime version. The builtins registered with RegisterBuiltin are available for evaluation.

func (*Runtime) AddInst

func (r *Runtime) AddInst(path string, key *adt.Vertex, p *build.Instance)

func (*Runtime) Build

func (x *Runtime) Build(cfg *Config, b *build.Instance) (v *adt.Vertex, errs errors.Error)

Build builds b and all its transitive dependencies, insofar they have not been build yet.

func (*Runtime) BuildData added in v0.4.0

func (r *Runtime) BuildData(b *build.Instance) (x interface{}, ok bool)

func (*Runtime) BuiltinPackagePath added in v0.4.0

func (x *Runtime) BuiltinPackagePath(path string) string

BuiltinPackagePath converts a short-form builtin package identifier to its full path or "" if this doesn't exist.

func (*Runtime) Compile added in v0.4.0

func (r *Runtime) Compile(cfg *Config, source interface{}) (*adt.Vertex, *build.Instance)

func (*Runtime) CompileFile added in v0.4.0

func (r *Runtime) CompileFile(cfg *Config, file *ast.File) (*adt.Vertex, *build.Instance)

func (*Runtime) EvaluatorVersion added in v0.8.0

func (r *Runtime) EvaluatorVersion() internal.EvaluatorVersion

func (*Runtime) GetInstanceFromNode

func (r *Runtime) GetInstanceFromNode(key *adt.Vertex) *build.Instance

func (*Runtime) IndexToString

func (r *Runtime) IndexToString(i int64) string

func (*Runtime) Init added in v0.4.0

func (r *Runtime) Init()

func (*Runtime) IsInitialized added in v0.6.0

func (r *Runtime) IsInitialized() bool

IsInitialized reports whether the runtime has been initialized.

func (*Runtime) Label

func (r *Runtime) Label(s string, isIdent bool) adt.Feature

func (*Runtime) LabelStr

func (r *Runtime) LabelStr(l adt.Feature) string

func (*Runtime) LoadImport

func (r *Runtime) LoadImport(importPath string) *adt.Vertex

func (*Runtime) LoadType

func (x *Runtime) LoadType(t reflect.Type) (src ast.Expr, expr adt.Expr, ok bool)

func (*Runtime) NextUniqueID added in v0.5.0

func (r *Runtime) NextUniqueID() uint64

func (*Runtime) ResolveFiles

func (r *Runtime) ResolveFiles(p *build.Instance) (errs errors.Error)

TODO(resolve): this is also done in compile, do we need both?

func (*Runtime) SetBuildData added in v0.4.0

func (r *Runtime) SetBuildData(b *build.Instance, x interface{})

func (*Runtime) SetInterpreter added in v0.6.0

func (r *Runtime) SetInterpreter(i Interpreter)

SetInterpreter sets the interpreter for interpretation of files marked with @extern(kind).

func (*Runtime) StoreType

func (x *Runtime) StoreType(t reflect.Type, src ast.Expr, expr adt.Expr)

func (*Runtime) StrLabel

func (r *Runtime) StrLabel(str string) adt.Feature

func (*Runtime) StringToIndex

func (r *Runtime) StringToIndex(s string) int64

Jump to

Keyboard shortcuts

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