types

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package types implements a type system for TTCN-3.

Index

Constants

This section is empty.

Variables

View Source
var Predefined = map[string]Type{
	"any":                  &PrimitiveType{Kind: Any, Name: "any"},
	"integer":              &PrimitiveType{Kind: Integer, Name: "integer"},
	"float":                &PrimitiveType{Kind: Float, Name: "float"},
	"boolean":              &PrimitiveType{Kind: Boolean, Name: "boolean"},
	"verdicttype":          &PrimitiveType{Kind: Verdict, Name: "verdicttype"},
	"bitstring":            &ListType{Kind: Bitstring, Name: "bitstring"},
	"charstring":           &ListType{Kind: Charstring, Name: "charstring"},
	"hexstring":            &ListType{Kind: Hexstring, Name: "hexstring"},
	"octetstring":          &ListType{Kind: Octetstring, Name: "octetstring"},
	"universal charstring": &ListType{Kind: UniversalCharstring, Name: "universal charstring"},
	"default":              &BehaviourType{Kind: Altstep, Name: "default"},
	"timer":                &StructuredType{Kind: Object, Name: "timer"},
	"anytype":              &StructuredType{Kind: Union, Name: "anytype"},
}

Functions

This section is empty.

Types

type BehaviourType added in v0.18.0

type BehaviourType struct {
	Kind
	Name       string
	External   bool
	Parameters []Type
	Receiver   Type
	RunsOn     Type
	System     Type
	MTC        Type
	Port       Type
	ExecuteOn  Type
	Return     Type
}

A BehaviourType represents behaviour (testcases, functions, behaviour types, ...)

func (*BehaviourType) String added in v0.18.0

func (t *BehaviourType) String() string

type Field added in v0.18.0

type Field struct {
	Type
	Name     string
	Optional bool
	Default  bool
	Abstract bool
}

A Field represents a fields in structures types.

func (*Field) String added in v0.18.0

func (f *Field) String() string

type Kind

type Kind uint64

Kind is a bitmask describing the kinds of values a type can have, such as "integer" or "record".

const (
	Any   Kind = 0
	Error Kind = 1 << iota
	Incomplete

	// Primitive types
	Boolean
	Enumerated
	Float
	Integer
	Verdict

	// List types
	Array
	Bitstring
	Charstring
	Hexstring
	Octetstring
	RecordOf
	SetOf
	UniversalCharstring

	// Structured types
	Anytype
	Component
	Object
	Port
	Record
	Set
	Timer
	Trait
	Union

	// Behaviour types
	Altstep
	Configuration
	Default
	Function
	Testcase
)

func (Kind) String added in v0.18.0

func (k Kind) String() string

String returns a string describing the kind, such as "error or integer or float".

type ListType added in v0.18.0

type ListType struct {
	Kind
	Name             string
	ElementType      Type
	ValueConstraints []Value
	LengthConstraint Value
	Methods          map[string]Type
}

A ListType represents a collection of values of the same type, such as a record, set, map, hexstring, ...

The behaviour of a list type is determined by its kind:

  • a RecordOf is a ordered collection, while SetOf is an unordered collection or pairs.
  • an Array has a different string representation than a RecordOf: `integer[5]` vs. `record length(5) of integer`

The behaviour for other kinds than Array, RecordOf, Hexstring, Bitstring, Octetstring, Charstring, UniversalCharstring is undefined and may or may not cause a runtime error.

func (*ListType) String added in v0.18.0

func (t *ListType) String() string

type MapType added in v0.18.0

type MapType struct {
	Name     string
	From, To Type
}

A MapType represents a map type.

func (*MapType) String added in v0.18.0

func (t *MapType) String() string

type PrimitiveType added in v0.18.0

type PrimitiveType struct {
	Kind
	Name             string
	ValueConstraints []Value
	Methods          map[string]Type
}

A PrimitiveType represents a non-composite type, such as integer, boolean, verdicttype, ...

func (*PrimitiveType) String added in v0.18.0

func (t *PrimitiveType) String() string

type StructuredType added in v0.18.0

type StructuredType struct {
	Kind
	Name             string
	External         bool
	Fields           []Field
	Extends          []Type
	ValueConstraints []Value
	Methods          map[string]Type
}

A StructuredType represents structured types, such as record, set, union, class, ...

func (*StructuredType) String added in v0.18.0

func (t *StructuredType) String() string

type Type

type Type interface {
	String() string
	// contains filtered or unexported methods
}

A Type represents a TTCN-3 type.

func TypeOf added in v0.18.0

func TypeOf(n syntax.Expr) Type

type Value added in v0.18.0

type Value struct {
	syntax.Expr
}

A Value represents a single value constraint, such as '1' or '10..20'.

func (Value) String added in v0.18.0

func (v Value) String() string

Jump to

Keyboard shortcuts

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