vida

package module
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

README

Vida Language

The official repo of the Vida programming language.

Welcome to Vida 🌿🌻! Version 0.5.11

Vida is a simple, general-purpose and extensible scripting language.

Vida is is still a WIP.

The next milestone is stabilize it and take it to the version 1.0.0

Documentation

Index

Constants

View Source
const (
	VidaFileExtension = ".vida"

	DefaultInputPrompt = "Input > "

	EmptyString            = ""
	DefaultValField        = "value"
	DefaultCloseMethodName = "close"
)
View Source
const (
	VIDAPATH        = "VIDAPATH"
	ProjectCellsDir = "cells"
	VidaPathDirName = "vida-cells"
)
View Source
const (
	FileErrType      = "File"
	LexicalErrType   = "Lexical"
	SyntaxErrType    = "Syntax"
	BuildErrType     = "Build"
	RunTimeErrType   = "Runtime"
	AssertionErrType = "Assertion Failure"
	ExceptionErrType = "Exception"
	MaxMemSize       = 0x7FFF_FFFF
)
View Source
const (
	ErrStringLimit                      = internalBasicError("max size for strings has been reached")
	ErrOpNotDefinedForIterators         = internalBasicError("operation not defined for iterators")
	ErrValueNotIndexable                = internalBasicError("value not indexable")
	ErrPrefixOpNotDefined               = internalBasicError("prefix operation not defined")
	ErrBinaryOpNotDefined               = internalBasicError("binary operation not defined")
	ErrDivisionByZero                   = internalBasicError("division by zero")
	ErrExpectedInteger                  = internalBasicError("expected a value of type integer")
	ErrExpectedIntegerDifferentFromZero = internalBasicError("expected an integer value different from zero")
	ErrValueNotIterable                 = internalBasicError("value is not iterable")
	ErrValueNotCallable                 = internalBasicError("value is not callable")
	ErrStackOverflow                    = internalBasicError("stack overflow")
	ErrArity                            = internalBasicError("number of arguments different from function arity")
	ErrNotEnoughArgs                    = internalBasicError("not enough arguments passed to the function")
	ErrVariadicArgs                     = internalBasicError("expected an array for variadic arguments or the given array overflows the stack")
	ErrSlice                            = internalBasicError("could not process the slice")
	ErrView                             = internalBasicError("could not process the view")
	ErrValueIsConstant                  = internalBasicError("value is constant")
	ErrMaxMemSize                       = internalBasicError("max memory size reached")
	ErrNotImplemented                   = internalBasicError("not implemented functionality for this value")
	ErrNotThread                        = internalBasicError("value is not a thread")
	ErrResumingNotSuspendedThread       = internalBasicError("cannot run a completed, running or waiting thread")
	ErrNotAFunction                     = internalBasicError("threads must be build from functions")
	ErrSuspendingMainThread             = internalBasicError("cannot suspend the main thread")
	ErrSuspendingRunningThread          = internalBasicError("cannot suspend a running thread")
	ErrClosingAThread                   = internalBasicError("cannot complete a running, waiting or completed thread")
	ErrStartThreadSignal                = internalBasicError("start-thread-signal")
	ErrResumeThreadSignal               = internalBasicError("resume-thread-signal")
	ErrSuspendThreadSignal              = internalBasicError("suspend-thread-signal")
	ErrRecyclingThread                  = internalBasicError("cannot recycle an active thread")
	ErrSoringMixedTypes                 = internalBasicError("cannot sort mixed data types")
	ErrParallelArgs                     = internalBasicError("arguments for parallel tasks must be non empty arrays")
	ErrParallelFn                       = internalBasicError("first argument of a parallel argument must be a function")
	ErrNonNegativeIntegerTimeout        = internalBasicError("timeout must be a non negative integer milliseconds")
	ErrNonEmptyTaskArray                = internalBasicError("parallel tasks must be inside a non empty array")
	ErrInvalidJSON                      = internalBasicError("invalid json")
	ErrExpectedString                   = internalBasicError("expected argument of type string")
	ErrExpectedIntegerArg               = internalBasicError("expected argument of type integer")
	ErrExpectedBool                     = internalBasicError("expected argument of type bool")
	ErrInvalidNumberOfArguments         = internalBasicError("invalid number of arguments")
	ErrInvalidTypeOfArgument            = internalBasicError("invalid type of argument")
)
View Source
const False = Bool(false)
View Source
const True = Bool(true)

Variables

View Source
var Nil = NilValue{}

Functions

func About

func About() string

func DownloadCellTo

func DownloadCellTo(rawURL, destPath string) error

DownloadCellTo fetches rawURL and writes it verbatim to destPath, creating any needed directories. It does not check for an existing cached file — callers decide caching policy.

func ErrOperatorOverrideNotCallable

func ErrOperatorOverrideNotCallable(operator string) error

ErrOperatorOverrideNotCallable reports that a vtable entry was found under a binary operator's message name (e.g. "add", "lt" — see tokenBinopToString) but the value stored there is not a function — so it cannot actually be used as an operator override. This is kept distinct from ErrBinaryOpNotDefined on purpose: "no override exists" and "an override exists but is broken" are different problems for a developer to diagnose, and collapsing them into the same generic message hides a very findable mistake (usually a plain value assigned to a vtable slot where a function was meant to go).

Note: this does not apply to equality ("eq"). Object.Equals has its own separate, inline override-lookup logic and can't surface this error at all, since the Value.Equals contract returns only a Bool, with no error channel — a non-callable "eq" override is currently treated the same as no override at all (falls back to pointer identity) rather than erroring.

func LoadScriptFromFile

func LoadScriptFromFile(path string) ([]byte, error)

func Name

func Name() string

func PrintBytecode

func PrintBytecode(script *Script, name string) string

func VFprint

func VFprint(w io.Writer, a ...Value) (n int, err error)

func VFprintf

func VFprintf(w io.Writer, format string, a ...Value) (n int, err error)

VFprintf is like fmt.Fprintf but using Values.

func VFprintln

func VFprintln(w io.Writer, a ...Value) (n int, err error)

Custom Basic ftm family of functions

func VSprintf

func VSprintf(format string, a ...Value) (string, error)

VSprintf is like fmt.Sprintf but using Values.

func Version

func Version() string

Types

type Array

type Array struct {
	ReferenceSemanticsImpl
	Value []Value
}

func (*Array) Binop

func (xs *Array) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*Array) Boolean

func (xs *Array) Boolean() Bool

func (*Array) Clone

func (xs *Array) Clone() Value

func (*Array) Equals

func (xs *Array) Equals(ctx *Context, other Value) Bool

func (*Array) Get

func (xs *Array) Get(ctx *Context, index Value) Value

func (*Array) GetVTable

func (xs *Array) GetVTable(ctx *Context) Value

func (*Array) IsCallable

func (xs *Array) IsCallable() Bool

func (*Array) IsIterable

func (xs *Array) IsIterable() Bool

func (*Array) Iterator

func (xs *Array) Iterator(ctx *Context) Value

func (*Array) LookUp

func (xs *Array) LookUp(ctx *Context, message Value) Value

func (*Array) MarshalJSON

func (xs *Array) MarshalJSON() ([]byte, error)

func (*Array) ObjectKey

func (xs *Array) ObjectKey() string

func (*Array) Prefix

func (xs *Array) Prefix(ctx *Context, op uint64) (Value, error)

func (*Array) Set

func (xs *Array) Set(index, val Value) error

func (*Array) String

func (xs *Array) String() string

func (*Array) Type

func (xs *Array) Type() string

type ArrayIterator

type ArrayIterator struct {
	ReferenceSemanticsImpl
	Array []Value
	Init  int
	End   int
}

func (*ArrayIterator) Clone

func (it *ArrayIterator) Clone() Value

func (*ArrayIterator) IsIterable added in v0.5.11

func (it *ArrayIterator) IsIterable() Bool

func (*ArrayIterator) Iterator added in v0.5.11

func (it *ArrayIterator) Iterator(ctx *Context) Value

func (*ArrayIterator) Key

func (it *ArrayIterator) Key(ctx *Context) Value

func (*ArrayIterator) Next

func (it *ArrayIterator) Next() bool

func (*ArrayIterator) ObjectKey added in v0.5.11

func (it *ArrayIterator) ObjectKey() string

func (*ArrayIterator) String

func (it *ArrayIterator) String() string

func (*ArrayIterator) Type

func (it *ArrayIterator) Type() string

func (*ArrayIterator) Value

func (it *ArrayIterator) Value(ctx *Context) Value

type Bool

type Bool bool

func (Bool) Binop

func (b Bool) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (Bool) Boolean

func (b Bool) Boolean() Bool

func (Bool) Call

func (b Bool) Call(ctx *Context, args ...Value) (Value, error)

func (Bool) Clone

func (b Bool) Clone() Value

func (Bool) Equals

func (b Bool) Equals(ctx *Context, other Value) Bool

func (Bool) Get

func (b Bool) Get(ctx *Context, index Value) Value

func (Bool) GetVTable

func (b Bool) GetVTable(ctx *Context) Value

func (Bool) IsCallable

func (b Bool) IsCallable() Bool

func (Bool) IsIterable

func (b Bool) IsIterable() Bool

func (Bool) Iterator

func (b Bool) Iterator(ctx *Context) Value

func (Bool) LookUp

func (b Bool) LookUp(ctx *Context, message Value) Value

func (Bool) ObjectKey

func (b Bool) ObjectKey() string

func (Bool) Prefix

func (b Bool) Prefix(ctx *Context, op uint64) (Value, error)

func (Bool) Set

func (b Bool) Set(index, val Value) error

func (Bool) String

func (b Bool) String() string

func (Bool) Type

func (b Bool) Type() string

type Bundle added in v0.5.11

type Bundle struct {
	// Source is the generated, single-file .vida program. It has no
	// remaining local import(...) calls: every local dependency has been
	// inlined. Remote imports (disallowed directly in code, same as in
	// ordinary compilation) still surface as an error during bundling.
	Source []byte
	// Entry is the resolved, absolute path of the script that was bundled.
	Entry string
	// Files lists every file folded into Source, starting with Entry,
	// followed by its dependencies in the order they were first
	// encountered (depth-first).
	Files []string
}

Bundle is the result of flattening a script's import graph into a single self-contained source file.

func BundleSource added in v0.5.11

func BundleSource(entryPath string) (*Bundle, error)

BundleSource walks entryPath's import graph -- exactly the same resolution rules the compiler itself uses (relative to each importing file, then that file's 'cells' directory, then VIDAPATH) -- and produces a single .vida file with every local dependency inlined.

Each dependency is wrapped as `let __vida_bundle_N = fun { ... }` and every import("...") call site that used to load it becomes a call to that function, preserving the original re-execute-on-every-import semantics. A dependency's own top-level `let` declarations are rewritten to `var` so that dependencies don't collide in a shared global namespace once they're all compiled as one program (they're independent modules in the original multi-file compilation; wrapping keeps them independent). A dependency's trailing `export <expr>` becomes `ret <expr>`, matching how import() already treats it. The entry file itself is left otherwise untouched -- its own top-level `let`s and any `export` (a no-op at the true top level, exactly as it is today) keep their original meaning.

type Bytes

type Bytes struct {
	ReferenceSemanticsImpl
	Value []byte
}

func (*Bytes) Binop

func (b *Bytes) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*Bytes) Boolean

func (b *Bytes) Boolean() Bool

func (*Bytes) Clone

func (b *Bytes) Clone() Value

func (*Bytes) Equals

func (b *Bytes) Equals(ctx *Context, other Value) Bool

func (*Bytes) Get

func (b *Bytes) Get(ctx *Context, index Value) Value

func (*Bytes) GetVTable

func (b *Bytes) GetVTable(ctx *Context) Value

func (*Bytes) IsCallable

func (b *Bytes) IsCallable() Bool

func (*Bytes) IsIterable

func (b *Bytes) IsIterable() Bool

func (*Bytes) Iterator

func (b *Bytes) Iterator(ctx *Context) Value

func (*Bytes) LookUp

func (b *Bytes) LookUp(ctx *Context, message Value) Value

func (*Bytes) ObjectKey

func (b *Bytes) ObjectKey() string

func (*Bytes) Prefix

func (b *Bytes) Prefix(ctx *Context, op uint64) (Value, error)

func (*Bytes) Set

func (b *Bytes) Set(index, val Value) error

func (Bytes) String

func (b Bytes) String() string

func (*Bytes) Type

func (b *Bytes) Type() string

type BytesIterator

type BytesIterator struct {
	ReferenceSemanticsImpl
	Bytes []byte
	Init  int
	End   int
}

func (*BytesIterator) Clone

func (bi *BytesIterator) Clone() Value

func (*BytesIterator) IsIterable added in v0.5.11

func (bi *BytesIterator) IsIterable() Bool

func (*BytesIterator) Iterator added in v0.5.11

func (bi *BytesIterator) Iterator(ctx *Context) Value

func (*BytesIterator) Key

func (bi *BytesIterator) Key(ctx *Context) Value

func (*BytesIterator) Next

func (bi *BytesIterator) Next() bool

func (*BytesIterator) ObjectKey added in v0.5.11

func (it *BytesIterator) ObjectKey() string

func (*BytesIterator) String

func (bi *BytesIterator) String() string

func (*BytesIterator) Type

func (bi *BytesIterator) Type() string

func (*BytesIterator) Value

func (bi *BytesIterator) Value(ctx *Context) Value

type Context

type Context struct {
	// contains filtered or unexported fields
}

func NewContext

func NewContext(src []byte, contextID string, extensionsLoader ExtensionsLoader) *Context

func (*Context) Compile

func (ctx *Context) Compile() (err error)

func (*Context) CompileAndRun

func (ctx *Context) CompileAndRun() (err error)

func (*Context) IsMainThreadRunning

func (ctx *Context) IsMainThreadRunning() bool

func (*Context) MeasureRunTime

func (ctx *Context) MeasureRunTime() (end time.Duration, err error)

func (*Context) PrintAST

func (ctx *Context) PrintAST(withColors bool) error

func (*Context) PrintCallStack

func (ctx *Context) PrintCallStack() error

func (*Context) PrintMachineCode

func (ctx *Context) PrintMachineCode() error

func (*Context) PrintTokens

func (ctx *Context) PrintTokens() error

func (*Context) Run

func (ctx *Context) Run() error

func (*Context) RunDebugSession

func (ctx *Context) RunDebugSession() (err error)

func (*Context) SetContextID

func (ctx *Context) SetContextID(contextId string)

func (*Context) SetExtensionsLoader

func (ctx *Context) SetExtensionsLoader(extensionsLoader ExtensionsLoader)

func (*Context) SetSource

func (ctx *Context) SetSource(src []byte)

type CoreFunction

type CoreFunction struct {
	ReferenceSemanticsImpl
	Code            []uint64
	FreeVarsInfo    []freeVarsInfo
	ScriptID        string
	MapScriptIPLine MapScriptIPLine
	FreeVarsCount   int
	Arity           int
	IsVarArg        bool
}

func (*CoreFunction) Boolean

func (c *CoreFunction) Boolean() Bool

func (*CoreFunction) Clone

func (f *CoreFunction) Clone() Value

func (*CoreFunction) Equals

func (c *CoreFunction) Equals(ctx *Context, other Value) Bool

func (CoreFunction) String

func (f CoreFunction) String() string

func (*CoreFunction) Type

func (c *CoreFunction) Type() string

type Enum

type Enum struct {
	Pairs map[string]Integer
}

func (*Enum) Binop

func (e *Enum) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*Enum) Boolean

func (e *Enum) Boolean() Bool

func (*Enum) Call

func (e *Enum) Call(ctx *Context, args ...Value) (Value, error)

func (*Enum) Clone

func (e *Enum) Clone() Value

func (*Enum) Equals

func (e *Enum) Equals(ctx *Context, other Value) Bool

func (*Enum) Get

func (e *Enum) Get(ctx *Context, index Value) Value

func (*Enum) GetVTable

func (e *Enum) GetVTable(ctx *Context) Value

func (*Enum) IsCallable

func (e *Enum) IsCallable() Bool

func (*Enum) IsIterable

func (e *Enum) IsIterable() Bool

func (*Enum) Iterator

func (e *Enum) Iterator(ctx *Context) Value

func (*Enum) LookUp

func (e *Enum) LookUp(ctx *Context, message Value) Value

func (*Enum) MarshalJSON

func (e *Enum) MarshalJSON() ([]byte, error)

func (*Enum) ObjectKey

func (e *Enum) ObjectKey() string

func (*Enum) Prefix

func (e *Enum) Prefix(ctx *Context, op uint64) (Value, error)

func (*Enum) Set

func (e *Enum) Set(Value, Value) error

func (Enum) String

func (e Enum) String() string

func (*Enum) Type

func (e *Enum) Type() string

type ExtensionsLoader

type ExtensionsLoader map[string]func() Value

type File added in v0.5.11

type File struct {
	ReferenceSemanticsImpl
	Handler  *os.File
	Reader   *bufio.Reader
	Writer   *bufio.Writer
	Path     string
	Flags    int
	IsClosed bool
}

File Handler API

func (*File) Binop added in v0.5.11

func (file *File) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*File) Boolean added in v0.5.11

func (file *File) Boolean() Bool

func (*File) Clone added in v0.5.11

func (file *File) Clone() Value

func (*File) Equals added in v0.5.11

func (file *File) Equals(ctx *Context, other Value) Bool

func (*File) GetMethod added in v0.5.11

func (vf *File) GetMethod(name string) (Value, bool)

func (*File) GetVTable added in v0.5.11

func (file *File) GetVTable(ctx *Context) Value

func (*File) LookUp added in v0.5.11

func (file *File) LookUp(ctx *Context, message Value) Value

func (*File) ObjectKey added in v0.5.11

func (file *File) ObjectKey() string

func (*File) Prefix added in v0.5.11

func (file *File) Prefix(ctx *Context, op uint64) (Value, error)

func (*File) String added in v0.5.11

func (file *File) String() string

func (*File) Type added in v0.5.11

func (file *File) Type() string

type Float

type Float float64

func (Float) Binop

func (f Float) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (Float) Boolean

func (f Float) Boolean() Bool

func (Float) Call

func (f Float) Call(ctx *Context, args ...Value) (Value, error)

func (Float) Clone

func (f Float) Clone() Value

func (Float) Equals

func (f Float) Equals(ctx *Context, other Value) Bool

func (Float) Get

func (f Float) Get(ctx *Context, index Value) Value

func (Float) GetVTable

func (f Float) GetVTable(ctx *Context) Value

func (Float) IsCallable

func (f Float) IsCallable() Bool

func (Float) IsIterable

func (f Float) IsIterable() Bool

func (Float) Iterator

func (f Float) Iterator(ctx *Context) Value

func (Float) LookUp

func (f Float) LookUp(ctx *Context, message Value) Value

func (Float) ObjectKey

func (f Float) ObjectKey() string

func (Float) Prefix

func (f Float) Prefix(ctx *Context, op uint64) (Value, error)

func (Float) Set

func (f Float) Set(index, val Value) error

func (Float) String

func (f Float) String() string

func (Float) Type

func (f Float) Type() string

type Function

type Function struct {
	ReferenceSemanticsImpl
	FreeVarStore []Value
	CoreFn       *CoreFunction
}

func (*Function) Binop

func (f *Function) Binop(ctx *Context, op uint64, r Value) (Value, error)

func (*Function) Boolean

func (f *Function) Boolean() Bool

func (*Function) Clone

func (f *Function) Clone() Value

func (*Function) Equals

func (f *Function) Equals(ctx *Context, other Value) Bool

func (*Function) GetVTable

func (f *Function) GetVTable(ctx *Context) Value

func (*Function) IsCallable

func (f *Function) IsCallable() Bool

func (*Function) LookUp

func (f *Function) LookUp(ctx *Context, message Value) Value

func (*Function) ObjectKey

func (f *Function) ObjectKey() string

func (*Function) Prefix

func (f *Function) Prefix(ctx *Context, op uint64) (Value, error)

func (Function) String

func (f Function) String() string

func (*Function) Type

func (f *Function) Type() string

type Integer

type Integer int64

func StringLength

func StringLength(input *String) Integer

func (Integer) Binop

func (l Integer) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (Integer) Boolean

func (i Integer) Boolean() Bool

func (Integer) Call

func (i Integer) Call(ctx *Context, args ...Value) (Value, error)

func (Integer) Clone

func (i Integer) Clone() Value

func (Integer) Equals

func (i Integer) Equals(ctx *Context, other Value) Bool

func (Integer) Get

func (i Integer) Get(ctx *Context, index Value) Value

func (Integer) GetVTable

func (i Integer) GetVTable(ctx *Context) Value

func (Integer) IsCallable

func (i Integer) IsCallable() Bool

func (Integer) IsIterable

func (i Integer) IsIterable() Bool

func (Integer) Iterator

func (i Integer) Iterator(ctx *Context) Value

func (Integer) LookUp

func (i Integer) LookUp(ctx *Context, message Value) Value

func (Integer) ObjectKey

func (i Integer) ObjectKey() string

func (Integer) Prefix

func (i Integer) Prefix(ctx *Context, op uint64) (Value, error)

func (Integer) Set

func (i Integer) Set(index, val Value) error

func (Integer) String

func (i Integer) String() string

func (Integer) Type

func (i Integer) Type() string

type IntegerIterator

type IntegerIterator struct {
	ReferenceSemanticsImpl
	Init Integer
	End  Integer
}

func (*IntegerIterator) Clone

func (it *IntegerIterator) Clone() Value

func (*IntegerIterator) IsIterable added in v0.5.11

func (it *IntegerIterator) IsIterable() Bool

func (*IntegerIterator) Iterator added in v0.5.11

func (it *IntegerIterator) Iterator(ctx *Context) Value

func (*IntegerIterator) Key

func (it *IntegerIterator) Key(ctx *Context) Value

func (*IntegerIterator) Next

func (it *IntegerIterator) Next() bool

func (*IntegerIterator) ObjectKey added in v0.5.11

func (it *IntegerIterator) ObjectKey() string

func (*IntegerIterator) String

func (it *IntegerIterator) String() string

func (*IntegerIterator) Type

func (it *IntegerIterator) Type() string

func (*IntegerIterator) Value

func (it *IntegerIterator) Value(ctx *Context) Value

type Iterator

type Iterator interface {
	Next() bool
	Key(*Context) Value
	Value(*Context) Value
}

type Lexer

type Lexer struct {
	ScriptID     string
	LexicalError *VidaRunTimeError
	// contains filtered or unexported fields
}

func (*Lexer) Next

func (l *Lexer) Next() (line uint, tok token.Token, lit string)

type MapScriptIPLine

type MapScriptIPLine map[string]map[int]uint

type NativeFunction

type NativeFunction func(ctx *Context, args ...Value) (Value, error)

func (NativeFunction) Binop

func (nativeFn NativeFunction) Binop(ctx *Context, op uint64, r Value) (Value, error)

func (NativeFunction) Boolean

func (nativeFn NativeFunction) Boolean() Bool

func (NativeFunction) Call

func (nativeFn NativeFunction) Call(ctx *Context, args ...Value) (Value, error)

func (NativeFunction) Clone

func (nativeFn NativeFunction) Clone() Value

func (NativeFunction) Equals

func (nativeFn NativeFunction) Equals(ctx *Context, other Value) Bool

func (NativeFunction) Get

func (nativeFn NativeFunction) Get(ctx *Context, index Value) Value

func (NativeFunction) GetVTable

func (nativeFn NativeFunction) GetVTable(ctx *Context) Value

func (NativeFunction) IsCallable

func (nativeFn NativeFunction) IsCallable() Bool

func (NativeFunction) IsIterable

func (nativeFn NativeFunction) IsIterable() Bool

func (NativeFunction) Iterator

func (nativeFn NativeFunction) Iterator(ctx *Context) Value

func (NativeFunction) LookUp

func (nativeFn NativeFunction) LookUp(ctx *Context, message Value) Value

func (NativeFunction) MarshalJSON

func (nativeFn NativeFunction) MarshalJSON() ([]byte, error)

func (NativeFunction) ObjectKey

func (nativeFn NativeFunction) ObjectKey() string

func (NativeFunction) Prefix

func (nativeFn NativeFunction) Prefix(ctx *Context, op uint64) (Value, error)

func (NativeFunction) Set

func (nativeFn NativeFunction) Set(index, val Value) error

func (NativeFunction) String

func (nativeFn NativeFunction) String() string

func (NativeFunction) Type

func (nativeFn NativeFunction) Type() string

type NilValue

type NilValue struct {
	ValueSemanticsImpl
}

func (NilValue) Binop

func (n NilValue) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (NilValue) Boolean

func (n NilValue) Boolean() Bool

func (NilValue) Clone

func (n NilValue) Clone() Value

func (NilValue) Equals

func (n NilValue) Equals(ctx *Context, other Value) Bool

func (NilValue) LookUp

func (n NilValue) LookUp(ctx *Context, message Value) Value

func (NilValue) ObjectKey

func (n NilValue) ObjectKey() string

func (NilValue) Prefix

func (n NilValue) Prefix(ctx *Context, op uint64) (Value, error)

func (NilValue) String

func (n NilValue) String() string

func (NilValue) Type

func (n NilValue) Type() string

type Object

type Object struct {
	ReferenceSemanticsImpl
	Value  map[string]Value
	VTable *Object
}

func (*Object) Binop

func (o *Object) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*Object) Boolean

func (o *Object) Boolean() Bool

func (*Object) Call

func (o *Object) Call(ctx *Context, args ...Value) (Value, error)

func (*Object) Clone

func (o *Object) Clone() Value

func (*Object) Equals

func (o *Object) Equals(ctx *Context, other Value) Bool

func (*Object) Get

func (o *Object) Get(ctx *Context, message Value) Value

func (*Object) GetVTable

func (o *Object) GetVTable(ctx *Context) Value

func (*Object) IsCallable

func (o *Object) IsCallable() Bool

func (*Object) IsIterable

func (o *Object) IsIterable() Bool

func (*Object) Iterator

func (o *Object) Iterator(ctx *Context) Value

func (*Object) LookUp

func (o *Object) LookUp(ctx *Context, message Value) Value

func (*Object) MarshalJSON

func (o *Object) MarshalJSON() ([]byte, error)

func (*Object) ObjectKey

func (o *Object) ObjectKey() string

func (*Object) Prefix

func (o *Object) Prefix(ctx *Context, op uint64) (Value, error)

func (*Object) Set

func (o *Object) Set(index, val Value) error

func (*Object) String

func (o *Object) String() string

func (*Object) Type

func (o *Object) Type() string

type ObjectIterator

type ObjectIterator struct {
	ReferenceSemanticsImpl
	Keys []string
	Obj  map[string]Value
	Init int
	End  int
}

func (*ObjectIterator) Clone

func (it *ObjectIterator) Clone() Value

func (*ObjectIterator) IsIterable added in v0.5.11

func (it *ObjectIterator) IsIterable() Bool

func (*ObjectIterator) Iterator added in v0.5.11

func (it *ObjectIterator) Iterator(ctx *Context) Value

func (*ObjectIterator) Key

func (it *ObjectIterator) Key(ctx *Context) Value

func (*ObjectIterator) Next

func (it *ObjectIterator) Next() bool

func (*ObjectIterator) ObjectKey added in v0.5.11

func (it *ObjectIterator) ObjectKey() string

func (*ObjectIterator) String

func (it *ObjectIterator) String() string

func (*ObjectIterator) Type

func (it *ObjectIterator) Type() string

func (*ObjectIterator) Value

func (it *ObjectIterator) Value(ctx *Context) Value

type RGB

type RGB struct {
	R, G, B uint8
}

func (RGB) Hex

func (c RGB) Hex() string

type ReferenceSemanticsImpl

type ReferenceSemanticsImpl struct{}

Reference semantics default impl

func (*ReferenceSemanticsImpl) Binop

func (*ReferenceSemanticsImpl) Boolean

func (i *ReferenceSemanticsImpl) Boolean() Bool

func (*ReferenceSemanticsImpl) Call

func (i *ReferenceSemanticsImpl) Call(ctx *Context, args ...Value) (Value, error)

func (*ReferenceSemanticsImpl) Clone

func (i *ReferenceSemanticsImpl) Clone() Value

func (*ReferenceSemanticsImpl) Equals

func (*ReferenceSemanticsImpl) Get

func (*ReferenceSemanticsImpl) GetVTable

func (i *ReferenceSemanticsImpl) GetVTable(ctx *Context) Value

func (*ReferenceSemanticsImpl) IsCallable

func (i *ReferenceSemanticsImpl) IsCallable() Bool

func (*ReferenceSemanticsImpl) IsIterable

func (i *ReferenceSemanticsImpl) IsIterable() Bool

func (*ReferenceSemanticsImpl) Iterator

func (i *ReferenceSemanticsImpl) Iterator(*Context) Value

func (*ReferenceSemanticsImpl) LookUp

func (*ReferenceSemanticsImpl) MarshalJSON

func (i *ReferenceSemanticsImpl) MarshalJSON() ([]byte, error)

func (*ReferenceSemanticsImpl) ObjectKey

func (i *ReferenceSemanticsImpl) ObjectKey() string

func (*ReferenceSemanticsImpl) Prefix

func (*ReferenceSemanticsImpl) Set

func (ReferenceSemanticsImpl) String

func (i ReferenceSemanticsImpl) String() string

func (*ReferenceSemanticsImpl) Type

func (i *ReferenceSemanticsImpl) Type() string

type Script

type Script struct {
	GlobalStore  *[]Value
	Konstants    *[]Value
	MainFunction *Function
}

func (Script) String

func (s Script) String() string

type StackFrameInfo

type StackFrameInfo struct {
	ScriptID string
	Line     uint
	Frame    uint
}

func (StackFrameInfo) Error

func (sfi StackFrameInfo) Error() string

type String

type String struct {
	ReferenceSemanticsImpl
	Runes []rune
	Value string
}

func (*String) Binop

func (s *String) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*String) Boolean

func (s *String) Boolean() Bool

func (*String) Clone

func (s *String) Clone() Value

func (*String) Equals

func (s *String) Equals(ctx *Context, other Value) Bool

func (*String) Get

func (s *String) Get(ctx *Context, index Value) Value

func (*String) GetVTable

func (s *String) GetVTable(ctx *Context) Value

func (*String) IsCallable

func (s *String) IsCallable() Bool

func (*String) IsIterable

func (s *String) IsIterable() Bool

func (*String) Iterator

func (s *String) Iterator(ctx *Context) Value

func (*String) LookUp

func (s *String) LookUp(ctx *Context, message Value) Value

func (*String) MarshalJSON

func (s *String) MarshalJSON() ([]byte, error)

func (*String) ObjectKey

func (s *String) ObjectKey() string

func (*String) Prefix

func (s *String) Prefix(ctx *Context, op uint64) (Value, error)

func (*String) Set

func (s *String) Set(index, val Value) error

func (String) String

func (s String) String() string

func (*String) Type

func (s *String) Type() string

type StringIterator

type StringIterator struct {
	ReferenceSemanticsImpl
	Runes []rune
	Init  int
	End   int
}

func (*StringIterator) Clone

func (it *StringIterator) Clone() Value

func (*StringIterator) IsIterable added in v0.5.11

func (it *StringIterator) IsIterable() Bool

func (*StringIterator) Iterator added in v0.5.11

func (it *StringIterator) Iterator(ctx *Context) Value

func (*StringIterator) Key

func (it *StringIterator) Key(ctx *Context) Value

func (*StringIterator) Next

func (it *StringIterator) Next() bool

func (*StringIterator) ObjectKey added in v0.5.11

func (it *StringIterator) ObjectKey() string

func (*StringIterator) String

func (it *StringIterator) String() string

func (*StringIterator) Type

func (it *StringIterator) Type() string

func (*StringIterator) Value

func (it *StringIterator) Value(ctx *Context) Value

type Style

type Style struct {
	ReferenceSemanticsImpl
	// contains filtered or unexported fields
}

func (*Style) Bg16

func (s *Style) Bg16(idx uint8) *Style

func (*Style) Bg256

func (s *Style) Bg256(idx uint8) *Style

func (*Style) BgHex

func (s *Style) BgHex(hex string) (*Style, error)

func (*Style) BgHexMust

func (s *Style) BgHexMust(hex string) *Style

BgHexMust is BgHex without the error return, for call sites using a compile-time-known-valid literal. Panics on malformed input — do not use with user- or script-supplied strings.

func (*Style) BgName

func (s *Style) BgName(name string) (*Style, error)

func (*Style) BgRGB

func (s *Style) BgRGB(r, g, b uint8) *Style

func (*Style) Binop

func (s *Style) Binop(ctx *Context, op uint64, rhs Value) (Value, error)
func (s *Style) Blink() *Style

func (*Style) Bold

func (s *Style) Bold() *Style

func (*Style) Boolean

func (s *Style) Boolean() Bool

func (*Style) Clone

func (s *Style) Clone() Value

func (*Style) Dim

func (s *Style) Dim() *Style

func (*Style) Enabled

func (s *Style) Enabled(on bool) *Style

func (*Style) Equals

func (s *Style) Equals(ctx *Context, other Value) Bool

func (*Style) Fg16

func (s *Style) Fg16(idx uint8) *Style

func (*Style) Fg256

func (s *Style) Fg256(idx uint8) *Style

func (*Style) FgHex

func (s *Style) FgHex(hex string) (*Style, error)

func (*Style) FgHexMust

func (s *Style) FgHexMust(hex string) *Style

FgHexMust is FgHex without the error return, for call sites using a compile-time-known-valid literal. Panics on malformed input — do not use with user- or script-supplied strings.

func (*Style) FgName

func (s *Style) FgName(name string) (*Style, error)

func (*Style) FgRGB

func (s *Style) FgRGB(r, g, b uint8) *Style

func (*Style) Fill

func (s *Style) Fill(a ...any) string

func (*Style) GetVTable

func (s *Style) GetVTable(ctx *Context) Value

func (*Style) Italic

func (s *Style) Italic() *Style

func (*Style) LookUp

func (s *Style) LookUp(ctx *Context, message Value) Value

func (*Style) NoReset

func (s *Style) NoReset() *Style

func (*Style) ObjectKey

func (s *Style) ObjectKey() string

func (*Style) Prefix

func (s *Style) Prefix(ctx *Context, op uint64) (Value, error)

func (*Style) Reverse

func (s *Style) Reverse() *Style

func (*Style) Sprint

func (s *Style) Sprint(a ...any) string

func (*Style) Sprintf

func (s *Style) Sprintf(format string, a ...any) string

func (*Style) Strike

func (s *Style) Strike() *Style

func (*Style) String

func (s *Style) String() string

func (*Style) Type

func (s *Style) Type() string

func (*Style) Underline

func (s *Style) Underline() *Style

func (*Style) Width

func (s *Style) Width(w int) *Style

type Thread

type Thread struct {
	ReferenceSemanticsImpl
	Frames  []frame
	Stack   []Value
	Script  *Script
	Frame   *frame
	Invoker *Thread
	State   ThreadState
	Channel Value
	Reg     uint64
	// contains filtered or unexported fields
}

func (*Thread) Binop

func (th *Thread) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*Thread) Boolean

func (th *Thread) Boolean() Bool

func (*Thread) Clone

func (th *Thread) Clone() Value

func (*Thread) Equals

func (th *Thread) Equals(ctx *Context, other Value) Bool

func (*Thread) GetVTable

func (th *Thread) GetVTable(ctx *Context) Value

func (*Thread) LookUp

func (th *Thread) LookUp(ctx *Context, message Value) Value

func (*Thread) ObjectKey

func (th *Thread) ObjectKey() string

func (*Thread) Prefix

func (th *Thread) Prefix(ctx *Context, op uint64) (Value, error)

func (*Thread) Reset

func (th *Thread) Reset(fn *Function) *Thread

func (*Thread) String

func (th *Thread) String() string

func (*Thread) Type

func (th *Thread) Type() string

type ThreadState

type ThreadState int
const (
	Ready ThreadState = iota
	Running
	Suspended
	Waiting
	Done
)

func (ThreadState) String

func (state ThreadState) String() string

type Time

type Time time.Time

func (Time) Binop

func (t Time) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (Time) Boolean

func (t Time) Boolean() Bool

func (Time) Call

func (t Time) Call(ctx *Context, args ...Value) (Value, error)

func (Time) Clone

func (t Time) Clone() Value

func (Time) Equals

func (t Time) Equals(ctx *Context, other Value) Bool

func (Time) Get

func (t Time) Get(ctx *Context, index Value) Value

func (Time) GetVTable

func (t Time) GetVTable(ctx *Context) Value

func (Time) IsCallable

func (t Time) IsCallable() Bool

func (Time) IsIterable

func (t Time) IsIterable() Bool

func (Time) Iterator

func (t Time) Iterator(ctx *Context) Value

func (Time) LookUp

func (t Time) LookUp(ctx *Context, message Value) Value

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) ObjectKey

func (t Time) ObjectKey() string

func (Time) Prefix

func (t Time) Prefix(ctx *Context, op uint64) (Value, error)

func (Time) Set

func (t Time) Set(index, val Value) error

func (Time) String

func (t Time) String() string

func (Time) Type

func (t Time) Type() string

type UserIterator added in v0.5.11

type UserIterator struct {
	ReferenceSemanticsImpl
	// contains filtered or unexported fields
}

func (*UserIterator) Boolean added in v0.5.11

func (vi *UserIterator) Boolean() Bool

func (*UserIterator) Clone added in v0.5.11

func (vi *UserIterator) Clone() Value

func (*UserIterator) IsIterable added in v0.5.11

func (vi *UserIterator) IsIterable() Bool

func (*UserIterator) Iterator added in v0.5.11

func (vi *UserIterator) Iterator(ctx *Context) Value

func (*UserIterator) Key added in v0.5.11

func (vi *UserIterator) Key(ctx *Context) Value

func (*UserIterator) Next added in v0.5.11

func (vi *UserIterator) Next() bool

func (*UserIterator) ObjectKey added in v0.5.11

func (it *UserIterator) ObjectKey() string

func (*UserIterator) String added in v0.5.11

func (vi *UserIterator) String() string

func (*UserIterator) Type added in v0.5.11

func (vi *UserIterator) Type() string

func (*UserIterator) Value added in v0.5.11

func (vi *UserIterator) Value(ctx *Context) Value

type VM

type VM struct {
	*Thread
	// contains filtered or unexported fields
}

func (*VM) Inspect

func (vm *VM) Inspect(ip int)

type Value

type Value interface {
	Boolean() Bool
	Prefix(ctx *Context, op uint64) (Value, error)
	Binop(ctx *Context, op uint64, other Value) (Value, error)
	Get(ctx *Context, message Value) Value
	Set(Value, Value) error
	Equals(ctx *Context, value Value) Bool
	IsIterable() Bool
	Iterator(ctx *Context) Value
	IsCallable() Bool
	Call(ctx *Context, args ...Value) (Value, error)
	String() string
	Type() string
	Clone() Value
	ObjectKey() string
	LookUp(ctx *Context, message Value) Value
	GetVTable(ctx *Context) Value
}

type ValueSemanticsImpl

type ValueSemanticsImpl struct{}

Value semantics default impl

func (ValueSemanticsImpl) Binop

func (ValueSemanticsImpl) Boolean

func (i ValueSemanticsImpl) Boolean() Bool

func (ValueSemanticsImpl) Call

func (i ValueSemanticsImpl) Call(ctx *Context, args ...Value) (Value, error)

func (ValueSemanticsImpl) Clone

func (i ValueSemanticsImpl) Clone() Value

func (ValueSemanticsImpl) Equals

func (i ValueSemanticsImpl) Equals(*Context, Value) Bool

func (ValueSemanticsImpl) Get

func (ValueSemanticsImpl) GetVTable

func (i ValueSemanticsImpl) GetVTable(ctx *Context) Value

func (ValueSemanticsImpl) IsCallable

func (i ValueSemanticsImpl) IsCallable() Bool

func (ValueSemanticsImpl) IsIterable

func (i ValueSemanticsImpl) IsIterable() Bool

func (ValueSemanticsImpl) Iterator

func (i ValueSemanticsImpl) Iterator(*Context) Value

func (ValueSemanticsImpl) LookUp

func (i ValueSemanticsImpl) LookUp(*Context, Value) Value

func (ValueSemanticsImpl) MarshalJSON

func (i ValueSemanticsImpl) MarshalJSON() ([]byte, error)

func (ValueSemanticsImpl) ObjectKey

func (i ValueSemanticsImpl) ObjectKey() string

func (ValueSemanticsImpl) Prefix

func (i ValueSemanticsImpl) Prefix(*Context, uint64) (Value, error)

func (ValueSemanticsImpl) Set

func (ValueSemanticsImpl) String

func (i ValueSemanticsImpl) String() string

func (ValueSemanticsImpl) Type

func (i ValueSemanticsImpl) Type() string

type VidaBytesBuilder

type VidaBytesBuilder struct {
	ReferenceSemanticsImpl
	Buffer *bytes.Buffer
}

Bytes Builder Value

func (*VidaBytesBuilder) Binop

func (bb *VidaBytesBuilder) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*VidaBytesBuilder) Clone

func (bb *VidaBytesBuilder) Clone() Value

func (*VidaBytesBuilder) Equals

func (bb *VidaBytesBuilder) Equals(ctx *Context, other Value) Bool

func (*VidaBytesBuilder) GetVTable

func (bb *VidaBytesBuilder) GetVTable(ctx *Context) Value

func (*VidaBytesBuilder) LookUp

func (bb *VidaBytesBuilder) LookUp(ctx *Context, message Value) Value

func (*VidaBytesBuilder) ObjectKey

func (bb *VidaBytesBuilder) ObjectKey() string

func (*VidaBytesBuilder) Prefix

func (bb *VidaBytesBuilder) Prefix(ctx *Context, op uint64) (Value, error)

func (*VidaBytesBuilder) String

func (bb *VidaBytesBuilder) String() string

func (*VidaBytesBuilder) Type

func (bb *VidaBytesBuilder) Type() string

type VidaError

type VidaError struct {
	ReferenceSemanticsImpl
	Message Value
}

func (*VidaError) Binop

func (e *VidaError) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*VidaError) Boolean

func (e *VidaError) Boolean() Bool

func (*VidaError) Clone

func (e *VidaError) Clone() Value

func (*VidaError) Equals

func (e *VidaError) Equals(ctx *Context, other Value) Bool

func (*VidaError) Error added in v0.5.11

func (e *VidaError) Error() string

func (*VidaError) Get

func (e *VidaError) Get(ctx *Context, index Value) Value

func (*VidaError) GetVTable

func (e *VidaError) GetVTable(ctx *Context) Value

func (*VidaError) IsCallable

func (e *VidaError) IsCallable() Bool

func (*VidaError) IsIterable

func (e *VidaError) IsIterable() Bool

func (*VidaError) Iterator

func (e *VidaError) Iterator(ctx *Context) Value

func (*VidaError) LookUp

func (e *VidaError) LookUp(ctx *Context, message Value) Value

func (*VidaError) ObjectKey

func (e *VidaError) ObjectKey() string

func (*VidaError) Prefix

func (e *VidaError) Prefix(ctx *Context, op uint64) (Value, error)

func (*VidaError) Set

func (e *VidaError) Set(index, val Value) error

func (*VidaError) String

func (e *VidaError) String() string

func (*VidaError) Type

func (e *VidaError) Type() string

type VidaRunTimeError

type VidaRunTimeError struct {
	ScriptID string
	Message  string
	ErrType  string
	Line     uint
}

func NewRuntimeError

func NewRuntimeError(scriptID string, message string, errorType string, line uint) *VidaRunTimeError

func (*VidaRunTimeError) Error

func (e *VidaRunTimeError) Error() string

type VidaStringBuilder

type VidaStringBuilder struct {
	ReferenceSemanticsImpl
	Builder *strings.Builder
}

String Builder Value

func (*VidaStringBuilder) Binop

func (sb *VidaStringBuilder) Binop(ctx *Context, op uint64, rhs Value) (Value, error)

func (*VidaStringBuilder) Clone

func (sb *VidaStringBuilder) Clone() Value

func (*VidaStringBuilder) Equals

func (sb *VidaStringBuilder) Equals(ctx *Context, other Value) Bool

func (*VidaStringBuilder) GetVTable

func (sb *VidaStringBuilder) GetVTable(ctx *Context) Value

func (*VidaStringBuilder) LookUp

func (sb *VidaStringBuilder) LookUp(ctx *Context, message Value) Value

func (*VidaStringBuilder) ObjectKey

func (sb *VidaStringBuilder) ObjectKey() string

func (*VidaStringBuilder) Prefix

func (sb *VidaStringBuilder) Prefix(ctx *Context, op uint64) (Value, error)

func (*VidaStringBuilder) String

func (sb *VidaStringBuilder) String() string

func (*VidaStringBuilder) Type

func (sb *VidaStringBuilder) Type() string

Directories

Path Synopsis
cmd
vida command

Jump to

Keyboard shortcuts

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