Documentation
¶
Index ¶
- Constants
- func Eval(ctx context.Context, expr string, params map[string]core.Value) (any, error)
- type Compiled
- func (c *Compiled) Clone(a *core.Arena) (*Compiled, error)
- func (c *Compiled) Get(name string) *Variable
- func (c *Compiled) GetAll() []*Variable
- func (c *Compiled) GetValue(name string) core.Value
- func (c *Compiled) Run(a *core.Arena, v *vm.VM) error
- func (c *Compiled) RunContext(ctx context.Context, a *core.Arena, v *vm.VM) (err error)
- func (c *Compiled) Set(name string, val core.Value) error
- func (c *Compiled) Size() int64
- type Script
- func (s *Script) Add(name string, val core.Value)
- func (s *Script) Compile(a *core.Arena) (*Compiled, error)
- func (s *Script) EnableFileImport(enable bool)
- func (s *Script) Remove(name string) bool
- func (s *Script) SetAssignmentMode(mode compiler.AssignmentMode)
- func (s *Script) SetImportDir(dir string) error
- func (s *Script) SetImports(modules vm.ModuleGetter)
- func (s *Script) SetMaxConstObjects(n int)
- type Variable
- func (v *Variable) Array() []any
- func (v *Variable) Bool() bool
- func (v *Variable) Bytes() []byte
- func (v *Variable) Error() error
- func (v *Variable) Float() float64
- func (v *Variable) Int() int64
- func (v *Variable) IsUndefined() bool
- func (v *Variable) Map() map[string]any
- func (v *Variable) Name() string
- func (v *Variable) Object() core.Value
- func (v *Variable) Rune() rune
- func (v *Variable) String() string
- func (v *Variable) Time() time.Time
- func (v *Variable) Value() core.Value
- func (v *Variable) ValueType() string
Constants ¶
const (
// SourceFileExtDefault is the default extension for source files.
SourceFileExtDefault = ".kvn"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Compiled ¶
type Compiled struct {
// contains filtered or unexported fields
}
Compiled is a compiled instance of the user script. Use Script.Compile() to create Compiled object.
func (*Compiled) Get ¶
Get returns a variable identified by the name. Must be used right after script execution to get the updated variable. Otherwise, the result in ambiguous.
func (*Compiled) GetAll ¶
GetAll returns all the variables that are defined by the compiled script. Must be used right after script execution to get the updated variables. Otherwise, the result in ambiguous.
func (*Compiled) GetValue ¶ added in v0.0.7
GetValue returns a value identified by the name. Must be used right after script execution to get the updated value. Otherwise, the result in ambiguous.
func (*Compiled) RunContext ¶
RunContext is like Run but includes a context.
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script simplifies compilation and execution of embedded scripts.
func (*Script) Compile ¶
Compile compiles the script with all the defined variables, and, returns Compiled object. If compile-time arena is not provided, a new default arena will be used.
func (*Script) EnableFileImport ¶
EnableFileImport enables or disables module loading from local files. Local file modules are disabled by default.
func (*Script) Remove ¶
Remove removes (undefine) an existing variable for the script. It returns false if the variable name is not defined.
func (*Script) SetAssignmentMode ¶
func (s *Script) SetAssignmentMode(mode compiler.AssignmentMode)
SetAssignmentMode sets how plain '=' handles unresolved identifiers during compilation.
func (*Script) SetImportDir ¶
SetImportDir sets the initial import directory for script files.
func (*Script) SetImports ¶
func (s *Script) SetImports(modules vm.ModuleGetter)
SetImports sets import modules.
func (*Script) SetMaxConstObjects ¶
SetMaxConstObjects sets the maximum number of objects in the compiled constants.
type Variable ¶
type Variable struct {
// contains filtered or unexported fields
}
Variable is a user-defined variable for the script.
func NewVariable ¶
NewVariable creates a Variable.
func (*Variable) Array ¶
Array returns []interface value of the variable value. It returns 0 if the value is not convertible to []interface.
func (*Variable) Bool ¶
Bool returns bool value of the variable value. It returns 0 if the value is not convertible to bool.
func (*Variable) Bytes ¶
Bytes returns a byte slice of the variable value. It returns nil if the value is not convertible to byte slice.
func (*Variable) Error ¶
Error returns an error if the underlying value is error object. If not, this returns nil.
func (*Variable) Float ¶
Float returns float64 value of the variable value. It returns 0.0 if the value is not convertible to float64.
func (*Variable) Int ¶
Int returns int64 value of the variable value. It returns 0 if the value is not convertible to int64.
func (*Variable) IsUndefined ¶
IsUndefined returns true if the underlying value is undefined.
func (*Variable) Map ¶
Map returns map[string]any value of the variable value. It returns 0 if the value is not convertible to map[string]any.
func (*Variable) Object ¶
Object returns an underlying Object of the variable value. Note that returned Object is a copy of an actual Object used in the script.
func (*Variable) Rune ¶ added in v0.0.6
Rune returns rune value of the variable value. It returns 0 if the value is not convertible to rune.
func (*Variable) String ¶
String returns string value of the variable value. It returns 0 if the value is not convertible to string.
func (*Variable) Time ¶
Time returns time.Time value of the variable value. It returns zero time if the value is not convertible to time.Time.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
bench
command
|
|
|
gen-templates
command
|
|
|
kavun
command
|
|
|
Package errs defines the structured error type used throughout the Kavun runtime.
|
Package errs defines the structured error type used throughout the Kavun runtime. |
|
internal
|
|
