runtime

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSyntax = errors.New("invalid syntax")
	Undefined = &singelton{typ: UNDEFINED}
	Break     = &singelton{typ: BREAK}
	Continue  = &singelton{typ: CONTINUE}
	Any       = &singelton{typ: ANY}
	AnyOrNone = &singelton{typ: ANY_OR_NONE}
)
View Source
var (
	ErrExists          = errors.New("already exists")
	ErrRange           = errors.New("value out of range")
	ErrTypeMismatch    = errors.New("type mismatch")
	ErrInvalidArgCount = errors.New("invalid argument count")
	ErrNotImplemented  = errors.New("not implemented")
)

Functions

func AddBuiltin added in v0.16.2

func AddBuiltin(id string, fn func(args ...Object) Object) error

AddBuiltin adds a builtin function to the runtime environment.

An error is returned if the builtin-name is already registered.

If the given identifier provides formal parameters, the function will be checked for the correct number and type of arguments, automatically. An error is returnes if the input string contrains any syntax-errors.

func BigIntToBinaryString added in v0.18.0

func BigIntToBinaryString(b *big.Int, unit Unit) string

func EqualObjectSet added in v0.16.2

func EqualObjectSet(a, b []Object) bool

EqualObjectSet compares two Object slices for equality ignoring the order of the elements.

Current implementation is O(n^2).

func EqualObjects added in v0.9.6

func EqualObjects(a, b []Object) bool

EqualObjects compares two Object slices for equality.

func IsError

func IsError(v interface{}) bool

Types

type Binarystring added in v0.18.0

type Binarystring struct {
	String string
	Value  *big.Int
	Unit   Unit
	Length int
}

func NewBinarystring added in v0.18.0

func NewBinarystring(s string) (*Binarystring, error)

func NewBinarystringWithWildcards added in v0.18.0

func NewBinarystringWithWildcards(s string, unit Unit) (*Binarystring, error)

func (*Binarystring) Equal added in v0.18.0

func (b *Binarystring) Equal(obj Object) bool

func (*Binarystring) Get added in v0.18.0

func (b *Binarystring) Get(index int) Object

func (*Binarystring) Inspect added in v0.18.0

func (b *Binarystring) Inspect() string

func (*Binarystring) Len added in v0.18.0

func (b *Binarystring) Len() int

func (*Binarystring) Type added in v0.18.0

func (b *Binarystring) Type() ObjectType

type Bool

type Bool bool

func NewBool

func NewBool(b bool) Bool

func (Bool) Bool

func (b Bool) Bool() bool

func (Bool) Equal added in v0.9.6

func (b Bool) Equal(obj Object) 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) Equal added in v0.9.6

func (b *Builtin) Equal(obj Object) bool

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 EnumElements added in v0.18.0

type EnumElements map[string][]EnumRange

type EnumRange added in v0.18.0

type EnumRange struct {
	First, Last int
}

func (*EnumRange) Contains added in v0.18.0

func (er *EnumRange) Contains(x int) bool

func (EnumRange) ToString added in v0.18.0

func (er EnumRange) ToString() string

type EnumType added in v0.18.0

type EnumType struct {
	Name     string
	Elements EnumElements
}

func NewEnumType added in v0.18.0

func NewEnumType(enumTypeName string, Enums ...string) *EnumType

func (*EnumType) Equal added in v0.18.0

func (et *EnumType) Equal(obj Object) bool

func (*EnumType) Inspect added in v0.18.0

func (et *EnumType) Inspect() string

func (*EnumType) Type added in v0.18.0

func (et *EnumType) Type() ObjectType

type EnumValue added in v0.18.0

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

func NewEnumValue added in v0.18.0

func NewEnumValue(enumType *EnumType, key string, id int) (*EnumValue, error)

func NewEnumValueByKey added in v0.18.0

func NewEnumValueByKey(enumType *EnumType, key string) (*EnumValue, error)

func (*EnumValue) Equal added in v0.18.0

func (ev *EnumValue) Equal(obj Object) bool

func (*EnumValue) Inspect added in v0.18.0

func (ev *EnumValue) Inspect() string

func (*EnumValue) SetValueById added in v0.18.0

func (ev *EnumValue) SetValueById(id int) *Error

func (*EnumValue) SetValueByKey added in v0.18.0

func (ev *EnumValue) SetValueByKey(key string) *Error

func (*EnumValue) Type added in v0.18.0

func (ev *EnumValue) Type() ObjectType

type Env

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

func NewEnv

func NewEnv(outer Scope) *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 {
	Err error
}

func Errorf

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

func (*Error) Equal added in v0.9.6

func (e *Error) Equal(obj Object) bool

func (*Error) Error

func (e *Error) Error() string

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) Type

func (e *Error) Type() ObjectType

func (*Error) Unwrap added in v0.18.0

func (e *Error) Unwrap() error

type Float

type Float float64

func NewFloat

func NewFloat(s string) Float

func (Float) Equal added in v0.9.6

func (f Float) Equal(obj Object) bool

func (Float) Inspect

func (f Float) Inspect() string

func (Float) Type

func (f Float) Type() ObjectType

type Function

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

func (*Function) Equal added in v0.9.6

func (f *Function) Equal(obj Object) bool

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(v interface{}) Int

func (Int) Equal added in v0.9.6

func (i Int) Equal(obj Object) bool

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 {
	ListType
	Elements []Object
}

func NewComplement added in v0.16.2

func NewComplement(objs ...Object) *List

func NewList added in v0.16.2

func NewList(objs ...Object) *List

NewList creates a new ordered list.

func NewPermutation added in v0.16.2

func NewPermutation(objs ...Object) *List

func NewRecordOf added in v0.16.2

func NewRecordOf(objs ...Object) *List

func NewSetOf added in v0.16.2

func NewSetOf(objs ...Object) *List

func NewSubset added in v0.16.2

func NewSubset(objs ...Object) *List

func NewSuperset added in v0.16.2

func NewSuperset(objs ...Object) *List

func (*List) Equal added in v0.9.6

func (l *List) Equal(obj Object) bool

func (*List) Get added in v0.16.2

func (l *List) Get(index int) Object

func (*List) Inspect added in v0.9.5

func (l *List) Inspect() string

func (*List) IsOrdered added in v0.16.2

func (l *List) IsOrdered() bool

func (*List) Len added in v0.16.2

func (l *List) Len() int

func (*List) Type added in v0.9.5

func (l *List) Type() ObjectType

type ListType added in v0.16.2

type ListType string
const (
	RECORD_OF   ListType = "" //default
	SET_OF      ListType = "set of"
	COMPLEMENT  ListType = "complement"
	SUBSET      ListType = "subset"
	SUPERSET    ListType = "superset"
	PERMUTATION ListType = "permutation"
)

type Map added in v0.9.6

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

Map is a map of objects.

func NewMap added in v0.9.6

func NewMap() *Map

func (*Map) Equal added in v0.9.6

func (m *Map) Equal(obj Object) bool

func (*Map) Get added in v0.9.6

func (m *Map) Get(key Object) (Object, bool)

Get returns the value for the given key.

func (*Map) Inspect added in v0.9.6

func (m *Map) Inspect() string

func (*Map) Set added in v0.9.6

func (m *Map) Set(key Object, val Object) Object

func (*Map) Type added in v0.9.6

func (m *Map) Type() ObjectType

type Object

type Object interface {
	// Inspect returns a string-representation of the object for in TTCN-3 syntax.
	Inspect() string

	Type() ObjectType
	Equal(Object) bool
}

type ObjectType

type ObjectType string
const (
	UNKNOWN      ObjectType = "unknown object"
	UNDEFINED    ObjectType = "undefined value"
	ERROR        ObjectType = "runtime error"
	BREAK        ObjectType = "break event"
	CONTINUE     ObjectType = "continue event"
	RETURN_VALUE ObjectType = "return value"
	INTEGER      ObjectType = "integer"
	FLOAT        ObjectType = "float"
	BOOL         ObjectType = "boolean"

	// Charstring types
	CHARSTRING ObjectType = "string"

	// Binarystring types
	BITSTRING   ObjectType = "bitstring"
	HEXSTRING   ObjectType = "hexstring"
	OCTETSTRING ObjectType = "octetstring"

	FUNCTION    ObjectType = "function"
	LIST        ObjectType = "list"
	RECORD      ObjectType = "record"
	MAP         ObjectType = "map"
	BUILTIN_OBJ ObjectType = "builtin function"
	VERDICT     ObjectType = "verdict"
	ENUM_VALUE  ObjectType = "enumerated value"
	ENUM_TYPE   ObjectType = "enumerated type"
	ANY         ObjectType = "?"
	ANY_OR_NONE ObjectType = "*"
)

type Record added in v0.9.6

type Record struct {
	Fields map[string]Object
}

TODO(5nord) For simplicity we reuse the Map implementation. We should implement proper record semantics later.

func NewRecord added in v0.9.6

func NewRecord() *Record

func (*Record) Equal added in v0.9.6

func (r *Record) Equal(obj Object) bool

func (*Record) Get added in v0.9.6

func (r *Record) Get(name string) (Object, bool)

func (*Record) Inspect added in v0.9.6

func (r *Record) Inspect() string

func (*Record) Set added in v0.9.6

func (r *Record) Set(name string, val Object) Object

func (*Record) Type added in v0.9.6

func (r *Record) Type() ObjectType

type ReturnValue

type ReturnValue struct {
	Value Object
}

func (*ReturnValue) Equal added in v0.9.6

func (r *ReturnValue) Equal(obj Object) bool

func (*ReturnValue) Inspect

func (r *ReturnValue) Inspect() string

func (*ReturnValue) Type

func (r *ReturnValue) Type() ObjectType

type Scope added in v0.9.6

type Scope interface {
	Get(name string) (Object, bool)
	Set(name string, val Object) Object
}

type String

type String struct {
	Value []rune
	// contains filtered or unexported fields
}

func NewCharstring added in v0.18.0

func NewCharstring(s string) *String

func NewUniversalString added in v0.18.0

func NewUniversalString(s string) *String

func (*String) Equal added in v0.9.6

func (s *String) Equal(obj Object) bool

func (*String) Get added in v0.16.2

func (s *String) Get(i int) Object

func (*String) Inspect

func (s *String) Inspect() string

Inpect returns the string value as a TTCN-3 string literal.

func (*String) IsASCII added in v0.18.0

func (s *String) IsASCII() bool

IsASCII returns true if the string only contains ASCII characters.

func (*String) Len added in v0.16.2

func (s *String) Len() int

func (*String) String added in v0.18.0

func (s *String) String() string

String returns the string a Go string.

func (*String) Type

func (s *String) Type() ObjectType

Type returns the object type CHARSTRING. This type is used for both charstrings and universal charstrings.

type Unit

type Unit int
const (
	Bit   Unit = 1
	Hex   Unit = 4
	Octet Unit = 8
)

func (Unit) Base

func (u Unit) Base() int

func (Unit) String added in v0.18.0

func (u Unit) String() string

type Verdict

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

func (Verdict) Equal added in v0.9.6

func (v Verdict) Equal(obj Object) bool

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