spec

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ChanOut  = chanOutHandler
	ChanIn   = chanInHandler
	MakeChan = makeChan
	ChanOf   = func(i interface{}) interface{} {
		t, ok := i.(GoTyper)
		if !ok {
			panic(fmt.Sprintf("unknown type: %v", spew.Sdump(i)))
		}
		typeChanOf := reflect.ChanOf(3, t.GoType())
		return GoTypeFunc(typeChanOf)
	}
)
View Source
var (
	GetEx       = dummy2
	SetIndex    = dummySetIndex
	MapInit     = dummyN
	MapFrom     = dummyN
	Map         = dummy2
	Slice       = dummy1
	SliceFrom   = dummyN
	SliceFromTy = dummyN
	StructInit  = dummyN
	SubSlice    = dummy3
	Xor         = dummy2
	Lshr        = dummy2
	Rshr        = dummy2
	BitAnd      = dummy2
	BitOr       = dummy2
	AndNot      = dummy2
	EQ          = dummy2
	GetVar      = dummy2
	Get         = dummyGet
	Add         = dummy2
	Sub         = dummy2
	Mul         = dummy2
	Quo         = dummy2
	Mod         = dummy2
	Inc         = dummy1
	Dec         = dummy1
)
View Source
var (
	// DumpStack indicates to dump stack when error.
	DumpStack = false

	// AutoCall is reserved for internal use.
	AutoCall = make(map[reflect.Type]bool)

	// DontTyNormalize is reserved for internal use.
	DontTyNormalize = make(map[reflect.Type]bool)
)
View Source
var Fntable = map[string]interface{}{
	"$neg":  dummy1,
	"$elem": dummy1,
	"$mul":  dummy2,
	"$quo":  dummy2,
	"$mod":  dummy2,
	"$add":  dummy2,
	"$sub":  dummy2,

	"$xor":    dummy2,
	"$lshr":   dummy2,
	"$rshr":   dummy2,
	"$bitand": dummy2,
	"$bitor":  dummy2,
	"$bitnot": dummy1,
	"$andnot": dummy2,

	"$lt":  dummy2,
	"$gt":  dummy2,
	"$le":  dummy2,
	"$ge":  dummy2,
	"$eq":  dummy2,
	"$ne":  dummy2,
	"$and": dummy2,
	"$or":  dummy2,
	"$not": dummy1,
}

Fntable is function table required by tpl.Interpreter engine.

View Source
var SafeMode bool

SafeMode is the init mode of yak.

View Source
var (
	// Undefined is `undefined` in yak.
	Undefined interface{} = &undefinedType{undefined: true}
)

Functions

func AutoConvert

func AutoConvert(v reflect.Value, t reflect.Type) reflect.Value

AutoConvert converts a value to specified type automatically.

func GoModuleList

func GoModuleList() []string

GoModuleList returns yak modules implemented by Go.

func GoModuleName

func GoModuleName(table map[string]interface{}) (name string, ok bool)

GoModuleName returns name of a yak module.

func Import

func Import(mod string, table map[string]interface{})

Import imports a yak module implemented by Go.

func IsUndefinedType

func IsUndefinedType(val interface{}) bool

func SetAutoCall

func SetAutoCall(t reflect.Type)

SetAutoCall is reserved for internal use.

func SetDontTyNormalize

func SetDontTyNormalize(t reflect.Type)

SetDontTyNormalize is reserved for internal use.

func SetDumpStack

func SetDumpStack(dump bool)

SetDumpStack set to dump stack or not.

Types

type Chan

type Chan struct {
	Data reflect.Value
}

A Chan represents chan class in yak.

type DataIndex

type DataIndex struct {
	Data        interface{}
	Index       interface{}
	DataVerbose string
}

A DataIndex represents a compound data and its index. such as map[index], slice[index], object.member.

type GoTypeAdaptor

type GoTypeAdaptor struct {
	Type reflect.Type
}

func (*GoTypeAdaptor) GoType

func (g *GoTypeAdaptor) GoType() reflect.Type

type GoTyper

type GoTyper interface {
	GoType() reflect.Type
}

GoTyper is required by `yak type` spec.

func GoTypeFunc

func GoTypeFunc(r reflect.Type) GoTyper

type Module

type Module struct {
	Exports map[string]interface{}
}

A Module represents a yak module to be imported.

func (Module) Disable

func (p Module) Disable(fnNames ...string)

Disable disables some export names.

type Type

type Type struct {
	// contains filtered or unexported fields
}

A Type represents a yak builtin type.

func NewType

func NewType(t reflect.Type) *Type

NewType returns a yak builtin type object.

func StructOf

func StructOf(ptr interface{}) *Type

StructOf returns a yak builtin type object.

func TyMapOf

func TyMapOf(key, elem reflect.Type) *Type

TyMapOf represents the `map[key]elem` type.

func TyPtrTo

func TyPtrTo(elem reflect.Type) *Type

TyPtrTo represents the `*T` type.

func TySliceOf

func TySliceOf(elem reflect.Type) *Type

TySliceOf represents the `[]T` type.

func (*Type) Call

func (p *Type) Call(a interface{}) interface{}

Call returns `T(a)`.

func (*Type) GoType

func (p *Type) GoType() reflect.Type

GoType returns the underlying go type. required by `yak type` spec.

func (*Type) NewInstance

func (p *Type) NewInstance(args ...interface{}) interface{}

NewInstance creates a new instance of a yaklang type. required by `yaklang type` spec.

func (*Type) String

func (p *Type) String() string

type TypeEx

type TypeEx struct {
	Call interface{}
	// contains filtered or unexported fields
}

A TypeEx represents a yak builtin type with a cast function.

func NewTypeEx

func NewTypeEx(t reflect.Type, cast interface{}) *TypeEx

NewTypeEx returns a yak builtin type object with a cast function.

func StructOfEx

func StructOfEx(ptr interface{}, cast interface{}) *TypeEx

StructOfEx returns a yak builtin type object with a cast function.

func (*TypeEx) GoType

func (p *TypeEx) GoType() reflect.Type

GoType returns the underlying go type. required by `yak type` spec.

func (*TypeEx) NewInstance

func (p *TypeEx) NewInstance(args ...interface{}) interface{}

NewInstance creates a new instance of a yaklang type. required by `yaklang type` spec.

func (*TypeEx) String

func (p *TypeEx) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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