val

package
v0.18.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedType is the error that the value type is not supported.
	ErrUnsupportedType = errors.New("unsupported type")
	// ErrOperationNotDefined is the error that the operation is not defined.
	ErrOperationNotDefined = errors.New("operation not defined")
)

Functions

func RegisterType

func RegisterType(t Type)

RegisterType registers an abstract type t. Later registered types take precedence over earlier ones.

Types

type Adder

type Adder interface {
	Add(Value) (Value, error)
}

Adder is an interface that supports '+' operator.

type Any

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

Any represents an undefined type value.

func (Any) Equal

func (a Any) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Any) GoValue

func (a Any) GoValue() any

GoValue implements Value interface.

func (Any) Size added in v0.16.0

func (a Any) Size() (Value, error)

Size implements Sizer interface.

func (Any) Type

func (a Any) Type() Type

Type implements Value interface.

type Bool

type Bool bool

Bool represents a bool value.

func (Bool) Equal

func (b Bool) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Bool) GoValue

func (b Bool) GoValue() any

GoValue implements Value interface.

func (Bool) IsTruthy

func (b Bool) IsTruthy() bool

IsTruthy implements LogicalValue interface.

func (Bool) Type

func (b Bool) Type() Type

Type implements Value interface.

type Bytes

type Bytes []byte

Bytes represents a bytes value.

func (Bytes) Add

func (b Bytes) Add(v Value) (Value, error)

Add implements Adder interface.

func (Bytes) Compare

func (b Bytes) Compare(v Value) (Value, error)

Compare implements Comparer interface.

func (Bytes) Equal

func (b Bytes) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Bytes) GoValue

func (b Bytes) GoValue() any

GoValue implements Value interface.

func (Bytes) Size added in v0.16.0

func (b Bytes) Size() (Value, error)

Size implements Sizer interface.

func (Bytes) Type

func (b Bytes) Type() Type

Type implements Value interface.

type Comparer

type Comparer interface {
	Compare(Value) (Value, error)
}

Comparer is an interface that supports '<', '<=', '>', '>=' operators.

type Divider

type Divider interface {
	Div(Value) (Value, error)
}

Divider is an interface that supports '/' operator.

type Duration

type Duration time.Duration

Duration represents a duration value.

func (Duration) Add

func (d Duration) Add(v Value) (Value, error)

Add implements Adder interface.

func (Duration) Compare

func (d Duration) Compare(v Value) (Value, error)

Equal implements Equaler interface.

func (Duration) Equal

func (d Duration) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Duration) GoValue

func (d Duration) GoValue() any

GoValue implements Value interface.

func (Duration) Neg

func (d Duration) Neg() (Value, error)

Neg implements Negator interface.

func (Duration) Sub

func (d Duration) Sub(v Value) (Value, error)

Sub implements Subtractor interface.

func (Duration) Type

func (d Duration) Type() Type

Type implements Value interface.

type Equaler

type Equaler interface {
	Equal(Value) (LogicalValue, error)
}

Equaler is an interface that supports '==' operator.

type Float

type Float float64

Float represents a float value.

func (Float) Add

func (f Float) Add(v Value) (Value, error)

Add implements Adder interface.

func (Float) Compare

func (f Float) Compare(v Value) (Value, error)

Compare implements Comparer interface.

func (Float) Div

func (f Float) Div(v Value) (Value, error)

Div implements Divider interface.

func (Float) Equal

func (f Float) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Float) GoValue

func (f Float) GoValue() any

GoValue implements Value interface.

func (Float) Mul

func (f Float) Mul(v Value) (Value, error)

Mul implements Multiplier interface.

func (Float) Neg

func (f Float) Neg() (Value, error)

Neg implements Negator interface.

func (Float) Sub

func (f Float) Sub(v Value) (Value, error)

Sub implements Subtractor interface.

func (Float) Type

func (f Float) Type() Type

Type implements Value interface.

type Int

type Int int64

Int represents an int value.

func (Int) Add

func (i Int) Add(v Value) (Value, error)

Add implements Adder interface.

func (Int) Compare

func (i Int) Compare(v Value) (Value, error)

Compare implements Comparer interface.

func (Int) Div

func (i Int) Div(v Value) (Value, error)

Div implements Divider interface.

func (Int) Equal

func (i Int) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Int) GoValue

func (i Int) GoValue() any

GoValue implements Value interface.

func (Int) Mod

func (i Int) Mod(v Value) (Value, error)

Mod implements Modder interface.

func (Int) Mul

func (i Int) Mul(v Value) (Value, error)

Mul implements Multiplier interface.

func (Int) Neg

func (i Int) Neg() (Value, error)

Neg implements Negator interface.

func (Int) Sub

func (i Int) Sub(v Value) (Value, error)

Sub implements Subtractor interface.

func (Int) Type

func (i Int) Type() Type

Type implements Value interface.

type LogicalValue

type LogicalValue interface {
	Value
	IsTruthy() bool
}

LogicalValue is an interface that can be used in a boolean context.

type Modder

type Modder interface {
	Mod(Value) (Value, error)
}

Modder is an interface that supports '%' operator.

type Multiplier

type Multiplier interface {
	Mul(Value) (Value, error)
}

Multiplier is an interface that supports '*' operator.

type Negator

type Negator interface {
	Neg() (Value, error)
}

Negater is an interface that supports unary '-' operator.

type Nil

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

Nil represents a nil value.

func (Nil) Equal

func (n Nil) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Nil) GoValue

func (n Nil) GoValue() any

GoValue implements Value interface.

func (Nil) Type

func (n Nil) Type() Type

Type implements Value interface.

type Sizer added in v0.16.0

type Sizer interface {
	Size() (Value, error)
}

Sizer is an interface that supports 'size()' overloads.

type String

type String string

String represents a string value.

func (String) Add

func (s String) Add(v Value) (Value, error)

Add implements Adder interface.

func (String) Compare

func (s String) Compare(v Value) (Value, error)

Compare implements Comparer interface.

func (String) Equal

func (s String) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (String) GoValue

func (s String) GoValue() any

GoValue implements Value interface.

func (String) Size added in v0.16.0

func (s String) Size() (Value, error)

Size implements Sizer interface.

func (String) Type

func (s String) Type() Type

Type implements Value interface.

type Subtractor

type Subtractor interface {
	Sub(Value) (Value, error)
}

Subtractor is an interface that supports '-' operator.

type Time

type Time time.Time

Time represents a time value.

func (Time) Add

func (t Time) Add(v Value) (Value, error)

Add implements Adder interface.

func (Time) Compare

func (t Time) Compare(v Value) (Value, error)

Compare implements Comparer interface.

func (Time) Equal

func (t Time) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Time) GoValue

func (t Time) GoValue() any

GoValue implements Value interface.

func (Time) Sub

func (t Time) Sub(v Value) (Value, error)

Sub implements Subtractor interface.

func (Time) Type

func (t Time) Type() Type

Type implements Value interface.

type Type

type Type interface {
	Name() string
	NewValue(any) (Value, error)
	Convert(Value) (Value, error)
}

Type represents an abstract operand type.

func GetType

func GetType(name string) Type

GetType gets registered type by name. This function returns nil if a type is not found by the given name.

type Uint

type Uint uint64

Uint represents a uint value.

func (Uint) Add

func (i Uint) Add(v Value) (Value, error)

Add implements Adder interface.

func (Uint) Compare

func (i Uint) Compare(v Value) (Value, error)

Compare implements Comparer interface.

func (Uint) Div

func (i Uint) Div(v Value) (Value, error)

Div implements Divider interface.

func (Uint) Equal

func (i Uint) Equal(v Value) (LogicalValue, error)

Equal implements Equaler interface.

func (Uint) GoValue

func (i Uint) GoValue() any

GoValue implements Value interface.

func (Uint) Mod

func (i Uint) Mod(v Value) (Value, error)

Mod implements Modder interface.

func (Uint) Mul

func (i Uint) Mul(v Value) (Value, error)

Mul implements Multiplier interface.

func (Uint) Sub

func (i Uint) Sub(v Value) (Value, error)

Sub implements Subtractor interface.

func (Uint) Type

func (i Uint) Type() Type

Type implements Value interface.

type Value

type Value interface {
	Type() Type
	GoValue() any
}

Value represents an abstract operand value.

func NewValue

func NewValue(v any) Value

NewValue returns v as a an abstract value.

Jump to

Keyboard shortcuts

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