exec

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package exec provides an Execute function that is used to run arbitrary Tamarin source code and return the result.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoImport added in v0.0.10

func AutoImport(s *scope.Scope, allowList, denyList []string) error

AutoImport adds the default modules to the given scope.

func Execute

func Execute(ctx context.Context, opts Opts) (result object.Object, err error)

Execute the given source code as input and return the result. If the execution is successful, a Tamarin object is returned as the final result. The context may be used to cancel the evaluation based on a timeout or otherwise.

The opts should contain the required input as well as other optional parameters.

Any panic is handled internally and propagated as an error.

The result value is the final of the final statement or expression in the main source code, which may be object.Nil if the expression doesn't evaluate to a value.

Types

type ModuleFunc added in v0.0.4

type ModuleFunc func(*scope.Scope) (*object.Module, error)

ModuleFunc is the signature of a function that returns a module

type Opts added in v0.0.4

type Opts struct {
	// Input is the main source code to execute.
	Input string

	// InputProgram may be used instead of Input to provide an AST that
	// was already parsed.
	InputProgram *ast.Program

	// File is the name of the file being executed (optional).
	File string

	// Importer may optionally be supplied as an interface
	// used to import modules. If not provided, any attempt
	// to import will fail, halting execution with an error.
	Importer evaluator.Importer

	// Scope may optionally be supplied as the top-level scope
	// used during execution. If not provided, an empty scope
	// will be created automatically.
	Scope *scope.Scope

	// If set to true, the default modules will not be imported
	// automatically.
	DisableAutoImport bool

	// If set to true, the default builtins will not be registered.
	DisableDefaultBuiltins bool

	// Supplies extra and/or override builtins for evaluation.
	Builtins []*object.Builtin

	// Breakpoints to set
	Breakpoints []evaluator.Breakpoint
}

Opts is used configure the execution of a Tamarin program.

Jump to

Keyboard shortcuts

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