core

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxArgs = 65536

Variables

View Source
var (
	ErrMissedArgument        = errors.New("missed argument")
	ErrInvalidArgument       = errors.New("invalid argument")
	ErrInvalidArgumentNumber = errors.New("invalid argument number")
	ErrInvalidType           = errors.New("invalid type")
	ErrInvalidOperation      = errors.New("invalid operation")
	ErrNotFound              = errors.New("not found")
	ErrNotUnique             = errors.New("not unique")
	ErrTerminated            = errors.New("operation is terminated")
	ErrUnexpected            = errors.New("unexpected error")
	ErrTimeout               = errors.New("operation timed out")
	ErrNotImplemented        = errors.New("not implemented")
)

Functions

func Error

func Error(err error, msg string) error

func Errorf added in v0.4.0

func Errorf(err error, format string, args ...interface{}) error

func Errors

func Errors(err ...error) error

func IsNil

func IsNil(input interface{}) bool

func IsTypeOf

func IsTypeOf(value Value, check Type) bool

func NewRootScope

func NewRootScope() (*Scope, CloseFunc)

func ParamsFrom

func ParamsFrom(ctx context.Context) (map[string]Value, error)

func ParamsWith

func ParamsWith(ctx context.Context, params map[string]Value) context.Context

func SourceError

func SourceError(src SourceMap, err error) error

func TypeError

func TypeError(actual Type, expected ...Type) error

func ValidateArgs

func ValidateArgs(args []Value, minimum, maximum int) error

func ValidateType

func ValidateType(value Value, required ...Type) error

Types

type Cloneable

type Cloneable interface {
	Value
	Clone() Cloneable
}

type CloseFunc

type CloseFunc func()

type Expression

type Expression interface {
	Exec(ctx context.Context, scope *Scope) (Value, error)
}

type Function

type Function = func(ctx context.Context, args ...Value) (Value, error)

type OperatorExpression

type OperatorExpression interface {
	Expression
	Eval(ctx context.Context, left, right Value) (Value, error)
}

type Scope

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

func NewScope

func NewScope(parent *Scope) *Scope

func (*Scope) Fork

func (s *Scope) Fork() *Scope

func (*Scope) GetVariable

func (s *Scope) GetVariable(name string) (Value, error)

func (*Scope) HasVariable

func (s *Scope) HasVariable(name string) bool

func (*Scope) SetVariable

func (s *Scope) SetVariable(name string, val Value) error

type SourceMap

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

func NewSourceMap

func NewSourceMap(text string, line, col int) SourceMap

func (SourceMap) Column

func (s SourceMap) Column() int

func (SourceMap) Line

func (s SourceMap) Line() int

func (SourceMap) String

func (s SourceMap) String() string

type Type

type Type int64
const (
	NoneType         Type = 0
	BooleanType      Type = 1
	IntType          Type = 2
	FloatType        Type = 3
	StringType       Type = 4
	DateTimeType     Type = 5
	ArrayType        Type = 6
	ObjectType       Type = 7
	HTMLElementType  Type = 8
	HTMLDocumentType Type = 9
	BinaryType       Type = 10
)

func (Type) String

func (t Type) String() string

type Value

type Value interface {
	json.Marshaler
	Type() Type
	String() string
	Compare(other Value) int
	Unwrap() interface{}
	Hash() uint64
	Copy() Value
}

func ParamFrom

func ParamFrom(ctx context.Context, name string) (Value, error)

Jump to

Keyboard shortcuts

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