runtime

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bit    Unit = 1
	Hex         = 4
	Octett      = 8
)
View Source
const (
	UNKNOWN       ObjectType = "unknown"
	UNDEFINED                = "undefined"
	RUNTIME_ERROR            = "runtime error"
	RETURN_VALUE             = "return value"
	INTEGER                  = "integer"
	FLOAT                    = "float"
	BOOL                     = "boolean"
	STRING                   = "string"
	BITSTRING                = "bitstring"
	FUNCTION                 = "function"
	LIST                     = "list"
	BUILTIN_OBJ              = "builtin function"
	VERDICT                  = "verdict"
)

Variables

View Source
var Builtins = map[string]*Builtin{
	"lengthof": {Fn: func(args ...Object) Object {
		if len(args) != 1 {
			return Errorf("wrong number of arguments. got=%d, want=1", len(args))
		}

		switch arg := args[0].(type) {
		case *String:
			return Int{Int: big.NewInt(int64(len(arg.Value)))}
		case *Bitstring:
			return Int{Int: big.NewInt(int64(arg.Value.BitLen() / int(arg.Unit)))}

		}
		return Errorf("%s arguments not supported", args[0].Type())
	}},
}
View Source
var ErrSyntax = errors.New("invalid syntax")
View Source
var (
	Undefined = &undefined{}
)

Functions

func IsError

func IsError(v interface{}) bool

Types

type Bitstring added in v0.9.5

type Bitstring struct {
	Value *big.Int
	Unit  Unit
}

func NewBitstring added in v0.9.5

func NewBitstring(s string) (*Bitstring, error)

func (*Bitstring) Inspect added in v0.9.5

func (b *Bitstring) Inspect() string

func (*Bitstring) Type added in v0.9.5

func (b *Bitstring) Type() ObjectType

type Bool

type Bool bool

func NewBool

func NewBool(b bool) Bool

func (Bool) Bool

func (b Bool) Bool() bool

func (Bool) Inspect

func (b Bool) Inspect() string

func (Bool) Type

func (b Bool) Type() ObjectType

type Builtin added in v0.9.5

type Builtin struct {
	Fn func(args ...Object) Object
}

func (*Builtin) Inspect added in v0.9.5

func (b *Builtin) Inspect() string

func (*Builtin) Type added in v0.9.5

func (b *Builtin) Type() ObjectType

type Env

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

func NewEnv

func NewEnv(outer *Env) *Env

func (*Env) Get

func (env *Env) Get(name string) (Object, bool)

func (*Env) Set

func (env *Env) Set(name string, val Object) Object

type Error

type Error struct {
	Message string
}

func Errorf

func Errorf(format string, a ...interface{}) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() ObjectType

type Float

type Float struct{ *big.Float }

func NewFloat

func NewFloat(s string) Float

func (Float) Inspect

func (f Float) Inspect() string

func (Float) Type

func (f Float) Type() ObjectType

type Function

type Function struct {
	Params *ast.FormalPars
	Body   *ast.BlockStmt
	Env    *Env
}

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) Type

func (f *Function) Type() ObjectType

type Int

type Int struct{ *big.Int }

func NewInt

func NewInt(s string) Int

func (Int) Inspect

func (i Int) Inspect() string

func (Int) Type

func (i Int) Type() ObjectType

func (Int) Value

func (i Int) Value() *big.Int

type List added in v0.9.5

type List struct {
	Elements []Object
}

func (*List) Inspect added in v0.9.5

func (l *List) Inspect() string

func (*List) Type added in v0.9.5

func (l *List) Type() ObjectType

type Object

type Object interface {
	Inspect() string
	Type() ObjectType
}

type ObjectType

type ObjectType string

type ReturnValue

type ReturnValue struct {
	Value Object
}

func (*ReturnValue) Inspect

func (r *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (r *ReturnValue) Type() ObjectType

type String

type String struct {
	Value string
}

func (*String) Inspect

func (s *String) Inspect() string

func (*String) Type

func (s *String) Type() ObjectType

type Unit

type Unit int

func (Unit) Base

func (u Unit) Base() int

type Verdict

type Verdict string
const (
	NoneVerdict   Verdict = "none"
	PassVerdict   Verdict = "pass"
	InconcVerdict Verdict = "inconc"
	FailVerdict   Verdict = "fail"
	ErrorVerdict  Verdict = "error"
)

func (Verdict) Inspect

func (v Verdict) Inspect() string

func (Verdict) Type

func (v Verdict) Type() ObjectType

Jump to

Keyboard shortcuts

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