values

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VERBOSITY = 0

Functions

func IsAny

func IsAny(v_ Value) bool

func IsClass

func IsClass(v_ Value) bool

func IsInstance

func IsInstance(v_ Value) bool

func IsLiteral

func IsLiteral(v_ Value) bool

func PrototypeIsAncestorOf

func PrototypeIsAncestorOf(parent Prototype, child Prototype) bool

Types

type Any

type Any struct {
	ValueData
}

func (*Any) Check

func (v *Any) Check(other Value, ctx context.Context) error

func (*Any) EvalConstructor

func (v *Any) EvalConstructor(args []Value, ctx context.Context) (Value, error)

func (*Any) EvalFunction

func (v *Any) EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error)

func (*Any) GetMember

func (v *Any) GetMember(key string, includePrivate bool, ctx context.Context) (Value, error)

func (*Any) SetMember

func (v *Any) SetMember(key string, includePrivate bool, arg Value, ctx context.Context) error

func (*Any) TypeName

func (v *Any) TypeName() string

type Class

type Class struct {
	ValueData
	// contains filtered or unexported fields
}

func NewClass

func NewClass(args [][]Value, interf Interface, ctx context.Context) *Class

func NewCustomClass

func NewCustomClass(args [][]Value, fn func(args []Value, ctx_ context.Context) (Interface, error), ctx context.Context) *Class

func NewUnconstructableClass

func NewUnconstructableClass(interf Interface, ctx context.Context) *Class

func (*Class) Check

func (v *Class) Check(other_ Value, ctx context.Context) error

maybe it is a little silly that GetType always needs to be called

func (*Class) EvalConstructor

func (v *Class) EvalConstructor(args []Value, ctx context.Context) (Value, error)

func (*Class) EvalFunction

func (v *Class) EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error)

func (*Class) GetConstructorArgs

func (v *Class) GetConstructorArgs() [][]Value

func (*Class) GetMember

func (v *Class) GetMember(key string, includePrivate bool,
	ctx context.Context) (Value, error)

func (*Class) SetMember

func (v *Class) SetMember(key string, includePrivate bool, arg Value,
	ctx context.Context) error

func (*Class) TypeName

func (v *Class) TypeName() string

type ContextValue

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

give a different context to a value

func (*ContextValue) Check

func (v *ContextValue) Check(v_ Value, ctx context.Context) error

func (*ContextValue) Context

func (v *ContextValue) Context() context.Context

func (*ContextValue) EvalConstructor

func (v *ContextValue) EvalConstructor(args []Value, ctx context.Context) (Value, error)

func (*ContextValue) EvalFunction

func (v *ContextValue) EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error)

func (*ContextValue) GetMember

func (v *ContextValue) GetMember(key string, includePrivate bool,
	ctx context.Context) (Value, error)

func (*ContextValue) LiteralBooleanValue

func (v *ContextValue) LiteralBooleanValue() (bool, bool)

func (*ContextValue) LiteralIntValue

func (v *ContextValue) LiteralIntValue() (int, bool)

func (*ContextValue) LiteralStringValue

func (v *ContextValue) LiteralStringValue() (string, bool)

func (*ContextValue) SetMember

func (v *ContextValue) SetMember(key string, includePrivate bool, arg Value,
	ctx context.Context) error

func (*ContextValue) TypeName

func (v *ContextValue) TypeName() string

type Enum

type Enum struct {
	ValueData
	// contains filtered or unexported fields
}

func NewEnum

func NewEnum(proto Prototype, ctx context.Context) *Enum

func (*Enum) Check

func (v *Enum) Check(other_ Value, ctx context.Context) error

func (*Enum) EvalConstructor

func (v *Enum) EvalConstructor(args []Value, ctx context.Context) (Value, error)

func (*Enum) EvalFunction

func (v *Enum) EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error)

func (*Enum) GetMember

func (v *Enum) GetMember(key string, includePrivate bool,
	ctx context.Context) (Value, error)

func (*Enum) SetMember

func (v *Enum) SetMember(key string, includePrivate bool, arg Value,
	ctx context.Context) error

func (*Enum) TypeName

func (v *Enum) TypeName() string

type Function

type Function struct {
	ValueData
	// contains filtered or unexported fields
}

func NewCustomFunction

func NewCustomFunction(args []Value, fn func(args []Value, preferMethod bool, ctx_ context.Context) (Value, error), ctx context.Context) *Function

args dont contain return value in case fn is defined

func NewFunction

func NewFunction(argsAndRet []Value, ctx context.Context) *Function

func NewMethodLikeFunction

func NewMethodLikeFunction(argsAndRet []Value, ctx context.Context) *Function

func NewOverloadedCustomFunction

func NewOverloadedCustomFunction(args [][]Value, fn func(args []Value, preferMethod bool, ctx_ context.Context) (Value, error), ctx context.Context) *Function

func NewOverloadedFunction

func NewOverloadedFunction(argsAndRet [][]Value, ctx context.Context) *Function

func NewOverloadedMethodLikeFunction

func NewOverloadedMethodLikeFunction(argsAndRet [][]Value, ctx context.Context) *Function

func (*Function) Check

func (v *Function) Check(other_ Value, ctx context.Context) error

func (*Function) EvalConstructor

func (v *Function) EvalConstructor(args []Value, ctx context.Context) (Value, error)

func (*Function) EvalFunction

func (v *Function) EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error)

func (*Function) GetArgs

func (v *Function) GetArgs() [][]Value

get args, but ignore the return value

func (*Function) GetMember

func (v *Function) GetMember(key string, includePrivate bool, ctx context.Context) (Value, error)

func (*Function) IsVoid

func (v *Function) IsVoid() bool

func (*Function) SetMember

func (v *Function) SetMember(key string, includePrivate bool, arg Value, ctx context.Context) error

func (*Function) TypeName

func (v *Function) TypeName() string

type Instance

type Instance struct {
	ValueData
	// contains filtered or unexported fields
}

func AssertInstance

func AssertInstance(v_ Value) (*Instance, error)

func (*Instance) Check

func (v *Instance) Check(other_ Value, ctx context.Context) error

func (*Instance) EvalConstructor

func (v *Instance) EvalConstructor(args []Value, ctx context.Context) (Value, error)

func (*Instance) EvalFunction

func (v *Instance) EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error)

func (*Instance) GetInterface

func (v *Instance) GetInterface() Interface

func (*Instance) GetMember

func (v *Instance) GetMember(key string, includePrivate bool,
	ctx context.Context) (Value, error)

func (*Instance) SetMember

func (v *Instance) SetMember(key string, includePrivate bool, arg Value,
	ctx context.Context) error

func (*Instance) TypeName

func (v *Instance) TypeName() string

type Interface

type Interface interface {
	Name() string

	Context() context.Context

	Check(other Interface, ctx context.Context) error

	// if true: can be exported to databases etc.
	IsUniversal() bool // for actual interfaces: all implementations need to be universal
	IsRPC() bool       //

	// get extended interfaces in case of js.Interface, get implements interfaces in case of js.Class
	GetInterfaces() ([]Interface, error)

	// get all prototypes that implement this interface (actual prototypes dont need include themselves) (used by InstanceOf.Write())
	GetPrototypes() ([]Prototype, error)

	// returns nil if it doesnt exist
	GetInstanceMember(key string, includePrivate bool, ctx context.Context) (Value, error)

	SetInstanceMember(key string, includePrivate bool, arg Value, ctx context.Context) error
}

func FindInstanceMemberInterface

func FindInstanceMemberInterface(interf_ Interface, key string, includePrivate bool, ctx context.Context) (Interface, error)

func GetInterface

func GetInterface(v_ Value) Interface

returns nil if not an Instance with an Interface

type LiteralBooleanInstance

type LiteralBooleanInstance struct {
	Instance
	// contains filtered or unexported fields
}

func (*LiteralBooleanInstance) Check

func (v *LiteralBooleanInstance) Check(other_ Value, ctx context.Context) error

func (*LiteralBooleanInstance) LiteralBooleanValue

func (v *LiteralBooleanInstance) LiteralBooleanValue() (bool, bool)

type LiteralIntInstance

type LiteralIntInstance struct {
	Instance
	// contains filtered or unexported fields
}

func (*LiteralIntInstance) Check

func (v *LiteralIntInstance) Check(other_ Value, ctx context.Context) error

func (*LiteralIntInstance) LiteralIntValue

func (v *LiteralIntInstance) LiteralIntValue() (int, bool)

type LiteralStringInstance

type LiteralStringInstance struct {
	Instance
	// contains filtered or unexported fields
}

func (*LiteralStringInstance) Check

func (v *LiteralStringInstance) Check(other_ Value, ctx context.Context) error

func (*LiteralStringInstance) LiteralStringValue

func (v *LiteralStringInstance) LiteralStringValue() (string, bool)

func (*LiteralStringInstance) TypeName

func (v *LiteralStringInstance) TypeName() string

type Package

type Package interface {
	AddPrototype(proto Prototype)
	AddValue(name string, v Value)
}

type Prototype

type Prototype interface {
	Interface

	IsAbstract() bool

	IsFinal() bool

	// returns nil if it doesn't have a parent
	GetParent() (Prototype, error)

	// return nil if it doesnt exist
	GetClassMember(key string, includePrivate bool, ctx context.Context) (Value, error)

	// return nil if constructor doesn't exist
	GetClassValue() (*Class, error)
}

func GetPrototype

func GetPrototype(v_ Value) Prototype

returns nil if not an Instance with an Interface

type Super

type Super struct {
	ValueData
	// contains filtered or unexported fields
}

used in constructor, to allow calling

func (*Super) Check

func (v *Super) Check(other_ Value, ctx context.Context) error

func (*Super) EvalConstructor

func (v *Super) EvalConstructor(args []Value, ctx context.Context) (Value, error)

func (*Super) EvalFunction

func (v *Super) EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error)

always acts as method

func (*Super) GetMember

func (v *Super) GetMember(key string, includePrivate bool, ctx context.Context) (Value, error)

func (*Super) SetMember

func (v *Super) SetMember(key string, includePrivate bool, arg Value, ctx context.Context) error

func (*Super) TypeName

func (v *Super) TypeName() string

type This

type This struct {
	ValueData
	// contains filtered or unexported fields
}

so we can assert each property is touched during construction

func NewThis

func NewThis(this Value, ctx context.Context) *This

func (*This) AssertTouched

func (v *This) AssertTouched(key string, ctx context.Context) error

func (*This) Check

func (v *This) Check(other_ Value, ctx context.Context) error

func (*This) EvalConstructor

func (v *This) EvalConstructor(args []Value, ctx context.Context) (Value, error)

func (*This) EvalFunction

func (v *This) EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error)

func (*This) GetMember

func (v *This) GetMember(key string, includePrivate bool, ctx context.Context) (Value, error)

func (*This) SetMember

func (v *This) SetMember(key string, includePrivate bool, arg Value, ctx context.Context) error

func (*This) TypeName

func (v *This) TypeName() string

type Value

type Value interface {
	Context() context.Context

	TypeName() string
	Check(other Value, ctx context.Context) error

	EvalConstructor(args []Value, ctx context.Context) (Value, error)
	EvalFunction(args []Value, preferMethod bool, ctx context.Context) (Value, error) // method returns nil Value

	GetMember(key string, includePrivate bool, ctx context.Context) (Value, error)
	SetMember(key string, includePrivate bool, arg Value, ctx context.Context) error

	LiteralBooleanValue() (bool, bool)
	LiteralIntValue() (int, bool)
	LiteralStringValue() (string, bool)
}

func CommonValue

func CommonValue(vs []Value, ctx context.Context) Value

TODO: use parent prototypes too

func NewAll

func NewAll(ctx context.Context) Value

func NewAny

func NewAny(ctx context.Context) Value

func NewContextValue

func NewContextValue(val Value, ctx context.Context) Value

func NewInstance

func NewInstance(interf Interface, ctx context.Context) Value

func NewLiteralBooleanInstance

func NewLiteralBooleanInstance(interf Interface, b bool, ctx context.Context) Value

func NewLiteralIntInstance

func NewLiteralIntInstance(interf Interface, i int, ctx context.Context) Value

func NewLiteralStringInstance

func NewLiteralStringInstance(interf Interface, str string, ctx context.Context) Value

func NewSuper

func NewSuper(cl *Class, ctx context.Context) (Value, error)

func RemoveLiteralness

func RemoveLiteralness(v Value) Value

func UnpackContextValue

func UnpackContextValue(val Value) Value

type ValueData

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

func (*ValueData) Context

func (v *ValueData) Context() context.Context

func (*ValueData) LiteralBooleanValue

func (v *ValueData) LiteralBooleanValue() (bool, bool)

func (*ValueData) LiteralIntValue

func (v *ValueData) LiteralIntValue() (int, bool)

func (*ValueData) LiteralStringValue

func (v *ValueData) LiteralStringValue() (string, bool)

Jump to

Keyboard shortcuts

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