Documentation
¶
Index ¶
- Constants
- Variables
- func AddBuiltinField(name string)
- func AddBuiltinFunc(name string)
- func AddNativeFunc(f NativeFunction)
- func Eval(vm *VM, code string) error
- func Fprint(w io.Writer, p *Program)
- func FprintConstants(w io.Writer, p *Program)
- func FprintFunction(w io.Writer, prefix string, f *Function, p *Program)
- func FprintNames(w io.Writer, p *Program, registers bool)
- func NewCompiler() *compiler
- func Parse(fs filesystem.FS, path string) (*ast.Program, error)
- func ParseExpr(code string) (ast.Expr, error)
- func ParseStr(code string) (*ast.Program, error)
- func Print(p *Program)
- func PrintFunction(f *Function, p *Program)
- func PrintNames(p *Program, registers bool)
- func RegisterLib(funcs []NativeFunction, dts string)
- func Sprint(p *Program) (string, error)
- func SprintNames(p *Program, registers bool) (string, error)
- func Stacktrace() string
- func TypeDefs() string
- func Wrap(msg string, err error) error
- type Address
- type AddressKind
- type Allocator
- type Callable
- type Class
- type Closure
- type Comparable
- type CompilerError
- type EnumList
- type EnumValue
- type Enumerable
- type Equatable
- type ErrorMessenger
- type Exporter
- type Field
- type FieldGetter
- type FieldSetter
- type Finalizable
- type Frame
- type Function
- type FunctionKind
- type IndexIterator
- type IndexerGetter
- type IndexerSetter
- type Instance
- func (i *Instance) Function(name string, p *Program) (*Function, bool)
- func (i *Instance) GetField(name string, vm *VM) (Value, error)
- func (i *Instance) PropertyGetter(name string, p *Program) (*Function, bool)
- func (i *Instance) PropertySetter(name string, p *Program) (*Function, bool)
- func (i *Instance) SetField(name string, v Value, vm *VM) error
- func (i *Instance) String() string
- type Instruction
- type KeyGetter
- type KeyIterator
- type Localizer
- type MapValue
- type Method
- type NamedType
- type NativeFunction
- type NativeMethod
- type NativeObject
- type NewArrayObject
- type Opcode
- type Position
- type Program
- func (p *Program) AddPermission(name string)
- func (p *Program) Attribute(name string) string
- func (p *Program) Copy() *Program
- func (p *Program) FileIndex(file string) int
- func (p *Program) Function(name string) (*Function, bool)
- func (p *Program) HasPermission(name string) bool
- func (p *Program) Permissions() []string
- func (p *Program) SetAttribute(key, value string)
- func (p *Program) Strip()
- func (p *Program) ToTraceLine(f *Function, pc int) TraceLine
- type Register
- type StackTrace
- type TraceLine
- type Type
- type VM
- func (vm *VM) AddAllocations(size int) error
- func (vm *VM) AddSteps(n int64) error
- func (vm *VM) Allocations() int64
- func (vm *VM) Clone(p *Program) *VM
- func (vm *VM) CloneInitialized(p *Program, globals []Value) *VM
- func (vm *VM) CurrentFunc() *Function
- func (vm *VM) FinalizeGlobals()
- func (vm *VM) GetStderr() io.Writer
- func (vm *VM) GetStdin() io.Reader
- func (vm *VM) GetStdout() io.Writer
- func (vm *VM) Globals() []Value
- func (vm *VM) HasPermission(name string) bool
- func (vm *VM) Initialize() error
- func (vm *VM) Initialized() bool
- func (vm *VM) NewCodeError(code int, format string, a ...interface{}) *VMError
- func (vm *VM) NewError(format string, a ...interface{}) *VMError
- func (vm *VM) RegisterValue(name string) (Value, bool)
- func (vm *VM) ResetSteps()
- func (vm *VM) Run(args ...Value) (Value, error)
- func (vm *VM) RunClosure(c *Closure, args ...Value) (Value, error)
- func (vm *VM) RunFunc(name string, args ...Value) (Value, error)
- func (vm *VM) RunFuncIndex(index int, args ...Value) (Value, error)
- func (vm *VM) RunMethod(c *Method, args ...Value) (Value, error)
- func (vm *VM) SetFinalizer(v Finalizable)
- func (vm *VM) SetGlobalFinalizer(v Finalizable)
- func (vm *VM) SetGlobalRegister(name string, v Value) error
- func (vm *VM) Stacktrace() []string
- func (vm *VM) StacktraceLine() string
- func (vm *VM) Steps() int64
- func (vm *VM) WrapError(err error) *VMError
- type VMError
- func (e *VMError) Error() string
- func (e *VMError) ErrorMessage() string
- func (e *VMError) GetField(name string, vm *VM) (Value, error)
- func (e *VMError) GetMethod(name string) NativeMethod
- func (e *VMError) Is(msg string) bool
- func (e *VMError) MarshalJSON() ([]byte, error)
- func (e *VMError) SetField(key string, v Value, vm *VM) error
- func (e *VMError) Stack() string
- func (e *VMError) String() string
- func (e *VMError) Type() string
- type Value
- func NewArray(size int) Value
- func NewArrayValues(v []Value) Value
- func NewBool(v bool) Value
- func NewBytes(v []byte) Value
- func NewEnum(v int) Value
- func NewFloat(v float64) Value
- func NewFunction(v int) Value
- func NewInt(v int) Value
- func NewInt64(v int64) Value
- func NewMap(size int) Value
- func NewMapValues(m map[Value]Value) Value
- func NewNativeFunction(v int) Value
- func NewObject(v interface{}) Value
- func NewRune(v rune) Value
- func NewString(v string) Value
- func NewValue(v interface{}) Value
- func Run(fs filesystem.FS, path string) (Value, error)
- func RunStr(code string) (Value, error)
- func (v Value) Equals(other Value) bool
- func (v Value) Export(recursionLevel int) interface{}
- func (v Value) ExportMarshal(recursionLevel int) interface{}
- func (v Value) IsNil() bool
- func (v Value) IsNilOrEmpty() bool
- func (v Value) MarshalJSON() ([]byte, error)
- func (v Value) Size() int
- func (v Value) StrictEquals(other Value) bool
- func (v Value) String() string
- func (v Value) ToArray() []Value
- func (v Value) ToArrayObject() *NewArrayObject
- func (v Value) ToBool() bool
- func (v Value) ToBytes() []byte
- func (v Value) ToEnum() int
- func (v Value) ToFloat() float64
- func (v Value) ToFunction() int
- func (v Value) ToInt() int64
- func (v Value) ToMap() *MapValue
- func (v Value) ToNativeFunction() int
- func (v Value) ToObject() interface{}
- func (v Value) ToObjectOrNil() interface{}
- func (v Value) ToRune() rune
- func (v Value) ToString() string
- func (v Value) TypeName() string
Constants ¶
View Source
const GlobalNamespace = "--globalnamespace"
View Source
const MAX_EXPORT_RECURSION = 200
View Source
const VERSION = "1.0"
Variables ¶
View Source
var ( UndefinedValue = Value{Type: Undefined} NullValue = Value{Type: Null} TrueValue = Value{Type: Bool, /* contains filtered or unexported fields */} FalseValue = Value{Type: Bool, /* contains filtered or unexported fields */} )
View Source
var ErrFunctionNotExist = errors.New("function not found")
View Source
var Void = NewAddress(AddrVoid, 0)
Functions ¶
func AddBuiltinField ¶
func AddBuiltinField(name string)
func AddBuiltinFunc ¶
func AddBuiltinFunc(name string)
func AddNativeFunc ¶
func AddNativeFunc(f NativeFunction)
func FprintConstants ¶
func NewCompiler ¶
func NewCompiler() *compiler
func PrintFunction ¶
func PrintNames ¶
func RegisterLib ¶
func RegisterLib(funcs []NativeFunction, dts string)
func Stacktrace ¶
func Stacktrace() string
Types ¶
type Address ¶
type Address struct { Kind AddressKind Value int32 }
func NewAddress ¶
func NewAddress(kind AddressKind, value int) *Address
type AddressKind ¶
type AddressKind byte
const ( AddrVoid AddressKind = iota AddrLocal AddrGlobal AddrConstant AddrClosure AddrEnum AddrFunc AddrNativeFunc AddrClass AddrData AddrUnresolved )
func (AddressKind) String ¶
func (i AddressKind) String() string
type Callable ¶
type Callable interface {
GetMethod(name string) NativeMethod
}
type Class ¶
type Comparable ¶
Comparable returns:
-2 if both values are imcompatible for comparisson between each other. -1 is lesser 0 is equal 1 is greater
type CompilerError ¶
func (CompilerError) Error ¶
func (e CompilerError) Error() string
func (CompilerError) ErrorMessage ¶
func (e CompilerError) ErrorMessage() string
func (CompilerError) Position ¶
func (e CompilerError) Position() ast.Position
type Enumerable ¶
type ErrorMessenger ¶
type ErrorMessenger interface {
ErrorMessage() string
}
type Finalizable ¶
type Finalizable interface {
Close() error
}
type Function ¶
type Function struct { Name string Module string Attributes []string Positions []Position Instructions []*Instruction Closures []*Register Registers []*Register Arguments int OptionalArguments int Index int WrapClass int MaxRegIndex int Class int Lambda bool IsGlobal bool IsClass bool Exported bool Variadic bool Kind FunctionKind // contains filtered or unexported fields }
func (*Function) HasPermission ¶
func (*Function) Permissions ¶
type IndexIterator ¶
type IndexIterator interface { IndexerGetter Len() int }
type IndexerGetter ¶
type IndexerSetter ¶
type Instruction ¶
func NewInstruction ¶
func NewInstruction(op Opcode, a, b, c *Address) *Instruction
func (*Instruction) Copy ¶
func (r *Instruction) Copy() *Instruction
func (*Instruction) Format ¶
func (i *Instruction) Format(padd bool) string
func (*Instruction) String ¶
func (i *Instruction) String() string
type KeyIterator ¶
type NativeFunction ¶
type NativeFunction struct { Function func(this Value, args []Value, vm *VM) (Value, error) Name string Permissions []string Arguments int Index int }
NativeFunction is a function written in Go as opposed to an interpreted function
func AllNativeFuncs ¶
func AllNativeFuncs() []NativeFunction
func NativeFuncFromIndex ¶
func NativeFuncFromIndex(i int) NativeFunction
func NativeFuncFromName ¶
func NativeFuncFromName(name string) (NativeFunction, bool)
type NativeMethod ¶
func (NativeMethod) Type ¶
func (NativeMethod) Type() string
type NativeObject ¶
type NewArrayObject ¶
type NewArrayObject struct {
Array []Value
}
type Program ¶
type Program struct { Resources map[string][]byte Attributes []string Enums []*EnumList Classes []*Class Files []string Functions []*Function Constants []Value Name string sync.Mutex // contains filtered or unexported fields }
func CompileStr ¶
func (*Program) AddPermission ¶
func (*Program) HasPermission ¶
func (*Program) Permissions ¶
func (*Program) SetAttribute ¶
type Register ¶
type StackTrace ¶
type StackTrace []Frame
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
type VM ¶
type VM struct { Context Value StdLib Value Now time.Time RetValue Value Localizer Localizer Stderr io.Writer Error error FileSystem filesystem.FS Stdout io.Writer Stdin io.Reader Location *time.Location Program *Program Language string MaxFrames int MaxAllocations int64 MaxSteps int64 // contains filtered or unexported fields }
func NewInitializedVM ¶
func (*VM) AddAllocations ¶
func (*VM) Allocations ¶
func (*VM) CurrentFunc ¶
func (*VM) FinalizeGlobals ¶
func (vm *VM) FinalizeGlobals()
func (*VM) HasPermission ¶
func (*VM) Initialize ¶
func (*VM) Initialized ¶
func (*VM) NewCodeError ¶
func (*VM) RegisterValue ¶
return a value from the current scope
func (*VM) ResetSteps ¶
func (vm *VM) ResetSteps()
func (*VM) RunClosure ¶
RunClosure executes a program closure
func (*VM) RunFuncIndex ¶
RunFuncIndex executes a program function by index
func (*VM) SetFinalizer ¶
func (vm *VM) SetFinalizer(v Finalizable)
func (*VM) SetGlobalFinalizer ¶
func (vm *VM) SetGlobalFinalizer(v Finalizable)
func (*VM) Stacktrace ¶
func (*VM) StacktraceLine ¶
type VMError ¶
type VMError struct { Wrapped *VMError Message string Details string Code int IsRethrow bool TraceLines []TraceLine // contains filtered or unexported fields }
func NewCodeError ¶
func (*VMError) ErrorMessage ¶
func (*VMError) GetMethod ¶
func (e *VMError) GetMethod(name string) NativeMethod
func (*VMError) MarshalJSON ¶
type Value ¶
type Value struct { Type Type // contains filtered or unexported fields }
func NewArrayValues ¶
func NewFunction ¶
func NewMapValues ¶
func NewNativeFunction ¶
func (Value) ExportMarshal ¶
func (Value) IsNilOrEmpty ¶
func (Value) MarshalJSON ¶
func (Value) StrictEquals ¶
func (Value) ToArrayObject ¶
func (v Value) ToArrayObject() *NewArrayObject
func (Value) ToFunction ¶
func (Value) ToNativeFunction ¶
func (Value) ToObjectOrNil ¶
func (v Value) ToObjectOrNil() interface{}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.