Documentation ¶
Index ¶
- Variables
- func Instrument0(invariant Invariant, p engine.Predicate0) engine.Predicate0
- func Instrument1(invariant Invariant, p engine.Predicate1) engine.Predicate1
- func Instrument2(invariant Invariant, p engine.Predicate2) engine.Predicate2
- func Instrument3(invariant Invariant, p engine.Predicate3) engine.Predicate3
- func Instrument4(invariant Invariant, p engine.Predicate4) engine.Predicate4
- func Instrument5(invariant Invariant, p engine.Predicate5) engine.Predicate5
- func Instrument6(invariant Invariant, p engine.Predicate6) engine.Predicate6
- func Instrument7(invariant Invariant, p engine.Predicate7) engine.Predicate7
- func Instrument8(invariant Invariant, p engine.Predicate8) engine.Predicate8
- func New(opts ...Option) (*prolog.Interpreter, error)
- func Register(i *prolog.Interpreter, name string, hook Hook) error
- type Hook
- type Invariant
- type Option
Constants ¶
This section is empty.
Variables ¶
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 Option ¶
type Option func(*prolog.Interpreter) error
Option is a function that configures an Interpreter.
func WithBootstrap ¶
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 WithPredicate ¶
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 ¶
WithPredicates configures the interpreter to register the specified predicates. See WithPredicate for more details.
func WithUserOutputWriter ¶
WithUserOutputWriter configures the interpreter to use the specified writer for user output.