value

package
v0.0.0-...-0893d3e Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package value contains definitions of Elk values, classes, structs, modules etc.

Index

Constants

View Source
const (
	CLASS_SINGLETON_FLAG   bitfield.BitFlag8 = 1 << iota // Singleton classes are hidden classes often associated with a single value
	CLASS_MIXIN_PROXY_FLAG                               // This class serves as a proxy to an included mixin
	CLASS_MIXIN_FLAG                                     // This class is a mixin
)
View Source
const (
	Nanosecond  Duration = 1
	Microsecond          = 1000 * Nanosecond
	Millisecond          = 1000 * Microsecond
	Second               = 1000 * Millisecond
	Minute               = 60 * Second
	Hour                 = 60 * Minute
	Day                  = 24 * Hour
	Week                 = 7 * Day
	Year                 = Duration(365.25 * float64(Week))
)
View Source
const (
	UNDEFINED_FLAG = iota
	TRUE_FLAG
	FALSE_FLAG
	NIL_FLAG
	SMALL_INT_FLAG
	FLOAT_FLAG
	FLOAT32_FLAG
	INT8_FLAG
	UINT8_FLAG
	INT16_FLAG
	UINT16_FLAG
	INT32_FLAG
	UINT32_FLAG
	CHAR_FLAG
	SYMBOL_FLAG

	// only 64 bit systems
	INT64_FLAG
	UINT64_FLAG
	FLOAT64_FLAG
	DURATION_FLAG
	REFERENCE_FLAG
)
View Source
const BigFloatNaNMode big.RoundingMode = 0b111
View Source
const DefaultTimeFormat = "%Y-%m-%d %H:%M:%S.%9N %:z"
View Source
const FloatPrecision = 53
View Source
const HashMapMaxLoad = 0.75
View Source
const HashSetMaxLoad = 0.75
View Source
const MaxSmallInt = math.MaxInt

Max value of SmallInt

View Source
const MinSmallInt = math.MinInt

Min value of SmallInt

View Source
const PtrSize = 4 << (^uintptr(0) >> 63)
View Source
const SmallIntBits = PtrSize * 8

Number of bits available for a small int.

View Source
const ValueSize = unsafe.Sizeof(Value{})

Variables

View Source
var (
	// positive infinity
	BigFloatInfVal = BigFloatInf()
	// negative infinity
	BigFloatNegInfVal = BigFloatNegInf()
	// not a number value
	BigFloatNaNVal = BigFloatNaN()
)
View Source
var False = FalseType{}.ToValue()

Elk's false value

View Source
var GlobalObject = GlobalObjectType{}
View Source
var LocalTimezone = NewTimezone(time.Local)
View Source
var SYMBOL_TABLE_INITIAL_SIZE int

The number of preallocated slots for symbols in the symbol table at startup.

View Source
var True = TrueType{}.ToValue()

Elk's true value

View Source
var UTCTimezone = NewTimezone(time.UTC)
View Source
var Undefined = UndefinedType{}.ToValue()

Functions

func CountFloatDigits

func CountFloatDigits(str string) int

Counts the number of decimal digits in the string.

func Falsy

func Falsy(val Value) bool

Returns true when the Elk value is falsy (works like false in boolean logic) otherwise returns false.

func GetFromSlice

func GetFromSlice(collection *[]Value, index int) (Value, Value)

Get an element under the given index.

func Hash

func Hash(key Value) (result UInt64, err Value)

Calculate the hash of the value. When successful returns (result, undefined). When an error occurred returns (0, error). When there are no builtin addition functions for the given type returns (0, NotBuiltinError).

func InitGlobalEnvironment

func InitGlobalEnvironment()

Initialize all built-ins

func InspectSlice

func InspectSlice[T Inspectable](slice []T) string

Return the string representation of a slice of values.

func InspectSymbolContent

func InspectSymbolContent(name string) string

func InstanceOf

func InstanceOf(val Value, class *Class) bool

Check if the given value is an instance of the given class.

func IntToGoInt

func IntToGoInt(val Value) (int, bool)

Converts an Elk value strictly to Go int. Returns (0, false) when the value is incompatible. Returns (-1, false) when the value is a BigInt too large to be converted to int.

func IsA

func IsA(val Value, class *Class) bool

func IsMutableCollection

func IsMutableCollection(val Value) bool

func IsNil

func IsNil(val Value) bool

Returns true when the Elk value is nil otherwise returns false.

func LoadTimezone

func LoadTimezone(name string) (zone *Timezone, err Value)

Load a timezone from the IANA database.

func LogicalRightShift16

func LogicalRightShift16[L SimpleInt](left L, right uint64) L

func LogicalRightShift32

func LogicalRightShift32[L SimpleInt](left L, right uint64) L

func LogicalRightShift64

func LogicalRightShift64[L SimpleInt](left L, right uint64) L

func LogicalRightShift8

func LogicalRightShift8[L SimpleInt](left L, right uint64) L

func NewClassComparer

func NewClassComparer(opts *cmp.Options) cmp.Option

func NewInlineValueComparer

func NewInlineValueComparer(opts *cmp.Options) cmp.Option

func NewInterfaceComparer

func NewInterfaceComparer(opts *cmp.Options) cmp.Option

func NewModuleComparer

func NewModuleComparer(opts *cmp.Options) cmp.Option

func NewObjectComparer

func NewObjectComparer(opts *cmp.Options) cmp.Option

func NewReferenceComparer

func NewReferenceComparer() cmp.Option

func NewRegexComparer

func NewRegexComparer(opts *cmp.Options) cmp.Option

func NewSymbolTableComparer

func NewSymbolTableComparer() cmp.Option

func ParseBigFloat

func ParseBigFloat(str string) (*BigFloat, Value)

Parse a big float value from the given string.

func ParseBigInt

func ParseBigInt(s string, base int) (*BigInt, Value)

Parses a signed big.Int from a string using Elk syntax.

func ParseDuration

func ParseDuration(s String) (result Duration, err Value)

Parses a duration string and creates a Duration value. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

func ParseInt

func ParseInt(s string, base int) (Value, Value)

func ParseUBigInt

func ParseUBigInt(s string, base int) (*BigInt, Value)

Parses an unsigned big.Int from a string using Elk syntax.

func PrecisionForFloatString

func PrecisionForFloatString(str string) uint

Calculates the precision required to represent the float in the given string.

func RefErr

func RefErr(ref Reference, err Value) (Value, Value)

func ToGoInt

func ToGoInt(val Value) (int, bool)

Converts an Elk value to Go int. Returns (0, false) when the value is incompatible. Returns (-1, false) when the value is a BigInt too large to be converted to int.

func ToGoUInt

func ToGoUInt(val Value) (uint, bool)

Converts an Elk value to Go uint. Returns (0, false) when the value is incompatible, too large or negative.

func ToValueErr

func ToValueErr[T ToValuer](t T, err Value) (Value, Value)

func Truthy

func Truthy(val Value) bool

Returns true when the Elk value is truthy (works like true in boolean logic) otherwise returns false.

Types

type ArrayList

type ArrayList []Value

Elk's ArrayList value

func NewArrayList

func NewArrayList(capacity int) *ArrayList

func NewArrayListWithElements

func NewArrayListWithElements(capacity int, elements ...Value) *ArrayList

func NewArrayListWithLength

func NewArrayListWithLength(length int) *ArrayList

func (*ArrayList) Append

func (l *ArrayList) Append(elements ...Value)

Add new elements.

func (*ArrayList) At

func (l *ArrayList) At(i int) Value

Get an element under the given index without bounds checking

func (*ArrayList) Capacity

func (l *ArrayList) Capacity() int

func (*ArrayList) Class

func (*ArrayList) Class() *Class

func (*ArrayList) Concat

func (l *ArrayList) Concat(other Value) (*ArrayList, Value)

Concatenate another value with this list, creating a new list, and return the result. If the operation is illegal an error will be returned.

func (*ArrayList) Copy

func (l *ArrayList) Copy() Reference

func (*ArrayList) DirectClass

func (*ArrayList) DirectClass() *Class

func (*ArrayList) Error

func (l *ArrayList) Error() string

func (*ArrayList) Expand

func (l *ArrayList) Expand(newElements int)

Expands the list by n nil elements.

func (*ArrayList) Get

func (l *ArrayList) Get(index int) (Value, Value)

Get an element under the given index.

func (*ArrayList) Grow

func (l *ArrayList) Grow(newSlots int)

Expand the array list to have empty slots for new elements.

func (*ArrayList) Inspect

func (l *ArrayList) Inspect() string

func (*ArrayList) InstanceVariables

func (*ArrayList) InstanceVariables() SymbolMap

func (*ArrayList) LeftCapacity

func (l *ArrayList) LeftCapacity() int

func (*ArrayList) Length

func (l *ArrayList) Length() int

func (*ArrayList) Repeat

func (l *ArrayList) Repeat(other Value) (*ArrayList, Value)

Repeat the content of this list n times and return a new list containing the result. If the operation is illegal an error will be returned.

func (*ArrayList) Set

func (l *ArrayList) Set(index int, val Value) Value

Set an element under the given index.

func (*ArrayList) SetAt

func (l *ArrayList) SetAt(index int, val Value)

Set an element under the given index without bounds checking.

func (*ArrayList) SingletonClass

func (*ArrayList) SingletonClass() *Class

func (*ArrayList) Subscript

func (l *ArrayList) Subscript(key Value) (Value, Value)

Get an element under the given index.

func (*ArrayList) SubscriptSet

func (l *ArrayList) SubscriptSet(key, val Value) Value

Set an element under the given index.

type ArrayListIterator

type ArrayListIterator struct {
	ArrayList *ArrayList
	Index     int
}

func NewArrayListIterator

func NewArrayListIterator(list *ArrayList) *ArrayListIterator

func NewArrayListIteratorWithIndex

func NewArrayListIteratorWithIndex(list *ArrayList, index int) *ArrayListIterator

func (*ArrayListIterator) Class

func (*ArrayListIterator) Class() *Class

func (*ArrayListIterator) Copy

func (l *ArrayListIterator) Copy() Reference

func (*ArrayListIterator) DirectClass

func (*ArrayListIterator) DirectClass() *Class

func (*ArrayListIterator) Error

func (l *ArrayListIterator) Error() string

func (*ArrayListIterator) Inspect

func (l *ArrayListIterator) Inspect() string

func (*ArrayListIterator) InstanceVariables

func (*ArrayListIterator) InstanceVariables() SymbolMap

func (*ArrayListIterator) Next

func (l *ArrayListIterator) Next() (Value, Value)

func (*ArrayListIterator) SingletonClass

func (*ArrayListIterator) SingletonClass() *Class

type ArrayTuple

type ArrayTuple []Value

Elk's ArrayTuple value

func NewArrayTuple

func NewArrayTuple(capacity int) *ArrayTuple

func NewArrayTupleWithElements

func NewArrayTupleWithElements(capacity int, elements ...Value) *ArrayTuple

func NewArrayTupleWithLength

func NewArrayTupleWithLength(length int) *ArrayTuple

func (*ArrayTuple) Append

func (t *ArrayTuple) Append(element Value)

Add a new element.

func (*ArrayTuple) At

func (t *ArrayTuple) At(i int) Value

Get an element under the given index without bounds checking.

func (*ArrayTuple) Class

func (*ArrayTuple) Class() *Class

func (*ArrayTuple) Concat

func (t *ArrayTuple) Concat(other Value) (Value, Value)

Concatenate another value with this arrayTuple, creating a new value, and return the result. If the operation is illegal an error will be returned.

func (*ArrayTuple) Copy

func (t *ArrayTuple) Copy() Reference

func (*ArrayTuple) DirectClass

func (*ArrayTuple) DirectClass() *Class

func (*ArrayTuple) Error

func (t *ArrayTuple) Error() string

func (*ArrayTuple) Expand

func (t *ArrayTuple) Expand(newElements int)

Expands the arrayTuple by n nil elements.

func (*ArrayTuple) Get

func (t *ArrayTuple) Get(index int) (Value, Value)

Get an element under the given index.

func (*ArrayTuple) Inspect

func (t *ArrayTuple) Inspect() string

func (*ArrayTuple) InstanceVariables

func (*ArrayTuple) InstanceVariables() SymbolMap

func (*ArrayTuple) Length

func (t *ArrayTuple) Length() int

func (*ArrayTuple) Repeat

func (t *ArrayTuple) Repeat(other Value) (*ArrayTuple, Value)

Repeat the content of this arrayTuple n times and return a new arrayTuple containing the result. If the operation is illegal an error will be returned.

func (*ArrayTuple) Set

func (t *ArrayTuple) Set(index int, val Value) Value

Set an element under the given index.

func (*ArrayTuple) SetAt

func (t *ArrayTuple) SetAt(index int, val Value)

Set an element under the given index without bounds checking.

func (*ArrayTuple) SingletonClass

func (*ArrayTuple) SingletonClass() *Class

func (*ArrayTuple) Subscript

func (t *ArrayTuple) Subscript(key Value) (Value, Value)

Get an element under the given index.

func (*ArrayTuple) SubscriptSet

func (t *ArrayTuple) SubscriptSet(key, val Value) Value

Set an element under the given index.

type ArrayTupleIterator

type ArrayTupleIterator struct {
	ArrayTuple *ArrayTuple
	Index      int
}

func NewArrayTupleIterator

func NewArrayTupleIterator(arrayTuple *ArrayTuple) *ArrayTupleIterator

func NewArrayTupleIteratorWithIndex

func NewArrayTupleIteratorWithIndex(arrayTuple *ArrayTuple, index int) *ArrayTupleIterator

func (*ArrayTupleIterator) Class

func (*ArrayTupleIterator) Class() *Class

func (*ArrayTupleIterator) Copy

func (t *ArrayTupleIterator) Copy() Reference

func (*ArrayTupleIterator) DirectClass

func (*ArrayTupleIterator) DirectClass() *Class

func (*ArrayTupleIterator) Error

func (t *ArrayTupleIterator) Error() string

func (*ArrayTupleIterator) Inspect

func (t *ArrayTupleIterator) Inspect() string

func (*ArrayTupleIterator) InstanceVariables

func (*ArrayTupleIterator) InstanceVariables() SymbolMap

func (*ArrayTupleIterator) Next

func (t *ArrayTupleIterator) Next() (Value, Value)

func (*ArrayTupleIterator) SingletonClass

func (*ArrayTupleIterator) SingletonClass() *Class

type BeginlessClosedRange

type BeginlessClosedRange struct {
	End Value // end value
}

Represents a beginless closed range eg. `...2`

func NewBeginlessClosedRange

func NewBeginlessClosedRange(end Value) *BeginlessClosedRange

Create a new beginless closed range class.

func (*BeginlessClosedRange) Class

func (*BeginlessClosedRange) Class() *Class

func (*BeginlessClosedRange) Copy

func (r *BeginlessClosedRange) Copy() Reference

func (*BeginlessClosedRange) DirectClass

func (*BeginlessClosedRange) DirectClass() *Class

func (*BeginlessClosedRange) Error

func (r *BeginlessClosedRange) Error() string

func (*BeginlessClosedRange) Inspect

func (r *BeginlessClosedRange) Inspect() string

func (*BeginlessClosedRange) InstanceVariables

func (r *BeginlessClosedRange) InstanceVariables() SymbolMap

func (*BeginlessClosedRange) SingletonClass

func (*BeginlessClosedRange) SingletonClass() *Class

type BeginlessOpenRange

type BeginlessOpenRange struct {
	End Value // end value
}

Represents a beginless open range eg. `..<2`

func NewBeginlessOpenRange

func NewBeginlessOpenRange(end Value) *BeginlessOpenRange

Create a new beginless open range class.

func (*BeginlessOpenRange) Class

func (*BeginlessOpenRange) Class() *Class

func (*BeginlessOpenRange) Copy

func (r *BeginlessOpenRange) Copy() Reference

func (*BeginlessOpenRange) DirectClass

func (*BeginlessOpenRange) DirectClass() *Class

func (*BeginlessOpenRange) Error

func (r *BeginlessOpenRange) Error() string

func (*BeginlessOpenRange) Inspect

func (r *BeginlessOpenRange) Inspect() string

func (*BeginlessOpenRange) InstanceVariables

func (r *BeginlessOpenRange) InstanceVariables() SymbolMap

func (*BeginlessOpenRange) SingletonClass

func (*BeginlessOpenRange) SingletonClass() *Class

type BigFloat

type BigFloat big.Float

Elk's BigFloat value

func BigFloatInf

func BigFloatInf() *BigFloat

Create +Inf

func BigFloatNaN

func BigFloatNaN() *BigFloat

Create NaN

func BigFloatNegInf

func BigFloatNegInf() *BigFloat

Create -Inf

func NewBigFloat

func NewBigFloat(f float64) *BigFloat

Create a new BigFloat with the specified value.

func ParseBigFloatPanic

func ParseBigFloatPanic(str string) *BigFloat

Same as ParseBigFloat but panics on error.

func ToElkBigFloat

func ToElkBigFloat(f *big.Float) *BigFloat

Convert Go's big.Float values to Elk's BigFloat values.

func (*BigFloat) Add

func (f *BigFloat) Add(other Value) (Value, Value)

Add another value and return an error if something went wrong.

func (*BigFloat) AddBigFloat

func (z *BigFloat) AddBigFloat(x, y *BigFloat) *BigFloat

Add sets z to the rounded sum x+y and returns z.

func (*BigFloat) AsGoBigFloat

func (f *BigFloat) AsGoBigFloat() *big.Float

Convert Elk's BigFloat values to Go's big.Float values. Does a cast without any checks.

func (*BigFloat) Class

func (*BigFloat) Class() *Class

func (*BigFloat) Cmp

func (x *BigFloat) Cmp(y *BigFloat) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

Panics if x or y are NaN.

func (*BigFloat) Compare

func (f *BigFloat) Compare(other Value) (Value, Value)

Returns 1 if i is greater than other Returns 0 if both are equal. Returns -1 if i is less than other. Returns nil if the comparison was impossible (NaN)

func (*BigFloat) Copy

func (f *BigFloat) Copy() Reference

func (*BigFloat) DirectClass

func (*BigFloat) DirectClass() *Class

func (*BigFloat) DivBigFloat

func (z *BigFloat) DivBigFloat(x, y *BigFloat) *BigFloat

Div sets z to the rounded result x/y and returns z.

func (*BigFloat) Divide

func (f *BigFloat) Divide(other Value) (Value, Value)

Divide by another value and return an error if something went wrong.

func (*BigFloat) Equal

func (f *BigFloat) Equal(other Value) Value

Check whether f is equal to other and return an error if something went wrong.

func (*BigFloat) Error

func (f *BigFloat) Error() string

func (*BigFloat) ExpBigFloat

func (z *BigFloat) ExpBigFloat(x, y *BigFloat) *BigFloat

z = x ** y

func (*BigFloat) Exponentiate

func (f *BigFloat) Exponentiate(other Value) (Value, Value)

Exponentiate by another value and return an error if something went wrong.

func (*BigFloat) FloorBigFloat

func (f *BigFloat) FloorBigFloat() *BigFloat

func (*BigFloat) GreaterThan

func (f *BigFloat) GreaterThan(other Value) (Value, Value)

Check whether f is greater than other and return an error if something went wrong.

func (*BigFloat) GreaterThanEqual

func (f *BigFloat) GreaterThanEqual(other Value) (Value, Value)

Check whether f is greater than or equal to other and return an error if something went wrong.

func (*BigFloat) Hash

func (f *BigFloat) Hash() UInt64

func (*BigFloat) Inspect

func (f *BigFloat) Inspect() string

func (*BigFloat) InstanceVariables

func (f *BigFloat) InstanceVariables() SymbolMap

func (*BigFloat) IsInf

func (f *BigFloat) IsInf(sign int) bool

IsInf reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity.

func (*BigFloat) IsNaN

func (f *BigFloat) IsNaN() bool

IsNaN reports whether f is a “not-a-number” value.

func (*BigFloat) IsZero

func (z *BigFloat) IsZero() bool

func (*BigFloat) LaxEqual

func (f *BigFloat) LaxEqual(other Value) Value

Check whether f is equal to other and return an error if something went wrong.

func (*BigFloat) LessThan

func (f *BigFloat) LessThan(other Value) (Value, Value)

Check whether f is less than other and return an error if something went wrong.

func (*BigFloat) LessThanEqual

func (f *BigFloat) LessThanEqual(other Value) (Value, Value)

Check whether f is less than or equal to other and return an error if something went wrong.

func (*BigFloat) Mod

func (z *BigFloat) Mod(x, y *BigFloat) *BigFloat

Perform z = a % b by another BigFloat.

Special cases are:

Mod(±Inf, y) = NaN
Mod(NaN, y) = NaN
Mod(x, 0) = NaN
Mod(x, ±Inf) = x
Mod(x, NaN) = NaN

func (*BigFloat) Modulo

func (f *BigFloat) Modulo(other Value) (Value, Value)

Perform modulo by another numeric value and return an error if something went wrong.

func (*BigFloat) MulBigFloat

func (z *BigFloat) MulBigFloat(x, y *BigFloat) *BigFloat

Mul sets z to the rounded result x*y and returns z.

func (*BigFloat) Multiply

func (f *BigFloat) Multiply(other Value) (Value, Value)

Multiply by another value and return an error if something went wrong.

func (*BigFloat) Negate

func (f *BigFloat) Negate() *BigFloat

Negate the number and return the result.

func (*BigFloat) Precision

func (f *BigFloat) Precision() uint

Gets the f's precision.

func (*BigFloat) Set

func (z *BigFloat) Set(x *BigFloat) *BigFloat

Set z = x

func (*BigFloat) SetBigInt

func (f *BigFloat) SetBigInt(i *BigInt) *BigFloat

Sets f to the value of i.

func (*BigFloat) SetFloat

func (f *BigFloat) SetFloat(x Float) *BigFloat

Sets f to the possibly rounded value of x.

func (*BigFloat) SetFloat64

func (f *BigFloat) SetFloat64(x Float64) *BigFloat

Sets f to the possibly rounded value of x.

func (*BigFloat) SetInf

func (z *BigFloat) SetInf() *BigFloat

Set z = +Inf

func (*BigFloat) SetInt64

func (f *BigFloat) SetInt64(i Int64) *BigFloat

Sets f to the value of i.

func (*BigFloat) SetNaN

func (z *BigFloat) SetNaN() *BigFloat

Set z = NaN

func (*BigFloat) SetNegInf

func (z *BigFloat) SetNegInf() *BigFloat

Set z = -Inf

func (*BigFloat) SetPrecision

func (f *BigFloat) SetPrecision(prec uint) *BigFloat

Sets the f's precision to prec and possibly rounds the value.

func (*BigFloat) SetSmallInt

func (f *BigFloat) SetSmallInt(i SmallInt) *BigFloat

Sets f to the value of i.

func (*BigFloat) SetUInt64

func (f *BigFloat) SetUInt64(i UInt64) *BigFloat

Sets f to the value of i.

func (*BigFloat) Sign

func (f *BigFloat) Sign() int

Sign returns:

-1 if f < 0

0 if f is ±0

+1 if f > 0

func (*BigFloat) SingletonClass

func (*BigFloat) SingletonClass() *Class

func (*BigFloat) StrictEqual

func (f *BigFloat) StrictEqual(other Value) Value

Check whether f is strictly equal to other and return an error if something went wrong.

func (*BigFloat) SubBigFloat

func (z *BigFloat) SubBigFloat(x, y *BigFloat) *BigFloat

Sub sets z to the rounded result x-y and returns z.

func (*BigFloat) Subtract

func (f *BigFloat) Subtract(other Value) (Value, Value)

Subtract another value and return an error if something went wrong.

func (*BigFloat) ToBigInt

func (f *BigFloat) ToBigInt() *BigInt

Convert to a Float value.

func (*BigFloat) ToFloat

func (f *BigFloat) ToFloat() Float

Convert to a Float value.

func (*BigFloat) ToFloat32

func (f *BigFloat) ToFloat32() Float32

Convert to a Float32 value.

func (*BigFloat) ToFloat64

func (f *BigFloat) ToFloat64() Float64

Convert to a Float64 value.

func (*BigFloat) ToGoBigFloat

func (f *BigFloat) ToGoBigFloat() *big.Float

Convert Elk's BigFloat values to Go's big.Float values. Panics with big.ErrNaN if f is a NaN.

func (*BigFloat) ToInt

func (f *BigFloat) ToInt() Value

Convert to an Int value.

func (*BigFloat) ToInt16

func (f *BigFloat) ToInt16() Int16

Convert to an Int16 value.

func (*BigFloat) ToInt32

func (f *BigFloat) ToInt32() Int32

Convert to an Int32 value.

func (*BigFloat) ToInt64

func (f *BigFloat) ToInt64() Int64

Convert to an Int64 value.

func (*BigFloat) ToInt8

func (f *BigFloat) ToInt8() Int8

Convert to an Int8 value.

func (*BigFloat) ToUInt16

func (f *BigFloat) ToUInt16() UInt16

Convert to an UInt16 value.

func (*BigFloat) ToUInt32

func (f *BigFloat) ToUInt32() UInt32

Convert to an UInt32 value.

func (*BigFloat) ToUInt64

func (f *BigFloat) ToUInt64() UInt64

Convert to an UInt64 value.

func (*BigFloat) ToUInt8

func (f *BigFloat) ToUInt8() UInt8

Convert to an UInt8 value.

type BigFloatErrNaN

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

A BigFloatErrNaN panic is raised when converting a NaN value from Elk's BigFloat to Go's big.Float. Implements the error interface.

func (BigFloatErrNaN) Error

func (e BigFloatErrNaN) Error() string

type BigInt

type BigInt big.Int

Elk's BigInt value

func NewBigInt

func NewBigInt(i int64) *BigInt

Create a new BigInt with the specified value.

func ParseBigIntPanic

func ParseBigIntPanic(s string, base int) *BigInt

Same as ParseBigInt but panics on error.

func ToElkBigInt

func ToElkBigInt(i *big.Int) *BigInt

Convert Go big.Int value to Elk BigInt value.

func (*BigInt) Add

func (i *BigInt) Add(other Value) (Value, Value)

Add another value and return an error if something went wrong.

func (*BigInt) BitSize

func (i *BigInt) BitSize() int

Number of bits required to represent this integer.

func (*BigInt) BitwiseAnd

func (i *BigInt) BitwiseAnd(other Value) (Value, Value)

Perform bitwise AND with another value and return an error if something went wrong.

func (*BigInt) BitwiseAndNot

func (i *BigInt) BitwiseAndNot(other Value) (Value, Value)

Perform bitwise AND NOT with another value and return an error if something went wrong.

func (*BigInt) BitwiseNot

func (i *BigInt) BitwiseNot() *BigInt

Perform bitwise not on the number and return the result.

func (*BigInt) BitwiseOr

func (i *BigInt) BitwiseOr(other Value) (Value, Value)

Perform bitwise OR with another value and return an error if something went wrong.

func (*BigInt) BitwiseXor

func (i *BigInt) BitwiseXor(other Value) (Value, Value)

Perform bitwise XOR with another value and return an error if something went wrong.

func (*BigInt) Class

func (*BigInt) Class() *Class

func (*BigInt) Cmp

func (x *BigInt) Cmp(y *BigInt) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

func (*BigInt) Compare

func (i *BigInt) Compare(other Value) (Value, Value)

Returns 1 if i is greater than other Returns 0 if both are equal. Returns -1 if i is less than other. Returns nil if the comparison was impossible (NaN)

func (*BigInt) Copy

func (i *BigInt) Copy() Reference

func (*BigInt) Days

func (i *BigInt) Days() Duration

func (*BigInt) Decrement

func (i *BigInt) Decrement() Value

Decrement the number and return the result.

func (*BigInt) DirectClass

func (*BigInt) DirectClass() *Class

func (*BigInt) Divide

func (i *BigInt) Divide(other Value) (Value, Value)

Divide by another value and return an error if something went wrong.

func (*BigInt) Equal

func (i *BigInt) Equal(other Value) Value

Check whether i is equal to other

func (*BigInt) EqualBool

func (i *BigInt) EqualBool(other Value) bool

Check whether i is equal to other

func (*BigInt) Error

func (i *BigInt) Error() string

func (*BigInt) Exponentiate

func (i *BigInt) Exponentiate(other Value) (Value, Value)

Exponentiate by another value and return an error if something went wrong.

func (*BigInt) GreaterThan

func (i *BigInt) GreaterThan(other Value) (Value, Value)

Check whether i is greater than other and return an error if something went wrong.

func (*BigInt) GreaterThanBool

func (i *BigInt) GreaterThanBool(other Value) (bool, Value)

Check whether i is greater than other and return an error if something went wrong.

func (*BigInt) GreaterThanEqual

func (i *BigInt) GreaterThanEqual(other Value) (Value, Value)

Check whether i is greater than or equal to other and return an error if something went wrong.

func (*BigInt) GreaterThanEqualBool

func (i *BigInt) GreaterThanEqualBool(other Value) (bool, Value)

Check whether i is greater than or equal to other and return an error if something went wrong.

func (*BigInt) Hash

func (i *BigInt) Hash() UInt64

func (*BigInt) Hours

func (i *BigInt) Hours() Duration

func (*BigInt) Increment

func (i *BigInt) Increment() *BigInt

Increment the number and return the result.

func (*BigInt) Inspect

func (i *BigInt) Inspect() string

func (*BigInt) InstanceVariables

func (i *BigInt) InstanceVariables() SymbolMap

func (*BigInt) IsSmallInt

func (i *BigInt) IsSmallInt() bool

Reports whether i can be represented as a SmallInt.

func (*BigInt) IsZero

func (i *BigInt) IsZero() bool

Reports whether i is zero.

func (*BigInt) LaxEqual

func (i *BigInt) LaxEqual(other Value) Value

Check whether i is equal to other (with coercion)

func (*BigInt) LeftBitshift

func (i *BigInt) LeftBitshift(other Value) (Value, Value)

Bitshift to the left by another integer value and return an error if something went wrong.

func (*BigInt) LessThan

func (i *BigInt) LessThan(other Value) (Value, Value)

Check whether i is less than other and return an error if something went wrong.

func (*BigInt) LessThanBool

func (i *BigInt) LessThanBool(other Value) (bool, Value)

Check whether i is less than other and return an error if something went wrong.

func (*BigInt) LessThanEqual

func (i *BigInt) LessThanEqual(other Value) (Value, Value)

Check whether i is less than or equal to other and return an error if something went wrong.

func (*BigInt) LessThanEqualBool

func (i *BigInt) LessThanEqualBool(other Value) (bool, Value)

Check whether i is less than or equal to other and return an error if something went wrong.

func (*BigInt) Microseconds

func (i *BigInt) Microseconds() Duration

func (*BigInt) Milliseconds

func (i *BigInt) Milliseconds() Duration

func (*BigInt) Minutes

func (i *BigInt) Minutes() Duration

func (*BigInt) Modulo

func (i *BigInt) Modulo(other Value) (Value, Value)

Perform modulo with another numeric value and return an error if something went wrong.

func (*BigInt) Multiply

func (i *BigInt) Multiply(other Value) (Value, Value)

Multiply by another value and return an error if something went wrong.

func (*BigInt) Nanoseconds

func (i *BigInt) Nanoseconds() Duration

func (*BigInt) Negate

func (i *BigInt) Negate() *BigInt

Negate the number and return the result.

func (*BigInt) RightBitshift

func (i *BigInt) RightBitshift(other Value) (Value, Value)

Bitshift to the right by another integer value and return an error if something went wrong.

func (*BigInt) Seconds

func (i *BigInt) Seconds() Duration

func (*BigInt) SingletonClass

func (*BigInt) SingletonClass() *Class

func (*BigInt) StrictEqual

func (i *BigInt) StrictEqual(other Value) Value

Check whether i is strictly equal to other

func (*BigInt) Subtract

func (i *BigInt) Subtract(other Value) (Value, Value)

Subtract another value and return an error if something went wrong.

func (*BigInt) ToFloat

func (i *BigInt) ToFloat() Float

Returns the Float representation of i.

func (*BigInt) ToFloat32

func (i *BigInt) ToFloat32() Float32

Convert to Elk Float32

func (*BigInt) ToFloat64

func (i *BigInt) ToFloat64() Float64

Convert to Elk Float64

func (*BigInt) ToGoBigInt

func (i *BigInt) ToGoBigInt() *big.Int

Convert the Elk BigInt value to Go big.Int value.

func (*BigInt) ToInt16

func (i *BigInt) ToInt16() Int16

Convert to Elk Int16

func (*BigInt) ToInt32

func (i *BigInt) ToInt32() Int32

Convert to Elk Int32

func (*BigInt) ToInt64

func (i *BigInt) ToInt64() Int64

Convert to Elk Int64

func (*BigInt) ToInt8

func (i *BigInt) ToInt8() Int8

Convert to Elk Int8

func (*BigInt) ToSmallInt

func (i *BigInt) ToSmallInt() SmallInt

Returns the SmallInt representation of i.

func (*BigInt) ToString

func (i *BigInt) ToString() String

Convert the Elk BigInt value to Elk String.

func (*BigInt) ToUInt16

func (i *BigInt) ToUInt16() UInt16

Convert to Elk UInt16

func (*BigInt) ToUInt32

func (i *BigInt) ToUInt32() UInt32

Convert to Elk UInt32

func (*BigInt) ToUInt64

func (i *BigInt) ToUInt64() UInt64

Convert to Elk UInt64

func (*BigInt) ToUInt8

func (i *BigInt) ToUInt8() UInt8

Convert to Elk UInt8

func (*BigInt) Weeks

func (i *BigInt) Weeks() Duration

func (*BigInt) Years

func (i *BigInt) Years() Duration

type CallCache

type CallCache struct {
	Class  *Class
	Method Method
}

type CallSiteInfo

type CallSiteInfo struct {
	Name          Symbol
	ArgumentCount int
	Cache         [3]CallCache
}

Contains details like the number of arguments or the method name of a particular call site.

func NewCallSiteInfo

func NewCallSiteInfo(methodName Symbol, argCount int) *CallSiteInfo

Create a new CallSiteInfo.

func (*CallSiteInfo) Class

func (*CallSiteInfo) Class() *Class

func (*CallSiteInfo) Copy

func (c *CallSiteInfo) Copy() Reference

func (*CallSiteInfo) DirectClass

func (*CallSiteInfo) DirectClass() *Class

func (*CallSiteInfo) Error

func (c *CallSiteInfo) Error() string

func (*CallSiteInfo) Inspect

func (c *CallSiteInfo) Inspect() string

func (*CallSiteInfo) InstanceVariables

func (*CallSiteInfo) InstanceVariables() SymbolMap

func (*CallSiteInfo) SingletonClass

func (*CallSiteInfo) SingletonClass() *Class

type Char

type Char rune

Elk's Char value

func (Char) ByteCount

func (c Char) ByteCount() int

Returns the number of bytes present in the character.

func (Char) CharCount

func (Char) CharCount() int

func (Char) Class

func (Char) Class() *Class

func (Char) Cmp

func (x Char) Cmp(y Char) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

func (Char) Compare

func (c Char) Compare(other Value) (Value, Value)

Returns 1 if i is greater than other Returns 0 if both are equal. Returns -1 if i is less than other. Returns nil if the comparison was impossible (NaN)

func (Char) Concat

func (c Char) Concat(other Value) (String, Value)

Concatenate another value with this character, creating a new string, and return the result. If the operation is illegal an error will be returned.

func (Char) DirectClass

func (Char) DirectClass() *Class

func (Char) Equal

func (c Char) Equal(other Value) Value

Check whether s is equal to other

func (Char) Error

func (c Char) Error() string

func (Char) GraphemeCount

func (Char) GraphemeCount() int

func (Char) GreaterThan

func (c Char) GreaterThan(other Value) (Value, Value)

Check whether c is greater than other and return an error if something went wrong.

func (Char) GreaterThanEqual

func (c Char) GreaterThanEqual(other Value) (Value, Value)

Check whether c is greater than or equal to other and return an error if something went wrong.

func (Char) Hash

func (c Char) Hash() UInt64

func (Char) Inspect

func (c Char) Inspect() string

func (Char) InstanceVariables

func (Char) InstanceVariables() SymbolMap

func (Char) LaxEqual

func (c Char) LaxEqual(other Value) Value

Check whether c is equal to other

func (Char) LessThan

func (c Char) LessThan(other Value) (Value, Value)

Check whether c is less than other and return an error if something went wrong.

func (Char) LessThanEqual

func (c Char) LessThanEqual(other Value) (Value, Value)

Check whether c is less than or equal to other and return an error if something went wrong.

func (Char) Lowercase

func (c Char) Lowercase() Char

Convert to lowercase

func (Char) Repeat

func (c Char) Repeat(other Value) (String, Value)

Repeat this character n times and return a new string containing the result. If the operation is illegal an error will be returned.

func (Char) Rune

func (c Char) Rune() rune

func (Char) SingletonClass

func (Char) SingletonClass() *Class

func (Char) StrictEqual

func (c Char) StrictEqual(other Value) Value

Check whether s is strictly equal to other

func (Char) ToValue

func (c Char) ToValue() Value

func (Char) Uppercase

func (c Char) Uppercase() Char

Convert to uppercase

type Class

type Class struct {
	ConstantContainer
	MethodContainer
	ConstructorFunc ConstructorFunc
	Flags           bitfield.BitField8
	// contains filtered or unexported fields
}

Represents an Elk Class.

var ArgumentErrorClass *Class

::Std::ArgumentError

Thrown when the arguments don't match the defined parameters for a given method.

var ArrayListClass *Class

::Std::ArrayList

Represents a dynamically sized array, that can shrink and grow.

var ArrayListIteratorClass *Class

::Std::ArrayList::Iterator

ArrayList iterator class.

var ArrayTupleClass *Class

::Std::ArrayTuple

Represents an immutable array.

var ArrayTupleIteratorClass *Class

::Std::ArrayTuple::Iterator

ArrayTuple iterator class.

var BeginlessClosedRangeClass *Class // ::Std::BeginlessClosedRange
var BeginlessOpenRangeClass *Class // ::Std::BeginlessOpenRange
var BigFloatClass *Class // ::Std::BigFloat
var BoolClass *Class // ::Std::Bool
var CharClass *Class

::Std::Char

Represents a single UTF-8 character. Takes up 4 bytes.

var ClassClass *Class // ::Std::Class
var ClosedRangeClass *Class // ::Std::ClosedRange
var ClosedRangeIteratorClass *Class

::Std::ClosedRange::Iterator

ClosedRange iterator class.

var DurationClass *Class // ::Std::Duration
var EndlessClosedRangeClass *Class // ::Std::EndlessClosedRange
var EndlessClosedRangeIteratorClass *Class

::Std::EndlessClosedRange::Iterator

EndlessClosedRange iterator class.

var EndlessOpenRangeClass *Class // ::Std::EndlessOpenRange
var EndlessOpenRangeIteratorClass *Class

::Std::EndlessOpenRange::Iterator

EndlessOpenRange iterator class.

var ErrorClass *Class

::Std::Error

Parent class for all exceptions.

var FalseClass *Class // ::Std::False
var FileSystemErrorClass *Class

::Std::FileSystemError

var Float32Class *Class // ::Std::Float32
var Float64Class *Class // ::Std::Float64
var FloatClass *Class // ::Std::Float
var FormatErrorClass *Class

::Std::FormatError

Thrown when a literal or interpreted string has an incorrect format.

var FunctionClass *Class // ::Std::Function
var GlobalObjectSingletonClass *Class
var HashMapClass *Class // ::Std::HashMap
var HashMapIteratorClass *Class // ::Std::HashMap::Iterator
var HashRecordClass *Class // ::Std::HashRecord
var HashRecordIteratorClass *Class // ::Std::HashRecord::Iterator
var HashSetClass *Class // ::Std::HashSet
var HashSetIteratorClass *Class // ::Std::HashSet::Iterator
var IndexErrorClass *Class

::Std::IndexError

Thrown when the index is invalid.

var Int16Class *Class // ::Std::Int16
var Int32Class *Class // ::Std::Int32
var Int64Class *Class // ::Std::Int64
var Int8Class *Class // ::Std::Int8
var IntClass *Class // ::Std::Int
var InterfaceClass *Class // ::Std::Interface
var InvalidTimezoneErrorClass *Class

::Std::InvalidTimezoneError

Thrown when a timezone wasn't found.

var LeftOpenRangeClass *Class // ::Std::LeftOpenRange
var LeftOpenRangeIteratorClass *Class

::Std::LeftOpenRange::Iterator

LeftOpenRange iterator class.

var MethodClass *Class // ::Std::Method
var MixinClass *Class // ::Std::Mixin
var ModifierMismatchErrorClass *Class

::Std::ModifierMismatchError

Thrown when a class was originally defined with some modifiers and later on reopened with different ones.

var ModuleClass *Class // ::Std::Module
var NilClass *Class // ::Std::Nil
var NoConstantErrorClass *Class

::Std::NoConstantError

Thrown after trying to read a nonexistent constant.

var NoMethodErrorClass *Class

::Std::NoMethodError

Thrown after attempting to call a method that is not available to the value.

var NotBuiltinErrorClass *Class

::Std::NotBuiltinError

Thrown when the called method is not builtin.

var ObjectClass *Class // ::Std::Object
var OpenRangeClass *Class // ::Std::OpenRange
var OpenRangeIteratorClass *Class

::Std::OpenRange::Iterator

OpenRange iterator class.

var OutOfRangeErrorClass *Class

::Std::OutOfRangeError

Thrown when a numeric value is too large or too small to be used in a particular setting.

var PairClass *Class // ::Std::Pair
var PairIteratorClass *Class

::Std::Pair::Iterator

Pair iterator class.

var PatternNotMatchedErrorClass *Class

::Std::PatternNotMatchedError

Thrown when a pattern was not matched in destructuring etc

var PrimitiveValueErrorClass *Class

::Std::PrimitiveValueError

Thrown when trying to access or set instance variables on a primitive object that cannot have instance variables.

var RedefinedConstantErrorClass *Class

::Std::RedefinedConstantError

Thrown after trying to redefine a constant.

var RegexClass *Class // ::Std::Regex
var RegexCompileErrorClass *Class

::Std::RegexCompileError

Thrown when a Regex could not be compiled.

var RightOpenRangeClass *Class // ::Std::RightOpenRange
var RightOpenRangeIteratorClass *Class

::Std::RightOpenRange::Iterator

RightOpenRange iterator class.

var SealedClassErrorClass *Class

::Std::SealedClassError

Thrown when trying to inherit from a sealed class.

var StringByteIteratorClass *Class // ::Std::String::ByteIterator
var StringCharIteratorClass *Class // ::Std::String::CharIterator
var StringClass *Class // ::Std::String
var SymbolClass *Class // ::Std::Symbol
var SymbolMapClass *Class // ::Std::SymbolMap
var TimeClass *Class // ::Std::Time
var TimezoneClass *Class // ::Std::Timezone
var TrueClass *Class // ::Std::True
var TypeErrorClass *Class

::Std::TypeError

Thrown when an argument given to a method has an incorrect type.

var UInt16Class *Class // ::Std::UInt16
var UInt32Class *Class // ::Std::UInt32
var UInt64Class *Class // ::Std::UInt64
var UInt8Class *Class // ::Std::UInt8
var UndefinedClass *Class
var UnexpectedNilErrorClass *Class

::Std::UnexpectedNilError

Thrown when a `nil` value is encountered in a `must` expression.

var ValueClass *Class // ::Std::Value
var ZeroDivisionErrorClass *Class

::Std::ZeroDivisionError

Thrown when an integer is divided by zero.

func NewClass

func NewClass() *Class

Create a new class.

func NewClassWithOptions

func NewClassWithOptions(opts ...ClassOption) *Class

Create a new class.

func NewMixinWithOptions

func NewMixinWithOptions(opts ...MixinOption) *Class

Create a new mixin.

func NewSingletonClass

func NewSingletonClass(originalClass *Class, originalName string) *Class

func (*Class) Class

func (c *Class) Class() *Class

func (*Class) Copy

func (c *Class) Copy() Reference

func (*Class) CreateInstance

func (c *Class) CreateInstance() Value

Create a new instance of the class without initialising it.

func (*Class) DirectClass

func (c *Class) DirectClass() *Class

func (*Class) Doc

func (c *Class) Doc() Value

func (*Class) Error

func (c *Class) Error() string

func (*Class) IncludeMixin

func (c *Class) IncludeMixin(mixin *Mixin)

Include the passed in mixin in this class.

func (*Class) Inspect

func (c *Class) Inspect() string

func (*Class) InspectInheritance

func (c *Class) InspectInheritance() string

func (*Class) InspectParents

func (c *Class) InspectParents() string

func (*Class) InstanceVariables

func (c *Class) InstanceVariables() SymbolMap

func (*Class) IsMixin

func (c *Class) IsMixin() bool

func (*Class) IsMixinProxy

func (c *Class) IsMixinProxy() bool

func (*Class) IsSingleton

func (c *Class) IsSingleton() bool

func (*Class) Parents

func (c *Class) Parents() iter.Seq[*Class]

Iterates over every parent of the class/mixin (including itself)

func (*Class) SetDirectClass

func (c *Class) SetDirectClass(metaClass *Class)

func (*Class) SetDoc

func (c *Class) SetDoc(doc String)

func (*Class) SetMixin

func (c *Class) SetMixin()

func (*Class) SetMixinProxy

func (c *Class) SetMixinProxy()

func (*Class) SetSingleton

func (c *Class) SetSingleton()

func (*Class) SetSingletonName

func (c *Class) SetSingletonName(name string)

func (*Class) SingletonClass

func (c *Class) SingletonClass() *Class

type ClassOption

type ClassOption = func(*Class)

Class constructor option function

func ClassWithConstants

func ClassWithConstants(constants SymbolMap) ClassOption

func ClassWithConstructor

func ClassWithConstructor(constructor ConstructorFunc) ClassOption

func ClassWithMetaClass

func ClassWithMetaClass(metaClass *Class) ClassOption

func ClassWithMethods

func ClassWithMethods(methods MethodMap) ClassOption

func ClassWithMixin

func ClassWithMixin() ClassOption

func ClassWithMixinProxy

func ClassWithMixinProxy() ClassOption

func ClassWithName

func ClassWithName(name string) ClassOption

func ClassWithParent

func ClassWithParent(parent *Class) ClassOption

func ClassWithSingleton

func ClassWithSingleton() ClassOption

type ClosedRange

type ClosedRange struct {
	Start Value // start value
	End   Value // end value
}

Represents a closed range eg. `5...2`

func NewClosedRange

func NewClosedRange(start, end Value) *ClosedRange

Create a new closed range class.

func (*ClosedRange) Class

func (*ClosedRange) Class() *Class

func (*ClosedRange) Copy

func (r *ClosedRange) Copy() Reference

func (*ClosedRange) DirectClass

func (*ClosedRange) DirectClass() *Class

func (*ClosedRange) Error

func (r *ClosedRange) Error() string

func (*ClosedRange) Inspect

func (r *ClosedRange) Inspect() string

func (*ClosedRange) InstanceVariables

func (r *ClosedRange) InstanceVariables() SymbolMap

func (*ClosedRange) SingletonClass

func (*ClosedRange) SingletonClass() *Class

type ClosedRangeIterator

type ClosedRangeIterator struct {
	Range          *ClosedRange
	CurrentElement Value
}

func NewClosedRangeIterator

func NewClosedRangeIterator(r *ClosedRange) *ClosedRangeIterator

func NewClosedRangeIteratorWithCurrentElement

func NewClosedRangeIteratorWithCurrentElement(r *ClosedRange, currentElement Value) *ClosedRangeIterator

func (*ClosedRangeIterator) Class

func (*ClosedRangeIterator) Class() *Class

func (*ClosedRangeIterator) Copy

func (r *ClosedRangeIterator) Copy() Reference

func (*ClosedRangeIterator) DirectClass

func (*ClosedRangeIterator) DirectClass() *Class

func (*ClosedRangeIterator) Error

func (r *ClosedRangeIterator) Error() string

func (*ClosedRangeIterator) Inspect

func (r *ClosedRangeIterator) Inspect() string

func (*ClosedRangeIterator) InstanceVariables

func (*ClosedRangeIterator) InstanceVariables() SymbolMap

func (*ClosedRangeIterator) SingletonClass

func (*ClosedRangeIterator) SingletonClass() *Class

type ConstantContainer

type ConstantContainer struct {
	Name      string
	Constants SymbolMap
}

Struct for embedding, contains fields shared by Module, Mixin, Class, Struct

func (*ConstantContainer) AddConstant

func (m *ConstantContainer) AddConstant(name Symbol, val Value)

Set the constant with the specified name to the given value.

func (*ConstantContainer) AddConstantString

func (m *ConstantContainer) AddConstantString(name string, val Value)

Set the constant with the specified name to the given value.

func (*ConstantContainer) PrintableName

func (m *ConstantContainer) PrintableName() string

Return a human readable name.

type ConstructorFunc

type ConstructorFunc func(class *Class) Value

Function that creates a new instance.

type Duration

type Duration time.Duration

Represents the elapsed time between two Times as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years. Wraps Go's time.Duration.

func DurationSince

func DurationSince(t Time) Duration

func DurationUntil

func DurationUntil(t Time) Duration

func (Duration) Add

func (d Duration) Add(other Duration) Duration

func (Duration) Class

func (Duration) Class() *Class

func (Duration) Copy

func (d Duration) Copy() Reference

func (Duration) Days

func (d Duration) Days() Value

func (Duration) DirectClass

func (Duration) DirectClass() *Class

func (Duration) Divide

func (d Duration) Divide(other Value) (Duration, Value)

func (Duration) Error

func (d Duration) Error() string

func (Duration) Go

func (d Duration) Go() time.Duration

func (Duration) Hours

func (d Duration) Hours() Value

func (Duration) InDays

func (d Duration) InDays() Float

func (Duration) InHours

func (d Duration) InHours() Float

func (Duration) InMicroseconds

func (d Duration) InMicroseconds() Float

func (Duration) InMilliseconds

func (d Duration) InMilliseconds() Float

func (Duration) InMinutes

func (d Duration) InMinutes() Float

func (Duration) InNanoseconds

func (d Duration) InNanoseconds() Float

func (Duration) InSeconds

func (d Duration) InSeconds() Float

func (Duration) InWeeks

func (d Duration) InWeeks() Float

func (Duration) InYears

func (d Duration) InYears() Float

func (Duration) Inspect

func (d Duration) Inspect() string

func (Duration) InstanceVariables

func (Duration) InstanceVariables() SymbolMap

func (Duration) Microseconds

func (d Duration) Microseconds() Value

func (Duration) Milliseconds

func (d Duration) Milliseconds() Value

func (Duration) Minutes

func (d Duration) Minutes() Value

func (Duration) Multiply

func (d Duration) Multiply(other Value) (Duration, Value)

func (Duration) Nanoseconds

func (d Duration) Nanoseconds() Value

func (Duration) Seconds

func (d Duration) Seconds() Value

func (Duration) SingletonClass

func (Duration) SingletonClass() *Class

func (Duration) String

func (d Duration) String() string

func (Duration) Subtract

func (d Duration) Subtract(other Duration) Duration

func (Duration) ToString

func (d Duration) ToString() String

func (Duration) ToValue

func (d Duration) ToValue() Value

func (Duration) Weeks

func (d Duration) Weeks() Value

func (Duration) Years

func (d Duration) Years() Value

type EndlessClosedRange

type EndlessClosedRange struct {
	Start Value // start value
}

Represents an endless closed range eg. `5...`

func NewEndlessClosedRange

func NewEndlessClosedRange(start Value) *EndlessClosedRange

Create a new endless closed range class.

func (*EndlessClosedRange) Class

func (*EndlessClosedRange) Class() *Class

func (*EndlessClosedRange) Copy

func (r *EndlessClosedRange) Copy() Reference

func (*EndlessClosedRange) DirectClass

func (*EndlessClosedRange) DirectClass() *Class

func (*EndlessClosedRange) Error

func (r *EndlessClosedRange) Error() string

func (*EndlessClosedRange) Inspect

func (r *EndlessClosedRange) Inspect() string

func (*EndlessClosedRange) InstanceVariables

func (r *EndlessClosedRange) InstanceVariables() SymbolMap

func (*EndlessClosedRange) SingletonClass

func (*EndlessClosedRange) SingletonClass() *Class

type EndlessClosedRangeIterator

type EndlessClosedRangeIterator struct {
	Range          *EndlessClosedRange
	CurrentElement Value
}

func NewEndlessClosedRangeIterator

func NewEndlessClosedRangeIterator(r *EndlessClosedRange) *EndlessClosedRangeIterator

func NewEndlessClosedRangeIteratorWithCurrentElement

func NewEndlessClosedRangeIteratorWithCurrentElement(r *EndlessClosedRange, currentElement Value) *EndlessClosedRangeIterator

func (*EndlessClosedRangeIterator) Class

func (*EndlessClosedRangeIterator) Copy

func (*EndlessClosedRangeIterator) DirectClass

func (*EndlessClosedRangeIterator) DirectClass() *Class

func (*EndlessClosedRangeIterator) Error

func (*EndlessClosedRangeIterator) Inspect

func (r *EndlessClosedRangeIterator) Inspect() string

func (*EndlessClosedRangeIterator) InstanceVariables

func (*EndlessClosedRangeIterator) InstanceVariables() SymbolMap

func (*EndlessClosedRangeIterator) SingletonClass

func (*EndlessClosedRangeIterator) SingletonClass() *Class

type EndlessOpenRange

type EndlessOpenRange struct {
	Start Value // start value
}

Represents an endless open range eg. `5<..`

func NewEndlessOpenRange

func NewEndlessOpenRange(start Value) *EndlessOpenRange

Create a new endless open range class.

func (*EndlessOpenRange) Class

func (*EndlessOpenRange) Class() *Class

func (*EndlessOpenRange) Copy

func (r *EndlessOpenRange) Copy() Reference

func (*EndlessOpenRange) DirectClass

func (*EndlessOpenRange) DirectClass() *Class

func (*EndlessOpenRange) Error

func (r *EndlessOpenRange) Error() string

func (*EndlessOpenRange) Inspect

func (r *EndlessOpenRange) Inspect() string

func (*EndlessOpenRange) InstanceVariables

func (r *EndlessOpenRange) InstanceVariables() SymbolMap

func (*EndlessOpenRange) SingletonClass

func (*EndlessOpenRange) SingletonClass() *Class

type EndlessOpenRangeIterator

type EndlessOpenRangeIterator struct {
	Range          *EndlessOpenRange
	CurrentElement Value
}

func NewEndlessOpenRangeIterator

func NewEndlessOpenRangeIterator(r *EndlessOpenRange) *EndlessOpenRangeIterator

func NewEndlessOpenRangeIteratorWithCurrentElement

func NewEndlessOpenRangeIteratorWithCurrentElement(r *EndlessOpenRange, currentElement Value) *EndlessOpenRangeIterator

func (*EndlessOpenRangeIterator) Class

func (*EndlessOpenRangeIterator) Class() *Class

func (*EndlessOpenRangeIterator) Copy

func (*EndlessOpenRangeIterator) DirectClass

func (*EndlessOpenRangeIterator) DirectClass() *Class

func (*EndlessOpenRangeIterator) Error

func (r *EndlessOpenRangeIterator) Error() string

func (*EndlessOpenRangeIterator) Inspect

func (r *EndlessOpenRangeIterator) Inspect() string

func (*EndlessOpenRangeIterator) InstanceVariables

func (*EndlessOpenRangeIterator) InstanceVariables() SymbolMap

func (*EndlessOpenRangeIterator) SingletonClass

func (*EndlessOpenRangeIterator) SingletonClass() *Class

type FalseType

type FalseType struct{}

func (FalseType) Class

func (FalseType) Class() *Class

func (FalseType) DirectClass

func (FalseType) DirectClass() *Class

func (FalseType) Error

func (f FalseType) Error() string

func (FalseType) Hash

func (FalseType) Hash() UInt64

func (FalseType) Inspect

func (FalseType) Inspect() string

func (FalseType) InstanceVariables

func (FalseType) InstanceVariables() SymbolMap

func (FalseType) SingletonClass

func (FalseType) SingletonClass() *Class

func (FalseType) ToValue

func (FalseType) ToValue() Value

type Float

type Float float64

Elk's Float value

func FloatInf

func FloatInf() Float

Positive infinity

func FloatNaN

func FloatNaN() Float

Not a number

func FloatNegInf

func FloatNegInf() Float

Negative infinity

func (Float) Add

func (f Float) Add(other Value) (result, err Value)

Add another value and return an error if something went wrong.

func (Float) Class

func (Float) Class() *Class

func (Float) Cmp

func (x Float) Cmp(y Float) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

Panics if x or y are NaN.

func (Float) Compare

func (f Float) Compare(other Value) (result, err Value)

Returns 1 if i is greater than other Returns 0 if both are equal. Returns -1 if i is less than other. Returns nil if the comparison was impossible (NaN)

func (Float) Days

func (f Float) Days() Duration

func (Float) DirectClass

func (Float) DirectClass() *Class

func (Float) Divide

func (f Float) Divide(other Value) (result, err Value)

Divide by another value and return an error if something went wrong.

func (Float) Equal

func (f Float) Equal(other Value) Value

Check whether f is equal to other and return an error if something went wrong.

func (Float) Error

func (f Float) Error() string

func (Float) Exponentiate

func (f Float) Exponentiate(other Value) (result, err Value)

Exponentiate by another value and return an error if something went wrong.

func (Float) GreaterThan

func (f Float) GreaterThan(other Value) (result, err Value)

Check whether f is greater than other and return an error if something went wrong.

func (Float) GreaterThanEqual

func (f Float) GreaterThanEqual(other Value) (result, err Value)

Check whether f is greater than or equal to other and return an error if something went wrong.

func (Float) Hash

func (f Float) Hash() UInt64

func (Float) Hours

func (f Float) Hours() Duration

func (Float) Inspect

func (f Float) Inspect() string

func (Float) InstanceVariables

func (f Float) InstanceVariables() SymbolMap

func (Float) IsInf

func (f Float) IsInf(sign int) bool

IsInf reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity.

func (Float) IsInt

func (f Float) IsInt() bool

Check if the float is an integer.

func (Float) IsNaN

func (f Float) IsNaN() bool

IsNaN reports whether f is a “not-a-number” value.

func (Float) LaxEqual

func (f Float) LaxEqual(other Value) Value

Check whether f is equal to other

func (Float) LessThan

func (f Float) LessThan(other Value) (result, err Value)

Check whether f is less than other and return an error if something went wrong.

func (Float) LessThanEqual

func (f Float) LessThanEqual(other Value) (result, err Value)

Check whether f is less than or equal to other and return an error if something went wrong.

func (Float) Microseconds

func (f Float) Microseconds() Duration

func (Float) Milliseconds

func (f Float) Milliseconds() Duration

func (Float) Minutes

func (f Float) Minutes() Duration

func (Float) Mod

func (a Float) Mod(b Float) Float

func (Float) Modulo

func (f Float) Modulo(other Value) (result, err Value)

Perform modulo by another numeric value and return an error if something went wrong.

func (Float) Multiply

func (f Float) Multiply(other Value) (result, err Value)

Add another value and return an error if something went wrong.

func (Float) Nanoseconds

func (f Float) Nanoseconds() Duration

func (Float) Seconds

func (f Float) Seconds() Duration

func (Float) SingletonClass

func (Float) SingletonClass() *Class

func (Float) StrictEqual

func (f Float) StrictEqual(other Value) Value

Check whether f is strictly equal to other and return an error if something went wrong.

func (Float) Subtract

func (f Float) Subtract(other Value) (result, err Value)

Subtract another value and return an error if something went wrong.

func (Float) ToFloat32

func (f Float) ToFloat32() Float32

Convert to Elk Float32

func (Float) ToFloat64

func (f Float) ToFloat64() Float64

Convert to Elk Float64

func (Float) ToInt

func (f Float) ToInt() Value

Convert to Elk Int.

func (Float) ToInt16

func (f Float) ToInt16() Int16

Convert to Elk Int16

func (Float) ToInt32

func (f Float) ToInt32() Int32

Convert to Elk Int32

func (Float) ToInt64

func (f Float) ToInt64() Int64

Convert to Elk Int64

func (Float) ToInt8

func (f Float) ToInt8() Int8

Convert to Elk Int8

func (Float) ToString

func (f Float) ToString() String

func (Float) ToUInt16

func (f Float) ToUInt16() UInt16

Convert to Elk UInt16

func (Float) ToUInt32

func (f Float) ToUInt32() UInt32

Convert to Elk UInt32

func (Float) ToUInt64

func (f Float) ToUInt64() UInt64

Convert to Elk UInt64

func (Float) ToUInt8

func (f Float) ToUInt8() UInt8

Convert to Elk UInt8

func (Float) ToValue

func (f Float) ToValue() Value

func (Float) Weeks

func (f Float) Weeks() Duration

func (Float) Years

func (f Float) Years() Duration

type Float32

type Float32 float32

Elk's Float32 value

func Float32Inf

func Float32Inf() Float32

Positive infinity

func Float32NaN

func Float32NaN() Float32

Not a number

func Float32NegInf

func Float32NegInf() Float32

Negative infinity

func (Float32) Add

func (f Float32) Add(other Value) (Float32, Value)

func (Float32) Class

func (Float32) Class() *Class

func (Float32) Compare

func (f Float32) Compare(other Value) (Value, Value)

func (Float32) DirectClass

func (Float32) DirectClass() *Class

func (Float32) Divide

func (f Float32) Divide(other Value) (Float32, Value)

func (Float32) Equal

func (f Float32) Equal(other Value) Value

func (Float32) Error

func (f Float32) Error() string

func (Float32) Exponentiate

func (f Float32) Exponentiate(other Value) (Float32, Value)

Exponentiate by the right value.

func (Float32) GreaterThan

func (f Float32) GreaterThan(other Value) (Value, Value)

func (Float32) GreaterThanEqual

func (f Float32) GreaterThanEqual(other Value) (Value, Value)

func (Float32) Hash

func (f Float32) Hash() UInt64

func (Float32) Inspect

func (f Float32) Inspect() string

func (Float32) InstanceVariables

func (f Float32) InstanceVariables() SymbolMap

func (Float32) IsInf

func (f Float32) IsInf(sign int) bool

IsInf reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity.

func (Float32) IsNaN

func (f Float32) IsNaN() bool

IsNaN reports whether f is a “not-a-number” value.

func (Float32) LessThan

func (f Float32) LessThan(other Value) (Value, Value)

func (Float32) LessThanEqual

func (f Float32) LessThanEqual(other Value) (Value, Value)

func (Float32) Modulo

func (f Float32) Modulo(other Value) (Float32, Value)

func (Float32) Multiply

func (f Float32) Multiply(other Value) (Float32, Value)

func (Float32) SingletonClass

func (Float32) SingletonClass() *Class

func (Float32) StrictEqual

func (f Float32) StrictEqual(other Value) Value

func (Float32) Subtract

func (f Float32) Subtract(other Value) (Float32, Value)

func (Float32) ToString

func (f Float32) ToString() String

func (Float32) ToValue

func (f Float32) ToValue() Value

type Float64

type Float64 float64

Elk's Float64 value

func Float64Inf

func Float64Inf() Float64

Positive infinity

func Float64NaN

func Float64NaN() Float64

Not a number

func Float64NegInf

func Float64NegInf() Float64

Negative infinity

func (Float64) Add

func (f Float64) Add(other Value) (Float64, Value)

func (Float64) Class

func (Float64) Class() *Class

func (Float64) Compare

func (f Float64) Compare(other Value) (Value, Value)

func (Float64) Copy

func (f Float64) Copy() Reference

func (Float64) DirectClass

func (Float64) DirectClass() *Class

func (Float64) Divide

func (f Float64) Divide(other Value) (Float64, Value)

func (Float64) Equal

func (f Float64) Equal(other Value) Value

func (Float64) Error

func (f Float64) Error() string

func (Float64) Exponentiate

func (f Float64) Exponentiate(other Value) (Float64, Value)

Exponentiate by the right value.

func (Float64) GreaterThan

func (f Float64) GreaterThan(other Value) (Value, Value)

func (Float64) GreaterThanEqual

func (f Float64) GreaterThanEqual(other Value) (Value, Value)

func (Float64) Hash

func (f Float64) Hash() UInt64

func (Float64) Inspect

func (f Float64) Inspect() string

func (Float64) InstanceVariables

func (f Float64) InstanceVariables() SymbolMap

func (Float64) IsInf

func (f Float64) IsInf(sign int) bool

IsInf reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity.

func (Float64) IsNaN

func (f Float64) IsNaN() bool

IsNaN reports whether f is a “not-a-number” value.

func (Float64) LessThan

func (f Float64) LessThan(other Value) (Value, Value)

func (Float64) LessThanEqual

func (f Float64) LessThanEqual(other Value) (Value, Value)

func (Float64) Modulo

func (f Float64) Modulo(other Value) (Float64, Value)

func (Float64) Multiply

func (f Float64) Multiply(other Value) (Float64, Value)

func (Float64) SingletonClass

func (Float64) SingletonClass() *Class

func (Float64) StrictEqual

func (f Float64) StrictEqual(other Value) Value

func (Float64) Subtract

func (f Float64) Subtract(other Value) (Float64, Value)

func (Float64) ToString

func (f Float64) ToString() String

func (Float64) ToValue

func (f Float64) ToValue() Value

type Function

type Function interface {
	Reference
	// The number of parameters in total
	ParameterCount() int
	// The number of optional parameters with default values
	OptionalParameterCount() int
}

Elk function object

type GlobalObjectType

type GlobalObjectType struct{}

func (GlobalObjectType) Class

func (GlobalObjectType) Class() *Class

func (GlobalObjectType) Copy

func (g GlobalObjectType) Copy() Reference

func (GlobalObjectType) DirectClass

func (GlobalObjectType) DirectClass() *Class

func (GlobalObjectType) Error

func (g GlobalObjectType) Error() string

func (GlobalObjectType) Inspect

func (GlobalObjectType) Inspect() string

func (GlobalObjectType) InstanceVariables

func (GlobalObjectType) InstanceVariables() SymbolMap

func (GlobalObjectType) SingletonClass

func (GlobalObjectType) SingletonClass() *Class

type HashMap

type HashMap struct {
	Table         []Pair
	OccupiedSlots int
	Elements      int
}

func NewHashMap

func NewHashMap(capacity int) *HashMap

func (*HashMap) Capacity

func (h *HashMap) Capacity() int

func (*HashMap) Class

func (*HashMap) Class() *Class

func (*HashMap) Clone

func (h *HashMap) Clone() *HashMap

func (*HashMap) Copy

func (h *HashMap) Copy() Reference

func (*HashMap) DirectClass

func (*HashMap) DirectClass() *Class

func (*HashMap) Error

func (h *HashMap) Error() string

func (*HashMap) Inspect

func (h *HashMap) Inspect() string

func (*HashMap) InstanceVariables

func (*HashMap) InstanceVariables() SymbolMap

func (*HashMap) LeftCapacity

func (h *HashMap) LeftCapacity() int

func (*HashMap) Length

func (h *HashMap) Length() int

func (*HashMap) SingletonClass

func (*HashMap) SingletonClass() *Class

type HashMapIterator

type HashMapIterator struct {
	HashMap *HashMap
	Index   int
}

func NewHashMapIterator

func NewHashMapIterator(hmap *HashMap) *HashMapIterator

func NewHashMapIteratorWithIndex

func NewHashMapIteratorWithIndex(hmap *HashMap, index int) *HashMapIterator

func (*HashMapIterator) Class

func (*HashMapIterator) Class() *Class

func (*HashMapIterator) Copy

func (h *HashMapIterator) Copy() Reference

func (*HashMapIterator) DirectClass

func (*HashMapIterator) DirectClass() *Class

func (*HashMapIterator) Error

func (h *HashMapIterator) Error() string

func (*HashMapIterator) Inspect

func (h *HashMapIterator) Inspect() string

func (*HashMapIterator) InstanceVariables

func (*HashMapIterator) InstanceVariables() SymbolMap

func (*HashMapIterator) Next

func (h *HashMapIterator) Next() (Value, Value)

func (*HashMapIterator) SingletonClass

func (*HashMapIterator) SingletonClass() *Class

type HashRecord

type HashRecord HashMap

func NewHashRecord

func NewHashRecord(capacity int) *HashRecord

func (*HashRecord) Class

func (*HashRecord) Class() *Class

func (*HashRecord) Copy

func (h *HashRecord) Copy() Reference

func (*HashRecord) DirectClass

func (*HashRecord) DirectClass() *Class

func (*HashRecord) Error

func (h *HashRecord) Error() string

func (*HashRecord) Inspect

func (h *HashRecord) Inspect() string

func (*HashRecord) InstanceVariables

func (*HashRecord) InstanceVariables() SymbolMap

func (*HashRecord) Length

func (h *HashRecord) Length() int

func (*HashRecord) SingletonClass

func (*HashRecord) SingletonClass() *Class

type HashRecordIterator

type HashRecordIterator struct {
	HashRecord *HashRecord
	Index      int
}

func NewHashRecordIterator

func NewHashRecordIterator(hrec *HashRecord) *HashRecordIterator

func NewHashRecordIteratorWithIndex

func NewHashRecordIteratorWithIndex(hrec *HashRecord, index int) *HashRecordIterator

func (*HashRecordIterator) Class

func (*HashRecordIterator) Class() *Class

func (*HashRecordIterator) Copy

func (h *HashRecordIterator) Copy() Reference

func (*HashRecordIterator) DirectClass

func (*HashRecordIterator) DirectClass() *Class

func (*HashRecordIterator) Error

func (h *HashRecordIterator) Error() string

func (*HashRecordIterator) Inspect

func (h *HashRecordIterator) Inspect() string

func (*HashRecordIterator) InstanceVariables

func (*HashRecordIterator) InstanceVariables() SymbolMap

func (*HashRecordIterator) Next

func (h *HashRecordIterator) Next() (Value, Value)

func (*HashRecordIterator) SingletonClass

func (*HashRecordIterator) SingletonClass() *Class

type HashSet

type HashSet struct {
	Table         []Value
	OccupiedSlots int
	Elements      int
}

func NewHashSet

func NewHashSet(capacity int) *HashSet

func (*HashSet) Capacity

func (h *HashSet) Capacity() int

func (*HashSet) Class

func (*HashSet) Class() *Class

func (*HashSet) Copy

func (h *HashSet) Copy() Reference

func (*HashSet) DirectClass

func (*HashSet) DirectClass() *Class

func (*HashSet) Error

func (h *HashSet) Error() string

func (*HashSet) Inspect

func (h *HashSet) Inspect() string

func (*HashSet) InstanceVariables

func (*HashSet) InstanceVariables() SymbolMap

func (*HashSet) LeftCapacity

func (h *HashSet) LeftCapacity() int

func (*HashSet) Length

func (h *HashSet) Length() int

func (*HashSet) SingletonClass

func (*HashSet) SingletonClass() *Class

type HashSetIterator

type HashSetIterator struct {
	HashSet *HashSet
	Index   int
}

func NewHashSetIterator

func NewHashSetIterator(set *HashSet) *HashSetIterator

func NewHashSetIteratorWithIndex

func NewHashSetIteratorWithIndex(set *HashSet, index int) *HashSetIterator

func (*HashSetIterator) Class

func (*HashSetIterator) Class() *Class

func (*HashSetIterator) Copy

func (h *HashSetIterator) Copy() Reference

func (*HashSetIterator) DirectClass

func (*HashSetIterator) DirectClass() *Class

func (*HashSetIterator) Error

func (h *HashSetIterator) Error() string

func (*HashSetIterator) Inspect

func (h *HashSetIterator) Inspect() string

func (*HashSetIterator) InstanceVariables

func (*HashSetIterator) InstanceVariables() SymbolMap

func (*HashSetIterator) Next

func (h *HashSetIterator) Next() (Value, Value)

func (*HashSetIterator) SingletonClass

func (*HashSetIterator) SingletonClass() *Class

type Inspectable

type Inspectable interface {
	Inspect() string
}

type Int16

type Int16 int16

Elk's Int16 value

func (Int16) Add

func (i Int16) Add(other Value) (Int16, Value)

func (Int16) BitwiseAnd

func (i Int16) BitwiseAnd(other Value) (Int16, Value)

Perform a bitwise AND.

func (Int16) BitwiseAndNot

func (i Int16) BitwiseAndNot(other Value) (Int16, Value)

Perform a bitwise AND NOT.

func (Int16) BitwiseOr

func (i Int16) BitwiseOr(other Value) (Int16, Value)

Perform a bitwise OR.

func (Int16) BitwiseXor

func (i Int16) BitwiseXor(other Value) (Int16, Value)

Perform a bitwise XOR.

func (Int16) Class

func (i Int16) Class() *Class

func (Int16) Compare

func (i Int16) Compare(other Value) (Value, Value)

func (Int16) DirectClass

func (Int16) DirectClass() *Class

func (Int16) Divide

func (i Int16) Divide(other Value) (Int16, Value)

func (Int16) Equal

func (i Int16) Equal(other Value) Value

func (Int16) Error

func (i Int16) Error() string

func (Int16) Exponentiate

func (i Int16) Exponentiate(other Value) (Int16, Value)

func (Int16) GreaterThan

func (i Int16) GreaterThan(other Value) (Value, Value)

func (Int16) GreaterThanEqual

func (i Int16) GreaterThanEqual(other Value) (Value, Value)

func (Int16) Hash

func (i Int16) Hash() UInt64

func (Int16) Inspect

func (i Int16) Inspect() string

func (Int16) InstanceVariables

func (i Int16) InstanceVariables() SymbolMap

func (Int16) LessThan

func (i Int16) LessThan(other Value) (Value, Value)

func (Int16) LessThanEqual

func (i Int16) LessThanEqual(other Value) (Value, Value)

func (Int16) Modulo

func (i Int16) Modulo(other Value) (Int16, Value)

func (Int16) Multiply

func (i Int16) Multiply(other Value) (Int16, Value)

func (Int16) SingletonClass

func (Int16) SingletonClass() *Class

func (Int16) StrictEqual

func (i Int16) StrictEqual(other Value) Value

func (Int16) Subtract

func (i Int16) Subtract(other Value) (Int16, Value)

func (Int16) ToFloat

func (i Int16) ToFloat() Float

Convert to Elk Float.

func (Int16) ToFloat32

func (i Int16) ToFloat32() Float32

Convert to Elk Float32.

func (Int16) ToFloat64

func (i Int16) ToFloat64() Float64

Convert to Elk Float64.

func (Int16) ToInt32

func (i Int16) ToInt32() Int32

Convert to Elk Int32.

func (Int16) ToInt64

func (i Int16) ToInt64() Int64

Convert to Elk Int64.

func (Int16) ToSmallInt

func (i Int16) ToSmallInt() SmallInt

Convert to Elk SmallInt.

func (Int16) ToString

func (i Int16) ToString() String

Convert to Elk String.

func (Int16) ToUInt16

func (i Int16) ToUInt16() UInt16

Convert to Elk UInt16.

func (Int16) ToUInt32

func (i Int16) ToUInt32() UInt32

Convert to Elk UInt32.

func (Int16) ToUInt64

func (i Int16) ToUInt64() UInt64

Convert to Elk UInt64.

func (Int16) ToUInt8

func (i Int16) ToUInt8() UInt8

Convert to Elk UInt8.

func (Int16) ToValue

func (i Int16) ToValue() Value

type Int32

type Int32 int32

Elk's Int32 value

func (Int32) Add

func (i Int32) Add(other Value) (Int32, Value)

func (Int32) BitwiseAnd

func (i Int32) BitwiseAnd(other Value) (Int32, Value)

Perform a bitwise AND.

func (Int32) BitwiseAndNot

func (i Int32) BitwiseAndNot(other Value) (Int32, Value)

Perform a bitwise AND NOT.

func (Int32) BitwiseOr

func (i Int32) BitwiseOr(other Value) (Int32, Value)

Perform a bitwise OR.

func (Int32) BitwiseXor

func (i Int32) BitwiseXor(other Value) (Int32, Value)

Perform a bitwise XOR.

func (Int32) Class

func (i Int32) Class() *Class

func (Int32) Compare

func (i Int32) Compare(other Value) (Value, Value)

func (Int32) DirectClass

func (Int32) DirectClass() *Class

func (Int32) Divide

func (i Int32) Divide(other Value) (Int32, Value)

func (Int32) Equal

func (i Int32) Equal(other Value) Value

func (Int32) Error

func (i Int32) Error() string

func (Int32) Exponentiate

func (i Int32) Exponentiate(other Value) (Int32, Value)

func (Int32) GreaterThan

func (i Int32) GreaterThan(other Value) (Value, Value)

func (Int32) GreaterThanEqual

func (i Int32) GreaterThanEqual(other Value) (Value, Value)

func (Int32) Hash

func (i Int32) Hash() UInt64

func (Int32) Inspect

func (i Int32) Inspect() string

func (Int32) InstanceVariables

func (i Int32) InstanceVariables() SymbolMap

func (Int32) LessThan

func (i Int32) LessThan(other Value) (Value, Value)

func (Int32) LessThanEqual

func (i Int32) LessThanEqual(other Value) (Value, Value)

func (Int32) Modulo

func (i Int32) Modulo(other Value) (Int32, Value)

func (Int32) Multiply

func (i Int32) Multiply(other Value) (Int32, Value)

func (Int32) SingletonClass

func (Int32) SingletonClass() *Class

func (Int32) StrictEqual

func (i Int32) StrictEqual(other Value) Value

func (Int32) Subtract

func (i Int32) Subtract(other Value) (Int32, Value)

func (Int32) ToFloat

func (i Int32) ToFloat() Float

Convert to Elk Float.

func (Int32) ToFloat32

func (i Int32) ToFloat32() Float32

Convert to Elk Float32.

func (Int32) ToFloat64

func (i Int32) ToFloat64() Float64

Convert to Elk Float64.

func (Int32) ToInt16

func (i Int32) ToInt16() Int16

Convert to Elk Int16.

func (Int32) ToInt32

func (i Int32) ToInt32() Int32

Convert to Elk Int32.

func (Int32) ToInt8

func (i Int32) ToInt8() Int8

Convert to Elk Int8.

func (Int32) ToSmallInt

func (i Int32) ToSmallInt() SmallInt

Convert to Elk SmallInt.

func (Int32) ToString

func (i Int32) ToString() String

Convert to Elk String.

func (Int32) ToUInt16

func (i Int32) ToUInt16() UInt16

Convert to Elk UInt16.

func (Int32) ToUInt32

func (i Int32) ToUInt32() UInt32

Convert to Elk UInt32.

func (Int32) ToUInt64

func (i Int32) ToUInt64() UInt64

Convert to Elk UInt64.

func (Int32) ToUInt8

func (i Int32) ToUInt8() UInt8

Convert to Elk UInt8.

func (Int32) ToValue

func (i Int32) ToValue() Value

type Int64

type Int64 int64

Elk's Int64 value

func (Int64) Add

func (i Int64) Add(other Value) (Int64, Value)

func (Int64) BitwiseAnd

func (i Int64) BitwiseAnd(other Value) (Int64, Value)

Perform a bitwise AND.

func (Int64) BitwiseAndNot

func (i Int64) BitwiseAndNot(other Value) (Int64, Value)

Perform a bitwise AND NOT.

func (Int64) BitwiseOr

func (i Int64) BitwiseOr(other Value) (Int64, Value)

Perform a bitwise OR.

func (Int64) BitwiseXor

func (i Int64) BitwiseXor(other Value) (Int64, Value)

Perform a bitwise XOR.

func (Int64) Class

func (i Int64) Class() *Class

func (Int64) Compare

func (i Int64) Compare(other Value) (Value, Value)

func (Int64) Copy

func (i Int64) Copy() Reference

func (Int64) DirectClass

func (Int64) DirectClass() *Class

func (Int64) Divide

func (i Int64) Divide(other Value) (Int64, Value)

func (Int64) Equal

func (i Int64) Equal(other Value) Value

func (Int64) Error

func (i Int64) Error() string

func (Int64) Exponentiate

func (i Int64) Exponentiate(other Value) (Int64, Value)

func (Int64) GreaterThan

func (i Int64) GreaterThan(other Value) (Value, Value)

func (Int64) GreaterThanEqual

func (i Int64) GreaterThanEqual(other Value) (Value, Value)

func (Int64) Hash

func (i Int64) Hash() UInt64

func (Int64) Inspect

func (i Int64) Inspect() string

func (Int64) InstanceVariables

func (i Int64) InstanceVariables() SymbolMap

func (Int64) LessThan

func (i Int64) LessThan(other Value) (Value, Value)

func (Int64) LessThanEqual

func (i Int64) LessThanEqual(other Value) (Value, Value)

func (Int64) Modulo

func (i Int64) Modulo(other Value) (Int64, Value)

func (Int64) Multiply

func (i Int64) Multiply(other Value) (Int64, Value)

func (Int64) SingletonClass

func (Int64) SingletonClass() *Class

func (Int64) StrictEqual

func (i Int64) StrictEqual(other Value) Value

func (Int64) Subtract

func (i Int64) Subtract(other Value) (Int64, Value)

func (Int64) ToFloat

func (i Int64) ToFloat() Float

Convert to Elk Float.

func (Int64) ToFloat32

func (i Int64) ToFloat32() Float32

Convert to Elk Float32.

func (Int64) ToFloat64

func (i Int64) ToFloat64() Float64

Convert to Elk Float64.

func (Int64) ToInt16

func (i Int64) ToInt16() Int16

Convert to Elk Int16.

func (Int64) ToInt32

func (i Int64) ToInt32() Int32

Convert to Elk Int32.

func (Int64) ToInt8

func (i Int64) ToInt8() Int8

Convert to Elk Int8.

func (Int64) ToSmallInt

func (i Int64) ToSmallInt() SmallInt

Convert to Elk SmallInt.

func (Int64) ToString

func (i Int64) ToString() String

Convert to Elk String.

func (Int64) ToUInt16

func (i Int64) ToUInt16() UInt16

Convert to Elk UInt16.

func (Int64) ToUInt32

func (i Int64) ToUInt32() UInt32

Convert to Elk UInt32.

func (Int64) ToUInt64

func (i Int64) ToUInt64() UInt64

Convert to Elk UInt64.

func (Int64) ToUInt8

func (i Int64) ToUInt8() UInt8

Convert to Elk UInt8.

func (Int64) ToValue

func (i Int64) ToValue() Value

type Int8

type Int8 int8

Elk's Int8 value

func (Int8) Add

func (i Int8) Add(other Value) (Int8, Value)

func (Int8) BitwiseAnd

func (i Int8) BitwiseAnd(other Value) (Int8, Value)

Perform a bitwise AND.

func (Int8) BitwiseAndNot

func (i Int8) BitwiseAndNot(other Value) (Int8, Value)

Perform a bitwise AND NOT.

func (Int8) BitwiseOr

func (i Int8) BitwiseOr(other Value) (Int8, Value)

Perform a bitwise OR.

func (Int8) BitwiseXor

func (i Int8) BitwiseXor(other Value) (Int8, Value)

Perform a bitwise XOR.

func (Int8) Class

func (i Int8) Class() *Class

func (Int8) Compare

func (i Int8) Compare(other Value) (Value, Value)

func (Int8) DirectClass

func (Int8) DirectClass() *Class

func (Int8) Divide

func (i Int8) Divide(other Value) (Int8, Value)

func (Int8) Equal

func (i Int8) Equal(other Value) Value

func (Int8) Error

func (i Int8) Error() string

func (Int8) Exponentiate

func (i Int8) Exponentiate(other Value) (Int8, Value)

func (Int8) GreaterThan

func (i Int8) GreaterThan(other Value) (Value, Value)

func (Int8) GreaterThanEqual

func (i Int8) GreaterThanEqual(other Value) (Value, Value)

func (Int8) Hash

func (i Int8) Hash() UInt64

func (Int8) Inspect

func (i Int8) Inspect() string

func (Int8) InstanceVariables

func (i Int8) InstanceVariables() SymbolMap

func (Int8) LessThan

func (i Int8) LessThan(other Value) (Value, Value)

func (Int8) LessThanEqual

func (i Int8) LessThanEqual(other Value) (Value, Value)

func (Int8) Modulo

func (i Int8) Modulo(other Value) (Int8, Value)

func (Int8) Multiply

func (i Int8) Multiply(other Value) (Int8, Value)

func (Int8) SingletonClass

func (Int8) SingletonClass() *Class

func (Int8) StrictEqual

func (i Int8) StrictEqual(other Value) Value

func (Int8) Subtract

func (i Int8) Subtract(other Value) (Int8, Value)

func (Int8) ToFloat

func (i Int8) ToFloat() Float

Convert to Elk Float.

func (Int8) ToFloat32

func (i Int8) ToFloat32() Float32

Convert to Elk Float32.

func (Int8) ToFloat64

func (i Int8) ToFloat64() Float64

Convert to Elk Float64.

func (Int8) ToInt16

func (i Int8) ToInt16() Int16

Convert to Elk Int16.

func (Int8) ToInt32

func (i Int8) ToInt32() Int32

Convert to Elk Int32.

func (Int8) ToInt64

func (i Int8) ToInt64() Int64

Convert to Elk Int64.

func (Int8) ToInt8

func (i Int8) ToInt8() Int8

Convert to Elk Int8.

func (Int8) ToSmallInt

func (i Int8) ToSmallInt() SmallInt

Convert to Elk SmallInt.

func (Int8) ToString

func (i Int8) ToString() String

Convert to Elk String.

func (Int8) ToUInt16

func (i Int8) ToUInt16() UInt16

Convert to Elk UInt16.

func (Int8) ToUInt32

func (i Int8) ToUInt32() UInt32

Convert to Elk UInt32.

func (Int8) ToUInt64

func (i Int8) ToUInt64() UInt64

Convert to Elk UInt64.

func (Int8) ToUInt8

func (i Int8) ToUInt8() UInt8

Convert to Elk UInt8.

func (Int8) ToValue

func (i Int8) ToValue() Value

type Interface

type Interface struct {
	ConstantContainer
	// contains filtered or unexported fields
}

Represents an Elk interface.

func NewInterface

func NewInterface() *Interface

Create a new module.

func NewInterfaceWithOptions

func NewInterfaceWithOptions(opts ...InterfaceOption) *Interface

Create a new class.

func (*Interface) Class

func (i *Interface) Class() *Class

func (*Interface) Copy

func (i *Interface) Copy() Reference

func (*Interface) DirectClass

func (i *Interface) DirectClass() *Class

func (*Interface) Error

func (i *Interface) Error() string

func (*Interface) Inspect

func (i *Interface) Inspect() string

func (*Interface) InstanceVariables

func (i *Interface) InstanceVariables() SymbolMap

func (*Interface) SingletonClass

func (i *Interface) SingletonClass() *Class

type InterfaceOption

type InterfaceOption = func(*Interface)

Interface constructor option function

func InterfaceWithName

func InterfaceWithName(name string) InterfaceOption

type LeftOpenRange

type LeftOpenRange struct {
	Start Value // start value
	End   Value // end value
}

Represents a left open range eg. `5<..2`

func NewLeftOpenRange

func NewLeftOpenRange(start, end Value) *LeftOpenRange

Create a new left open range class.

func (*LeftOpenRange) Class

func (*LeftOpenRange) Class() *Class

func (*LeftOpenRange) Copy

func (r *LeftOpenRange) Copy() Reference

func (*LeftOpenRange) DirectClass

func (*LeftOpenRange) DirectClass() *Class

func (*LeftOpenRange) Error

func (r *LeftOpenRange) Error() string

func (*LeftOpenRange) Inspect

func (r *LeftOpenRange) Inspect() string

func (*LeftOpenRange) InstanceVariables

func (r *LeftOpenRange) InstanceVariables() SymbolMap

func (*LeftOpenRange) SingletonClass

func (*LeftOpenRange) SingletonClass() *Class

type LeftOpenRangeIterator

type LeftOpenRangeIterator struct {
	Range          *LeftOpenRange
	CurrentElement Value
}

func NewLeftOpenRangeIterator

func NewLeftOpenRangeIterator(r *LeftOpenRange) *LeftOpenRangeIterator

func NewLeftOpenRangeIteratorWithCurrentElement

func NewLeftOpenRangeIteratorWithCurrentElement(r *LeftOpenRange, currentElement Value) *LeftOpenRangeIterator

func (*LeftOpenRangeIterator) Class

func (*LeftOpenRangeIterator) Class() *Class

func (*LeftOpenRangeIterator) Copy

func (r *LeftOpenRangeIterator) Copy() Reference

func (*LeftOpenRangeIterator) DirectClass

func (*LeftOpenRangeIterator) DirectClass() *Class

func (*LeftOpenRangeIterator) Error

func (r *LeftOpenRangeIterator) Error() string

func (*LeftOpenRangeIterator) Inspect

func (r *LeftOpenRangeIterator) Inspect() string

func (*LeftOpenRangeIterator) InstanceVariables

func (*LeftOpenRangeIterator) InstanceVariables() SymbolMap

func (*LeftOpenRangeIterator) SingletonClass

func (*LeftOpenRangeIterator) SingletonClass() *Class

type Method

type Method interface {
	Reference
	Function
	// Name of the method
	Name() Symbol
}

Elk Method object

type MethodContainer

type MethodContainer struct {
	Methods MethodMap
	Parent  *Class
}

func (*MethodContainer) AttachMethod

func (m *MethodContainer) AttachMethod(name Symbol, method Method)

Attaches the given method under the given name.

func (*MethodContainer) DefineAlias

func (m *MethodContainer) DefineAlias(newMethodName, oldMethodName Symbol)

Define an alternative name for an existing method.

func (*MethodContainer) DefineAliasString

func (m *MethodContainer) DefineAliasString(newMethodName, oldMethodName string)

Define an alternative name for an existing method.

func (*MethodContainer) LookupMethod

func (m *MethodContainer) LookupMethod(name Symbol) Method

Search for a method with the given name in this container and its ancestors.

func (*MethodContainer) Superclass

func (m *MethodContainer) Superclass() *Class

Get the superclass (skipping any mixin proxies)

type MethodMap

type MethodMap map[Symbol]Method

Map that associates methods with their names.

type Mixin

type Mixin = Class

Represents an Elk Mixin.

var ComparableMixin *Mixin // ::Std::Comparable
var ListMixin *Mixin // ::Std::List
var MapMixin *Mixin // ::Std::Map
var RangeMixin *Mixin // ::Std::Range
var RecordMixin *Mixin // ::Std::Record
var SetMixin *Mixin // ::Std::Set
var TupleMixin *Mixin // ::Std::Tuple

func NewMixin

func NewMixin() *Mixin

Create a new mixin.

func (*Mixin) CreateProxyClass

func (m *Mixin) CreateProxyClass() *Class

Create a proxy class that has a pointer to the method map of this mixin.

Returns two values, the head and tail proxy classes. This is because of the fact that it's possible to include one mixin in another, so there is an entire inheritance chain.

type MixinOption

type MixinOption = func(*Class)

Mixin constructor option function

func MixinWithClass

func MixinWithClass(class *Class) MixinOption

func MixinWithConstants

func MixinWithConstants(constants SymbolMap) MixinOption

func MixinWithMethods

func MixinWithMethods(methods MethodMap) MixinOption

func MixinWithName

func MixinWithName(name string) MixinOption

func MixinWithParent

func MixinWithParent(parent *Class) MixinOption

type Module

type Module struct {
	ConstantContainer
	// contains filtered or unexported fields
}

Represents an Elk Module.

var DebugModule *Module // ::Std::Debug
var KernelModule *Module // ::Std::Kernel
var RootModule *Module // ::Root
var StdModule *Module // ::Std

func NewModule

func NewModule() *Module

Create a new module.

func NewModuleWithOptions

func NewModuleWithOptions(opts ...ModuleOption) *Module

Create a new module.

func (*Module) Class

func (m *Module) Class() *Class

func (*Module) Copy

func (m *Module) Copy() Reference

func (*Module) DirectClass

func (m *Module) DirectClass() *Class

func (*Module) Error

func (m *Module) Error() string

func (*Module) Inspect

func (m *Module) Inspect() string

func (*Module) InstanceVariables

func (m *Module) InstanceVariables() SymbolMap

func (*Module) SetDirectClass

func (m *Module) SetDirectClass(class *Class)

func (*Module) SingletonClass

func (m *Module) SingletonClass() *Class

type ModuleOption

type ModuleOption func(*Module)

Module constructor option function.

func ModuleWithClass

func ModuleWithClass(class *Class) ModuleOption

func ModuleWithConstants

func ModuleWithConstants(constants SymbolMap) ModuleOption

func ModuleWithName

func ModuleWithName(name string) ModuleOption

func ModuleWithSingletonClass

func ModuleWithSingletonClass() ModuleOption

type NilType

type NilType struct{}

func (NilType) Class

func (NilType) Class() *Class

func (NilType) DirectClass

func (NilType) DirectClass() *Class

func (NilType) Error

func (n NilType) Error() string

func (NilType) Hash

func (NilType) Hash() UInt64

func (NilType) Inspect

func (NilType) Inspect() string

func (NilType) InstanceVariables

func (NilType) InstanceVariables() SymbolMap

func (NilType) SingletonClass

func (NilType) SingletonClass() *Class

func (NilType) ToString

func (NilType) ToString() String

func (NilType) ToValue

func (n NilType) ToValue() Value

type Object

type Object struct {
	// contains filtered or unexported fields
}
var NotBuiltinError *Object

func Errorf

func Errorf(class *Class, format string, a ...any) *Object

Mimics fmt.Errorf but creates an Elk error value.

func NewArgumentTypeError

func NewArgumentTypeError(argName, given, expected string) *Object

Create a new error that signals that the type of the given argument is wrong.

func NewBigFloatPrecisionError

func NewBigFloatPrecisionError(precision string) *Object

Create a new error that signals that the big float precision is out of range (negative or too large).

func NewBitshiftOperandError

func NewBitshiftOperandError(other Value) *Object

Create a new error which signals that the given operand is not suitable for bit shifting

func NewCantAccessInstanceVariablesOnPrimitiveError

func NewCantAccessInstanceVariablesOnPrimitiveError(value string) *Object

Create a new error that signals that accessing instance variables of primitive values is impossible.

func NewCantSetInstanceVariablesOnPrimitiveError

func NewCantSetInstanceVariablesOnPrimitiveError(value string) *Object

Create a new error that signals that setting instance variables of primitive values is impossible.

func NewCapacityTypeError

func NewCapacityTypeError(val string) *Object

Create a new error which signals that the value can't be used as capacity.

func NewCoerceError

func NewCoerceError(target, other *Class) *Object

Create a new error which signals that a value of one type cannot be coerced into the other type.

func NewDuplicatedArgumentError

func NewDuplicatedArgumentError(methodName, paramName string) *Object

Create a new error that signals that an argument is duplicated

func NewError

func NewError(class *Class, message string) *Object

Create a new Elk error.

func NewIndexOutOfRangeError

func NewIndexOutOfRangeError(index string, length int) *Object

Create a new error that signals that the given index is out of range.

func NewInvalidSuperclassError

func NewInvalidSuperclassError(superclass string) *Object

Create a new error that signals that the given superclass is not a valid class object.

func NewIsNotClassError

func NewIsNotClassError(value string) *Object

Create a new error that signals that the given value is not a class, even though it should be.

func NewIsNotClassOrMixinError

func NewIsNotClassOrMixinError(value string) *Object

Create a new error that signals that the given value is not a class or mixin, even though it should be.

func NewIsNotMixinError

func NewIsNotMixinError(value string) *Object

Create a new error that signals that the given value is not a mixin, even though it should be.

func NewModifierMismatchError

func NewModifierMismatchError(object, modifier string, with bool) *Object

Create a new error that signals that the given class should have different modifiers.

func NewNegativeCapacityError

func NewNegativeCapacityError(capacity string) *Object

Create a new error that signals that the given capacity should not be negative.

func NewNegativeIndicesInCollectionLiteralsError

func NewNegativeIndicesInCollectionLiteralsError(index string) *Object

Create a new error that signals that negative indices cannot be used in collection literals.

func NewNoMethodError

func NewNoMethodError(methodName string, receiver Value) *Object

Create a new Std::NoMethodError.

func NewObject

func NewObject(opts ...ObjectOption) *Object

Create a new value.

func NewRedefinedConstantError

func NewRedefinedConstantError(module, symbol string) *Object

Create a new Std::RedefinedConstantError

func NewRequiredArgumentMissingError

func NewRequiredArgumentMissingError(methodName, paramName string) *Object

Create a new error that signals that a required argument was not given.

func NewSingletonError

func NewSingletonError(given string) *Object

Create a new error that signals that the given object cannot have a singleton class.

func NewSuperclassMismatchError

func NewSuperclassMismatchError(class, wantSuperclass, gotSuperclass string) *Object

Create a new error that signals that the given superclass doesn't match the original one.

func NewTooLargeCapacityError

func NewTooLargeCapacityError(capacity string) *Object

Create a new error that signals that the given capacity is too large.

func NewUnexpectedNilError

func NewUnexpectedNilError() *Object

Create a new error which signals that a `nil` value has been encountered in a `must` expression

func NewUnknownArgumentsError

func NewUnknownArgumentsError(method string, names []Symbol) *Object

Create a new error that signals that some given arguments are not defined in the method.

func NewWrongArgumentCountError

func NewWrongArgumentCountError(method string, given, expected int) *Object

Create a new error that signals that the number of given arguments is wrong.

func NewWrongArgumentCountRangeError

func NewWrongArgumentCountRangeError(method string, given, expectedFrom, expectedTo int) *Object

Create a new error that signals that the number of given arguments is not within the accepted range.

func NewWrongArgumentCountRestError

func NewWrongArgumentCountRestError(method string, given, expectedFrom int) *Object

Create a new error that signals that the number of given arguments is not within the accepted range. For methods with rest parameters.

func NewWrongPositionalArgumentCountError

func NewWrongPositionalArgumentCountError(method string, given, expectedFrom int) *Object

Create a new error that signals that the number of given arguments is not within the accepted range. For methods with rest parameters.

func NewZeroDivisionError

func NewZeroDivisionError() *Object

Create a new error which signals that a the program tried to divide by zero.

func (*Object) Class

func (o *Object) Class() *Class

func (*Object) Copy

func (o *Object) Copy() Reference

func (*Object) DirectClass

func (o *Object) DirectClass() *Class

func (*Object) Error

func (e *Object) Error() string

Implement the error interface.

func (*Object) Inspect

func (o *Object) Inspect() string

func (*Object) InstanceVariables

func (o *Object) InstanceVariables() SymbolMap

func (*Object) Message

func (e *Object) Message() Value

Get the error message.

func (*Object) SetMessage

func (e *Object) SetMessage(message string)

Set the error message.

func (*Object) SingletonClass

func (o *Object) SingletonClass() *Class

type ObjectOption

type ObjectOption = func(*Object)

Class constructor option function

func ObjectWithClass

func ObjectWithClass(class *Class) ObjectOption

func ObjectWithInstanceVariables

func ObjectWithInstanceVariables(ivars SymbolMap) ObjectOption

type OpenRange

type OpenRange struct {
	Start Value // start value
	End   Value // end value
}

Represents an open range eg. `5<.<2`

func NewOpenRange

func NewOpenRange(start, end Value) *OpenRange

Create a new open range class.

func (*OpenRange) Class

func (*OpenRange) Class() *Class

func (*OpenRange) Copy

func (r *OpenRange) Copy() Reference

func (*OpenRange) DirectClass

func (*OpenRange) DirectClass() *Class

func (*OpenRange) Error

func (r *OpenRange) Error() string

func (*OpenRange) Inspect

func (r *OpenRange) Inspect() string

func (*OpenRange) InstanceVariables

func (r *OpenRange) InstanceVariables() SymbolMap

func (*OpenRange) SingletonClass

func (*OpenRange) SingletonClass() *Class

type OpenRangeIterator

type OpenRangeIterator struct {
	Range          *OpenRange
	CurrentElement Value
}

func NewOpenRangeIterator

func NewOpenRangeIterator(r *OpenRange) *OpenRangeIterator

func NewOpenRangeIteratorWithCurrentElement

func NewOpenRangeIteratorWithCurrentElement(r *OpenRange, currentElement Value) *OpenRangeIterator

func (*OpenRangeIterator) Class

func (*OpenRangeIterator) Class() *Class

func (*OpenRangeIterator) Copy

func (r *OpenRangeIterator) Copy() Reference

func (*OpenRangeIterator) DirectClass

func (*OpenRangeIterator) DirectClass() *Class

func (*OpenRangeIterator) Error

func (r *OpenRangeIterator) Error() string

func (*OpenRangeIterator) Inspect

func (r *OpenRangeIterator) Inspect() string

func (*OpenRangeIterator) InstanceVariables

func (*OpenRangeIterator) InstanceVariables() SymbolMap

func (*OpenRangeIterator) SingletonClass

func (*OpenRangeIterator) SingletonClass() *Class

type Pair

type Pair struct {
	Key   Value
	Value Value
}

func NewPair

func NewPair(key, val Value) *Pair

func (*Pair) Class

func (*Pair) Class() *Class

func (*Pair) Copy

func (p *Pair) Copy() Reference

func (*Pair) DirectClass

func (*Pair) DirectClass() *Class

func (*Pair) Error

func (p *Pair) Error() string

func (*Pair) Get

func (p *Pair) Get(index int) (Value, Value)

Get an element under the given index.

func (*Pair) Inspect

func (p *Pair) Inspect() string

func (*Pair) InstanceVariables

func (*Pair) InstanceVariables() SymbolMap

func (*Pair) Length

func (*Pair) Length() int

func (*Pair) Set

func (p *Pair) Set(index int, val Value) Value

Set an element under the given index.

func (*Pair) SingletonClass

func (*Pair) SingletonClass() *Class

func (*Pair) Subscript

func (p *Pair) Subscript(key Value) (Value, Value)

Get an element under the given index.

func (*Pair) SubscriptSet

func (p *Pair) SubscriptSet(key, val Value) Value

Set an element under the given index.

type PairIterator

type PairIterator struct {
	Pair  *Pair
	Index int
}

func NewPairIterator

func NewPairIterator(pair *Pair) *PairIterator

func NewPairIteratorWithIndex

func NewPairIteratorWithIndex(pair *Pair, index int) *PairIterator

func (*PairIterator) Class

func (*PairIterator) Class() *Class

func (*PairIterator) Copy

func (l *PairIterator) Copy() Reference

func (*PairIterator) DirectClass

func (*PairIterator) DirectClass() *Class

func (*PairIterator) Error

func (l *PairIterator) Error() string

func (*PairIterator) Inspect

func (l *PairIterator) Inspect() string

func (*PairIterator) InstanceVariables

func (*PairIterator) InstanceVariables() SymbolMap

func (*PairIterator) Next

func (l *PairIterator) Next() (Value, Value)

func (*PairIterator) SingletonClass

func (*PairIterator) SingletonClass() *Class

type Reference

type Reference interface {
	Class() *Class                // Return the class of the value
	DirectClass() *Class          // Return the direct class of this value that will be searched for methods first
	SingletonClass() *Class       // Return the singleton class of this value that holds methods unique to this object
	Inspect() string              // Returns the string representation of the value
	InstanceVariables() SymbolMap // Returns the map of instance vars of this value, nil if value doesn't support instance vars
	Copy() Reference              // Creates a shallow copy of the reference. If the value is immutable, no copying should be done, the same value should be returned.
	Error() string                // Implements the error interface
}

Elk Reference Value

type Regex

type Regex struct {
	Re     regexp.Regexp
	Source string
	Flags  bitfield.BitField8
}

Elk's compiled regex

func CompileRegex

func CompileRegex(src string, flags bitfield.BitField8) (*Regex, error)

func MustCompileRegex

func MustCompileRegex(src string, flags bitfield.BitField8) *Regex

func NewRegex

func NewRegex(re regexp.Regexp, src string, flags bitfield.BitField8) *Regex

func (*Regex) Class

func (*Regex) Class() *Class

func (*Regex) Concat

func (r *Regex) Concat(other Value) (Value, Value)

Create a new regex concatenating r with other

func (*Regex) Copy

func (r *Regex) Copy() Reference

func (*Regex) DirectClass

func (*Regex) DirectClass() *Class

func (*Regex) Equal

func (r *Regex) Equal(other Value) Value

Check whether r is equal to other

func (*Regex) Error

func (r *Regex) Error() string

func (*Regex) Hash

func (r *Regex) Hash() UInt64

func (*Regex) Inspect

func (r *Regex) Inspect() string

func (*Regex) InstanceVariables

func (r *Regex) InstanceVariables() SymbolMap

func (*Regex) LaxEqual

func (r *Regex) LaxEqual(other Value) Value

Check whether r is equal to other

func (*Regex) Matches

func (r *Regex) Matches(other Value) (Value, Value)

Check whether the regex matches the given string

func (*Regex) Repeat

func (r *Regex) Repeat(other Value) (Value, Value)

Repeat the content of this Regex n times and return a new Regex.

func (*Regex) SingletonClass

func (*Regex) SingletonClass() *Class

func (*Regex) String

func (r *Regex) String() string

func (*Regex) ToString

func (r *Regex) ToString() String

func (*Regex) ToStringWithFlags

func (r *Regex) ToStringWithFlags() String

func (*Regex) WriteSourceTo

func (r *Regex) WriteSourceTo(w io.StringWriter)

type RightOpenRange

type RightOpenRange struct {
	Start Value // start value
	End   Value // end value
}

Represents a right open range eg. `5..<2`

func NewRightOpenRange

func NewRightOpenRange(start, end Value) *RightOpenRange

Create a new right open range class.

func (*RightOpenRange) Class

func (*RightOpenRange) Class() *Class

func (*RightOpenRange) Copy

func (r *RightOpenRange) Copy() Reference

func (*RightOpenRange) DirectClass

func (*RightOpenRange) DirectClass() *Class

func (*RightOpenRange) Error

func (r *RightOpenRange) Error() string

func (*RightOpenRange) Inspect

func (r *RightOpenRange) Inspect() string

func (*RightOpenRange) InstanceVariables

func (r *RightOpenRange) InstanceVariables() SymbolMap

func (*RightOpenRange) SingletonClass

func (*RightOpenRange) SingletonClass() *Class

type RightOpenRangeIterator

type RightOpenRangeIterator struct {
	Range          *RightOpenRange
	CurrentElement Value
}

func NewRightOpenRangeIterator

func NewRightOpenRangeIterator(r *RightOpenRange) *RightOpenRangeIterator

func NewRightOpenRangeIteratorWithCurrentElement

func NewRightOpenRangeIteratorWithCurrentElement(r *RightOpenRange, currentElement Value) *RightOpenRangeIterator

func (*RightOpenRangeIterator) Class

func (*RightOpenRangeIterator) Class() *Class

func (*RightOpenRangeIterator) Copy

func (*RightOpenRangeIterator) DirectClass

func (*RightOpenRangeIterator) DirectClass() *Class

func (*RightOpenRangeIterator) Error

func (r *RightOpenRangeIterator) Error() string

func (*RightOpenRangeIterator) Inspect

func (r *RightOpenRangeIterator) Inspect() string

func (*RightOpenRangeIterator) InstanceVariables

func (*RightOpenRangeIterator) InstanceVariables() SymbolMap

func (*RightOpenRangeIterator) SingletonClass

func (*RightOpenRangeIterator) SingletonClass() *Class

type SimpleInt

type SimpleInt interface {
	SmallInt | Int64 | Int32 | Int16 | Int8 | UInt64 | UInt32 | UInt16 | UInt8
}

All simple Elk integer types (without BigInt)

type SingedInt

type SingedInt interface {
	SmallInt | Int64 | Int32 | Int16 | Int8
}

type SmallInt

type SmallInt int

Elk's SmallInt value

func (SmallInt) Add

func (i SmallInt) Add(other Value) (Value, Value)

Add another value and return an error if something went wrong.

func (SmallInt) AddOverflow

func (a SmallInt) AddOverflow(b SmallInt) (result SmallInt, ok bool)

Add two small ints and check for overflow/underflow.

func (SmallInt) BitwiseAnd

func (i SmallInt) BitwiseAnd(other Value) (Value, Value)

Perform a bitwise AND with another integer value and return an error if something went wrong.

func (SmallInt) BitwiseAndNot

func (i SmallInt) BitwiseAndNot(other Value) (Value, Value)

Perform a bitwise AND NOT with another integer value and return an error if something went wrong.

func (SmallInt) BitwiseNot

func (i SmallInt) BitwiseNot() SmallInt

Perform bitwise NOT.

func (SmallInt) BitwiseOr

func (i SmallInt) BitwiseOr(other Value) (Value, Value)

Perform a bitwise OR with another integer value and return an error if something went wrong.

func (SmallInt) BitwiseXor

func (i SmallInt) BitwiseXor(other Value) (Value, Value)

Perform a bitwise XOR with another integer value and return an error if something went wrong.

func (SmallInt) Class

func (SmallInt) Class() *Class

func (SmallInt) Cmp

func (x SmallInt) Cmp(y SmallInt) int

Cmp compares x and y and returns:

  -1 if x <  y
	 0 if x == y
  +1 if x >  y

func (SmallInt) Compare

func (i SmallInt) Compare(other Value) (Value, Value)

Returns 1 if i is greater than other Returns 0 if both are equal. Returns -1 if i is less than other. Returns nil if the comparison was impossible (NaN)

func (SmallInt) Days

func (i SmallInt) Days() Duration

func (SmallInt) Decrement

func (i SmallInt) Decrement() Value

Decrement the number and return the result.

func (SmallInt) DirectClass

func (SmallInt) DirectClass() *Class

func (SmallInt) Divide

func (i SmallInt) Divide(other Value) (Value, Value)

Divide another value and return an error if something went wrong.

func (SmallInt) DivideOverflow

func (a SmallInt) DivideOverflow(b SmallInt) (result SmallInt, ok bool)

Divide two small ints and check for overflow/underflow.

func (SmallInt) Equal

func (i SmallInt) Equal(other Value) Value

Check whether i is equal to other

func (SmallInt) Error

func (i SmallInt) Error() string

func (SmallInt) Exponentiate

func (i SmallInt) Exponentiate(other Value) (Value, Value)

Exponentiate by another value and return an error if something went wrong.

func (SmallInt) GreaterThan

func (i SmallInt) GreaterThan(other Value) (Value, Value)

Check whether i is greater than other and return an error if something went wrong.

func (SmallInt) GreaterThanBool

func (i SmallInt) GreaterThanBool(other Value) (bool, Value)

Check whether i is greater than other and return an error if something went wrong.

func (SmallInt) GreaterThanEqual

func (i SmallInt) GreaterThanEqual(other Value) (Value, Value)

Check whether i is greater than or equal to other and return an error if something went wrong.

func (SmallInt) GreaterThanEqualBool

func (i SmallInt) GreaterThanEqualBool(other Value) (bool, Value)

Check whether i is greater than or equal to other and return an error if something went wrong.

func (SmallInt) Hash

func (i SmallInt) Hash() UInt64

func (SmallInt) Hours

func (i SmallInt) Hours() Duration

func (SmallInt) Increment

func (i SmallInt) Increment() Value

Increment the number and return the result.

func (SmallInt) Inspect

func (i SmallInt) Inspect() string

func (SmallInt) InstanceVariables

func (i SmallInt) InstanceVariables() SymbolMap

func (SmallInt) LaxEqual

func (i SmallInt) LaxEqual(other Value) Value

Check whether i is equal to other (with coercion)

func (SmallInt) LeftBitshift

func (i SmallInt) LeftBitshift(other Value) (Value, Value)

Bitshift to the left by another integer value and return an error if something went wrong.

func (SmallInt) LessThan

func (i SmallInt) LessThan(other Value) (Value, Value)

Check whether i is less than other and return an error if something went wrong.

func (SmallInt) LessThanBool

func (i SmallInt) LessThanBool(other Value) (bool, Value)

Check whether i is less than other and return an error if something went wrong.

func (SmallInt) LessThanEqual

func (i SmallInt) LessThanEqual(other Value) (Value, Value)

Check whether i is less than or equal to other and return an error if something went wrong.

func (SmallInt) LessThanEqualBool

func (i SmallInt) LessThanEqualBool(other Value) (bool, Value)

Check whether i is less than or equal to other and return an error if something went wrong.

func (SmallInt) Microseconds

func (i SmallInt) Microseconds() Duration

func (SmallInt) Milliseconds

func (i SmallInt) Milliseconds() Duration

func (SmallInt) Minutes

func (i SmallInt) Minutes() Duration

func (SmallInt) Modulo

func (i SmallInt) Modulo(other Value) (Value, Value)

Perform modulo by another numeric value and return an error if something went wrong.

func (SmallInt) Multiply

func (i SmallInt) Multiply(other Value) (Value, Value)

Multiply another value and return an error if something went wrong.

func (SmallInt) MultiplyOverflow

func (a SmallInt) MultiplyOverflow(b SmallInt) (result SmallInt, ok bool)

Multiply two small ints and check for overflow/underflow.

func (SmallInt) Nanoseconds

func (i SmallInt) Nanoseconds() Duration

func (SmallInt) Negate

func (i SmallInt) Negate() Value

Negate the number and return the result.

func (SmallInt) RightBitshift

func (i SmallInt) RightBitshift(other Value) (Value, Value)

Bitshift to the right by another integer value and return an error if something went wrong.

func (SmallInt) Seconds

func (i SmallInt) Seconds() Duration

func (SmallInt) SingletonClass

func (SmallInt) SingletonClass() *Class

func (SmallInt) StrictEqual

func (i SmallInt) StrictEqual(other Value) Value

Check whether i is strictly equal to other

func (SmallInt) StrictEqualBool

func (i SmallInt) StrictEqualBool(other Value) bool

Check whether i is strictly equal to other

func (SmallInt) Subtract

func (i SmallInt) Subtract(other Value) (Value, Value)

Add another value and return an error if something went wrong.

func (SmallInt) SubtractOverflow

func (a SmallInt) SubtractOverflow(b SmallInt) (result SmallInt, ok bool)

Subtract two small ints and check for overflow/underflow.

func (SmallInt) ToFloat

func (i SmallInt) ToFloat() Float

Convert to Elk Float.

func (SmallInt) ToFloat32

func (i SmallInt) ToFloat32() Float32

Convert to Elk Float32.

func (SmallInt) ToFloat64

func (i SmallInt) ToFloat64() Float64

Convert to Elk Float64.

func (SmallInt) ToInt16

func (i SmallInt) ToInt16() Int16

Convert to Elk Int16.

func (SmallInt) ToInt32

func (i SmallInt) ToInt32() Int32

Convert to Elk Int32.

func (SmallInt) ToInt64

func (i SmallInt) ToInt64() Int64

Convert to Elk Int64.

func (SmallInt) ToInt8

func (i SmallInt) ToInt8() Int8

Convert to Elk Int8.

func (SmallInt) ToString

func (i SmallInt) ToString() String

Convert to Elk String.

func (SmallInt) ToUInt16

func (i SmallInt) ToUInt16() UInt16

Convert to Elk UInt16.

func (SmallInt) ToUInt32

func (i SmallInt) ToUInt32() UInt32

Convert to Elk UInt32.

func (SmallInt) ToUInt64

func (i SmallInt) ToUInt64() UInt64

Convert to Elk UInt64.

func (SmallInt) ToUInt8

func (i SmallInt) ToUInt8() UInt8

Convert to Elk UInt8.

func (SmallInt) ToValue

func (i SmallInt) ToValue() Value

func (SmallInt) Weeks

func (i SmallInt) Weeks() Duration

func (SmallInt) Years

func (i SmallInt) Years() Duration

type StrictFloat

type StrictFloat interface {
	Float64 | Float32
}

Strict floats are sized and cannot be automatically coerced to other types.

type StrictInt

type StrictInt interface {
	Int64 | Int32 | Int16 | Int8 | UInt64 | UInt32 | UInt16 | UInt8
}

Strict integers are sized and cannot be automatically coerced to other types.

type StrictNumeric

type StrictNumeric interface {
	Float64 | Float32 | Int64 | Int32 | Int16 | Int8 | UInt64 | UInt32 | UInt16 | UInt8
}

Strict numerics are sized and cannot be automatically coerced to other types.

type StrictSignedInt

type StrictSignedInt interface {
	Int64 | Int32 | Int16 | Int8
}

Strict signed integers are sized and cannot be automatically coerced to other types.

type StrictUnsignedInt

type StrictUnsignedInt interface {
	UInt64 | UInt32 | UInt16 | UInt8
}

Strict unsigned integers are sized and cannot be automatically coerced to other types.

type String

type String string

Elk's String value

func (String) ByteAt

func (s String) ByteAt(key Value) (UInt8, Value)

Get the byte under the given index.

func (String) ByteAtInt

func (s String) ByteAtInt(index int) (UInt8, Value)

Get the byte under the given index.

func (String) ByteCount

func (s String) ByteCount() int

Returns the number of bytes present in the string.

func (String) CharCount

func (s String) CharCount() int

Returns the number of unicode chars present in the string.

func (String) Class

func (s String) Class() *Class

func (String) Cmp

func (x String) Cmp(y String) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

func (String) Compare

func (s String) Compare(other Value) (Value, Value)

Returns 1 if i is greater than other Returns 0 if both are equal. Returns -1 if i is less than other. Returns nil if the comparison was impossible (NaN)

func (String) Concat

func (s String) Concat(other Value) (result String, err Value)

Concatenate another value with this string and return the result. If the operation is illegal an error will be returned.

func (String) Copy

func (s String) Copy() Reference

func (String) DirectClass

func (String) DirectClass() *Class

func (String) Equal

func (s String) Equal(other Value) Value

Check whether s is equal to other

func (String) Error

func (s String) Error() string

func (String) Get

func (s String) Get(index int) (Char, Value)

Get an element under the given index.

func (String) GraphemeAt

func (s String) GraphemeAt(key Value) (String, Value)

Get the grapheme under the given index.

func (String) GraphemeAtInt

func (s String) GraphemeAtInt(index int) (String, Value)

Get the grapheme under the given index.

func (String) GraphemeCount

func (s String) GraphemeCount() int

Returns the number of grapheme clusters present in the string.

func (String) GreaterThan

func (s String) GreaterThan(other Value) (Value, Value)

Check whether s is greater than other and return an error if something went wrong.

func (String) GreaterThanEqual

func (s String) GreaterThanEqual(other Value) (Value, Value)

Check whether s is greater than or equal to other and return an error if something went wrong.

func (String) Hash

func (s String) Hash() UInt64

func (String) Inspect

func (s String) Inspect() string

func (String) InstanceVariables

func (s String) InstanceVariables() SymbolMap

func (String) IsEmpty

func (s String) IsEmpty() bool

func (String) LaxEqual

func (s String) LaxEqual(other Value) Value

Check whether s is equal to other

func (String) LessThan

func (s String) LessThan(other Value) (Value, Value)

Check whether s is less than other and return an error if something went wrong.

func (String) LessThanEqual

func (s String) LessThanEqual(other Value) (Value, Value)

Check whether s is less than or equal to other and return an error if something went wrong.

func (String) Lowercase

func (s String) Lowercase() String

Return a new string that has all characters turned to lowercase.

func (String) RemoveSuffix

func (s String) RemoveSuffix(other Value) (String, Value)

Return a copy of the string without the given suffix.

func (String) Repeat

func (s String) Repeat(other Value) (result String, err Value)

Repeat the content of this string n times and return a new string containing the result. If the operation is illegal an error will be returned.

func (String) ReverseBytes

func (s String) ReverseBytes() String

Reverse the bytes of the string.

func (String) ReverseChars

func (s String) ReverseChars() String

Reverse the string while preserving the UTF-8 chars.

func (String) ReverseGraphemes

func (s String) ReverseGraphemes() String

Reverse the string while preserving the grapheme clusters.

func (String) SingletonClass

func (String) SingletonClass() *Class

func (String) StrictEqual

func (s String) StrictEqual(other Value) Value

Check whether s is strictly equal to other

func (String) String

func (s String) String() string

func (String) Subscript

func (s String) Subscript(key Value) (Char, Value)

Get the character under the given index.

func (String) ToChar

func (s String) ToChar() (Char, bool)

Convert this String to a Char. Returns (Char, true) if the conversion was successful. Returns (0, false) if the conversion failed.

func (String) ToInt

func (s String) ToInt() (Value, Value)

Convert this String to an Int.

func (String) ToSymbol

func (s String) ToSymbol() Symbol

Convert the String to a Symbol

func (String) Uppercase

func (s String) Uppercase() String

Return a new string that has all characters turned to uppercase.

type StringByteIterator

type StringByteIterator struct {
	String     String
	ByteOffset int
}

func NewStringByteIterator

func NewStringByteIterator(str String) *StringByteIterator

func NewStringByteIteratorWithByteOffset

func NewStringByteIteratorWithByteOffset(str String, offset int) *StringByteIterator

func (*StringByteIterator) Class

func (*StringByteIterator) Class() *Class

func (*StringByteIterator) Copy

func (s *StringByteIterator) Copy() Reference

func (*StringByteIterator) DirectClass

func (*StringByteIterator) DirectClass() *Class

func (*StringByteIterator) Error

func (s *StringByteIterator) Error() string

func (*StringByteIterator) Inspect

func (s *StringByteIterator) Inspect() string

func (*StringByteIterator) InstanceVariables

func (*StringByteIterator) InstanceVariables() SymbolMap

func (*StringByteIterator) Next

func (s *StringByteIterator) Next() (Value, Value)

func (*StringByteIterator) SingletonClass

func (*StringByteIterator) SingletonClass() *Class

type StringCharIterator

type StringCharIterator struct {
	String     String
	ByteOffset int
}

func NewStringCharIterator

func NewStringCharIterator(str String) *StringCharIterator

func NewStringCharIteratorWithByteOffset

func NewStringCharIteratorWithByteOffset(str String, offset int) *StringCharIterator

func (*StringCharIterator) Class

func (*StringCharIterator) Class() *Class

func (*StringCharIterator) Copy

func (s *StringCharIterator) Copy() Reference

func (*StringCharIterator) DirectClass

func (*StringCharIterator) DirectClass() *Class

func (*StringCharIterator) Error

func (s *StringCharIterator) Error() string

func (*StringCharIterator) Inspect

func (s *StringCharIterator) Inspect() string

func (*StringCharIterator) InstanceVariables

func (*StringCharIterator) InstanceVariables() SymbolMap

func (*StringCharIterator) Next

func (s *StringCharIterator) Next() (Value, Value)

func (*StringCharIterator) SingletonClass

func (*StringCharIterator) SingletonClass() *Class

type Symbol

type Symbol int

Numerical ID of a particular symbol.

func ToSymbol

func ToSymbol[T ~string](str T) Symbol

Convert a string to a Symbol

func (Symbol) Class

func (Symbol) Class() *Class

func (Symbol) DirectClass

func (Symbol) DirectClass() *Class

func (Symbol) Equal

func (s Symbol) Equal(other Value) Value

Check whether s is equal to other

func (Symbol) Error

func (s Symbol) Error() string

func (Symbol) Hash

func (s Symbol) Hash() UInt64

func (Symbol) Inspect

func (s Symbol) Inspect() string

func (Symbol) InspectContent

func (s Symbol) InspectContent() string

func (Symbol) InstanceVariables

func (s Symbol) InstanceVariables() SymbolMap

func (Symbol) LaxEqual

func (s Symbol) LaxEqual(other Value) Value

Check whether s is equal to other

func (Symbol) SingletonClass

func (Symbol) SingletonClass() *Class

func (Symbol) StrictEqual

func (s Symbol) StrictEqual(other Value) Value

Check whether s is equal to other

func (Symbol) String

func (s Symbol) String() string

func (Symbol) ToString

func (s Symbol) ToString() String

func (Symbol) ToValue

func (s Symbol) ToValue() Value

type SymbolMap

type SymbolMap map[Symbol]Value

Simple map with symbol keys.

func (SymbolMap) Class

func (SymbolMap) Class() *Class

func (SymbolMap) Copy

func (s SymbolMap) Copy() Reference

func (SymbolMap) Delete

func (s SymbolMap) Delete(key Symbol)

func (SymbolMap) DeleteString

func (s SymbolMap) DeleteString(key string)

func (SymbolMap) DirectClass

func (SymbolMap) DirectClass() *Class

func (SymbolMap) Error

func (s SymbolMap) Error() string

func (SymbolMap) Get

func (s SymbolMap) Get(key Symbol) Value

Get a value stored using the given key.

func (SymbolMap) GetString

func (s SymbolMap) GetString(key string) (val Value)

Get a value stored using the given key.

func (SymbolMap) Has

func (s SymbolMap) Has(key Symbol) bool

Check if the given key exists.

func (SymbolMap) HasString

func (s SymbolMap) HasString(key string) bool

Check if the given key exists.

func (SymbolMap) Inspect

func (s SymbolMap) Inspect() string

func (SymbolMap) InstanceVariables

func (s SymbolMap) InstanceVariables() SymbolMap

func (SymbolMap) Set

func (s SymbolMap) Set(key Symbol, val Value)

Set the passed value under the given key.

func (SymbolMap) SetString

func (s SymbolMap) SetString(key string, val Value)

Set the passed value under the given key.

func (SymbolMap) SingletonClass

func (SymbolMap) SingletonClass() *Class

type SymbolTableOption

type SymbolTableOption func(*SymbolTableStruct)

func SymbolTableWithIdTable

func SymbolTableWithIdTable(idTable []string) SymbolTableOption

func SymbolTableWithNameTable

func SymbolTableWithNameTable(nameTable map[string]Symbol) SymbolTableOption

type SymbolTableStruct

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

Data structure that holds Elk Symbols.

var SymbolTable *SymbolTableStruct = NewSymbolTable()

The global Symbol Table of the Elk interpreter.

func NewSymbolTable

func NewSymbolTable(opts ...SymbolTableOption) *SymbolTableStruct

func (*SymbolTableStruct) Add

func (s *SymbolTableStruct) Add(name string) Symbol

Add a new symbol with the specified name. This function is idempotent, if the Symbol already exists nothing happens and a pointer to it gets returned. This function is thread-safe.

func (*SymbolTableStruct) Exists

func (s *SymbolTableStruct) Exists(name string) bool

Check if a symbol with the given name exists. This function is thread-safe.

func (*SymbolTableStruct) ExistsId

func (s *SymbolTableStruct) ExistsId(symbol Symbol) bool

Check if a given symbol exists.

func (*SymbolTableStruct) Get

func (s *SymbolTableStruct) Get(name string) (Symbol, bool)

Get the Symbol with the specified name. This function is thread-safe.

func (*SymbolTableStruct) GetName

func (s *SymbolTableStruct) GetName(symbol Symbol) (string, bool)

Get the name of the given symbol. This function is thread-safe.

type Time

type Time struct {
	Go time.Time
}

Elk's Time value

func NewTime

func NewTime(year, month, day, hour, min, sec, nsec int, zone *Timezone) *Time

Create a new Time object.

func TimeNow

func TimeNow() *Time

func ToElkTime

func ToElkTime(time time.Time) *Time

func (*Time) AbbreviatedMonthName

func (t *Time) AbbreviatedMonthName() string

func (*Time) AbbreviatedWeekdayName

func (t *Time) AbbreviatedWeekdayName() string

func (*Time) Add

func (t *Time) Add(val Duration) *Time

Adds the given duration to the time. Returns a new time structure.

func (*Time) Attosecond

func (t *Time) Attosecond() int64

func (*Time) Century

func (t *Time) Century() int

func (*Time) Class

func (*Time) Class() *Class

func (*Time) Cmp

func (x *Time) Cmp(y *Time) int

Cmp compares x and y and returns:

  -1 if x <  y
	 0 if x == y
  +1 if x >  y

func (*Time) Copy

func (t *Time) Copy() Reference

func (*Time) Day

func (t *Time) Day() int

func (*Time) Diff

func (t *Time) Diff(val *Time) Duration

Calculates the difference between two time objects. Returns a duration.

func (*Time) DirectClass

func (*Time) DirectClass() *Class

func (*Time) Equal

func (t *Time) Equal(other Value) Value

Check whether t is equal to other and return an error if something went wrong.

func (*Time) Error

func (t *Time) Error() string

func (*Time) Femtosecond

func (t *Time) Femtosecond() int64

func (*Time) Format

func (t *Time) Format(formatString string) (_ string, err Value)

Create a string formatted according to the given format string.

func (*Time) GreaterThan

func (t *Time) GreaterThan(other Value) (result Value, err Value)

Check whether t is greater than other and return an error if something went wrong.

func (*Time) GreaterThanEqual

func (t *Time) GreaterThanEqual(other Value) (result Value, err Value)

Check whether t is greater than or equal to other and return an error if something went wrong.

func (*Time) Hour

func (t *Time) Hour() int

Hour in a 24 hour clock.

func (*Time) Hour12

func (t *Time) Hour12() int

Hour in a twelve hour clock.

func (*Time) ISOWeek

func (t *Time) ISOWeek() int

func (*Time) ISOYear

func (t *Time) ISOYear() int

func (*Time) ISOYearLastTwo

func (t *Time) ISOYearLastTwo() int

func (*Time) Inspect

func (t *Time) Inspect() string

func (*Time) InstanceVariables

func (t *Time) InstanceVariables() SymbolMap

func (*Time) IsAM

func (t *Time) IsAM() bool

Whether the current hour is AM.

func (*Time) IsFriday

func (t *Time) IsFriday() bool

func (*Time) IsLocal

func (t *Time) IsLocal() bool

func (*Time) IsMonday

func (t *Time) IsMonday() bool

func (*Time) IsPM

func (t *Time) IsPM() bool

Whether the current hour is PM.

func (*Time) IsSaturday

func (t *Time) IsSaturday() bool

func (*Time) IsSunday

func (t *Time) IsSunday() bool

func (*Time) IsThursday

func (t *Time) IsThursday() bool

func (*Time) IsTuesday

func (t *Time) IsTuesday() bool

func (*Time) IsUTC

func (t *Time) IsUTC() bool

func (*Time) IsWednesday

func (t *Time) IsWednesday() bool

func (*Time) LaxEqual

func (t *Time) LaxEqual(other Value) Value

func (*Time) LessThan

func (t *Time) LessThan(other Value) (result Value, err Value)

Check whether t is less than other and return an error if something went wrong.

func (*Time) LessThanEqual

func (t *Time) LessThanEqual(other Value) (result Value, err Value)

Check whether t is less than or equal to other and return an error if something went wrong.

func (*Time) Local

func (t *Time) Local() *Time

Convert the time to the local timezone.

func (*Time) Meridiem

func (t *Time) Meridiem() string

func (*Time) MeridiemLowercase

func (t *Time) MeridiemLowercase() string

func (*Time) Microsecond

func (t *Time) Microsecond() int

func (*Time) Millisecond

func (t *Time) Millisecond() int

func (*Time) Minute

func (t *Time) Minute() int

func (*Time) Month

func (t *Time) Month() int

func (*Time) MonthName

func (t *Time) MonthName() string

func (*Time) MustFormat

func (t *Time) MustFormat(formatString string) string

func (*Time) Nanosecond

func (t *Time) Nanosecond() int

func (*Time) Picosecond

func (t *Time) Picosecond() int64

func (*Time) Second

func (t *Time) Second() int

func (*Time) SingletonClass

func (*Time) SingletonClass() *Class

func (*Time) StrictEqual

func (t *Time) StrictEqual(other Value) Value

func (*Time) String

func (t *Time) String() string

func (*Time) Subtract

func (t *Time) Subtract(val Duration) *Time

Subtracts the given duration from the time. Returns a new time structure.

func (*Time) ToGoTime

func (t *Time) ToGoTime() time.Time

func (*Time) ToString

func (t *Time) ToString() String

func (*Time) UTC

func (t *Time) UTC() *Time

Convert the time to the UTC zone.

func (*Time) UnixAttoseconds

func (t *Time) UnixAttoseconds() *big.Int

func (*Time) UnixFemtoseconds

func (t *Time) UnixFemtoseconds() *big.Int

func (*Time) UnixMicroseconds

func (t *Time) UnixMicroseconds() *big.Int

func (*Time) UnixMilliseconds

func (t *Time) UnixMilliseconds() int64

func (*Time) UnixNanoseconds

func (t *Time) UnixNanoseconds() *big.Int

func (*Time) UnixPicoseconds

func (t *Time) UnixPicoseconds() *big.Int

func (*Time) UnixSeconds

func (t *Time) UnixSeconds() int64

func (*Time) UnixYoctoseconds

func (t *Time) UnixYoctoseconds() *big.Int

func (*Time) UnixZeptoseconds

func (t *Time) UnixZeptoseconds() *big.Int

func (*Time) WeekFromMonday

func (t *Time) WeekFromMonday() int

The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.

func (*Time) WeekFromSunday

func (t *Time) WeekFromSunday() int

The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01.

func (*Time) WeekdayFromMonday

func (t *Time) WeekdayFromMonday() int

Specifies the day of the week (Monday = 1, ...).

func (*Time) WeekdayFromSunday

func (t *Time) WeekdayFromSunday() int

Specifies the day of the week (Sunday = 0, ...).

func (*Time) WeekdayName

func (t *Time) WeekdayName() string

func (*Time) Year

func (t *Time) Year() int

func (*Time) YearDay

func (t *Time) YearDay() int

Day of the year.

func (*Time) YearLastTwo

func (t *Time) YearLastTwo() int

func (*Time) Yoctosecond

func (t *Time) Yoctosecond() *big.Int

func (*Time) Zeptosecond

func (t *Time) Zeptosecond() *big.Int

func (*Time) Zone

func (t *Time) Zone() *Timezone

func (*Time) ZoneAbbreviatedName

func (t *Time) ZoneAbbreviatedName() string

func (*Time) ZoneName

func (t *Time) ZoneName() string

func (*Time) ZoneOffsetHourMinutes

func (t *Time) ZoneOffsetHourMinutes() int

func (*Time) ZoneOffsetHours

func (t *Time) ZoneOffsetHours() int

func (*Time) ZoneOffsetSeconds

func (t *Time) ZoneOffsetSeconds() int

type Timezone

type Timezone time.Location

Elk's Timezone value

func MustLoadTimezone

func MustLoadTimezone(name string) *Timezone

func NewTimezone

func NewTimezone(loc *time.Location) *Timezone

Create a new Timezone object.

func (*Timezone) Class

func (*Timezone) Class() *Class

func (*Timezone) Copy

func (t *Timezone) Copy() Reference

func (*Timezone) DirectClass

func (*Timezone) DirectClass() *Class

func (*Timezone) Error

func (t *Timezone) Error() string

func (*Timezone) Inspect

func (t *Timezone) Inspect() string

func (*Timezone) InstanceVariables

func (t *Timezone) InstanceVariables() SymbolMap

func (*Timezone) IsLocal

func (t *Timezone) IsLocal() bool

func (*Timezone) IsUTC

func (t *Timezone) IsUTC() bool

func (*Timezone) Name

func (t *Timezone) Name() string

func (*Timezone) SingletonClass

func (*Timezone) SingletonClass() *Class

func (*Timezone) ToGoLocation

func (t *Timezone) ToGoLocation() *time.Location

type ToValuer

type ToValuer interface {
	ToValue() Value
}

type TrueType

type TrueType struct{}

func (TrueType) Class

func (TrueType) Class() *Class

func (TrueType) DirectClass

func (TrueType) DirectClass() *Class

func (TrueType) Error

func (t TrueType) Error() string

func (TrueType) Hash

func (TrueType) Hash() UInt64

func (TrueType) Inspect

func (TrueType) Inspect() string

func (TrueType) InstanceVariables

func (TrueType) InstanceVariables() SymbolMap

func (TrueType) SingletonClass

func (TrueType) SingletonClass() *Class

func (TrueType) ToValue

func (TrueType) ToValue() Value

type UInt16

type UInt16 uint16

Elk's UInt16 value

func (UInt16) Add

func (i UInt16) Add(other Value) (UInt16, Value)

func (UInt16) BitwiseAnd

func (i UInt16) BitwiseAnd(other Value) (UInt16, Value)

Perform a bitwise AND.

func (UInt16) BitwiseAndNot

func (i UInt16) BitwiseAndNot(other Value) (UInt16, Value)

Perform a bitwise AND NOT.

func (UInt16) BitwiseOr

func (i UInt16) BitwiseOr(other Value) (UInt16, Value)

Perform a bitwise OR.

func (UInt16) BitwiseXor

func (i UInt16) BitwiseXor(other Value) (UInt16, Value)

Perform a bitwise XOR.

func (UInt16) Class

func (UInt16) Class() *Class

func (UInt16) Compare

func (i UInt16) Compare(other Value) (Value, Value)

func (UInt16) DirectClass

func (UInt16) DirectClass() *Class

func (UInt16) Divide

func (i UInt16) Divide(other Value) (UInt16, Value)

func (UInt16) Equal

func (i UInt16) Equal(other Value) Value

func (UInt16) Error

func (i UInt16) Error() string

func (UInt16) Exponentiate

func (i UInt16) Exponentiate(other Value) (UInt16, Value)

func (UInt16) GreaterThan

func (i UInt16) GreaterThan(other Value) (Value, Value)

func (UInt16) GreaterThanEqual

func (i UInt16) GreaterThanEqual(other Value) (Value, Value)

func (UInt16) Hash

func (i UInt16) Hash() UInt64

func (UInt16) Inspect

func (i UInt16) Inspect() string

func (UInt16) InstanceVariables

func (i UInt16) InstanceVariables() SymbolMap

func (UInt16) LessThan

func (i UInt16) LessThan(other Value) (Value, Value)

func (UInt16) LessThanEqual

func (i UInt16) LessThanEqual(other Value) (Value, Value)

func (UInt16) Modulo

func (i UInt16) Modulo(other Value) (UInt16, Value)

func (UInt16) Multiply

func (i UInt16) Multiply(other Value) (UInt16, Value)

func (UInt16) SingletonClass

func (UInt16) SingletonClass() *Class

func (UInt16) StrictEqual

func (i UInt16) StrictEqual(other Value) Value

func (UInt16) Subtract

func (i UInt16) Subtract(other Value) (UInt16, Value)

func (UInt16) ToFloat

func (i UInt16) ToFloat() Float

Convert to Elk Float.

func (UInt16) ToFloat32

func (i UInt16) ToFloat32() Float32

Convert to Elk Float32.

func (UInt16) ToFloat64

func (i UInt16) ToFloat64() Float64

Convert to Elk Float64.

func (UInt16) ToInt16

func (i UInt16) ToInt16() Int16

Convert to Elk Int16.

func (UInt16) ToInt32

func (i UInt16) ToInt32() Int32

Convert to Elk Int32.

func (UInt16) ToInt64

func (i UInt16) ToInt64() Int64

Convert to Elk Int64.

func (UInt16) ToInt8

func (i UInt16) ToInt8() Int8

Convert to Elk Int8.

func (UInt16) ToSmallInt

func (i UInt16) ToSmallInt() SmallInt

Convert to Elk SmallInt.

func (UInt16) ToString

func (i UInt16) ToString() String

Convert to Elk String.

func (UInt16) ToUInt32

func (i UInt16) ToUInt32() UInt32

Convert to Elk UInt32.

func (UInt16) ToUInt64

func (i UInt16) ToUInt64() UInt64

Convert to Elk UInt64.

func (UInt16) ToUInt8

func (i UInt16) ToUInt8() UInt8

Convert to Elk UInt8.

func (UInt16) ToValue

func (i UInt16) ToValue() Value

type UInt32

type UInt32 uint32

Elk's UInt32 value

func (UInt32) Add

func (i UInt32) Add(other Value) (UInt32, Value)

func (UInt32) BitwiseAnd

func (i UInt32) BitwiseAnd(other Value) (UInt32, Value)

Perform a bitwise AND.

func (UInt32) BitwiseAndNot

func (i UInt32) BitwiseAndNot(other Value) (UInt32, Value)

Perform a bitwise AND NOT.

func (UInt32) BitwiseOr

func (i UInt32) BitwiseOr(other Value) (UInt32, Value)

Perform a bitwise OR.

func (UInt32) BitwiseXor

func (i UInt32) BitwiseXor(other Value) (UInt32, Value)

Perform a bitwise XOR.

func (UInt32) Class

func (UInt32) Class() *Class

func (UInt32) Compare

func (i UInt32) Compare(other Value) (Value, Value)

func (UInt32) DirectClass

func (UInt32) DirectClass() *Class

func (UInt32) Divide

func (i UInt32) Divide(other Value) (UInt32, Value)

func (UInt32) Equal

func (i UInt32) Equal(other Value) Value

func (UInt32) Error

func (i UInt32) Error() string

func (UInt32) Exponentiate

func (i UInt32) Exponentiate(other Value) (UInt32, Value)

func (UInt32) GreaterThan

func (i UInt32) GreaterThan(other Value) (Value, Value)

func (UInt32) GreaterThanEqual

func (i UInt32) GreaterThanEqual(other Value) (Value, Value)

func (UInt32) Hash

func (i UInt32) Hash() UInt64

func (UInt32) Inspect

func (i UInt32) Inspect() string

func (UInt32) InstanceVariables

func (i UInt32) InstanceVariables() SymbolMap

func (UInt32) LessThan

func (i UInt32) LessThan(other Value) (Value, Value)

func (UInt32) LessThanEqual

func (i UInt32) LessThanEqual(other Value) (Value, Value)

func (UInt32) Modulo

func (i UInt32) Modulo(other Value) (UInt32, Value)

func (UInt32) Multiply

func (i UInt32) Multiply(other Value) (UInt32, Value)

func (UInt32) SingletonClass

func (UInt32) SingletonClass() *Class

func (UInt32) StrictEqual

func (i UInt32) StrictEqual(other Value) Value

func (UInt32) Subtract

func (i UInt32) Subtract(other Value) (UInt32, Value)

func (UInt32) ToFloat

func (i UInt32) ToFloat() Float

Convert to Elk Float.

func (UInt32) ToFloat32

func (i UInt32) ToFloat32() Float32

Convert to Elk Float32.

func (UInt32) ToFloat64

func (i UInt32) ToFloat64() Float64

Convert to Elk Float64.

func (UInt32) ToInt16

func (i UInt32) ToInt16() Int16

Convert to Elk Int16.

func (UInt32) ToInt32

func (i UInt32) ToInt32() Int32

Convert to Elk Int32.

func (UInt32) ToInt64

func (i UInt32) ToInt64() Int64

Convert to Elk Int64.

func (UInt32) ToInt8

func (i UInt32) ToInt8() Int8

Convert to Elk Int8.

func (UInt32) ToSmallInt

func (i UInt32) ToSmallInt() SmallInt

Convert to Elk SmallInt.

func (UInt32) ToString

func (i UInt32) ToString() String

Convert to Elk String.

func (UInt32) ToUInt16

func (i UInt32) ToUInt16() UInt16

Convert to Elk UInt16.

func (UInt32) ToUInt64

func (i UInt32) ToUInt64() UInt64

Convert to Elk UInt64.

func (UInt32) ToUInt8

func (i UInt32) ToUInt8() UInt8

Convert to Elk UInt8.

func (UInt32) ToValue

func (i UInt32) ToValue() Value

type UInt64

type UInt64 uint64

Elk's UInt64 value

func (UInt64) Add

func (i UInt64) Add(other Value) (UInt64, Value)

func (UInt64) BitwiseAnd

func (i UInt64) BitwiseAnd(other Value) (UInt64, Value)

Perform a bitwise AND.

func (UInt64) BitwiseAndNot

func (i UInt64) BitwiseAndNot(other Value) (UInt64, Value)

Perform a bitwise AND NOT.

func (UInt64) BitwiseOr

func (i UInt64) BitwiseOr(other Value) (UInt64, Value)

Perform a bitwise OR.

func (UInt64) BitwiseXor

func (i UInt64) BitwiseXor(other Value) (UInt64, Value)

Perform a bitwise XOR.

func (UInt64) Class

func (UInt64) Class() *Class

func (UInt64) Compare

func (i UInt64) Compare(other Value) (Value, Value)

func (UInt64) Copy

func (i UInt64) Copy() Reference

func (UInt64) DirectClass

func (UInt64) DirectClass() *Class

func (UInt64) Divide

func (i UInt64) Divide(other Value) (UInt64, Value)

func (UInt64) Equal

func (i UInt64) Equal(other Value) Value

func (UInt64) Error

func (i UInt64) Error() string

func (UInt64) Exponentiate

func (i UInt64) Exponentiate(other Value) (UInt64, Value)

func (UInt64) GreaterThan

func (i UInt64) GreaterThan(other Value) (Value, Value)

func (UInt64) GreaterThanEqual

func (i UInt64) GreaterThanEqual(other Value) (Value, Value)

func (UInt64) Hash

func (i UInt64) Hash() UInt64

func (UInt64) Inspect

func (i UInt64) Inspect() string

func (UInt64) InstanceVariables

func (i UInt64) InstanceVariables() SymbolMap

func (UInt64) LessThan

func (i UInt64) LessThan(other Value) (Value, Value)

func (UInt64) LessThanEqual

func (i UInt64) LessThanEqual(other Value) (Value, Value)

func (UInt64) Modulo

func (i UInt64) Modulo(other Value) (UInt64, Value)

func (UInt64) Multiply

func (i UInt64) Multiply(other Value) (UInt64, Value)

func (UInt64) SingletonClass

func (UInt64) SingletonClass() *Class

func (UInt64) StrictEqual

func (i UInt64) StrictEqual(other Value) Value

func (UInt64) Subtract

func (i UInt64) Subtract(other Value) (UInt64, Value)

func (UInt64) ToFloat

func (i UInt64) ToFloat() Float

Convert to Elk Float.

func (UInt64) ToFloat32

func (i UInt64) ToFloat32() Float32

Convert to Elk Float32.

func (UInt64) ToFloat64

func (i UInt64) ToFloat64() Float64

Convert to Elk Float64.

func (UInt64) ToInt16

func (i UInt64) ToInt16() Int16

Convert to Elk Int16.

func (UInt64) ToInt32

func (i UInt64) ToInt32() Int32

Convert to Elk Int32.

func (UInt64) ToInt64

func (i UInt64) ToInt64() Int64

Convert to Elk Int64.

func (UInt64) ToInt8

func (i UInt64) ToInt8() Int8

Convert to Elk Int8.

func (UInt64) ToSmallInt

func (i UInt64) ToSmallInt() SmallInt

Convert to Elk SmallInt.

func (UInt64) ToString

func (i UInt64) ToString() String

Convert to Elk String.

func (UInt64) ToUInt16

func (i UInt64) ToUInt16() UInt16

Convert to Elk UInt16.

func (UInt64) ToUInt32

func (i UInt64) ToUInt32() UInt32

Convert to Elk UInt32.

func (UInt64) ToUInt8

func (i UInt64) ToUInt8() UInt8

Convert to Elk UInt8.

func (UInt64) ToValue

func (i UInt64) ToValue() Value

type UInt8

type UInt8 uint8

Elk's UInt8 value

func (UInt8) Add

func (i UInt8) Add(other Value) (UInt8, Value)

func (UInt8) BitwiseAnd

func (i UInt8) BitwiseAnd(other Value) (UInt8, Value)

Perform a bitwise AND.

func (UInt8) BitwiseAndNot

func (i UInt8) BitwiseAndNot(other Value) (UInt8, Value)

Perform a bitwise AND NOT.

func (UInt8) BitwiseOr

func (i UInt8) BitwiseOr(other Value) (UInt8, Value)

Perform a bitwise OR.

func (UInt8) BitwiseXor

func (i UInt8) BitwiseXor(other Value) (UInt8, Value)

Perform a bitwise XOR.

func (UInt8) Class

func (UInt8) Class() *Class

func (UInt8) Compare

func (i UInt8) Compare(other Value) (Value, Value)

func (UInt8) DirectClass

func (UInt8) DirectClass() *Class

func (UInt8) Divide

func (i UInt8) Divide(other Value) (UInt8, Value)

func (UInt8) Equal

func (i UInt8) Equal(other Value) Value

func (UInt8) Error

func (i UInt8) Error() string

func (UInt8) Exponentiate

func (i UInt8) Exponentiate(other Value) (UInt8, Value)

func (UInt8) GreaterThan

func (i UInt8) GreaterThan(other Value) (Value, Value)

func (UInt8) GreaterThanEqual

func (i UInt8) GreaterThanEqual(other Value) (Value, Value)

func (UInt8) Hash

func (i UInt8) Hash() UInt64

func (UInt8) Inspect

func (i UInt8) Inspect() string

func (UInt8) InstanceVariables

func (i UInt8) InstanceVariables() SymbolMap

func (UInt8) LessThan

func (i UInt8) LessThan(other Value) (Value, Value)

func (UInt8) LessThanEqual

func (i UInt8) LessThanEqual(other Value) (Value, Value)

func (UInt8) Modulo

func (i UInt8) Modulo(other Value) (UInt8, Value)

func (UInt8) Multiply

func (i UInt8) Multiply(other Value) (UInt8, Value)

func (UInt8) SingletonClass

func (UInt8) SingletonClass() *Class

func (UInt8) StrictEqual

func (i UInt8) StrictEqual(other Value) Value

func (UInt8) Subtract

func (i UInt8) Subtract(other Value) (UInt8, Value)

func (UInt8) ToFloat

func (i UInt8) ToFloat() Float

Convert to Elk Float.

func (UInt8) ToFloat32

func (i UInt8) ToFloat32() Float32

Convert to Elk Float32.

func (UInt8) ToFloat64

func (i UInt8) ToFloat64() Float64

Convert to Elk Float64.

func (UInt8) ToInt16

func (i UInt8) ToInt16() Int16

Convert to Elk Int16.

func (UInt8) ToInt32

func (i UInt8) ToInt32() Int32

Convert to Elk Int32.

func (UInt8) ToInt64

func (i UInt8) ToInt64() Int64

Convert to Elk Int64.

func (UInt8) ToInt8

func (i UInt8) ToInt8() Int8

Convert to Elk Int8.

func (UInt8) ToSmallInt

func (i UInt8) ToSmallInt() SmallInt

Convert to Elk SmallInt.

func (UInt8) ToString

func (i UInt8) ToString() String

Convert to Elk String.

func (UInt8) ToUInt16

func (i UInt8) ToUInt16() UInt16

Convert to Elk UInt16.

func (UInt8) ToUInt32

func (i UInt8) ToUInt32() UInt32

Convert to Elk UInt32.

func (UInt8) ToUInt64

func (i UInt8) ToUInt64() UInt64

Convert to Elk UInt64.

func (UInt8) ToValue

func (i UInt8) ToValue() Value

type UndefinedType

type UndefinedType struct{}

Elk's internal undefined value. Serves as a sentinel value that indicates that no "real" value is present.

It is the zero value of `Value` and maps to Go's `nil`

func (UndefinedType) Class

func (UndefinedType) Class() *Class

func (UndefinedType) DirectClass

func (UndefinedType) DirectClass() *Class

func (UndefinedType) Error

func (u UndefinedType) Error() string

func (UndefinedType) Inspect

func (UndefinedType) Inspect() string

func (UndefinedType) InstanceVariables

func (UndefinedType) InstanceVariables() SymbolMap

func (UndefinedType) SingletonClass

func (UndefinedType) SingletonClass() *Class

func (UndefinedType) ToValue

func (u UndefinedType) ToValue() Value

type UnsignedInt

type UnsignedInt interface {
	UInt64 | UInt32 | UInt16 | UInt8
}

type Value

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

`undefined` is the zero value of `Value`, it maps directly to Go `nil`

var Nil Value = NilType{}.ToValue()

Elk's Nil value

func Add

func Add(left, right Value) (result, err Value)

Add two values. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func BitwiseAnd

func BitwiseAnd(left, right Value) (result, err Value)

Execute a bitwise AND &. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func BitwiseAndNot

func BitwiseAndNot(left, right Value) (result, err Value)

Execute a bitwise AND NOT &^. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func BitwiseNot

func BitwiseNot(operand Value) Value

Perform bitwise not on a value When successful returns result. When there are no builtin negation functions for the given type returns nil.

func BitwiseOr

func BitwiseOr(left, right Value) (result, err Value)

Execute a bitwise OR |. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func BitwiseXor

func BitwiseXor(left, right Value) (result, err Value)

Execute a bitwise XOR ^. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func ClassConstructor

func ClassConstructor(metaClass *Class) Value

Used by the VM, create a new class.

func Compare

func Compare(left, right Value) (result, err Value)

Compare two values. Returns 1 if left is greater than right. Returns 0 if both are equal. Returns -1 if left is less than right.

When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func Decrement

func Decrement(operand Value) Value

Decrement a value When successful returns result. When there are no builtin negation functions for the given type returns nil.

func Divide

func Divide(left, right Value) (result, err Value)

Divide two values When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func Equal

func Equal(left, right Value) Value

Check whether left is equal to right. When successful returns (result). When there are no builtin addition functions for the given type returns (undefined).

func Exponentiate

func Exponentiate(left, right Value) (result, err Value)

Exponentiate two values When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func GreaterThan

func GreaterThan(left, right Value) (result, err Value)

Check whether left is greater than right. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func GreaterThanEqual

func GreaterThanEqual(left, right Value) (result, err Value)

Check whether left is greater than or equal to right. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func Increment

func Increment(operand Value) Value

Increment a value When successful returns result. When there are no builtin negation functions for the given type returns nil.

func InterfaceConstructor

func InterfaceConstructor(class *Class) Value

Used by the VM, create a new interface value.

func LaxEqual

func LaxEqual(left, right Value) Value

Check whether left is equal to right. When successful returns (result). When there are no builtin addition functions for the given type returns (nil).

func LaxNotEqual

func LaxNotEqual(left, right Value) Value

Check whether left is not equal to right. When successful returns (result). When there are no builtin addition functions for the given type returns (nil).

func LeftBitshift

func LeftBitshift(left, right Value) (result, err Value)

Execute a left bit shift <<. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func LessThan

func LessThan(left, right Value) (result, err Value)

Check whether left is less than right. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func LessThanEqual

func LessThanEqual(left, right Value) (result, err Value)

Check whether left is less than or equal to right. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func LogicalLeftBitshift

func LogicalLeftBitshift(left, right Value) (result, err Value)

Execute a logical left bit shift <<<. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func LogicalRightBitshift

func LogicalRightBitshift(left, right Value) (result, err Value)

Execute a logical right bit shift >>>. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func MixinConstructor

func MixinConstructor(class *Class) Value

Used by the VM, create a new mixin.

func ModuleConstructor

func ModuleConstructor(class *Class) Value

Used by the VM, create a new module value.

func Modulo

func Modulo(left, right Value) (result, err Value)

Perform modulo on two values When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func Multiply

func Multiply(left, right Value) (result, err Value)

Multiply two values When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func Negate

func Negate(operand Value) Value

Negate a value When successful returns result. When there are no builtin negation functions for the given type returns nil.

func NotEqual

func NotEqual(left, right Value) Value

Check whether left is not equal to right. When successful returns (result). When there are no builtin addition functions for the given type returns (nil).

func ObjectConstructor

func ObjectConstructor(class *Class) Value

Creates a new value.

func PairConstructor

func PairConstructor(class *Class) Value

Creates a new Pair.

func Ref

func Ref(ref Reference) Value

Convert a Reference to a Value

func RightBitshift

func RightBitshift(left, right Value) (result, err Value)

Execute a right bit shift >>. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func SetInSlice

func SetInSlice(collection *[]Value, index int, val Value) Value

Set an element under the given index.

func StrictEqual

func StrictEqual(left, right Value) Value

Check whether left is strictly equal to right. When successful returns (result). When there are no builtin addition functions for the given type returns (nil).

func StrictFloatLaxEqual

func StrictFloatLaxEqual[T StrictFloat](left T, right Value) Value

Check whether the left float is equal to right.

func StrictIntLeftBitshift

func StrictIntLeftBitshift[T StrictInt](left T, right Value) (T, Value)

Bitshift a strict int to the left.

func StrictIntLogicalLeftBitshift

func StrictIntLogicalLeftBitshift[T StrictInt](left T, right Value, shiftFunc logicalShiftFunc[T]) (T, Value)

Bitshift a strict int to the left.

func StrictIntLogicalRightBitshift

func StrictIntLogicalRightBitshift[T StrictInt](left T, right Value, shiftFunc logicalShiftFunc[T]) (T, Value)

Logically bitshift a strict int to the right.

func StrictIntRightBitshift

func StrictIntRightBitshift[T StrictInt](left T, right Value) (T, Value)

Bitshift a strict int to the right.

func StrictNotEqual

func StrictNotEqual(left, right Value) Value

Check whether left is strictly not equal to right. When successful returns (result). When there are no builtin addition functions for the given type returns (nil).

func StrictParseInt

func StrictParseInt(s string, base int, bitSize int) (int64, Value)

Parses a signed strict integer from a string using Elk syntax.

func StrictParseUint

func StrictParseUint(s string, base int, bitSize int) (uint64, Value)

Parses an unsigned strict integer from a string using Elk syntax.

func StrictSignedIntLaxEqual

func StrictSignedIntLaxEqual[T StrictSignedInt](left T, right Value) Value

Check whether the left signed integer is equal to right.

func StrictUnsignedIntLaxEqual

func StrictUnsignedIntLaxEqual[T StrictUnsignedInt](left T, right Value) Value

Check whether the left unsigned integer is equal to right.

func Subscript

func Subscript(collection, key Value) (result, err Value)

Get an element by key. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func SubscriptSet

func SubscriptSet(collection, key, val Value) (result, err Value)

Set an element under the given key. When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func Subtract

func Subtract(left, right Value) (result, err Value)

Subtract two values When successful returns (result, undefined). When an error occurred returns (undefined, error). When there are no builtin addition functions for the given type returns (undefined, undefined).

func ToBool

func ToBool(val Value) Value

Converts an Elk Value to an Elk Bool.

func ToElkBool

func ToElkBool(val bool) Value

Convert a Go bool value to Elk.

func ToElkInt

func ToElkInt(i int64) Value

Convert Go int64 to Elk Int.

func ToNotBool

func ToNotBool(val Value) Value

Converts an Elk Value to an Elk Bool and negates it.

func UnaryPlus

func UnaryPlus(operand Value) Value

Perform unary plus on a value When successful returns result. When there are no builtin negation functions for the given type returns nil.

func (Value) AsChar

func (v Value) AsChar() Char

func (Value) AsDuration

func (v Value) AsDuration() Duration

func (Value) AsFalse

func (v Value) AsFalse() FalseType

func (Value) AsFloat

func (v Value) AsFloat() Float

func (Value) AsFloat32

func (v Value) AsFloat32() Float32

func (Value) AsFloat64

func (v Value) AsFloat64() Float64

func (Value) AsInt16

func (v Value) AsInt16() Int16

func (Value) AsInt32

func (v Value) AsInt32() Int32

func (Value) AsInt64

func (v Value) AsInt64() Int64

func (Value) AsInt8

func (v Value) AsInt8() Int8

func (Value) AsNil

func (v Value) AsNil() NilType

func (Value) AsReference

func (v Value) AsReference() Reference

func (Value) AsSmallInt

func (v Value) AsSmallInt() SmallInt

func (Value) AsSymbol

func (v Value) AsSymbol() Symbol

func (Value) AsTrue

func (v Value) AsTrue() TrueType

func (Value) AsUInt16

func (v Value) AsUInt16() UInt16

func (Value) AsUInt32

func (v Value) AsUInt32() UInt32

func (Value) AsUInt64

func (v Value) AsUInt64() UInt64

func (Value) AsUInt8

func (v Value) AsUInt8() UInt8

func (Value) AsUndefined

func (v Value) AsUndefined() UndefinedType

func (Value) Class

func (v Value) Class() *Class

func (Value) Copy

func (v Value) Copy() Value

func (Value) DirectClass

func (v Value) DirectClass() *Class

func (Value) Error

func (v Value) Error() string

func (Value) Inspect

func (v Value) Inspect() string

func (Value) InstanceVariables

func (v Value) InstanceVariables() SymbolMap

func (Value) IsChar

func (v Value) IsChar() bool

func (Value) IsDuration

func (v Value) IsDuration() bool

func (Value) IsFalse

func (v Value) IsFalse() bool

func (Value) IsFloat

func (v Value) IsFloat() bool

func (Value) IsFloat32

func (v Value) IsFloat32() bool

func (Value) IsFloat64

func (v Value) IsFloat64() bool

func (Value) IsInlineValue

func (v Value) IsInlineValue() bool

func (Value) IsInt16

func (v Value) IsInt16() bool

func (Value) IsInt32

func (v Value) IsInt32() bool

func (Value) IsInt64

func (v Value) IsInt64() bool

func (Value) IsInt8

func (v Value) IsInt8() bool

func (Value) IsNil

func (v Value) IsNil() bool

func (Value) IsReference

func (v Value) IsReference() bool

func (Value) IsSmallInt

func (v Value) IsSmallInt() bool

func (Value) IsSymbol

func (v Value) IsSymbol() bool

func (Value) IsTrue

func (v Value) IsTrue() bool

func (Value) IsUInt16

func (v Value) IsUInt16() bool

func (Value) IsUInt32

func (v Value) IsUInt32() bool

func (Value) IsUInt64

func (v Value) IsUInt64() bool

func (Value) IsUInt8

func (v Value) IsUInt8() bool

func (Value) IsUndefined

func (v Value) IsUndefined() bool

func (Value) MustChar

func (v Value) MustChar() Char

func (Value) MustDuration

func (v Value) MustDuration() Duration

func (Value) MustFalse

func (v Value) MustFalse() FalseType

func (Value) MustFloat

func (v Value) MustFloat() Float

func (Value) MustFloat32

func (v Value) MustFloat32() Float32

func (Value) MustFloat64

func (v Value) MustFloat64() Float64

func (Value) MustInt16

func (v Value) MustInt16() Int16

func (Value) MustInt32

func (v Value) MustInt32() Int32

func (Value) MustInt64

func (v Value) MustInt64() Int64

func (Value) MustInt8

func (v Value) MustInt8() Int8

func (Value) MustNil

func (v Value) MustNil() NilType

func (Value) MustReference

func (v Value) MustReference() Reference

func (Value) MustSmallInt

func (v Value) MustSmallInt() SmallInt

func (Value) MustSymbol

func (v Value) MustSymbol() Symbol

func (Value) MustTrue

func (v Value) MustTrue() TrueType

func (Value) MustUInt16

func (v Value) MustUInt16() UInt16

func (Value) MustUInt32

func (v Value) MustUInt32() UInt32

func (Value) MustUInt64

func (v Value) MustUInt64() UInt64

func (Value) MustUInt8

func (v Value) MustUInt8() UInt8

func (Value) MustUndefined

func (v Value) MustUndefined() UndefinedType

func (Value) SafeAsReference

func (v Value) SafeAsReference() Reference

Returns `nil` when the value is not a reference

func (Value) SingletonClass

func (v Value) SingletonClass() *Class

func (Value) ValueFlag

func (v Value) ValueFlag() uint8

Directories

Path Synopsis
Package timescanner implements a tokenizer/lexer that analyses Elk time format strings.
Package timescanner implements a tokenizer/lexer that analyses Elk time format strings.

Jump to

Keyboard shortcuts

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