values

package
v0.0.0-...-f5b6858 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: MIT Imports: 7 Imported by: 12

Documentation

Overview

Package values declares the flux data types and implements them.

Index

Constants

This section is empty.

Variables

View Source
var InvalidValue = value{/* contains filtered or unexported fields */}

InvalidValue is a non nil value who's type is semantic.Invalid

Functions

func CheckKind

func CheckKind(got, exp semantic.Kind)

CheckKind panics if got != exp.

func NewObject

func NewObject() *object

func UnexpectedKind

func UnexpectedKind(got, exp semantic.Kind) error

Types

type Array

type Array interface {
	Value
	Get(i int) Value
	Set(i int, v Value)
	Append(v Value)
	Len() int
	Range(func(i int, v Value))
	Sort(func(i, j Value) bool)
}

Array represents an sequence of elements All elements must be the same type

func NewArray

func NewArray(elementType semantic.Type) Array

func NewArrayWithBacking

func NewArrayWithBacking(elementType semantic.Type, elements []Value) Array

type BinaryFuncSignature

type BinaryFuncSignature struct {
	Operator    ast.OperatorKind
	Left, Right semantic.Type
}

type BinaryFunction

type BinaryFunction func(l, r Value) Value

func LookupBinaryFunction

func LookupBinaryFunction(sig BinaryFuncSignature) (BinaryFunction, error)

type Duration

type Duration int64

func ParseDuration

func ParseDuration(s string) (Duration, error)

func (Duration) Duration

func (d Duration) Duration() time.Duration

func (Duration) String

func (d Duration) String() string

type Function

type Function interface {
	Value
	HasSideEffect() bool
	Call(args Object) (Value, error)
}

Function represents a callable type

func NewFunction

func NewFunction(name string, typ semantic.Type, call func(args Object) (Value, error), sideEffect bool) Function

NewFunction returns a new function value

type Object

type Object interface {
	Value
	Get(name string) (Value, bool)
	Set(name string, v Value)
	Len() int
	Range(func(name string, v Value))
}

type Time

type Time int64

func ConvertTime

func ConvertTime(t time.Time) Time

func ParseTime

func ParseTime(s string) (Time, error)

func (Time) Add

func (t Time) Add(d Duration) Time

func (Time) Round

func (t Time) Round(d Duration) Time

func (Time) String

func (t Time) String() string

func (Time) Time

func (t Time) Time() time.Time

func (Time) Truncate

func (t Time) Truncate(d Duration) Time

type Typer

type Typer interface {
	Type() semantic.Type
}

type Value

type Value interface {
	Typer
	Str() string
	Int() int64
	UInt() uint64
	Float() float64
	Bool() bool
	Time() Time
	Duration() Duration
	Regexp() *regexp.Regexp
	Array() Array
	Object() Object
	Function() Function
	Equal(Value) bool
}

func NewBoolValue

func NewBoolValue(v bool) Value

func NewDurationValue

func NewDurationValue(v Duration) Value

func NewFloatValue

func NewFloatValue(v float64) Value

func NewIntValue

func NewIntValue(v int64) Value

func NewRegexpValue

func NewRegexpValue(v *regexp.Regexp) Value

func NewStringValue

func NewStringValue(v string) Value

func NewTimeValue

func NewTimeValue(v Time) Value

func NewUIntValue

func NewUIntValue(v uint64) Value

func NewValue

func NewValue(v interface{}, k semantic.Kind) (Value, error)

Jump to

Keyboard shortcuts

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