conf

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldName added in v1.10.0

func FieldName(field reflect.StructField) string

func FindSuitableOperatorOverload

func FindSuitableOperatorOverload(fns []string, types TypesTable, l, r reflect.Type) (reflect.Type, string, bool)

Types

type Config

type Config struct {
	Env         any
	Types       TypesTable
	MapEnv      bool
	DefaultType reflect.Type
	Operators   OperatorsTable
	Expect      reflect.Kind
	ExpectAny   bool
	Optimize    bool
	Strict      bool
	ConstFns    map[string]reflect.Value
	Visitors    []ast.Visitor
	Functions   map[string]*ast.Function
	Builtins    map[string]*ast.Function
	Disabled    map[string]bool // disabled builtins
}

func CreateNew added in v1.11.0

func CreateNew() *Config

CreateNew creates new config with default values.

func New

func New(env any) *Config

New creates new config with environment.

func (*Config) Check

func (c *Config) Check()

func (*Config) ConstExpr

func (c *Config) ConstExpr(name string)

func (*Config) Operator added in v1.10.0

func (c *Config) Operator(operator string, fns ...string)

func (*Config) WithEnv added in v1.10.0

func (c *Config) WithEnv(env any)

type OperatorPatcher added in v1.10.0

type OperatorPatcher struct {
	Operators OperatorsTable
	Types     TypesTable
}

func (*OperatorPatcher) Visit added in v1.10.0

func (p *OperatorPatcher) Visit(node *ast.Node)

type OperatorsTable

type OperatorsTable map[string][]string

OperatorsTable maps binary operators to corresponding list of functions. Functions should be provided in the environment to allow operator overloading.

type Tag

type Tag struct {
	Type        reflect.Type
	Ambiguous   bool
	FieldIndex  []int
	Method      bool
	MethodIndex int
}

type TypesTable

type TypesTable map[string]Tag

func CreateTypesTable

func CreateTypesTable(i any) TypesTable

CreateTypesTable creates types table for type checks during parsing. If struct is passed, all fields will be treated as variables, as well as all fields of embedded structs and struct itself.

If map is passed, all items will be treated as variables (key as name, value as type).

func FieldsFromStruct

func FieldsFromStruct(t reflect.Type) TypesTable

Jump to

Keyboard shortcuts

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