vida

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TKAdd byte
	TKMinus
	TKMul
	TKDiv
	TKMod
	TKPercent
	TKPower
	TKAmpersand
	TKBar
	TKHat
	TKLShift
	TKRShift

	TKGT
	TKGE
	TKLT
	TKLE
	TKAnd
	TKOr
	TKNot
	TKTilde
)

Numeric constants for the definition of the token types

View Source
const (
	ModuleExtension         = ".vida"
	ModuleCompiledExtension = ".vo"
	LangVersion             = "0.7.0"
	VMEngineVersion         = "0.5.0"
	STDLibVersion           = "0.3.0"
	LangName                = "Vida 🌻"
	LangHeader              = "A general-purpose programming language."
	LangWebSite             = "https://www.vida-lang.org"
)
View Source
const (
	True       = Bool(true)
	False      = Bool(false)
	NilValue   = Nil(0)
	IStopValue = IStop(0)
)

Global values for true, false, nil and iterator stop.

Variables

View Source
var BytesInterface = Namespace{
	"isEmpty":       GFunction{Name: "isEmpty", Value: bytesIsEmpty},
	"length":        GFunction{Name: "length", Value: bytesLength},
	"clear":         GFunction{Name: "clear", Value: bytesClear},
	"contains":      GFunction{Name: "contains", Value: bytesContains},
	"clone":         GFunction{Name: "clone", Value: bytesClone},
	"remove":        GFunction{Name: "remove", Value: bytesRemove},
	"randomElement": GFunction{Name: "randomElement", Value: bytesRandomElement},
	"makeIterator":  GFunction{Name: "makeIterator", Value: bytesMakeIterator},
}

BytesInterface is the collection of methods for the type Bytes.

View Source
var FiberInterface = Namespace{
	"isAlive":   GFunction{Name: "isAlive", Value: FiberIsAlive},
	"state":     GFunction{Name: "state", Value: FiberState},
	"run":       GFunction{Name: "run", Value: FiberRun},
	"terminate": GFunction{Name: "terminate", Value: FiberTerminate},
}

FiberInterface is the set of methods for fiber instances.

View Source
var KindDescription = [...]string{

	TKAdd:       "+",
	TKMinus:     "-",
	TKMul:       "*",
	TKDiv:       "/",
	TKMod:       "mod",
	TKPercent:   "%",
	TKPower:     "**",
	TKAmpersand: "&",
	TKBar:       "|",
	TKHat:       "^",
	TKLShift:    "<<",
	TKRShift:    ">>",

	TKGT:    ">",
	TKGE:    ">=",
	TKLT:    "<",
	TKLE:    "<=",
	TKAnd:   "and",
	TKOr:    "or",
	TKNot:   "not",
	TKTilde: "~",
	// contains filtered or unexported fields
}

KindDescription is the string representation of a token type.

View Source
var ListInterface = Namespace{
	"isEmpty":       GFunction{Name: "isEmpty", Value: xsIsEmpty},
	"length":        GFunction{Name: "length", Value: xsLength},
	"clear":         GFunction{Name: "clear", Value: xsClear},
	"contains":      GFunction{Name: "contains", Value: xsContains},
	"clone":         GFunction{Name: "clone", Value: xsClone},
	"remove":        GFunction{Name: "remove", Value: xsRemove},
	"randomElement": GFunction{Name: "randomElement", Value: xsRandomElement},
	"makeIterator":  GFunction{Name: "makeIterator", Value: xsMakeIterator},
	"append":        GFunction{Name: "append", Value: xsAppend},
	"insert":        GFunction{Name: "insert", Value: xsInsert},
	"extend":        GFunction{Name: "extend", Value: xsExtend},
	"popLast":       GFunction{Name: "popLast", Value: xsPopLast},
	"popFirst":      GFunction{Name: "popLast", Value: xsPopFirst},
	"sort":          GFunction{Name: "sort", Value: xsSort},
	"sorted":        GFunction{Name: "sorted", Value: xsSorted},
	"reverse":       GFunction{Name: "reverse", Value: xsReverse},
	"reversed":      GFunction{Name: "reversed", Value: xsReversed},
	"shuffle":       GFunction{Name: "shuffle", Value: xsShuffle},
	"shuffled":      GFunction{Name: "shuffled", Value: xsShuffled},
	"removed":       GFunction{Name: "removed", Value: xsRemoved},
	"capacity":      GFunction{Name: "capacity", Value: xsCap},
	"indexOf":       GFunction{Name: "indexOf", Value: xsIndex},
	"countOf":       GFunction{Name: "countOf", Value: xsCount},
	"midIndex":      GFunction{Name: "midIndex", Value: xsMidIndex},
}

ListInterface is the collection of methods for the type List.

View Source
var MapInterface = Namespace{
	"isEmpty":       GFunction{Name: "isEmpty", Value: mapIsEmpty},
	"length":        GFunction{Name: "length", Value: mapLength},
	"clear":         GFunction{Name: "clear", Value: mapClear},
	"contains":      GFunction{Name: "contains", Value: mapContains},
	"clone":         GFunction{Name: "clone", Value: mapClone},
	"randomElement": GFunction{Name: "randomElement", Value: mapRandomElement},
	"makeIterator":  GFunction{Name: "makeIterator", Value: mapMakeIterator},
	"remove":        GFunction{Name: "remove", Value: mapDelete},
	"keys":          GFunction{Name: "keys", Value: mapKeys},
	"values":        GFunction{Name: "values", Value: mapValues},
	"pairs":         GFunction{Name: "pairs", Value: mapItems},
}
View Source
var SetInterface = Namespace{

	"isEmpty":             GFunction{Name: "isEmpty", Value: setIsEmpty},
	"length":              GFunction{Name: "length", Value: setLength},
	"clear":               GFunction{Name: "clear", Value: setClear},
	"contains":            GFunction{Name: "contains", Value: setMemebership},
	"clone":               GFunction{Name: "clone", Value: setClone},
	"randomElement":       GFunction{Name: "randomElement", Value: setRandomElement},
	"makeIterator":        GFunction{Name: "makeIterator", Value: setMakeIterator},
	"remove":              GFunction{Name: "remove", Value: setRemoveElements},
	"add":                 GFunction{Name: "add", Value: setAddElements},
	"difference":          GFunction{Name: "difference", Value: setDifference},
	"merge":               GFunction{Name: "merge", Value: setMerge},
	"merged":              GFunction{Name: "merged", Value: setMerged},
	"toList":              GFunction{Name: "toList", Value: setToList},
	"intersection":        GFunction{Name: "intersection", Value: setIntersection},
	"isDisjoint":          GFunction{Name: "isDisjoint", Value: setIsDisjoint},
	"isSubset":            GFunction{Name: "isSubset", Value: setIsSubset},
	"isSuperset":          GFunction{Name: "isSuperset", Value: setIsSuperSet},
	"symmetricDifference": GFunction{Name: "symmetricDifference", Value: setSymmetricDifference},
	"union":               GFunction{Name: "union", Value: setUnion},
}
View Source
var StringInterface = Namespace{
	"isEmpty":       GFunction{Name: "isEmpty", Value: stringIsEmpty},
	"length":        GFunction{Name: "length", Value: stringLength},
	"contains":      GFunction{Name: "contains", Value: stringContains},
	"clone":         GFunction{Name: "clone", Value: stringClone},
	"randomElement": GFunction{Name: "randomElement", Value: stringRandomElement},
	"makeIterator":  GFunction{Name: "makeIterator", Value: stringMakeIterator},
	"join":          GFunction{Name: "join", Value: stringJoin},
	"containsAny":   GFunction{Name: "containsAny", Value: stringContainsAny},
	"fields":        GFunction{Name: "fields", Value: stringFields},
	"trim":          GFunction{Name: "trim", Value: stringTrim},
	"trimLeft":      GFunction{Name: "trimLeft", Value: stringTrimLeft},
	"trimRight":     GFunction{Name: "trimRight", Value: stringTrimRight},
	"toLower":       GFunction{Name: "toLower", Value: stringToLower},
	"toUpper":       GFunction{Name: "toUpper", Value: stringToUpper},
	"toTitle":       GFunction{Name: "toTittle", Value: stringToTitle},
	"split":         GFunction{Name: "split", Value: stringSplit},
	"repeat":        GFunction{Name: "repeat", Value: stringRepeat},
	"replace":       GFunction{Name: "replace", Value: stringReplace},
	"hasPrefix":     GFunction{Name: "hasPrefix", Value: stringHasPrefix},
	"hasSuffix":     GFunction{Name: "hasSuffix", Value: stringHasSuffix},
	"count":         GFunction{Name: "count", Value: stringCount},
	"runes":         GFunction{Name: "runes", Value: stringGetRunes},
	"bytes":         GFunction{Name: "runes", Value: stringGetBytes},
}

Functions

func ArityError

func ArityError(arity, argCount UInt32) error

Error when a method or property was not found.

func ArityErrorInBinaryOperatorOverload

func ArityErrorInBinaryOperatorOverload() error

Arity error in binary operator overload.

func ArityErrorInUnaryOperatorOverload

func ArityErrorInUnaryOperatorOverload() error

Arity error in unary operator overload.

func ArityGeneratorError

func ArityGeneratorError(method string) error

Error when arity of a generator function is not zero.

func AssertionFailure

func AssertionFailure(message string) error

Error when an assertion failure occurs.

func BytesChangeMustBeWithNumericTypesOnly

func BytesChangeMustBeWithNumericTypesOnly() error

Error message used when changing a byte array with wrong data type.

func CannotDeriveFromValue

func CannotDeriveFromValue(value Value) error

Error produced when trying to deriving properties and methods from a non-Struct value.

func DebugModule

func DebugModule(input *bytes.Buffer, script string, stdlib map[string]LibLoader)

DebugModule runs the given Vida script in step by step computation fashion.

func DivisionByZeroError

func DivisionByZeroError() error

Division by zero error.

func ExpectedCallableValueInDeferError

func ExpectedCallableValueInDeferError(value Value) error

Error when expected a callable value.

func ExpectedIterableValueError

func ExpectedIterableValueError(value Value) error

Error when expected an iterable value.

func ExpectedListToSpreadError

func ExpectedListToSpreadError(value Value) error

Error when a unpackable value was expected.

func ExpectedTypeAndGotOtherType

func ExpectedTypeAndGotOtherType(expected, got string) error

Error when another value was expected.

func ExpectedUnpackableValueError

func ExpectedUnpackableValueError(value Value) error

Error when a unpackable value was expected.

func IndexOutOfRangeError

func IndexOutOfRangeError(length, index Int) error

Error messages for data structure subscriptions.

func InstancesDoNotSupportSubscriptionWriting

func InstancesDoNotSupportSubscriptionWriting() error

Error message for subscription operations in instances.

func IsNotMethodProperty

func IsNotMethodProperty(method, structName string) error

Error when a method or property was not found.

func LoadModule

func LoadModule(moduleName string) (*bytes.Buffer, error)

LoadModule loads a script file and returns a buffer of bytes.

func MethodNotDefined

func MethodNotDefined(method string, value Value) error

Method not defined error.

func MethodNotOverloaded

func MethodNotOverloaded(method, structName string) error

Error when not found overloaded some method.

func NameNotDefinedInCompoundDataType

func NameNotDefinedInCompoundDataType(name string, dataStructure Value) error

Error messages for selection operations.

func NegativeShiftError

func NegativeShiftError(op string, lhs, rhs Value) error

func NeverShouldHaveHappened

func NeverShouldHaveHappened(what string) error

Error message used when an unknown flag is used for subscription or selection operations. This error never should have happened.

func OperatorNotDefined

func OperatorNotDefined(op byte, value Value) error

Error when an operator is not defined for some data type.

func OverloadedOperatorWithWrongArity

func OverloadedOperatorWithWrongArity(method string, foundArity, must UInt32) error

Error when an instance overloaded __next operator with wrong arity.

func PrintCode

func PrintCode(input *bytes.Buffer, script string)

PrintCode prints the machine code in human readable fashion.

func PrintError

func PrintError(err error)

PrintError shows a given error in the terminal.

func RangeExpectedIntegerValue

func RangeExpectedIntegerValue(value Value) error

Error when step range is negative.

func RangeExpectedPositiveValue

func RangeExpectedPositiveValue(value Value) error

Error when step range is negative.

func RangeExpressionError

func RangeExpressionError(value Value) error

Error when range expression error.

func RecordPropertyError

func RecordPropertyError(key Value) error

Error message when using a non-string value as key in a record.

func RunModule

func RunModule(input *bytes.Buffer, script string, stdlib map[string]LibLoader)

RunModule runs the given Vida Script

func RuneOutOfRangeOrIllegal

func RuneOutOfRangeOrIllegal() error

Error when rune is out of range or it is illegal.

func SelectionOperationNotSupported

func SelectionOperationNotSupported(value Value) error

Error messages for values that does not support selector operator (.).

func StackOverfloError

func StackOverfloError() error

Stack Overflow Error

func TimeModule

func TimeModule(input *bytes.Buffer, script string, stdlib map[string]LibLoader)

TimeModule runs the given Vida Script

func TypeErrorInBinaryOperator

func TypeErrorInBinaryOperator(op string, lhs, rhs Value) error

Error messages for type errors in binary operations.

func TypeErrorInPrefixOperator

func TypeErrorInPrefixOperator(op string, value Value) error

Error message for type errors in unary operations.

func UnpackCountDoesNotMatchError

func UnpackCountDoesNotMatchError() error

Error when unpacking values.

func ValueDoesNotSupportExtension

func ValueDoesNotSupportExtension(value Value) error

Error produced when trying to extend a non-Struct Value.

func ValueDoesNotSupportSlicing

func ValueDoesNotSupportSlicing(value Value) error

Error when type does not support slicing.

func ValueDoesNotSupportSubscription

func ValueDoesNotSupportSubscription(value Value) error

Error message when using a value that does not support subscription operations [].

func ValueIsImmutable

func ValueIsImmutable(value Value) error

Error message used when trying to mutate an immutable value.

func ValueIsNotAnIndexError

func ValueIsNotAnIndexError(value Value) error

Error message when using a value that cannot be an index.

func ValueIsNotValueSemantics

func ValueIsNotValueSemantics(value Value) error

Error when type does not support value semantics.

func ValueNotHashableError

func ValueNotHashableError(key Value) error

Error message when using a value not hashable as key in a map or a set.

func VarArgArityError

func VarArgArityError(arity, argCount UInt32) error

Error when a method or property was not found.

func VariableAlreadyDefined

func VariableAlreadyDefined(identifier string) error

Error when declaring a declared variable.

func VariableNotDefined

func VariableNotDefined(identifier string) error

Error when changing the value of a not-declared variable.

func VidaFprint

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

Fprint formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func VidaFprintf

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

Fprintf formats according to a format specifier and writes to w. It returns the number of bytes written and any write error encountered.

func VidaFprintln

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

Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func VidaPrintf

func VidaPrintf(format string, a ...Value) (n int, err error)

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func VidaSprint

func VidaSprint(a ...Value) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func VidaSprintf

func VidaSprintf(format string, a ...Value) string

Sprintf formats according to a format specifier and returns the resulting string.

func VidaSprintln

func VidaSprintln(a ...Value) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

Types

type BInt

type BInt struct {
	Value *big.Int
}

BInt models an arbitrary precision singned integer.

func (*BInt) BinaryOp

func (b *BInt) BinaryOp(op byte, rhs Value) (Value, error)

func (*BInt) Clone

func (b *BInt) Clone() Value

func (*BInt) Description

func (b *BInt) Description() string

func (*BInt) Equals

func (b *BInt) Equals(other Value) bool

func (*BInt) GetMethod

func (b *BInt) GetMethod(name string) (Value, bool, error)

func (*BInt) HasMethods

func (b *BInt) HasMethods() bool

func (*BInt) IsHashable

func (b *BInt) IsHashable() bool

func (*BInt) IsIterable

func (b *BInt) IsIterable() bool

func (*BInt) IsValueSemantics

func (b *BInt) IsValueSemantics() bool

func (*BInt) MakeHashKey

func (b *BInt) MakeHashKey() HashKey

func (*BInt) MakeIterator

func (b *BInt) MakeIterator() Iterator

func (*BInt) PrefixOp

func (b *BInt) PrefixOp(op byte) (Value, error)

func (*BInt) ToInt

func (b *BInt) ToInt() Int

Interface IntegerNumber

func (*BInt) TypeName

func (b *BInt) TypeName() string

Interface Value

type Bool

type Bool bool

Bool models binary boolean values true, false

func (Bool) BinaryOp

func (b Bool) BinaryOp(op byte, rhs Value) (Value, error)

func (Bool) Clone

func (b Bool) Clone() Value

func (Bool) Description

func (b Bool) Description() string

func (Bool) Equals

func (b Bool) Equals(other Value) bool

func (Bool) GetMethod

func (b Bool) GetMethod(name string) (Value, bool, error)

func (Bool) HasMethods

func (b Bool) HasMethods() bool

func (Bool) IsHashable

func (b Bool) IsHashable() bool

func (Bool) IsIterable

func (b Bool) IsIterable() bool

func (Bool) IsValueSemantics

func (b Bool) IsValueSemantics() bool

func (Bool) MakeHashKey

func (b Bool) MakeHashKey() HashKey

func (Bool) MakeIterator

func (b Bool) MakeIterator() Iterator

func (Bool) PrefixOp

func (b Bool) PrefixOp(op byte) (Value, error)

func (Bool) TypeName

func (b Bool) TypeName() string

Interface Value

type Byte

type Byte byte

Byte models raw machine Bytes or unisgned integers of 8 bits.

func (Byte) BinaryOp

func (b Byte) BinaryOp(op byte, rhs Value) (Value, error)

func (Byte) Clone

func (b Byte) Clone() Value

func (Byte) Description

func (b Byte) Description() string

func (Byte) Equals

func (b Byte) Equals(other Value) bool

func (Byte) GetMethod

func (b Byte) GetMethod(name string) (Value, bool, error)

func (Byte) HasMethods

func (b Byte) HasMethods() bool

func (Byte) IsHashable

func (b Byte) IsHashable() bool

func (Byte) IsIterable

func (b Byte) IsIterable() bool

func (Byte) IsValueSemantics

func (b Byte) IsValueSemantics() bool

func (Byte) MakeHashKey

func (b Byte) MakeHashKey() HashKey

func (Byte) MakeIterator

func (b Byte) MakeIterator() Iterator

func (Byte) PrefixOp

func (b Byte) PrefixOp(op byte) (Value, error)

func (Byte) ToInt

func (b Byte) ToInt() Int

Interface IntegerNumber

func (Byte) TypeName

func (b Byte) TypeName() string

Interface Value

type Bytecode

type Bytecode = uint32

Interpreter global type aliases.

const (
	OPConst Bytecode = iota
	OPTrue
	OPFalse
	OPNil
	OPClosure
	OPStruct
	OPExtension
	OPDerive
	OPBinop
	OPEqual
	OPNotEqual
	OPNilChoice
	OPList
	OPMap
	OPRecord
	OPConstNamespace
	OPSubscript
	OPSelect
	OPPrefix
	OPNewGlobal
	OPGetGlobal
	OPSetGlobal
	OPCompSetGlobal
	OPGetLocal
	OPSetLocal
	OPCompSetLocal
	OPMutDataStructure
	OPCompMutDataStructure
	OPGetFreeVariable
	OPSetFreeVariable
	OPCompSetFreeVariable
	OPFreeVariable
	OPJumpIfFalse
	OPGoto
	OPRange
	OPNext
	OPMatch
	OPCall
	OPDefer
	OPDeferInvoke
	OPRunDefer
	OPReturn
	OPUnpack
	OPUnpackFor
	OPInvokeMethod
	OPAppend
	OPPop
	OPEnd
)

Opcodes for the VM.

type Bytes

type Bytes struct {
	Value []byte
}

Bytes models a dynamic mutable array of bytes.

func (*Bytes) BinaryOp

func (b *Bytes) BinaryOp(op byte, rhs Value) (Value, error)

func (*Bytes) Clone

func (b *Bytes) Clone() Value

func (*Bytes) Description

func (b *Bytes) Description() string

func (*Bytes) Equals

func (b *Bytes) Equals(other Value) bool

func (*Bytes) GetMethod

func (b *Bytes) GetMethod(name string) (Value, bool, error)

func (*Bytes) HasMethods

func (b *Bytes) HasMethods() bool

func (*Bytes) IsHashable

func (b *Bytes) IsHashable() bool

func (*Bytes) IsIterable

func (b *Bytes) IsIterable() bool

func (*Bytes) IsValueSemantics

func (b *Bytes) IsValueSemantics() bool

func (*Bytes) MakeHashKey

func (b *Bytes) MakeHashKey() HashKey

func (*Bytes) MakeIterator

func (b *Bytes) MakeIterator() Iterator

func (*Bytes) PrefixOp

func (b *Bytes) PrefixOp(op byte) (Value, error)

func (*Bytes) SliceGet

func (b *Bytes) SliceGet(sliceType UInt32, low, high Value) (Value, error)

Interface Slice operator.

func (*Bytes) SliceSet

func (b *Bytes) SliceSet(sliceType UInt32, low, high, value Value) error

func (*Bytes) SubscriptGet

func (b *Bytes) SubscriptGet(index Value) (Value, error)

Interface subscript operator.

func (*Bytes) SubscriptSet

func (b *Bytes) SubscriptSet(index, value Value) error

func (*Bytes) TypeName

func (b *Bytes) TypeName() string

Value Interface

type BytesIterator

type BytesIterator struct {
	Object          *Bytes
	EndIndex, Index Int
	IsRange         bool
}

BytesIterator is an object to iterate over bytes buffers and returns an item or a tuple (idx, val).

func NewBytesIterator

func NewBytesIterator(bytes *Bytes, isrange bool) *BytesIterator

func (*BytesIterator) BinaryOp

func (iter *BytesIterator) BinaryOp(op byte, rhs Value) (Value, error)

func (*BytesIterator) Clone

func (iter *BytesIterator) Clone() Value

func (*BytesIterator) Description

func (iter *BytesIterator) Description() string

func (*BytesIterator) Equals

func (iter *BytesIterator) Equals(other Value) bool

func (*BytesIterator) Exhausted

func (iter *BytesIterator) Exhausted() bool

func (*BytesIterator) GetMethod

func (iter *BytesIterator) GetMethod(name string) (Value, bool, error)

func (*BytesIterator) HasMethods

func (iter *BytesIterator) HasMethods() bool

func (*BytesIterator) IsHashable

func (iter *BytesIterator) IsHashable() bool

func (*BytesIterator) IsIterable

func (iter *BytesIterator) IsIterable() bool

func (*BytesIterator) IsValueSemantics

func (iter *BytesIterator) IsValueSemantics() bool

func (*BytesIterator) MakeHashKey

func (iter *BytesIterator) MakeHashKey() HashKey

func (*BytesIterator) MakeIterator

func (iter *BytesIterator) MakeIterator() Iterator

func (*BytesIterator) Next

func (iter *BytesIterator) Next() Value

func (*BytesIterator) PrefixOp

func (iter *BytesIterator) PrefixOp(op byte) (Value, error)

func (*BytesIterator) TypeName

func (iter *BytesIterator) TypeName() string

Interface Value

type Closure

type Closure struct {
	Function *Function // The function this closure has.
	FreeVars []Value   // The run time free variables linked to this closure.
	StructID UInt      // In case the function can access private state, this is the run time structu id linked to.
}

Closure is the run time representation of a function with its own captured environment.

func (Closure) BinaryOp

func (closure Closure) BinaryOp(op byte, rhs Value) (Value, error)

func (Closure) Clone

func (closure Closure) Clone() Value

func (Closure) Description

func (closure Closure) Description() string

func (Closure) Equals

func (closure Closure) Equals(other Value) bool

func (Closure) GetMethod

func (closure Closure) GetMethod(name string) (Value, bool, error)

func (Closure) HasMethods

func (closure Closure) HasMethods() bool

func (Closure) IsHashable

func (closure Closure) IsHashable() bool

func (Closure) IsIterable

func (closure Closure) IsIterable() bool

func (Closure) IsValueSemantics

func (closure Closure) IsValueSemantics() bool

func (Closure) MakeHashKey

func (closure Closure) MakeHashKey() HashKey

func (Closure) MakeIterator

func (closure Closure) MakeIterator() Iterator

func (Closure) PrefixOp

func (closure Closure) PrefixOp(op byte) (Value, error)

func (Closure) TypeName

func (closure Closure) TypeName() string

Interface Value

type Complex

type Complex complex128

Type Complex models complex numbers of 128 bits.

func (Complex) BinaryOp

func (z Complex) BinaryOp(op byte, rhs Value) (Value, error)

func (Complex) Clone

func (z Complex) Clone() Value

func (Complex) Description

func (z Complex) Description() string

func (Complex) Equals

func (z Complex) Equals(other Value) bool

func (Complex) GetMethod

func (z Complex) GetMethod(name string) (Value, bool, error)

func (Complex) HasMethods

func (z Complex) HasMethods() bool

func (Complex) IsHashable

func (z Complex) IsHashable() bool

func (Complex) IsIterable

func (z Complex) IsIterable() bool

func (Complex) IsValueSemantics

func (z Complex) IsValueSemantics() bool

func (Complex) MakeHashKey

func (z Complex) MakeHashKey() HashKey

func (Complex) MakeIterator

func (z Complex) MakeIterator() Iterator

func (Complex) PrefixOp

func (z Complex) PrefixOp(op byte) (Value, error)

func (Complex) TypeName

func (z Complex) TypeName() string

Interface Value

type Fiber

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

Fiber is the basic unit of execution and model a computational sequential process.

func (*Fiber) BinaryOp

func (fiber *Fiber) BinaryOp(op byte, rhs Value) (Value, error)

func (*Fiber) Clone

func (fiber *Fiber) Clone() Value

func (Fiber) Description

func (fiber Fiber) Description() string

func (*Fiber) Equals

func (fiber *Fiber) Equals(other Value) bool

func (*Fiber) GetMethod

func (fiber *Fiber) GetMethod(name string) (Value, bool, error)

func (*Fiber) HasMethods

func (fiber *Fiber) HasMethods() bool

func (*Fiber) IsHashable

func (fiber *Fiber) IsHashable() bool

func (*Fiber) IsIterable

func (fiber *Fiber) IsIterable() bool

func (*Fiber) IsValueSemantics

func (fiber *Fiber) IsValueSemantics() bool

func (*Fiber) MakeHashKey

func (fiber *Fiber) MakeHashKey() HashKey

func (*Fiber) MakeIterator

func (fiber *Fiber) MakeIterator() Iterator

func (*Fiber) PrefixOp

func (fiber *Fiber) PrefixOp(op byte) (Value, error)

func (Fiber) TypeName

func (fiber Fiber) TypeName() string

Interface Value

type Float

type Float float64

Float models a double precision floating-point number IEEE-754 of 64 bits.

func (Float) BinaryOp

func (f Float) BinaryOp(op byte, rhs Value) (Value, error)

func (Float) Clone

func (f Float) Clone() Value

func (Float) Description

func (f Float) Description() string

func (Float) Equals

func (f Float) Equals(other Value) bool

func (Float) GetMethod

func (f Float) GetMethod(name string) (Value, bool, error)

func (Float) HasMethods

func (f Float) HasMethods() bool

func (Float) IsHashable

func (f Float) IsHashable() bool

func (Float) IsIterable

func (f Float) IsIterable() bool

func (Float) IsValueSemantics

func (f Float) IsValueSemantics() bool

func (Float) MakeHashKey

func (f Float) MakeHashKey() HashKey

func (Float) MakeIterator

func (f Float) MakeIterator() Iterator

func (Float) PrefixOp

func (f Float) PrefixOp(op byte) (Value, error)

func (Float) TypeName

func (f Float) TypeName() string

Interface Value

type Frame

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

Frame is a structure to support function calls and preserve its state.

type Function

type Function struct {
	Name                  string            // The name of the function.
	Arity                 UInt32            // The arity of the function.
	Vararg                bool              // The function can receive an arbitrary number of args.
	FreeVarCount          Bytecode          // Count of free variables.
	Code                  []Bytecode        // The Bytecode of the function.
	Lines                 map[UInt32]UInt32 // A map between Bytecode to number lines.
	Constants             []Value           // The constant list of values of the function.
	ModuleName            string            // The module in this function has been defined.
	CanAccessPrivateState bool              // The function can access private state of an instance.
}

Function models the static representation of callable, executable code.

func (Function) BinaryOp

func (function Function) BinaryOp(op byte, rhs Value) (Value, error)

func (Function) Clone

func (function Function) Clone() Value

func (Function) Description

func (function Function) Description() string

func (Function) Equals

func (function Function) Equals(other Value) bool

func (Function) GetMethod

func (function Function) GetMethod(name string) (Value, bool, error)

func (Function) HasMethods

func (function Function) HasMethods() bool

func (Function) IsHashable

func (function Function) IsHashable() bool

func (Function) IsIterable

func (function Function) IsIterable() bool

func (Function) IsValueSemantics

func (function Function) IsValueSemantics() bool

func (Function) MakeHashKey

func (function Function) MakeHashKey() HashKey

func (Function) MakeIterator

func (function Function) MakeIterator() Iterator

func (Function) PrefixOp

func (function Function) PrefixOp(op byte) (Value, error)

func (Function) TypeName

func (function Function) TypeName() string

Interface Value

type GFunction

type GFunction struct {
	Name  string
	Value func(args ...Value) (Value, error)
}

GFunction is a Value that represents a function written in Go that can be run for the Vida VM.

func (GFunction) BinaryOp

func (gf GFunction) BinaryOp(op byte, rhs Value) (Value, error)

func (GFunction) Clone

func (gf GFunction) Clone() Value

func (GFunction) Description

func (gf GFunction) Description() string

func (GFunction) Equals

func (gf GFunction) Equals(other Value) bool

func (GFunction) GetMethod

func (gf GFunction) GetMethod(name string) (Value, bool, error)

func (GFunction) HasMethods

func (gf GFunction) HasMethods() bool

func (GFunction) IsHashable

func (gf GFunction) IsHashable() bool

func (GFunction) IsIterable

func (gf GFunction) IsIterable() bool

func (GFunction) IsValueSemantics

func (gf GFunction) IsValueSemantics() bool

func (GFunction) MakeHashKey

func (gf GFunction) MakeHashKey() HashKey

func (GFunction) MakeIterator

func (gf GFunction) MakeIterator() Iterator

func (GFunction) PrefixOp

func (gf GFunction) PrefixOp(op byte) (Value, error)

func (GFunction) TypeName

func (gf GFunction) TypeName() string

Interface Value

type GModule

type GModule struct {
	Name      string
	Namespace Namespace
}

GModule is the data structure to models an importable named environment written in Go.

func (GModule) BinaryOp

func (mod GModule) BinaryOp(op byte, rhs Value) (Value, error)

func (GModule) Clone

func (mod GModule) Clone() Value

func (GModule) Description

func (module GModule) Description() string

func (GModule) Equals

func (mod GModule) Equals(other Value) bool

func (GModule) GetMethod

func (mod GModule) GetMethod(name string) (Value, bool, error)

func (GModule) GetModuleName

func (mod GModule) GetModuleName() string

Interface Importable

func (GModule) HasMethods

func (mod GModule) HasMethods() bool

func (GModule) IsGModule

func (mod GModule) IsGModule() bool

func (GModule) IsHashable

func (mod GModule) IsHashable() bool

func (GModule) IsIterable

func (mod GModule) IsIterable() bool

func (GModule) IsVModule

func (mod GModule) IsVModule() bool

func (GModule) IsValueSemantics

func (mod GModule) IsValueSemantics() bool

func (GModule) MakeHashKey

func (mod GModule) MakeHashKey() HashKey

func (GModule) MakeIterator

func (mod GModule) MakeIterator() Iterator

func (GModule) PrefixOp

func (mod GModule) PrefixOp(op byte) (Value, error)

func (GModule) SelectorGet

func (mod GModule) SelectorGet(field string) (Value, error)

Interface SelectorOperator. GModule implements only get becuase it is an immutable Value.

func (GModule) SelectorSet

func (mod GModule) SelectorSet(string, Value) error

func (GModule) TypeName

func (mod GModule) TypeName() string

Interface Value

type Global

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

Global is the unique shared state accesible for every fiber and for every module.

type HashKey

type HashKey struct {
	Type             string
	ValueDescription string
}

HashKey models a key for a Map and Set collections.

func (HashKey) BinaryOp

func (hash HashKey) BinaryOp(op byte, rhs Value) (Value, error)

func (HashKey) Clone

func (hash HashKey) Clone() Value

func (HashKey) Description

func (hash HashKey) Description() string

func (HashKey) Equals

func (hash HashKey) Equals(other Value) bool

func (HashKey) GetMethod

func (hash HashKey) GetMethod(name string) (Value, bool, error)

func (HashKey) HasMethods

func (hash HashKey) HasMethods() bool

func (HashKey) IsHashable

func (hash HashKey) IsHashable() bool

func (HashKey) IsIterable

func (hash HashKey) IsIterable() bool

func (HashKey) IsValueSemantics

func (hash HashKey) IsValueSemantics() bool

func (HashKey) MakeHashKey

func (hash HashKey) MakeHashKey() HashKey

func (HashKey) MakeIterator

func (hash HashKey) MakeIterator() Iterator

func (HashKey) PrefixOp

func (hash HashKey) PrefixOp(op byte) (Value, error)

func (HashKey) TypeName

func (hash HashKey) TypeName() string

Interface Value

type IStop

type IStop byte

Type IStop is a type for signaling the exhaustation of iterators.

func (IStop) BinaryOp

func (istop IStop) BinaryOp(op byte, rhs Value) (Value, error)

func (IStop) Clone

func (istop IStop) Clone() Value

func (IStop) Description

func (eof IStop) Description() string

func (IStop) Equals

func (istop IStop) Equals(other Value) bool

func (IStop) GetMethod

func (istop IStop) GetMethod(name string) (Value, bool, error)

func (IStop) HasMethods

func (istop IStop) HasMethods() bool

func (IStop) IsHashable

func (istop IStop) IsHashable() bool

func (IStop) IsIterable

func (istop IStop) IsIterable() bool

func (IStop) IsValueSemantics

func (istop IStop) IsValueSemantics() bool

func (IStop) MakeHashKey

func (istop IStop) MakeHashKey() HashKey

func (IStop) MakeIterator

func (istop IStop) MakeIterator() Iterator

func (IStop) PrefixOp

func (istop IStop) PrefixOp(op byte) (Value, error)

func (IStop) TypeName

func (istop IStop) TypeName() string

Interface Value

type Importable

type Importable interface {
	GetModuleName() string
	IsGModule() bool
	IsVModule() bool
}

Importable is the common interface for GModules and VModules.

type Instance

type Instance struct {
	Id      UInt
	Struct  *Struct
	Public  Namespace
	Private Namespace
}

Instance models unique objects instances of some structured data types.

func (Instance) BinaryOp

func (instance Instance) BinaryOp(op byte, rhs Value) (Value, error)

func (Instance) Clone

func (instance Instance) Clone() Value

func (Instance) Description

func (instance Instance) Description() string

func (Instance) Equals

func (instance Instance) Equals(other Value) bool

func (Instance) GetMethod

func (instance Instance) GetMethod(name string) (Value, bool, error)

func (Instance) HasMethods

func (instance Instance) HasMethods() bool

func (Instance) IsHashable

func (instance Instance) IsHashable() bool

func (Instance) IsIterable

func (instance Instance) IsIterable() bool

func (Instance) IsValueSemantics

func (instance Instance) IsValueSemantics() bool

func (Instance) MakeHashKey

func (instance Instance) MakeHashKey() HashKey

func (Instance) MakeIterator

func (instance Instance) MakeIterator() Iterator

func (Instance) PrefixOp

func (instance Instance) PrefixOp(op byte) (Value, error)

func (Instance) SelectorGet

func (instance Instance) SelectorGet(field string) (Value, error)

Interface SelectorOperator.

func (Instance) SelectorSet

func (instance Instance) SelectorSet(property string, value Value) error

func (Instance) SubscriptGet

func (instance Instance) SubscriptGet(index Value) (Value, error)

Interface subscript operator.

func (Instance) SubscriptSet

func (instance Instance) SubscriptSet(index, value Value) error

func (Instance) TypeName

func (instance Instance) TypeName() string

Interface Value

type Int

type Int int64

Int models a signed integer of 64 bits machine independent.

func (Int) BinaryOp

func (integer Int) BinaryOp(op byte, rhs Value) (Value, error)

Iterface Operable

func (Int) Clone

func (integer Int) Clone() Value

func (Int) Description

func (integer Int) Description() string

func (Int) Equals

func (integer Int) Equals(other Value) bool

func (Int) GetMethod

func (integer Int) GetMethod(name string) (Value, bool, error)

func (Int) HasMethods

func (integer Int) HasMethods() bool

func (Int) IsHashable

func (integer Int) IsHashable() bool

func (Int) IsIterable

func (integer Int) IsIterable() bool

func (Int) IsValueSemantics

func (integer Int) IsValueSemantics() bool

func (Int) MakeHashKey

func (integer Int) MakeHashKey() HashKey

func (Int) MakeIterator

func (integer Int) MakeIterator() Iterator

func (Int) PrefixOp

func (integer Int) PrefixOp(op byte) (Value, error)

func (Int) ToInt

func (integer Int) ToInt() Int

Interface IntegerNumber

func (Int) TypeName

func (integer Int) TypeName() string

Interface Value

type Int32

type Int32 = int32

type IntegerNumber

type IntegerNumber interface {
	ToInt() Int
}

IntegerNumber is the common interface for numeric values used as indexes in List, Strings or Bytes: Int, UInt, Byte and BInt.

type Iterator

type Iterator interface {
	Next() Value
	Exhausted() bool
}

Iterator is the interface for every iterator value.

type LibLoader

type LibLoader func() Importable

LibLoader is a function when called produces and returns a GModule.

type List

type List struct {
	Elements []Value
}

List is an indexed-ordered random-access linear collection of values.

func (*List) BinaryOp

func (list *List) BinaryOp(op byte, rhs Value) (Value, error)

func (*List) Clone

func (list *List) Clone() Value

func (*List) Description

func (list *List) Description() string

func (*List) Equals

func (list *List) Equals(other Value) bool

func (*List) GetMethod

func (list *List) GetMethod(name string) (Value, bool, error)

func (*List) HasMethods

func (list *List) HasMethods() bool

func (*List) IsHashable

func (list *List) IsHashable() bool

func (*List) IsIterable

func (list *List) IsIterable() bool

func (*List) IsValueSemantics

func (list *List) IsValueSemantics() bool

func (*List) MakeHashKey

func (list *List) MakeHashKey() HashKey

func (*List) MakeIterator

func (list *List) MakeIterator() Iterator

func (*List) PrefixOp

func (list *List) PrefixOp(op byte) (Value, error)

func (*List) SliceGet

func (list *List) SliceGet(sliceType UInt32, low, high Value) (Value, error)

Interface Slice operator.

func (*List) SliceSet

func (list *List) SliceSet(sliceType UInt32, low, high, value Value) error

func (*List) SubscriptGet

func (list *List) SubscriptGet(index Value) (Value, error)

Interface subscript operator.

func (*List) SubscriptSet

func (list *List) SubscriptSet(index, value Value) error

func (*List) TypeName

func (list *List) TypeName() string

Interface Value

type ListIterator

type ListIterator struct {
	Object          *List
	EndIndex, Index Int
	IsRange         bool
}

ListIterator is an object to iterate over lists and returns an item or a tuple (idx, val).

func NewListIterator

func NewListIterator(list *List, isrange bool) *ListIterator

func (*ListIterator) BinaryOp

func (iter *ListIterator) BinaryOp(op byte, rhs Value) (Value, error)

func (*ListIterator) Clone

func (iter *ListIterator) Clone() Value

func (*ListIterator) Description

func (iter *ListIterator) Description() string

func (*ListIterator) Equals

func (iter *ListIterator) Equals(other Value) bool

func (*ListIterator) Exhausted

func (iter *ListIterator) Exhausted() bool

func (*ListIterator) GetMethod

func (iter *ListIterator) GetMethod(name string) (Value, bool, error)

func (*ListIterator) HasMethods

func (iter *ListIterator) HasMethods() bool

func (*ListIterator) IsHashable

func (iter *ListIterator) IsHashable() bool

func (*ListIterator) IsIterable

func (iter *ListIterator) IsIterable() bool

func (*ListIterator) IsValueSemantics

func (iter *ListIterator) IsValueSemantics() bool

func (*ListIterator) MakeHashKey

func (iter *ListIterator) MakeHashKey() HashKey

func (*ListIterator) MakeIterator

func (iter *ListIterator) MakeIterator() Iterator

func (*ListIterator) Next

func (iter *ListIterator) Next() Value

func (*ListIterator) PrefixOp

func (iter *ListIterator) PrefixOp(op byte) (Value, error)

func (*ListIterator) TypeName

func (iter *ListIterator) TypeName() string

Interface Value

type Map

type Map map[HashKey]Pair

Map is a hash table or dictionary.

func (Map) BinaryOp

func (m Map) BinaryOp(op byte, rhs Value) (Value, error)

func (Map) Clone

func (m Map) Clone() Value

func (Map) Description

func (m Map) Description() string

func (Map) Equals

func (m Map) Equals(other Value) bool

func (Map) GetMethod

func (m Map) GetMethod(name string) (Value, bool, error)

func (Map) HasMethods

func (m Map) HasMethods() bool

func (Map) IsHashable

func (m Map) IsHashable() bool

func (Map) IsIterable

func (m Map) IsIterable() bool

func (Map) IsValueSemantics

func (m Map) IsValueSemantics() bool

func (Map) MakeHashKey

func (m Map) MakeHashKey() HashKey

func (Map) MakeIterator

func (m Map) MakeIterator() Iterator

func (Map) PrefixOp

func (m Map) PrefixOp(op byte) (Value, error)

func (Map) SubscriptGet

func (m Map) SubscriptGet(index Value) (Value, error)

Interface subscription operator.

func (Map) SubscriptSet

func (m Map) SubscriptSet(index, value Value) error

func (Map) TypeName

func (m Map) TypeName() string

Interface Value

type MapIterator

type MapIterator struct {
	Object          Map
	Keys            []HashKey
	Index, EndIndex Int
	IsRange         bool
}

MapIterator is an object to iterate over maps.

func NewMapIterator

func NewMapIterator(mmap Map, isrange bool) *MapIterator

func (*MapIterator) BinaryOp

func (iter *MapIterator) BinaryOp(op byte, rhs Value) (Value, error)

func (*MapIterator) Clone

func (iter *MapIterator) Clone() Value

func (*MapIterator) Description

func (iter *MapIterator) Description() string

func (*MapIterator) Equals

func (iter *MapIterator) Equals(other Value) bool

func (*MapIterator) Exhausted

func (iter *MapIterator) Exhausted() bool

func (*MapIterator) GetMethod

func (iter *MapIterator) GetMethod(name string) (Value, bool, error)

func (*MapIterator) HasMethods

func (iter *MapIterator) HasMethods() bool

func (*MapIterator) IsHashable

func (iter *MapIterator) IsHashable() bool

func (*MapIterator) IsIterable

func (iter *MapIterator) IsIterable() bool

func (*MapIterator) IsValueSemantics

func (iter *MapIterator) IsValueSemantics() bool

func (*MapIterator) MakeHashKey

func (iter *MapIterator) MakeHashKey() HashKey

func (*MapIterator) MakeIterator

func (iter *MapIterator) MakeIterator() Iterator

func (*MapIterator) Next

func (iter *MapIterator) Next() Value

func (*MapIterator) PrefixOp

func (iter *MapIterator) PrefixOp(op byte) (Value, error)

func (*MapIterator) TypeName

func (iter *MapIterator) TypeName() string

Interface Value

type NamedConstants

type NamedConstants struct {
	Name      string
	Constants Namespace
	Indexes   map[Bytecode]string
}

NamedConstants models small namespace of constant values. Those values must have value semantics.

func (NamedConstants) BinaryOp

func (constants NamedConstants) BinaryOp(op byte, rhs Value) (Value, error)

func (NamedConstants) Clone

func (constants NamedConstants) Clone() Value

func (NamedConstants) Description

func (constants NamedConstants) Description() string

func (NamedConstants) Equals

func (constants NamedConstants) Equals(other Value) bool

func (NamedConstants) GetMethod

func (constants NamedConstants) GetMethod(name string) (Value, bool, error)

func (NamedConstants) HasMethods

func (constants NamedConstants) HasMethods() bool

func (NamedConstants) IsHashable

func (constants NamedConstants) IsHashable() bool

func (NamedConstants) IsIterable

func (constants NamedConstants) IsIterable() bool

func (NamedConstants) IsValueSemantics

func (constants NamedConstants) IsValueSemantics() bool

func (NamedConstants) MakeHashKey

func (constants NamedConstants) MakeHashKey() HashKey

func (NamedConstants) MakeIterator

func (constants NamedConstants) MakeIterator() Iterator

func (NamedConstants) PrefixOp

func (constants NamedConstants) PrefixOp(op byte) (Value, error)

func (NamedConstants) SelectorGet

func (constants NamedConstants) SelectorGet(field string) (Value, error)

Interface SelectorOperator. NamedConstants implements only get becuase it is an immutable Value.

func (NamedConstants) SelectorSet

func (constants NamedConstants) SelectorSet(string, Value) error

func (NamedConstants) TypeName

func (constants NamedConstants) TypeName() string

Interface Value

type Namespace

type Namespace = map[string]Value

Namespace is a type alias for a map between variable names and arbitrary Values.

type Nil

type Nil byte

Nil is the value representing the absence of value.

func (Nil) BinaryOp

func (n Nil) BinaryOp(op byte, rhs Value) (Value, error)

func (Nil) Clone

func (n Nil) Clone() Value

func (Nil) Description

func (n Nil) Description() string

func (Nil) Equals

func (n Nil) Equals(other Value) bool

func (Nil) GetMethod

func (n Nil) GetMethod(name string) (Value, bool, error)

func (Nil) HasMethods

func (n Nil) HasMethods() bool

func (Nil) IsHashable

func (n Nil) IsHashable() bool

func (Nil) IsIterable

func (n Nil) IsIterable() bool

func (Nil) IsValueSemantics

func (n Nil) IsValueSemantics() bool

func (Nil) MakeHashKey

func (n Nil) MakeHashKey() HashKey

func (Nil) MakeIterator

func (n Nil) MakeIterator() Iterator

func (Nil) PrefixOp

func (n Nil) PrefixOp(op byte) (Value, error)

func (Nil) TypeName

func (n Nil) TypeName() string

Interface Value

type NumericIterator

type NumericIterator struct {
	Value, End, Step Int
	TowardsRight     Bool
}

NumericIterator is the iterator over a range of integers.

func NewRange

func NewRange(value, end, step Int, towardsRight Bool) *NumericIterator

func (*NumericIterator) BinaryOp

func (iter *NumericIterator) BinaryOp(op byte, rhs Value) (Value, error)

func (*NumericIterator) Clone

func (iter *NumericIterator) Clone() Value

func (*NumericIterator) Description

func (iter *NumericIterator) Description() string

func (*NumericIterator) Equals

func (iter *NumericIterator) Equals(other Value) bool

func (*NumericIterator) Exhausted

func (iter *NumericIterator) Exhausted() bool

func (*NumericIterator) GetMethod

func (iter *NumericIterator) GetMethod(name string) (Value, bool, error)

func (*NumericIterator) HasMethods

func (iter *NumericIterator) HasMethods() bool

func (*NumericIterator) IsHashable

func (iter *NumericIterator) IsHashable() bool

func (*NumericIterator) IsIterable

func (iter *NumericIterator) IsIterable() bool

func (*NumericIterator) IsValueSemantics

func (iter *NumericIterator) IsValueSemantics() bool

func (*NumericIterator) MakeHashKey

func (iter *NumericIterator) MakeHashKey() HashKey

func (*NumericIterator) MakeIterator

func (iter *NumericIterator) MakeIterator() Iterator

func (*NumericIterator) Next

func (iter *NumericIterator) Next() Value

func (*NumericIterator) PrefixOp

func (iter *NumericIterator) PrefixOp(op byte) (Value, error)

func (*NumericIterator) TypeName

func (iter *NumericIterator) TypeName() string

Interface Value

type Pair

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

Pair is a helper struct to hold keys and values as return value when iterating over maps and records.

func (Pair) BinaryOp

func (pair Pair) BinaryOp(op byte, rhs Value) (Value, error)

func (Pair) Clone

func (pair Pair) Clone() Value

func (Pair) Description

func (pair Pair) Description() string

func (Pair) Equals

func (pair Pair) Equals(other Value) bool

func (Pair) GetMethod

func (pair Pair) GetMethod(name string) (Value, bool, error)

func (Pair) HasMethods

func (pair Pair) HasMethods() bool

func (Pair) IsHashable

func (pair Pair) IsHashable() bool

func (Pair) IsIterable

func (pair Pair) IsIterable() bool

func (Pair) IsValueSemantics

func (pair Pair) IsValueSemantics() bool

func (Pair) MakeHashKey

func (pair Pair) MakeHashKey() HashKey

func (Pair) MakeIterator

func (pair Pair) MakeIterator() Iterator

func (Pair) PrefixOp

func (pair Pair) PrefixOp(op byte) (Value, error)

func (Pair) SelectorGet

func (pair Pair) SelectorGet(field string) (Value, error)

Interface SelectorOperator. Pair implements only get becuase it is an immutable Value.

func (Pair) SelectorSet

func (pair Pair) SelectorSet(string, Value) error

func (Pair) TypeName

func (pair Pair) TypeName() string

Interface Value

type Rational

type Rational struct {
	Value *big.Rat
}

Rational models an arbitrary precision rational number.

func (*Rational) BinaryOp

func (rat *Rational) BinaryOp(op byte, rhs Value) (Value, error)

func (*Rational) Clone

func (rat *Rational) Clone() Value

func (*Rational) Description

func (rat *Rational) Description() string

func (*Rational) Equals

func (rat *Rational) Equals(other Value) bool

func (*Rational) GetMethod

func (rat *Rational) GetMethod(name string) (Value, bool, error)

func (*Rational) HasMethods

func (rat *Rational) HasMethods() bool

func (*Rational) IsHashable

func (rat *Rational) IsHashable() bool

func (*Rational) IsIterable

func (rat *Rational) IsIterable() bool

func (*Rational) IsValueSemantics

func (rat *Rational) IsValueSemantics() bool

func (*Rational) MakeHashKey

func (rat *Rational) MakeHashKey() HashKey

func (*Rational) MakeIterator

func (rat *Rational) MakeIterator() Iterator

func (*Rational) PrefixOp

func (rat *Rational) PrefixOp(op byte) (Value, error)

func (*Rational) TypeName

func (rat *Rational) TypeName() string

Interface Value

type Record

type Record struct {
	Properties Namespace
}

Record is a non-ordered structured {property:value} data type.

func (Record) BinaryOp

func (record Record) BinaryOp(op byte, rhs Value) (Value, error)

func (Record) Clone

func (record Record) Clone() Value

func (Record) Description

func (record Record) Description() string

func (Record) Equals

func (record Record) Equals(other Value) bool

func (Record) GetMethod

func (record Record) GetMethod(name string) (Value, bool, error)

func (Record) HasMethods

func (record Record) HasMethods() bool

func (Record) IsHashable

func (record Record) IsHashable() bool

func (Record) IsIterable

func (record Record) IsIterable() bool

func (Record) IsValueSemantics

func (record Record) IsValueSemantics() bool

func (Record) MakeHashKey

func (record Record) MakeHashKey() HashKey

func (Record) MakeIterator

func (record Record) MakeIterator() Iterator

func (Record) PrefixOp

func (record Record) PrefixOp(op byte) (Value, error)

func (Record) SelectorGet

func (record Record) SelectorGet(field string) (Value, error)

Interface SelectorOperator.

func (Record) SelectorSet

func (record Record) SelectorSet(property string, value Value) error

func (Record) SubscriptGet

func (record Record) SubscriptGet(index Value) (Value, error)

Interface Subscript Operator.

func (Record) SubscriptSet

func (record Record) SubscriptSet(index, value Value) error

func (Record) TypeName

func (record Record) TypeName() string

Interface Value

type RecordIterator

type RecordIterator struct {
	Object          *Record
	Keys            []string
	Index, EndIndex Int
	IsRange         bool
}

func NewRecordIterator

func NewRecordIterator(record Record, isrange bool) *RecordIterator

func (*RecordIterator) BinaryOp

func (iter *RecordIterator) BinaryOp(op byte, rhs Value) (Value, error)

func (*RecordIterator) Clone

func (iter *RecordIterator) Clone() Value

func (*RecordIterator) Description

func (iter *RecordIterator) Description() string

func (*RecordIterator) Equals

func (iter *RecordIterator) Equals(other Value) bool

func (*RecordIterator) Exhausted

func (iter *RecordIterator) Exhausted() bool

func (*RecordIterator) GetMethod

func (iter *RecordIterator) GetMethod(name string) (Value, bool, error)

func (*RecordIterator) HasMethods

func (iter *RecordIterator) HasMethods() bool

func (*RecordIterator) IsHashable

func (iter *RecordIterator) IsHashable() bool

func (*RecordIterator) IsIterable

func (iter *RecordIterator) IsIterable() bool

func (*RecordIterator) IsValueSemantics

func (iter *RecordIterator) IsValueSemantics() bool

func (*RecordIterator) MakeHashKey

func (iter *RecordIterator) MakeHashKey() HashKey

func (*RecordIterator) MakeIterator

func (iter *RecordIterator) MakeIterator() Iterator

func (*RecordIterator) Next

func (iter *RecordIterator) Next() Value

func (*RecordIterator) PrefixOp

func (iter *RecordIterator) PrefixOp(op byte) (Value, error)

func (*RecordIterator) TypeName

func (iter *RecordIterator) TypeName() string

Interface Value

type Repl

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

Repl models an iterative updated computation structure.

func NewRepl

func NewRepl(moduleName string, stdlib map[string]LibLoader) *Repl

func (*Repl) Eval

func (repl *Repl) Eval(code string, showCode bool) (err error)

type Result

type Result struct {
	Error Value
	Value Value
}

Result models the result of computations that could fail.

func (Result) BinaryOp

func (result Result) BinaryOp(op byte, rhs Value) (Value, error)

func (Result) Clone

func (result Result) Clone() Value

func (Result) Description

func (result Result) Description() string

func (Result) Equals

func (result Result) Equals(other Value) bool

func (Result) GetMethod

func (result Result) GetMethod(name string) (Value, bool, error)

func (Result) HasMethods

func (result Result) HasMethods() bool

func (Result) IsHashable

func (result Result) IsHashable() bool

func (Result) IsIterable

func (result Result) IsIterable() bool

func (Result) IsValueSemantics

func (result Result) IsValueSemantics() bool

func (Result) MakeHashKey

func (result Result) MakeHashKey() HashKey

func (Result) MakeIterator

func (result Result) MakeIterator() Iterator

func (Result) PrefixOp

func (result Result) PrefixOp(op byte) (Value, error)

func (Result) SelectorGet

func (result Result) SelectorGet(field string) (Value, error)

Interface SelectorOperator. Result implements only get becuase it is an immutable Value.

func (Result) SelectorSet

func (result Result) SelectorSet(string, Value) error

func (Result) TypeName

func (result Result) TypeName() string

Interface Value

type Rune

type Rune rune

Rune models a unicode codepoint value.

func (Rune) BinaryOp

func (r Rune) BinaryOp(op byte, rhs Value) (Value, error)

func (Rune) Clone

func (r Rune) Clone() Value

func (Rune) Description

func (r Rune) Description() string

func (Rune) Equals

func (r Rune) Equals(other Value) bool

func (Rune) GetMethod

func (r Rune) GetMethod(name string) (Value, bool, error)

func (Rune) HasMethods

func (r Rune) HasMethods() bool

func (Rune) IsHashable

func (r Rune) IsHashable() bool

func (Rune) IsIterable

func (r Rune) IsIterable() bool

func (Rune) IsValueSemantics

func (r Rune) IsValueSemantics() bool

func (Rune) MakeHashKey

func (r Rune) MakeHashKey() HashKey

func (Rune) MakeIterator

func (r Rune) MakeIterator() Iterator

func (Rune) PrefixOp

func (r Rune) PrefixOp(op byte) (Value, error)

func (Rune) TypeName

func (r Rune) TypeName() string

Interface Value

type SelectorOperable

type SelectorOperable interface {
	SelectorGet(string) (Value, error)
	SelectorSet(string, Value) error
}

SelectorOperable interface for Values implementing operator selector (value '.' property)

type Set

type Set map[HashKey]Value

Set is a collection of unique values.

func (Set) BinaryOp

func (set Set) BinaryOp(op byte, rhs Value) (Value, error)

func (Set) Clone

func (set Set) Clone() Value

func (Set) Description

func (set Set) Description() string

func (Set) Equals

func (set Set) Equals(other Value) bool

func (Set) GetMethod

func (set Set) GetMethod(name string) (Value, bool, error)

func (Set) HasMethods

func (set Set) HasMethods() bool

func (Set) IsHashable

func (set Set) IsHashable() bool

func (Set) IsIterable

func (set Set) IsIterable() bool

func (Set) IsValueSemantics

func (set Set) IsValueSemantics() bool

func (Set) MakeHashKey

func (set Set) MakeHashKey() HashKey

func (Set) MakeIterator

func (set Set) MakeIterator() Iterator

func (Set) PrefixOp

func (set Set) PrefixOp(op byte) (Value, error)

func (Set) TypeName

func (set Set) TypeName() string

Interface Value

type SetIterator

type SetIterator struct {
	Object          Set
	Keys            []HashKey
	Index, EndIndex Int
	IsRange         bool
}

SetIterator is an objecto to iterate over sets.

func NewSetIterator

func NewSetIterator(set Set, isrange bool) *SetIterator

func (*SetIterator) BinaryOp

func (iter *SetIterator) BinaryOp(op byte, rhs Value) (Value, error)

func (*SetIterator) Clone

func (iter *SetIterator) Clone() Value

func (*SetIterator) Description

func (iter *SetIterator) Description() string

func (*SetIterator) Equals

func (iter *SetIterator) Equals(other Value) bool

func (*SetIterator) Exhausted

func (iter *SetIterator) Exhausted() bool

func (*SetIterator) GetMethod

func (iter *SetIterator) GetMethod(name string) (Value, bool, error)

func (*SetIterator) HasMethods

func (iter *SetIterator) HasMethods() bool

func (*SetIterator) IsHashable

func (iter *SetIterator) IsHashable() bool

func (*SetIterator) IsIterable

func (iter *SetIterator) IsIterable() bool

func (*SetIterator) IsValueSemantics

func (iter *SetIterator) IsValueSemantics() bool

func (*SetIterator) MakeHashKey

func (iter *SetIterator) MakeHashKey() HashKey

func (*SetIterator) MakeIterator

func (iter *SetIterator) MakeIterator() Iterator

func (*SetIterator) Next

func (iter *SetIterator) Next() Value

func (*SetIterator) PrefixOp

func (iter *SetIterator) PrefixOp(op byte) (Value, error)

func (*SetIterator) TypeName

func (iter *SetIterator) TypeName() string

Interface Value

type SliceOperable

type SliceOperable interface {
	SliceGet(UInt32, Value, Value) (Value, error)
	SliceSet(UInt32, Value, Value, Value) error
}

SliceOperable interface for Values implementing slice operator subscript (value '[e:e]' | '[e:]' | '[:e]' | '[:]')

type String

type String struct {
	Value string
	Runes []rune
}

func (*String) BinaryOp

func (s *String) BinaryOp(op byte, rhs Value) (Value, error)

func (*String) Clone

func (s *String) Clone() Value

func (*String) Description

func (s *String) Description() string

func (*String) Equals

func (s *String) Equals(other Value) bool

func (*String) GetMethod

func (s *String) GetMethod(name string) (Value, bool, error)

func (*String) HasMethods

func (s *String) HasMethods() bool

func (*String) IsHashable

func (s *String) IsHashable() bool

func (*String) IsIterable

func (s *String) IsIterable() bool

func (*String) IsValueSemantics

func (s *String) IsValueSemantics() bool

func (*String) MakeHashKey

func (s *String) MakeHashKey() HashKey

func (*String) MakeIterator

func (s *String) MakeIterator() Iterator

func (*String) PrefixOp

func (s *String) PrefixOp(op byte) (Value, error)

func (*String) SliceGet

func (s *String) SliceGet(sliceType UInt32, low, high Value) (Value, error)

Interface Slice operator.

func (*String) SliceSet

func (s *String) SliceSet(sliceType UInt32, low, high, value Value) error

func (*String) SubscriptGet

func (s *String) SubscriptGet(index Value) (Value, error)

Interface SubscriptOperable.

func (*String) SubscriptSet

func (s *String) SubscriptSet(index, value Value) error

func (*String) TypeName

func (s *String) TypeName() string

Interface Value

type StringIterator

type StringIterator struct {
	Object              *String
	EndIndex, RuneIndex Int
	IsRange             bool
}

String iterator is an object to iterate over runes in strings.

func NewStringIterator

func NewStringIterator(str *String, isrange bool) *StringIterator

func (*StringIterator) BinaryOp

func (iter *StringIterator) BinaryOp(op byte, rhs Value) (Value, error)

func (*StringIterator) Clone

func (iter *StringIterator) Clone() Value

func (*StringIterator) Description

func (iter *StringIterator) Description() string

func (*StringIterator) Equals

func (iter *StringIterator) Equals(other Value) bool

func (*StringIterator) Exhausted

func (iter *StringIterator) Exhausted() bool

func (*StringIterator) GetMethod

func (iter *StringIterator) GetMethod(name string) (Value, bool, error)

func (*StringIterator) HasMethods

func (iter *StringIterator) HasMethods() bool

func (*StringIterator) IsHashable

func (iter *StringIterator) IsHashable() bool

func (*StringIterator) IsIterable

func (iter *StringIterator) IsIterable() bool

func (*StringIterator) IsValueSemantics

func (iter *StringIterator) IsValueSemantics() bool

func (*StringIterator) MakeHashKey

func (iter *StringIterator) MakeHashKey() HashKey

func (*StringIterator) MakeIterator

func (iter *StringIterator) MakeIterator() Iterator

func (*StringIterator) Next

func (iter *StringIterator) Next() Value

func (*StringIterator) PrefixOp

func (iter *StringIterator) PrefixOp(op byte) (Value, error)

func (*StringIterator) TypeName

func (iter *StringIterator) TypeName() string

Interface Value

type Struct

type Struct struct {
	Id      UInt
	Name    string
	Public  Namespace
	Private Namespace
	Methods Namespace
}

Struct is the stencil or blueprint of a new user-defined structured data type.

func (Struct) BinaryOp

func (s Struct) BinaryOp(op byte, rhs Value) (Value, error)

func (Struct) Clone

func (s Struct) Clone() Value

func (Struct) Description

func (s Struct) Description() string

func (Struct) Equals

func (s Struct) Equals(other Value) bool

func (Struct) GetMethod

func (s Struct) GetMethod(name string) (Value, bool, error)

func (Struct) HasMethods

func (s Struct) HasMethods() bool

func (Struct) IsHashable

func (s Struct) IsHashable() bool

func (Struct) IsIterable

func (s Struct) IsIterable() bool

func (Struct) IsValueSemantics

func (s Struct) IsValueSemantics() bool

func (Struct) MakeHashKey

func (s Struct) MakeHashKey() HashKey

func (Struct) MakeIterator

func (s Struct) MakeIterator() Iterator

func (Struct) PrefixOp

func (s Struct) PrefixOp(op byte) (Value, error)

func (Struct) SelectorGet

func (s Struct) SelectorGet(field string) (Value, error)

Interface SelectorOperator. Struct implements only get becuase it is an immutable Value.

func (Struct) SelectorSet

func (s Struct) SelectorSet(string, Value) error

func (Struct) TypeName

func (s Struct) TypeName() string

Interface Value

type SubscriptOperable

type SubscriptOperable interface {
	SubscriptGet(Value) (Value, error)
	SubscriptSet(Value, Value) error
}

SubscriptOperable interface for Values implementing operator subscript (value '[expr]')

type Tuple

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

Tuple is a helper struct to hold indexes and values as return value when iterating over lists and strings.

func (Tuple) BinaryOp

func (tuple Tuple) BinaryOp(op byte, rhs Value) (Value, error)

func (Tuple) Clone

func (tuple Tuple) Clone() Value

func (Tuple) Description

func (tuple Tuple) Description() string

func (Tuple) Equals

func (tuple Tuple) Equals(other Value) bool

func (Tuple) GetMethod

func (tuple Tuple) GetMethod(name string) (Value, bool, error)

func (Tuple) HasMethods

func (tuple Tuple) HasMethods() bool

func (Tuple) IsHashable

func (tuple Tuple) IsHashable() bool

func (Tuple) IsIterable

func (tuple Tuple) IsIterable() bool

func (Tuple) IsValueSemantics

func (tuple Tuple) IsValueSemantics() bool

func (Tuple) MakeHashKey

func (tuple Tuple) MakeHashKey() HashKey

func (Tuple) MakeIterator

func (tuple Tuple) MakeIterator() Iterator

func (Tuple) PrefixOp

func (tuple Tuple) PrefixOp(op byte) (Value, error)

func (Tuple) SelectorGet

func (tuple Tuple) SelectorGet(field string) (Value, error)

Interface SelectorOperator. Tuple implements only get becuase it is an immutable Value.

func (Tuple) SelectorSet

func (tuple Tuple) SelectorSet(string, Value) error

func (Tuple) TypeName

func (tuple Tuple) TypeName() string

Interface Value

type UInt

type UInt uint64

Type UInt models unsigned inteters of 64 bits machine independent.

func (UInt) BinaryOp

func (u UInt) BinaryOp(op byte, rhs Value) (Value, error)

func (UInt) Clone

func (u UInt) Clone() Value

func (UInt) Description

func (u UInt) Description() string

func (UInt) Equals

func (u UInt) Equals(other Value) bool

func (UInt) GetMethod

func (u UInt) GetMethod(name string) (Value, bool, error)

func (UInt) HasMethods

func (u UInt) HasMethods() bool

func (UInt) IsHashable

func (u UInt) IsHashable() bool

func (UInt) IsIterable

func (u UInt) IsIterable() bool

func (UInt) IsValueSemantics

func (u UInt) IsValueSemantics() bool

func (UInt) MakeHashKey

func (u UInt) MakeHashKey() HashKey

func (UInt) MakeIterator

func (u UInt) MakeIterator() Iterator

func (UInt) PrefixOp

func (u UInt) PrefixOp(op byte) (Value, error)

func (UInt) ToInt

func (u UInt) ToInt() Int

Interface IntegerNumber

func (UInt) TypeName

func (u UInt) TypeName() string

Interface Value

type UInt32

type UInt32 = uint32

type VM

type VM struct {
	*Fiber
}

VM hosts a thread of execution.

func (*VM) Run

func (vm *VM) Run(fiberFunctionName string)

func (*VM) RunDebugger

func (vm *VM) RunDebugger(fiberFunctionName string)

type VModule

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

VModule models a Vida file with its compiled sorce code which is equivalent to a Vida module.

func (*VModule) BinaryOp

func (mod *VModule) BinaryOp(op byte, rhs Value) (Value, error)

func (*VModule) Clone

func (mod *VModule) Clone() Value

func (*VModule) Description

func (mod *VModule) Description() string

func (*VModule) Equals

func (mod *VModule) Equals(other Value) bool

func (*VModule) GetMethod

func (mod *VModule) GetMethod(name string) (Value, bool, error)

func (*VModule) GetModuleName

func (mod *VModule) GetModuleName() string

Interface Importable

func (*VModule) HasMethods

func (mod *VModule) HasMethods() bool

func (*VModule) IsGModule

func (mod *VModule) IsGModule() bool

func (*VModule) IsHashable

func (mod *VModule) IsHashable() bool

func (*VModule) IsIterable

func (mod *VModule) IsIterable() bool

func (*VModule) IsVModule

func (mod *VModule) IsVModule() bool

func (*VModule) IsValueSemantics

func (mod *VModule) IsValueSemantics() bool

func (*VModule) MakeHashKey

func (mod *VModule) MakeHashKey() HashKey

func (*VModule) MakeIterator

func (mod *VModule) MakeIterator() Iterator

func (*VModule) PrefixOp

func (mod *VModule) PrefixOp(op byte) (Value, error)

func (*VModule) SelectorGet

func (mod *VModule) SelectorGet(field string) (Value, error)

Interface SelectorOperator. VModule implements only get becuase it is an immutable Value.

func (*VModule) SelectorSet

func (mod *VModule) SelectorSet(string, Value) error

func (*VModule) TypeName

func (mod *VModule) TypeName() string

Interface Value

type Value

type Value interface {
	TypeName() string
	Description() string
	Equals(Value) bool
	BinaryOp(byte, Value) (Value, error)
	PrefixOp(byte) (Value, error)
	IsIterable() bool
	MakeIterator() Iterator
	IsHashable() bool
	MakeHashKey() HashKey
	IsValueSemantics() bool
	HasMethods() bool
	GetMethod(string) (Value, bool, error)
	Clone() Value
}

Value interface models the inteface for all Vida Values.

func FiberCurrent

func FiberCurrent(args ...Value) (Value, error)

Returns the current running a.k.a. resumed fiber.

func FiberIsAlive

func FiberIsAlive(args ...Value) (Value, error)

Checks if a fiber is alive or terminated.

func FiberNew

func FiberNew(args ...Value) (Value, error)

Creates a new Fiber with a function as its unique argument.

func FiberParent

func FiberParent(args ...Value) (Value, error)

Returns the current running a.k.a. resumed fiber's caller fiber.

func FiberPrintStack

func FiberPrintStack(args ...Value) (Value, error)

Prints the stack trace for a given fiber.

func FiberRecycle

func FiberRecycle(args ...Value) (Value, error)

func FiberRun

func FiberRun(args ...Value) (Value, error)

Activates or re-activates the fiber given as its first argument.

func FiberState

func FiberState(args ...Value) (Value, error)

func FiberSuspend

func FiberSuspend(args ...Value) (Value, error)

Suspends the fiber in which it is called and returns some value to the caller fiber. A.k.a. fiber yield.

func FiberTerminate

func FiberTerminate(args ...Value) (Value, error)

func FiberWrap

func FiberWrap(args ...Value) (Value, error)

Jump to

Keyboard shortcuts

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