interpreter

package
v7.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegistryNames = func() []string {
	names := make([]string, 0, len(registry))

	for name := range registry {
		names = append(names, name)
	}
	return names
}()

RegistryNames is the list of the predicate names in the Registry.

Functions

func Instrument0

func Instrument0(invariant Invariant, p engine.Predicate0) engine.Predicate0

Instrument0 is a higher order function that given a 0arg-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func Instrument1

func Instrument1(invariant Invariant, p engine.Predicate1) engine.Predicate1

Instrument1 is a higher order function that given a 1arg-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func Instrument2

func Instrument2(invariant Invariant, p engine.Predicate2) engine.Predicate2

Instrument2 is a higher order function that given a 2args-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func Instrument3

func Instrument3(invariant Invariant, p engine.Predicate3) engine.Predicate3

Instrument3 is a higher order function that given a 3args-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func Instrument4

func Instrument4(invariant Invariant, p engine.Predicate4) engine.Predicate4

Instrument4 is a higher order function that given a 4args-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func Instrument5

func Instrument5(invariant Invariant, p engine.Predicate5) engine.Predicate5

Instrument5 is a higher order function that given a 5args-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func Instrument6

func Instrument6(invariant Invariant, p engine.Predicate6) engine.Predicate6

Instrument6 is a higher order function that given a 6args-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func Instrument7

func Instrument7(invariant Invariant, p engine.Predicate7) engine.Predicate7

Instrument7 is a higher order function that given a 7args-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func Instrument8

func Instrument8(invariant Invariant, p engine.Predicate8) engine.Predicate8

Instrument8 is a higher order function that given a 8args-predicate and an invariant returns a new predicate that calls the invariant before calling the predicate.

func New

func New(
	opts ...Option,
) (*prolog.Interpreter, error)

New creates a new prolog.Interpreter with the specified options.

func Register

func Register(i *prolog.Interpreter, name string, hook Hook) error

Register registers a well-known predicate in the interpreter with support for consumption measurement. name is the name of the predicate in the form of "atom/arity". cost is the cost of executing the predicate. meter is the gas meter object that is called when the predicate is called and which allows to count the cost of executing the predicate(ctx).

Types

type Hook

type Hook = func(functor string) func(env *engine.Env) error

type Invariant

type Invariant func(env *engine.Env) error

type Option

type Option func(*prolog.Interpreter) error

Option is a function that configures an Interpreter.

func WithBootstrap

func WithBootstrap(ctx goctx.Context, bootstrap string) Option

WithBootstrap configures the interpreter to compile the specified bootstrap script to serve as setup context. If compilation of the bootstrap script fails, the function will return an error.

func WithFS

func WithFS(fs fs.FS) Option

WithFS configures the interpreter to use the specified file system.

func WithPredicate

func WithPredicate(_ goctx.Context, predicate string, hook Hook) Option

WithPredicate configures the interpreter to register the specified predicate with the specified hook. The hook is a function that is called before the predicate is executed and can be used to check some conditions, like the gas consumption or the permission to execute the predicate.

The predicates names must be present in the registry, otherwise the function will return an error.

func WithPredicates

func WithPredicates(ctx goctx.Context, predicates []string, hook Hook) Option

WithPredicates configures the interpreter to register the specified predicates. See WithPredicate for more details.

func WithUserOutputWriter

func WithUserOutputWriter(w io.Writer) Option

WithUserOutputWriter configures the interpreter to use the specified writer for user output.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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