eval

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilExprNode     = errors.New("nil expr node")
	ErrValNotValid     = errors.New("value not valid")
	ErrInvalidCallNode = errors.New("invalid call node")
)

Functions

func ConvParamToType

func ConvParamToType(rType reflect.Type, input string) (val reflect.Value, err error)

ConvParamToType 转换函数所有参数类型

func ParseBaseKindToType

func ParseBaseKindToType(rType reflect.Type, input string) (val reflect.Value, err error)

ParseBaseKindToType 转换函数所有参数类型

func ParseCallExprArgs

func ParseCallExprArgs(call *ast.CallExpr) ([]string, error)

ParseCallExprArgs 解析call表达式的参数列表

func ParseInputArgs

func ParseInputArgs(fnType reflect.Type, args []string) (result []reflect.Value, err error)

ParseInputArgs 解析传参

Types

type Context

type Context struct {
	This     any
	Expr     string
	ReadOnly bool
	Nodes    []*Node
}

func NewContext

func NewContext(this any) *Context

func (*Context) Delete

func (c *Context) Delete(expr string) error

Delete 删除 a[X]

func (*Context) Eval

func (c *Context) Eval(expr string) (any, error)

Eval 在`this`上,返回其`expr`对应的值

func (*Context) PrintNodes

func (c *Context) PrintNodes(w io.Writer)

func (*Context) Set

func (c *Context) Set(expr string, v any) error

Set 在`this`上,设置v到对应`expr`

type Node

type Node struct {
	Key string
	Val reflect.Value
}

Jump to

Keyboard shortcuts

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