prim

package
v0.0.0-...-79395b0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package prim contains primitive types used in the epxressions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean struct {
	Value bool
}

func NewBoolean

func NewBoolean(val bool) *Boolean

func (*Boolean) Binary

func (n *Boolean) Binary(o Primitive, op Operation) (Primitive, error)

func (*Boolean) Get

func (n *Boolean) Get() interface{}

func (*Boolean) Unary

func (n *Boolean) Unary(op Operation) (Primitive, error)

type Number

type Number struct {
	Value  uint64
	Size   int
	Signed bool
}

func NewNumber

func NewNumber(val uint64, size int, signed bool) *Number

func (*Number) Binary

func (n *Number) Binary(o Primitive, op Operation) (Primitive, error)

func (Number) Clone

func (n Number) Clone() *Number

func (*Number) Get

func (n *Number) Get() interface{}

func (*Number) Set

func (n *Number) Set(val uint64) *Number

func (*Number) Unary

func (n *Number) Unary(op Operation) (Primitive, error)

type Operation

type Operation int
const (
	// arith
	ADD Operation = iota
	SUB
	MUL
	DIV
	MOD

	// logic and shift/rotate
	AND
	OR
	XOR

	LSL
	LSR

	// compare
	EQ
	NE
	LT
	GT
	LE
	GE

	// logic
	BAND
	BOR
	BXOR

	// unary
	INV
	NEG
)

func RuneToOperation

func RuneToOperation(r rune) Operation

func StringToOperation

func StringToOperation(s string) Operation

func (Operation) String

func (o Operation) String() string

type Primitive

type Primitive interface {
	Get() interface{}
	Binary(o Primitive, op Operation) (Primitive, error)
	Unary(op Operation) (Primitive, error)
}

func ValueToPrimitive

func ValueToPrimitive(i interface{}) Primitive

type String

type String struct {
	Value []byte
}

func NewString

func NewString(str string) *String

func NewStringRaw

func NewStringRaw(val []byte) *String

func (*String) Binary

func (n *String) Binary(o Primitive, op Operation) (Primitive, error)

func (String) Clone

func (n String) Clone() *String

func (*String) Get

func (n *String) Get() interface{}

func (*String) Set

func (n *String) Set(data []byte)

func (*String) SetString

func (n *String) SetString(s string)

func (String) String

func (n String) String() string

func (*String) Unary

func (n *String) Unary(op Operation) (Primitive, error)

Jump to

Keyboard shortcuts

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