types

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package types provides TTCN-3 types, functions for compatibilty checks and a builder to create and resolve types from a TTCN-3 syntax tree.

Index

Constants

This section is empty.

Variables

View Source
var Typ = []*BasicType{
	Invalid:             {Invalid, "invalid"},
	Bitstring:           {Bitstring, "bitstring"},
	Boolean:             {Boolean, "boolean"},
	Charstring:          {Charstring, "charstring"},
	Component:           {Component, "component"},
	Float:               {Float, "float"},
	Hexstring:           {Hexstring, "hexstring"},
	Integer:             {Integer, "integer"},
	Octetstring:         {Octetstring, "octetstring"},
	Omit:                {Omit, "omit"},
	Template:            {Template, "template"},
	Timer:               {Timer, "timer"},
	UniversalCharstring: {UniversalCharstring, "universal charstring"},
	Verdict:             {Verdict, "verdict"},

	String:    {String, "string"},
	Numerical: {Numerical, "numerical"},
}
View Source
var Universe scope

Functions

This section is empty.

Types

type BasicType

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

func (*BasicType) Kind

func (b *BasicType) Kind() Kind

func (*BasicType) String

func (b *BasicType) String() string

func (*BasicType) Underlying

func (b *BasicType) Underlying() Type

type ComponentType

type ComponentType struct {
	Vars  []*Var
	Ports []*Port
	// contains filtered or unexported fields
}

func NewComponentType

func NewComponentType(n ast.Node, name string) *ComponentType

func (*ComponentType) End

func (obj *ComponentType) End() loc.Pos

func (*ComponentType) Insert

func (c *ComponentType) Insert(obj Object) Object

func (*ComponentType) Lookup

func (s *ComponentType) Lookup(name string) Object

func (*ComponentType) Name

func (obj *ComponentType) Name() string

func (*ComponentType) Names

func (s *ComponentType) Names() []string

func (*ComponentType) Node

func (obj *ComponentType) Node() ast.Node

func (*ComponentType) Parent

func (obj *ComponentType) Parent() Scope

func (*ComponentType) Pos

func (obj *ComponentType) Pos() loc.Pos

func (*ComponentType) String

func (c *ComponentType) String() string

func (*ComponentType) Type

func (obj *ComponentType) Type() Type

func (*ComponentType) Underlying

func (c *ComponentType) Underlying() Type

type EnumeratedType added in v0.7.0

type EnumeratedType struct {
	BasicType
	Fields []*Var
	// contains filtered or unexported fields
}

func NewEnumeratedType added in v0.7.0

func NewEnumeratedType(n ast.Node, name string, typ Type) *EnumeratedType

func (*EnumeratedType) End added in v0.7.0

func (obj *EnumeratedType) End() loc.Pos

func (*EnumeratedType) Insert added in v0.7.0

func (s *EnumeratedType) Insert(obj Object) Object

func (*EnumeratedType) Lookup added in v0.7.0

func (s *EnumeratedType) Lookup(name string) Object

func (*EnumeratedType) Name added in v0.7.0

func (obj *EnumeratedType) Name() string

func (*EnumeratedType) Names added in v0.7.0

func (s *EnumeratedType) Names() []string

func (*EnumeratedType) Node added in v0.7.0

func (obj *EnumeratedType) Node() ast.Node

func (*EnumeratedType) Parent added in v0.7.0

func (obj *EnumeratedType) Parent() Scope

func (*EnumeratedType) Pos added in v0.7.0

func (obj *EnumeratedType) Pos() loc.Pos

func (*EnumeratedType) Type added in v0.7.0

func (obj *EnumeratedType) Type() Type

type Func

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

Func describes testcases, altsteps, functions and external functions.

func NewFunc

func NewFunc(n *ast.FuncDecl, name string) *Func

func (*Func) End

func (obj *Func) End() loc.Pos

func (*Func) Name

func (obj *Func) Name() string

func (*Func) Node

func (obj *Func) Node() ast.Node

func (*Func) Parent

func (obj *Func) Parent() Scope

func (*Func) Pos

func (obj *Func) Pos() loc.Pos

func (*Func) Type

func (obj *Func) Type() Type

type Import

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

Import describes the view to an imported module.

func NewImport

func NewImport(n *ast.ImportDecl, name string, module string) *Import

func (*Import) End

func (obj *Import) End() loc.Pos

func (*Import) Name

func (obj *Import) Name() string

func (*Import) Node

func (obj *Import) Node() ast.Node

func (*Import) Parent

func (obj *Import) Parent() Scope

func (*Import) Pos

func (obj *Import) Pos() loc.Pos

func (*Import) Type

func (obj *Import) Type() Type

type Info

type Info struct {

	// Scopes associates identifiers with their enclosing scope.
	Scopes map[*ast.Ident]Scope

	// Types associcates expressions with their evaluated type.
	Types map[ast.Expr]Type

	//
	Fset *loc.FileSet

	//
	Modules map[string]*Module

	//
	Error func(error)

	Import func(name string) error
	// contains filtered or unexported fields
}

Info holds various information about TTCN-3 symbols and types.

func (*Info) Define

func (info *Info) Define(m *ast.Module)

func (*Info) Resolve

func (info *Info) Resolve()

Resolve

type Kind

type Kind int
const (
	Invalid Kind = iota
	Bitstring
	Boolean
	Charstring
	Component
	Float
	Hexstring
	Integer
	Octetstring
	Omit
	Template
	Timer
	UniversalCharstring
	Verdict

	// TODO(5nord) Merge strings types into String and merge integer, float into
	// Numerical. Or make them sort of untyped types like unused, omit and
	// template?
	String
	Numerical
)

type LocalScope

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

func NewLocalScope

func NewLocalScope(rng Range, parent Scope) *LocalScope

func (*LocalScope) Insert

func (s *LocalScope) Insert(obj Object) Object

func (*LocalScope) Lookup

func (ls *LocalScope) Lookup(name string) Object

func (*LocalScope) Names

func (s *LocalScope) Names() []string

type Module

type Module struct {
	Imports []string
	// contains filtered or unexported fields
}

Module describes a Module.

func NewModule

func NewModule(n *ast.Module, name string) *Module

func (*Module) End

func (obj *Module) End() loc.Pos

func (*Module) Insert

func (s *Module) Insert(obj Object) Object

func (*Module) Lookup

func (m *Module) Lookup(name string) Object

func (*Module) Name

func (obj *Module) Name() string

func (*Module) Names

func (s *Module) Names() []string

func (*Module) Node

func (obj *Module) Node() ast.Node

func (*Module) Parent

func (obj *Module) Parent() Scope

func (*Module) Pos

func (obj *Module) Pos() loc.Pos

func (*Module) Type

func (obj *Module) Type() Type

type NoFieldError

type NoFieldError struct {
	Type  string
	Field string
	Pos   loc.Position
}

func (*NoFieldError) Error

func (err *NoFieldError) Error() string

type Object

type Object interface {
	Name() string // Object name.

	// Parent returns the (lexical) scope the object is defined in.
	Parent() Scope

	// Type returns the type of the object.
	Type() Type

	// Node returns the representing AST node of the object.
	Node() ast.Node

	Range
	// contains filtered or unexported methods
}

Object describes a named language entity, such as a function or const.

type Port

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

func NewPort

func NewPort() *Port

func (*Port) End

func (obj *Port) End() loc.Pos

func (*Port) Name

func (obj *Port) Name() string

func (*Port) Node

func (obj *Port) Node() ast.Node

func (*Port) Parent

func (obj *Port) Parent() Scope

func (*Port) Pos

func (obj *Port) Pos() loc.Pos

func (*Port) Type

func (obj *Port) Type() Type

type Range

type Range interface {
	Pos() loc.Pos
	End() loc.Pos
}

Range interface is identical to ast.Node interface and helps handling source code locations.

type RedefinitionError

type RedefinitionError struct {
	Name           string
	OldPos, NewPos loc.Position
}

func (*RedefinitionError) Error

func (err *RedefinitionError) Error() string

type Scope

type Scope interface {

	// Insert attemps to insert an object obj into the Scope. If the scope
	// already contains an alternative object alt with the same name, Insert
	// leaves the scope unchanged and returns altnative object. Otherwise it
	// inserts obj, sets the object's parent scope, if not already set, and
	// returns nil.
	Insert(obj Object) Object

	// Lookup returns the object for a given name. Lookup may follow scope chains.
	Lookup(name string) Object

	// Names lists all names defined in this scope.
	Names() []string
}

type Struct

type Struct struct {
	Fields []*Var
	// contains filtered or unexported fields
}

Struct can be an union, a record or a set structure.

func NewStruct

func NewStruct(rng Range, parent Scope) *Struct

func (*Struct) End

func (s *Struct) End() loc.Pos

func (*Struct) Insert

func (s *Struct) Insert(obj Object) Object

func (*Struct) Lookup

func (s *Struct) Lookup(name string) Object

func (*Struct) Names

func (s *Struct) Names() []string

func (*Struct) Parent

func (s *Struct) Parent() Scope

func (*Struct) Pos

func (s *Struct) Pos() loc.Pos

func (*Struct) String

func (s *Struct) String() string

func (*Struct) Underlying

func (s *Struct) Underlying() Type

type Type

type Type interface {
	// Underlying  returns the underlying type of a type.
	Underlying() Type

	// String returns a string representation of a type.
	String() string
}

Type represents a type in TTCN-3

type TypeName

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

func NewTypeName

func NewTypeName(n ast.Node, name string, typ Type) *TypeName

func (*TypeName) End

func (obj *TypeName) End() loc.Pos

func (*TypeName) Name

func (obj *TypeName) Name() string

func (*TypeName) Node

func (obj *TypeName) Node() ast.Node

func (*TypeName) Parent

func (obj *TypeName) Parent() Scope

func (*TypeName) Pos

func (obj *TypeName) Pos() loc.Pos

func (*TypeName) Type

func (obj *TypeName) Type() Type

type UnknownIdentifierError

type UnknownIdentifierError struct {
	Name string
	Pos  loc.Position
}

func (*UnknownIdentifierError) Error

func (err *UnknownIdentifierError) Error() string

type Var

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

Var describes an object, which can hold an value. This could be a local variable, a constant, a module parameter or a template.

func NewVar

func NewVar(n ast.Node, name string) *Var

func (*Var) End

func (obj *Var) End() loc.Pos

func (*Var) Name

func (obj *Var) Name() string

func (*Var) Node

func (obj *Var) Node() ast.Node

func (*Var) Parent

func (obj *Var) Parent() Scope

func (*Var) Pos

func (obj *Var) Pos() loc.Pos

func (*Var) Type

func (obj *Var) Type() Type

Jump to

Keyboard shortcuts

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