runtime

package
v0.0.0-...-d9ce530 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Separate runtime package for recursive imports

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NativeFunction

type NativeFunction = func(*Runtime, []interface{}) (interface{}, error)

type Runtime

type Runtime struct {
	Scopes []string
	// Scope names => Variable names => values
	Vars           map[string]map[string]interface{}
	Funcs          map[string]map[string]func(*Runtime, []interface{}) (interface{}, error)
	Methods        map[reflect.Type]map[string]func(*Runtime, []interface{}) (interface{}, error)
	Stdout, Stderr io.Writer
	Stdin          io.Reader
}

TODO: scopes for if and loops, etc. TODO: allow a[1][1] ...

func NewRuntime

func NewRuntime(stdout, stderr io.Writer, stdin io.Reader) Runtime

func (*Runtime) AddScope

func (runtime *Runtime) AddScope(scopename string)

Set the current scope

func (*Runtime) ApplyToVariable

func (runtime *Runtime) ApplyToVariable(scopename string, varname string, operation func(interface{}) (interface{}, error)) error

func (*Runtime) CurrentScope

func (runtime *Runtime) CurrentScope() string

func (*Runtime) ExitScope

func (runtime *Runtime) ExitScope()

Exit the current scope

func (*Runtime) GetFunc

func (runtime *Runtime) GetFunc(funcname string) NativeFunction

func (*Runtime) GetMethod

func (runtime *Runtime) GetMethod(calledOnValue interface{}, methodname string) NativeFunction

func (*Runtime) GetVar

func (runtime *Runtime) GetVar(varname string) (interface{}, error)

func (*Runtime) SetArrayIndex

func (runtime *Runtime) SetArrayIndex(varname string, index int64, varval interface{})

func (*Runtime) SetFunc

func (runtime *Runtime) SetFunc(funcname string, fn NativeFunction)

func (*Runtime) SetMethod

func (runtime *Runtime) SetMethod(onType reflect.Type, methodname string, method NativeFunction)

func (*Runtime) SetVar

func (runtime *Runtime) SetVar(scopename string, varname string, varval interface{})

func (*Runtime) VarExists

func (runtime *Runtime) VarExists(varname string) (bool, string)

Jump to

Keyboard shortcuts

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