Documentation
¶
Index ¶
- func Call(ctx context.Context, main *compiler.Code, functionName string, ...) (object.Object, error)
- func Eval(ctx context.Context, source string, options ...Option) (object.Object, error)
- func EvalCode(ctx context.Context, main *compiler.Code, options ...Option) (object.Object, error)
- type Config
- type Option
- func WithConcurrency() Option
- func WithGlobal(name string, value any) Option
- func WithGlobalOverride(name string, value any) Option
- func WithGlobals(globals map[string]any) Option
- func WithImporter(i importer.Importer) Option
- func WithListenersAllowed() Option
- func WithLocalImporter(paths []string) Option
- func WithoutDefaultGlobals() Option
- func WithoutGlobal(name string) Option
- func WithoutGlobals(names ...string) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Call ¶
func Call( ctx context.Context, main *compiler.Code, functionName string, args []object.Object, options ...Option, ) (object.Object, error)
Call evaluates the precompiled code and then calls the named function. The supplied arguments are passed in the function call. The result of the function call is returned.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config assists in configuring Risor evaluations.
func NewConfig ¶
NewConfig returns a new Risor Config. Use the Risor options functions to customize the configuration.
func (*Config) CombinedGlobals
deprecated
func (*Config) CompilerOpts ¶
CompilerOpts returns compiler options derived from this configuration.
func (*Config) GlobalNames ¶
GlobalNames returns a list of all global variables names that should be available in a Risor evaluation.
type Option ¶
type Option func(*Config)
Option describes a function used to configure a Risor evaluation.
func WithConcurrency ¶
func WithConcurrency() Option
WithConcurrency enables the use of concurrency in Risor evaluations.
func WithGlobal ¶
WithGlobal supplies a single named global variable to the Risor evaluation.
func WithGlobalOverride ¶
WithGlobalOverride replaces the a global or module builtin with the given value
func WithGlobals ¶
WithGlobals provides global variables that are made available to Risor evaluations. This option is additive, so multiple WithGlobals options may be supplied. If the same key is supplied multiple times, the last supplied value is used.
func WithImporter ¶
WithImporter supplies an Importer that will be used to execute import statements.
func WithListenersAllowed ¶
func WithListenersAllowed() Option
WithListenersAllowed allows opening sockets for listening.
func WithLocalImporter ¶
WithLocalImporter enables importing Risor modules from the given directory.
func WithoutDefaultGlobals ¶
func WithoutDefaultGlobals() Option
WithoutDefaultGlobals opts out of all default global builtins and modules.
func WithoutGlobal ¶
WithoutGlobal opts out of a given global builtin or module. If the name can't be resolved, this is a no-op. This does operate on nested modules.
func WithoutGlobals ¶
WithoutGlobals removes multiple global builtins or modules.
Directories
¶
Path | Synopsis |
---|---|
Package ast defines the abstract syntax tree representation of Risor code.
|
Package ast defines the abstract syntax tree representation of Risor code. |
Package builtins defines a default set of built-in functions.
|
Package builtins defines a default set of built-in functions. |
Package compiler is used to compile a Risor abstract syntax tree (AST) into the corresponding bytecode.
|
Package compiler is used to compile a Risor abstract syntax tree (AST) into the corresponding bytecode. |
Package dis supports analysis of Risor bytecode by disassembling it.
|
Package dis supports analysis of Risor bytecode by disassembling it. |
Package errz defines a FriendlyError interface for errors that have a human friendly message in addition to the default error message.
|
Package errz defines a FriendlyError interface for errors that have a human friendly message in addition to the default error message. |
examples
|
|
Package importer provides a common interface used to import Risor modules.
|
Package importer provides a common interface used to import Risor modules. |
internal
|
|
tmpl
Package tmpl is used to parse Risor string templates.
|
Package tmpl is used to parse Risor string templates. |
Package lexer provides a Lexer that takes Risor source code as input and outputs a stream of tokens to be consumed by a parser.
|
Package lexer provides a Lexer that takes Risor source code as input and outputs a stream of tokens to be consumed by a parser. |
Package limits provides an interface and helpers for restricting resource usage during Risor evaluations.
|
Package limits provides an interface and helpers for restricting resource usage during Risor evaluations. |
modules
|
|
Package object provides the standard set of Risor object types.
|
Package object provides the standard set of Risor object types. |
Package op defines opcodes used by the Risor compiler and virtual machine.
|
Package op defines opcodes used by the Risor compiler and virtual machine. |
Package parser is used to generate the abstract syntax tree (AST) for a program.
|
Package parser is used to generate the abstract syntax tree (AST) for a program. |
tests
|
|
Package token defines language keywords and tokens used when lexing source code.
|
Package token defines language keywords and tokens used when lexing source code. |
Package vm provides a VirtualMachine that executes compiled Risor code.
|
Package vm provides a VirtualMachine that executes compiled Risor code. |