values

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CBORTagVoidValue = CBORTagBase + iota

	CBORTagSomeValue
	CBORTagAddressValue
	CBORTagCompositeValue
	CBORTagTypeValue

	CBORTagStringValue
	CBORTagCharacterValue
	CBORTagSomeValueWithNestedLevels

	// Int*
	CBORTagIntValue
	CBORTagInt8Value
	CBORTagInt16Value
	CBORTagInt32Value
	CBORTagInt64Value
	CBORTagInt128Value
	CBORTagInt256Value

	// UInt*
	CBORTagUIntValue
	CBORTagUInt8Value
	CBORTagUInt16Value
	CBORTagUInt32Value
	CBORTagUInt64Value
	CBORTagUInt128Value
	CBORTagUInt256Value

	CBORTagWord8Value
	CBORTagWord16Value
	CBORTagWord32Value
	CBORTagWord64Value
	CBORTagWord128Value
	CBORTagWord256Value

	CBORTagFix64Value
	CBORTagFix128Value

	CBORTagUFix64Value
	CBORTagUFix128Value

	// Locations
	CBORTagAddressLocation
	CBORTagStringLocation
	CBORTagIdentifierLocation
	CBORTagTransactionLocation
	CBORTagScriptLocation

	CBORTagPathValue
	// Deprecated: CBORTagPathCapabilityValue
	CBORTagPathCapabilityValue

	// Deprecated: CBORTagPathLinkValue
	CBORTagPathLinkValue
	CBORTagPublishedValue
	// Deprecated: CBORTagAccountLinkValue
	CBORTagAccountLinkValue
	CBORTagStorageCapabilityControllerValue
	CBORTagAccountCapabilityControllerValue
	CBORTagCapabilityValue

	// Static Types
	CBORTagPrimitiveStaticType
	CBORTagCompositeStaticType
	CBORTagInterfaceStaticType
	CBORTagVariableSizedStaticType
	CBORTagConstantSizedStaticType
	CBORTagDictionaryStaticType
	CBORTagOptionalStaticType
	CBORTagReferenceStaticType
	CBORTagIntersectionStaticType
	CBORTagCapabilityStaticType
	CBORTagUnauthorizedStaticAuthorization
	CBORTagEntitlementMapStaticAuthorization
	CBORTagEntitlementSetStaticAuthorization
	CBORTagInaccessibleStaticAuthorization

	CBORTagInclusiveRangeStaticType

	// !!! *WARNING* !!!
	// ADD NEW TYPES *BEFORE* THIS WARNING.
	// DO *NOT* ADD NEW TYPES AFTER THIS LINE!
	CBORTag_Count
)
View Source
const CBORTagBase = 128
View Source
const CBORTagSize = 2
View Source
const FalseValue = BoolValue(false)
View Source
const TrueValue = BoolValue(true)

Variables

This section is empty.

Functions

func BigEndianBytesToSignedBigInt

func BigEndianBytesToSignedBigInt(b []byte) *big.Int

func BigEndianBytesToUnsignedBigInt

func BigEndianBytesToUnsignedBigInt(b []byte) *big.Int

func GetBigIntCBORSize

func GetBigIntCBORSize(v *big.Int) uint32

func GetBytesCBORSize

func GetBytesCBORSize(b []byte) uint32

func GetIntCBORSize

func GetIntCBORSize(v int64) uint32

func GetUintCBORSize

func GetUintCBORSize(v uint64) uint32

func MaybeLargeImmutableStorable

func MaybeLargeImmutableStorable(
	storable atree.Storable,
	storage atree.SlabStorage,
	address atree.Address,
	maxInlineSize uint32,
) (
	atree.Storable,
	error,
)

MaybeLargeImmutableStorable either returns the given immutable atree.Storable if it can be stored inline inside its parent container, or else stores it in a separate slab and returns an atree.SlabIDStorable.

func SafeAddUint64

func SafeAddUint64(a, b uint64) (uint64, error)

func SignedBigIntToBigEndianBytes

func SignedBigIntToBigEndianBytes(bigInt *big.Int) []byte

func SignedBigIntToSizedBigEndianBytes

func SignedBigIntToSizedBigEndianBytes(bigInt *big.Int, sizeInBytes uint) []byte

func UnsignedBigIntToBigEndianBytes

func UnsignedBigIntToBigEndianBytes(bigInt *big.Int) []byte

func UnsignedBigIntToSizedBigEndianBytes

func UnsignedBigIntToSizedBigEndianBytes(bigInt *big.Int, sizeInBytes uint) []byte

Types

type BoolValue

type BoolValue bool

func (BoolValue) ByteSize

func (v BoolValue) ByteSize() uint32

func (BoolValue) ChildStorables

func (BoolValue) ChildStorables() []atree.Storable

func (BoolValue) Encode

func (v BoolValue) Encode(e *atree.Encoder) error

Encode encodes the value as a CBOR bool

func (BoolValue) Equal

func (v BoolValue) Equal(_ common.Gauge, other Value) bool

func (BoolValue) Greater

func (v BoolValue) Greater(_ common.Gauge, other BoolValue) bool

func (BoolValue) GreaterEqual

func (v BoolValue) GreaterEqual(_ common.Gauge, other BoolValue) bool

func (BoolValue) IsValue

func (BoolValue) IsValue()

func (BoolValue) Less

func (v BoolValue) Less(_ common.Gauge, other BoolValue) bool

func (BoolValue) LessEqual

func (v BoolValue) LessEqual(_ common.Gauge, other BoolValue) bool

func (BoolValue) Negate

func (v BoolValue) Negate() BoolValue

func (BoolValue) Storable

func (BoolValue) StoredValue

func (v BoolValue) StoredValue(_ atree.SlabStorage) (atree.Value, error)

func (BoolValue) String

func (v BoolValue) String() string

type ComparableValue

type ComparableValue[T Value] interface {
	EquatableValue
	Less(gauge common.Gauge, other T) bool
	LessEqual(gauge common.Gauge, other T) bool
	Greater(gauge common.Gauge, other T) bool
	GreaterEqual(gauge common.Gauge, other T) bool
}

type DivisionByZeroError

type DivisionByZeroError struct{}

func (DivisionByZeroError) Error

func (DivisionByZeroError) Error() string

func (DivisionByZeroError) IsUserError

func (DivisionByZeroError) IsUserError()

type EquatableValue

type EquatableValue interface {
	Value
	Equal(gauge common.Gauge, other Value) bool
}

type FixedPointValue

type FixedPointValue[T Value, U uint64 | int64] interface {
	NumberValue[T]
	IntegerPart() U
	Scale() int
}

FixedPointValue is a fixed-point number value

type IntValue

type IntValue struct {
	BigInt *big.Int
}

func NewIntValueFromBigInt

func NewIntValueFromBigInt(
	memoryGauge common.MemoryGauge,
	memoryUsage common.MemoryUsage,
	bigIntConstructor func() *big.Int,
) IntValue

func NewIntValueFromInt64

func NewIntValueFromInt64(memoryGauge common.MemoryGauge, value int64) IntValue

func NewUnmeteredIntValueFromBigInt

func NewUnmeteredIntValueFromBigInt(value *big.Int) IntValue

func NewUnmeteredIntValueFromInt64

func NewUnmeteredIntValueFromInt64(value int64) IntValue

func (IntValue) BitwiseAnd

func (v IntValue) BitwiseAnd(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) BitwiseLeftShift

func (v IntValue) BitwiseLeftShift(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) BitwiseOr

func (v IntValue) BitwiseOr(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) BitwiseRightShift

func (v IntValue) BitwiseRightShift(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) BitwiseXor

func (v IntValue) BitwiseXor(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) ByteSize

func (v IntValue) ByteSize() uint32

func (IntValue) ChildStorables

func (IntValue) ChildStorables() []atree.Storable

func (IntValue) Div

func (v IntValue) Div(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) Encode

func (v IntValue) Encode(e *atree.Encoder) error

Encode encodes the value as

cbor.Tag{
		Number:  CBORTagIntValue,
		Content: *big.Int(v.BigInt),
}

func (IntValue) Equal

func (v IntValue) Equal(gauge common.Gauge, other Value) bool

func (IntValue) Greater

func (v IntValue) Greater(gauge common.Gauge, other IntValue) bool

func (IntValue) GreaterEqual

func (v IntValue) GreaterEqual(gauge common.Gauge, other IntValue) bool

func (IntValue) IsValue

func (IntValue) IsValue()

func (IntValue) Less

func (v IntValue) Less(gauge common.Gauge, other IntValue) bool

func (IntValue) LessEqual

func (v IntValue) LessEqual(gauge common.Gauge, other IntValue) bool

func (IntValue) Minus

func (v IntValue) Minus(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) Mod

func (v IntValue) Mod(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) Mul

func (v IntValue) Mul(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) Negate

func (v IntValue) Negate(gauge common.Gauge) IntValue

func (IntValue) Plus

func (v IntValue) Plus(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) SaturatingDiv

func (v IntValue) SaturatingDiv(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) SaturatingMinus

func (v IntValue) SaturatingMinus(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) SaturatingMul

func (v IntValue) SaturatingMul(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) SaturatingPlus

func (v IntValue) SaturatingPlus(gauge common.Gauge, other IntValue) (IntValue, error)

func (IntValue) Storable

func (v IntValue) Storable(storage atree.SlabStorage, address atree.Address, maxInlineSize uint32) (atree.Storable, error)

func (IntValue) StoredValue

func (v IntValue) StoredValue(_ atree.SlabStorage) (atree.Value, error)

func (IntValue) String

func (v IntValue) String() string

func (IntValue) ToBigEndianBytes

func (v IntValue) ToBigEndianBytes() []byte

func (IntValue) ToInt

func (v IntValue) ToInt() (int, error)

type IntegerValue

type IntegerValue[T Value] interface {
	NumberValue[T]
	BitwiseOr(gauge common.Gauge, other T) (T, error)
	BitwiseXor(gauge common.Gauge, other T) (T, error)
	BitwiseAnd(gauge common.Gauge, other T) (T, error)
	BitwiseLeftShift(gauge common.Gauge, other T) (T, error)
	BitwiseRightShift(gauge common.Gauge, other T) (T, error)
}

type InvalidOperandsError

type InvalidOperandsError struct{}

func (InvalidOperandsError) Error

func (InvalidOperandsError) Error() string

func (InvalidOperandsError) IsUserError

func (InvalidOperandsError) IsUserError()

type NegativeShiftError

type NegativeShiftError struct{}

func (NegativeShiftError) Error

func (NegativeShiftError) Error() string

func (NegativeShiftError) IsUserError

func (NegativeShiftError) IsUserError()

type NumberValue

type NumberValue[T Value] interface {
	ComparableValue[T]
	ToInt() (int, error)
	Negate(gauge common.Gauge) T
	Plus(gauge common.Gauge, other T) (T, error)
	SaturatingPlus(gauge common.Gauge, other T) (T, error)
	Minus(gauge common.Gauge, other T) (T, error)
	SaturatingMinus(gauge common.Gauge, other T) (T, error)
	Mod(gauge common.Gauge, other T) (T, error)
	Mul(gauge common.Gauge, other T) (T, error)
	SaturatingMul(gauge common.Gauge, other T) (T, error)
	Div(gauge common.Gauge, other T) (T, error)
	SaturatingDiv(gauge common.Gauge, other T) (T, error)
	ToBigEndianBytes() []byte
}

type OverflowError

type OverflowError struct{}

func (OverflowError) Error

func (OverflowError) Error() string

func (OverflowError) IsUserError

func (OverflowError) IsUserError()

type UFix64Value

type UFix64Value uint64

func NewUFix64Value

func NewUFix64Value(gauge common.MemoryGauge, constructor func() (uint64, error)) (UFix64Value, error)

func NewUFix64ValueWithInteger

func NewUFix64ValueWithInteger(gauge common.MemoryGauge, constructor func() (uint64, error)) (UFix64Value, error)

func NewUnmeteredUFix64Value

func NewUnmeteredUFix64Value(integer uint64) UFix64Value

func NewUnmeteredUFix64ValueWithInteger

func NewUnmeteredUFix64ValueWithInteger(integer uint64) (UFix64Value, error)

func (UFix64Value) ByteSize

func (v UFix64Value) ByteSize() uint32

func (UFix64Value) ChildStorables

func (UFix64Value) ChildStorables() []atree.Storable

func (UFix64Value) Div

func (v UFix64Value) Div(gauge common.Gauge, other UFix64Value) (UFix64Value, error)

func (UFix64Value) Encode

func (v UFix64Value) Encode(e *atree.Encoder) error

Encode encodes UFix64Value as

cbor.Tag{
		Number:  CBORTagUFix64Value,
		Content: uint64(v),
}

func (UFix64Value) Equal

func (v UFix64Value) Equal(_ common.Gauge, other Value) bool

func (UFix64Value) Greater

func (v UFix64Value) Greater(_ common.Gauge, other UFix64Value) bool

func (UFix64Value) GreaterEqual

func (v UFix64Value) GreaterEqual(_ common.Gauge, other UFix64Value) bool

func (UFix64Value) IntegerPart

func (v UFix64Value) IntegerPart() uint64

func (UFix64Value) IsValue

func (UFix64Value) IsValue()

func (UFix64Value) Less

func (v UFix64Value) Less(_ common.Gauge, other UFix64Value) bool

func (UFix64Value) LessEqual

func (v UFix64Value) LessEqual(_ common.Gauge, other UFix64Value) bool

func (UFix64Value) Minus

func (v UFix64Value) Minus(gauge common.Gauge, other UFix64Value) (UFix64Value, error)

func (UFix64Value) Mod

func (v UFix64Value) Mod(gauge common.Gauge, other UFix64Value) (UFix64Value, error)

func (UFix64Value) Mul

func (v UFix64Value) Mul(gauge common.Gauge, other UFix64Value) (UFix64Value, error)

func (UFix64Value) Negate

func (v UFix64Value) Negate(_ common.Gauge) UFix64Value

func (UFix64Value) Plus

func (v UFix64Value) Plus(gauge common.Gauge, other UFix64Value) (UFix64Value, error)

func (UFix64Value) SaturatingDiv

func (v UFix64Value) SaturatingDiv(_ common.Gauge, _ UFix64Value) (UFix64Value, error)

func (UFix64Value) SaturatingMinus

func (v UFix64Value) SaturatingMinus(gauge common.Gauge, other UFix64Value) (UFix64Value, error)

func (UFix64Value) SaturatingMul

func (v UFix64Value) SaturatingMul(gauge common.Gauge, other UFix64Value) (UFix64Value, error)

func (UFix64Value) SaturatingPlus

func (v UFix64Value) SaturatingPlus(gauge common.Gauge, other UFix64Value) (UFix64Value, error)

func (UFix64Value) Scale

func (UFix64Value) Scale() int

func (UFix64Value) Storable

func (UFix64Value) StoredValue

func (v UFix64Value) StoredValue(_ atree.SlabStorage) (atree.Value, error)

func (UFix64Value) String

func (v UFix64Value) String() string

func (UFix64Value) ToBigEndianBytes

func (v UFix64Value) ToBigEndianBytes() []byte

func (UFix64Value) ToInt

func (v UFix64Value) ToInt() (int, error)

type UnderflowError

type UnderflowError struct{}

func (UnderflowError) Error

func (UnderflowError) Error() string

func (UnderflowError) IsUserError

func (UnderflowError) IsUserError()

type Value

type Value interface {
	IsValue()
	fmt.Stringer
}

Jump to

Keyboard shortcuts

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