value

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MaxKinds = 24

MaxKinds = 24 (Tối ưu cho CPU Cache và BCE)

Variables

View Source
var (
	NULL  = NewNull()
	TRUE  = NewBool(true)
	FALSE = NewBool(false)
)
View Source
var Methods = func() [MaxKinds]map[string]Method {
	var m [MaxKinds]map[string]Method
	for i := 0; i < MaxKinds; i++ {
		m[i] = make(map[string]Method)
	}
	return m
}()

Methods lưu trữ phương thức động (cho phép người dùng mở rộng sau này)

Functions

This section is empty.

Types

type Kind

type Kind uint8

Kind represents the underlying data type discriminator.

const (
	Invalid Kind = iota // Internal error or uninitialized
	Nil                 // Null / undefined

	// --- Scalar Types (Fast-path, data stored in N) ---
	Number
	Bool
	Time
	Duration

	// --- Reference Types (Slow-path, data stored in V) ---
	String
	Bytes
	Map
	Array

	// --- Complex Types ---
	Struct
	Func
	Any

	Return
	Proxy
)

func (Kind) Method

func (k Kind) Method(name string) (Method, bool)

Method tìm kiếm phương thức: Sử dụng Method Expressions để đạt hiệu năng tối đa

func (Kind) Prototype

func (k Kind) Prototype(name string, fn Method)

Prototype cho phép đăng ký phương thức động từ bên ngoài

func (Kind) String

func (k Kind) String() string

type Lambda added in v0.1.1

type Lambda struct {
	Address int
	Params  []string
	Scope   map[string]Value
}

type Method

type Method func(target Value, args ...Value) Value

Method đại diện cho hàm thực thi: target.method(args...)

type ProxyHandler

type ProxyHandler interface {
	OnGet(key string) Value
	OnCompare(op string, other Value) Value
	OnInvoke(method string, args ...Value) Value
}

ProxyHandler cho phép các module khác nhau định nghĩa cách xử lý logic biểu tượng

type Value

type Value struct {
	N float64
	V any
	K Kind
}

func New

func New(i any) Value

func NewBool

func NewBool(b bool) Value

NewBool - Tận dụng hàm ToBool hoặc New(bool) bạn đã viết

func NewFunc

func NewFunc(fn func(args ...Value) Value) Value

func NewNil

func NewNil() Value

func NewNull

func NewNull() Value

NewNull - Khớp với giá trị Nil trong gói của bạn

func NewString

func NewString(s string) Value

NewString - Đã có hàm New(any) trong gói value xử lý cực tốt

func Parse

func Parse(i any) Value

func ParseNumber

func ParseNumber(s string) Value

ParseNumber - Chuyển chuỗi thành số thực, nạp vào trường N

func ToBool

func ToBool(b bool) Value

func (Value) Add

func (a Value) Add(others ...Value) Value

func (Value) Append

func (v Value) Append(b []byte) []byte

func (Value) Array

func (v Value) Array() []Value

func (Value) AsBytes

func (v Value) AsBytes() []byte

AsBytes provides a zero-copy read-only view into string data.

func (Value) At

func (v Value) At(path ...any) Value

At allows deep path traversal

func (Value) ByteSlice

func (v Value) ByteSlice() []byte

func (Value) Bytes

func (v Value) Bytes() []byte

func (Value) Call

func (v Value) Call(name string, args ...Value) Value

func (Value) Capitalize added in v0.1.1

func (v Value) Capitalize(_ ...Value) Value

func (Value) Compact added in v0.1.1

func (v Value) Compact(_ ...Value) Value

func (Value) Delete

func (v Value) Delete(args ...Value) Value

func (Value) Div

func (a Value) Div(b Value) Value

func (Value) EndsWith

func (v Value) EndsWith(args ...Value) Value

func (Value) Equal

func (a Value) Equal(b Value) bool

Deep equality

func (Value) Extend

func (a Value) Extend(b Value) Value

func (Value) First added in v0.1.1

func (v Value) First() Value

func (Value) Float

func (v Value) Float() float64

func (Value) Get

func (v Value) Get(key string) Value

func (Value) Greater

func (a Value) Greater(b Value) bool

func (Value) GreaterEqual

func (a Value) GreaterEqual(b Value) bool

func (Value) Has

func (v Value) Has(args ...Value) Value

func (Value) Includes

func (v Value) Includes(args ...Value) Value

func (Value) Index

func (v Value) Index(i int) Value

func (Value) Int

func (v Value) Int() int

func (Value) Int64 added in v0.1.1

func (v Value) Int64() int64

func (Value) Integer

func (v Value) Integer(_ ...Value) Value

func (Value) Interface

func (v Value) Interface() any

func (Value) Invoke

func (v Value) Invoke(name string, args ...Value) Value

func (Value) IsArray

func (v Value) IsArray() bool

func (Value) IsBlank

func (v Value) IsBlank() bool

func (Value) IsBool

func (v Value) IsBool() bool

func (Value) IsBytes

func (v Value) IsBytes() bool

func (Value) IsCallable

func (v Value) IsCallable() bool

func (Value) IsImmediate

func (v Value) IsImmediate() bool

func (Value) IsInvalid

func (v Value) IsInvalid() bool

func (Value) IsIterable

func (v Value) IsIterable() bool

func (Value) IsMap

func (v Value) IsMap() bool

func (Value) IsNil

func (v Value) IsNil() bool

func (Value) IsNumber added in v0.1.1

func (v Value) IsNumber() bool

func (Value) IsNumeric

func (v Value) IsNumeric() bool

func (Value) IsObject

func (v Value) IsObject() bool

func (Value) IsReference

func (v Value) IsReference() bool

func (Value) IsReturn

func (v Value) IsReturn() bool

func (Value) IsScalar

func (v Value) IsScalar() bool

func (Value) IsString

func (v Value) IsString() bool

func (Value) IsTrue

func (v Value) IsTrue() bool

func (Value) IsValid

func (v Value) IsValid() bool

func (Value) ItemAt added in v0.1.1

func (v Value) ItemAt(args ...Value) Value

func (Value) Join

func (v Value) Join(args ...Value) Value

func (Value) Keys

func (v Value) Keys(_ ...Value) Value

func (Value) Last added in v0.1.1

func (v Value) Last() Value

func (Value) Len

func (v Value) Len() int

func (Value) Length

func (v Value) Length(_ ...Value) Value

func (Value) Less

func (a Value) Less(b Value) bool

func (Value) LessEqual

func (a Value) LessEqual(b Value) bool

func (Value) Lower

func (v Value) Lower(_ ...Value) Value

func (Value) Map

func (v Value) Map() map[string]Value

func (Value) MarshalJSON added in v0.1.1

func (v Value) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Value. This ensures that when a Value is marshaled, it outputs its actual content (e.g. string, number) rather than the internal struct fields (N, V, K, S). This enables critical performance optimizations by avoiding the need to convert the entire structure to interface{} (map[string]any) before marshaling.

func (Value) Merge added in v0.1.1

func (v Value) Merge(args ...Value) Value

func (Value) Method

func (v Value) Method(name string) (Method, bool)

func (Value) Mod added in v0.1.1

func (a Value) Mod(b Value) Value

func (Value) Mul

func (a Value) Mul(b Value) Value

func (Value) NotEqual

func (a Value) NotEqual(b Value) bool

func (Value) One added in v0.1.1

func (v Value) One() Value

func (Value) Pop

func (v Value) Pop(_ ...Value) Value

func (Value) Prototype

func (v Value) Prototype(name string, fn Method)

func (Value) Push

func (v Value) Push(args ...Value) Value

func (Value) Random added in v0.1.1

func (v Value) Random(args ...Value) Value

func (Value) Replace

func (v Value) Replace(args ...Value) Value

func (Value) Reverse

func (v Value) Reverse(_ ...Value) Value

func (*Value) Scan added in v0.1.1

func (v *Value) Scan(src any) error

Scan implements the database/sql.Scanner interface. This allows reading SQL results directly into a Value object.

func (Value) Set

func (v Value) Set(key string, val Value)

func (Value) Shift

func (v Value) Shift(_ ...Value) Value

func (Value) Shuffle added in v0.1.1

func (v Value) Shuffle(_ ...Value) Value

func (Value) Split

func (v Value) Split(args ...Value) Value

func (Value) StartsWith

func (v Value) StartsWith(args ...Value) Value

func (Value) String

func (v Value) String() string

func (Value) Sub

func (a Value) Sub(b Value) Value

func (Value) Text

func (v Value) Text() string

func (Value) To added in v0.1.1

func (v Value) To(target any) error

To maps the Value into a Go target (must be a pointer)

func (Value) ToFloat

func (v Value) ToFloat(_ ...Value) Value

func (Value) ToJSON

func (v Value) ToJSON() []byte

func (Value) ToJson

func (v Value) ToJson(args ...Value) Value

func (Value) ToString

func (v Value) ToString(args ...Value) Value

func (Value) Trim

func (v Value) Trim(_ ...Value) Value

func (Value) Truthy

func (v Value) Truthy() bool

Truthy evaluates logical truthiness: - Scalars: N > 0 - Objects: non-nil

func (Value) Unique added in v0.1.1

func (v Value) Unique(_ ...Value) Value

func (*Value) UnmarshalJSON added in v0.1.1

func (v *Value) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

func (Value) Unshift

func (v Value) Unshift(args ...Value) Value

func (Value) Upper

func (v Value) Upper(_ ...Value) Value

func (Value) Value added in v0.1.1

func (v Value) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface. This allowing Value objects to be used directly in SQL queries.

Jump to

Keyboard shortcuts

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