goatlang

package module
v0.0.0-...-87fb177 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 16 Imported by: 0

README

goatlang

Goatlang is a subset of Go written in Go for scripting in Go

Documentation

Index

Constants

View Source
const (
	TypeNil = Type(0b00000000)

	TypeUint8   = Type(0b00000011)
	TypeInt8    = Type(0b00010011)
	TypeUint32  = Type(0b00000111)
	TypeInt32   = Type(0b00010111)
	TypeFloat64 = Type(0b00011111)

	TypeBool   = Type(0b00100000)
	TypeString = Type(0b01000000)
	TypeObject = Type(0b01100000)

	TypeSlice  = Type(0b10000000)
	TypeMap    = Type(0b10100000)
	TypeFunc   = Type(0b11000000)
	TypeStruct = Type(0b11100000)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Object

type Object interface {
	Get(k Value) (Value, bool)
	Set(k, v Value)
	Len() int
	Range() func() (Value, Value, bool)

	Append(items ...Value) Value
	Delete(k Value)
	Slice(i, j int) Value

	GetAttr(k string) Value
	SetAttr(k string, v Value)
}

type RunOption

type RunOption func(*runConfig)

func WithCodeDump

func WithCodeDump(v io.Writer) RunOption

func WithEvalImports

func WithEvalImports(v map[string]string) RunOption

func WithTreeDump

func WithTreeDump(v io.Writer) RunOption

type Type

type Type int

type VM

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

func New

func New(options ...VMOption) *VM

func (*VM) Call

func (v *VM) Call(name string, xRets int, params ...Value) (rets []Value, err error)

func (*VM) Eval

func (v *VM) Eval(sys fs.FS, fname, input string, options ...RunOption) (rets []Value, err error)

func (*VM) Func

func (v *VM) Func(fnc Value, xRets int, params ...Value) (rets []Value, err error)

func (*VM) Get

func (v *VM) Get(key string) Value

func (*VM) Load

func (v *VM) Load(sys fs.FS, arg string, options ...RunOption) error

func (*VM) Set

func (v *VM) Set(key string, value Value)

func (*VM) Yield

func (v *VM) Yield()

type VMOption

type VMOption func(*vmConfig)

func WithLoaders

func WithLoaders(v ...func(*VM)) VMOption

func WithStdout

func WithStdout(v io.Writer) VMOption

type Value

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

func Bool

func Bool(v bool) Value

func Byte

func Byte(v byte) Value

func Error

func Error(err error) Value

func Float64

func Float64(v float64) Value

func Int

func Int(v int) Value

func Int32

func Int32(v int32) Value

func Int8

func Int8(v int8) Value

func NewFunc

func NewFunc[F func(vm *VM) | func(vm *VM) Value | func(vm *VM, args []Value) | func(v *VM, args []Value) Value | func(v *VM, args []Value) []Value | func(v *VM, args []Value, vargs ...Value) []Value](argc, rets int, fnc F) (res Value)

func NewMap

func NewMap(keyType, valueType Type, in []Value) Value

func NewSlice

func NewSlice(valueType Type, data []Value) Value

func NewStruct

func NewStruct(base Value, data []Value) Value

func Nil

func Nil() Value

func String

func String(v string) Value

func Uint

func Uint(v uint) Value

func Uint32

func Uint32(v uint32) Value

func Uint8

func Uint8(v uint8) Value

func Wrap

func Wrap(o Object) Value

func (Value) Append

func (v Value) Append(items ...Value) Value

func (Value) Bool

func (v Value) Bool() bool

func (Value) Byte

func (v Value) Byte() byte

func (Value) Delete

func (v Value) Delete(key Value)

func (Value) Equals

func (v Value) Equals(b Value) bool

func (Value) Float64

func (v Value) Float64() float64

func (Value) Get

func (v Value) Get(key Value) (Value, bool)

func (Value) GetAttr

func (v Value) GetAttr(key string) Value

func (Value) Int

func (v Value) Int() int

func (Value) Int32

func (v Value) Int32() int32

func (Value) Int8

func (v Value) Int8() int8

func (Value) IsNil

func (v Value) IsNil() bool

func (Value) Len

func (v Value) Len() int

func (Value) Range

func (v Value) Range() func() (Value, Value, bool)

func (Value) Set

func (v Value) Set(key, value Value)

func (Value) SetAttr

func (v Value) SetAttr(key string, value Value)

func (Value) Slice

func (v Value) Slice(i, j int) Value

func (Value) String

func (v Value) String() string

func (Value) Type

func (v Value) Type() Type

func (Value) Uint

func (v Value) Uint() uint

func (Value) Uint32

func (v Value) Uint32() uint32

func (Value) Uint8

func (v Value) Uint8() uint8

func (Value) Unwrap

func (v Value) Unwrap() Object

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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