types

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package types provides type inference and checking for TTCN-3.

Index

Constants

This section is empty.

Variables

View Source
var (
	Integer = &Basic{kind: IntegerType}
	Boolean = &Basic{kind: BooleanType}
)

Functions

func Equal

func Equal(a, b Object) bool

Equal returns true if the two object are equal.

Types

type Basic

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

Basic represents a basic TTCN-3 type, such as integer, boolean, ...

func (*Basic) CompatibleTo

func (b *Basic) CompatibleTo(other Type) bool

func (*Basic) EnclosingScope

func (b *Basic) EnclosingScope() Scope

func (*Basic) Kind

func (b *Basic) Kind() Kind

func (*Basic) String

func (b *Basic) String() string

type Component added in v0.11.0

type Component struct {
	Scope   Scope
	Extends []*Component
	// contains filtered or unexported fields
}

Component represents a component type.

func (*Component) Begin added in v0.11.0

func (c *Component) Begin() loc.Position

func (*Component) CompatibleTo added in v0.11.0

func (c *Component) CompatibleTo(other Type) bool

func (*Component) EnclosingScope added in v0.11.0

func (c *Component) EnclosingScope() Scope

func (*Component) End added in v0.11.0

func (c *Component) End() loc.Position

func (*Component) Insert added in v0.11.0

func (c *Component) Insert(name string, obj Object) Object

Insert inserts an object into the scope.

func (*Component) Kind added in v0.11.0

func (c *Component) Kind() Kind

func (*Component) Lookup added in v0.11.0

func (c *Component) Lookup(name string) Object

Lookup returns the object with the given name in the scope.

func (*Component) Names added in v0.11.0

func (c *Component) Names() []string

Names returns the names of all objects in the scope using the order of insertion.

type Info

type Info struct {
	Types  map[ast.Node]Type
	Scopes map[ast.Node]Scope
	// contains filtered or unexported fields
}

func (*Info) InsertTree

func (info *Info) InsertTree(n ast.Node, scp Scope) error

InsertTree inserts the given syntax tree n into the given parent scope scp.

func (*Info) TypeOf

func (info *Info) TypeOf(n ast.Node, scp Scope) Type

TypeOf returns the type of the given expression/typespec. The given scope is stored to resolve type references later.

type Kind

type Kind string

Kind returns the kind of the object.

const (
	UnknownType    Kind = "unknown type"
	IntegerType    Kind = "integer"
	UnionType      Kind = "union"
	EnumeratedType Kind = "enumerated"
	SetType        Kind = "set"
	RecordType     Kind = "record"
	BooleanType    Kind = "boolean"
	RecordOfType   Kind = "record of"
	SetOfType      Kind = "set of"
	ArrayType      Kind = "array of"
	ComponentType  Kind = "component"
	TypeReference  Kind = "type reference"
)

type List added in v0.11.0

type List struct {
	ElemType Type
	Scope    Scope
	// contains filtered or unexported fields
}

func (*List) Begin added in v0.11.0

func (l *List) Begin() loc.Position

func (*List) CompatibleTo added in v0.11.0

func (l *List) CompatibleTo(other Type) bool

func (*List) EnclosingScope added in v0.11.0

func (l *List) EnclosingScope() Scope

func (*List) End added in v0.11.0

func (l *List) End() loc.Position

func (*List) Kind added in v0.11.0

func (l *List) Kind() Kind

type Module added in v0.11.0

type Module struct {
	Name  string
	Scope Scope
	// contains filtered or unexported fields
}

Module represents a TTCN-3 module.

func (*Module) EnclosingScope added in v0.11.0

func (m *Module) EnclosingScope() Scope

EnclsosingScope returns the parent (== global) scope of the module

func (*Module) Insert added in v0.11.0

func (m *Module) Insert(name string, obj Object) Object

Insert inserts an object into the scope.

func (*Module) Lookup added in v0.11.0

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

Lookup returns the object with the given name in the scope.

func (*Module) Names added in v0.11.0

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

Names returns the names of all objects in the scope using the order of insertion.

type NamedType added in v0.11.0

type NamedType struct {
	Name  string
	Type  Type
	Scope Scope
}

func (*NamedType) CompatibleTo added in v0.11.0

func (n *NamedType) CompatibleTo(other Type) bool

func (*NamedType) EnclosingScope added in v0.11.0

func (n *NamedType) EnclosingScope() Scope

func (*NamedType) Kind added in v0.11.0

func (n *NamedType) Kind() Kind

type NodeNotImplementedError

type NodeNotImplementedError struct {
	Node ast.Node
}

NodeNotImplementedError is returned when a syntax node is not implemented.

func (*NodeNotImplementedError) Error

func (e *NodeNotImplementedError) Error() string

type Object

type Object interface {
	// Scope returns the enclosing (== lexical) scope of an object.
	EnclosingScope() Scope
}

Object represents a type system object; such a scope, a types, a variable, ...

type Range

type Range interface {
	Begin() loc.Position
	End() loc.Position
}

Range represents a range of TTCN-3 source code.

type RedefinitionError

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

func (*RedefinitionError) Error

func (e *RedefinitionError) Error() string

type Ref

type Ref struct {
	Expr ast.Expr // The expression that refers to the object.

	Scp Scope  // The context ( == scope) of the reference.
	Obj Object // The object referenced by the reference.
}

Ref is a reference to an object.

func (*Ref) CompatibleTo added in v0.11.0

func (r *Ref) CompatibleTo(other Type) bool

func (*Ref) EnclosingScope

func (r *Ref) EnclosingScope() Scope

func (*Ref) Kind added in v0.11.0

func (r *Ref) Kind() Kind

type Scope

type Scope interface {
	Object

	// Insert inserts an object into the scope.
	Insert(name string, obj Object) Object

	// Lookup returns the object with the given name in the scope.
	Lookup(name string) Object

	// Names returns the names of all objects in the scope.
	Names() []string
}

Scope represents a TTCN-3 scope; such as a modules, a function, ...

type Struct added in v0.11.0

type Struct struct {
	Scope Scope
	// contains filtered or unexported fields
}

Struct represents a structured type, such as record, set, union or enumerated.

func (*Struct) Begin added in v0.11.0

func (s *Struct) Begin() loc.Position

func (*Struct) CompatibleTo added in v0.11.0

func (s *Struct) CompatibleTo(other Type) bool

func (*Struct) EnclosingScope added in v0.11.0

func (s *Struct) EnclosingScope() Scope

func (*Struct) End added in v0.11.0

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

func (*Struct) Insert added in v0.11.0

func (s *Struct) Insert(name string, obj Object) Object

Insert inserts an object into the scope.

func (*Struct) Kind added in v0.11.0

func (s *Struct) Kind() Kind

func (*Struct) Lookup added in v0.11.0

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

Lookup returns the object with the given name in the scope.

func (*Struct) Names added in v0.11.0

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

Names returns the names of all objects in the scope using the order of insertion.

type Type

type Type interface {
	Object

	Kind() Kind

	// Compatible returns true if the type is compatible with the given type.
	CompatibleTo(other Type) bool
}

Type represents a TTCN-3 type.

type Var

type Var struct {
	Name  string
	Type  Type
	Scope Scope
	// contains filtered or unexported fields
}

Var represents a variable.

func (*Var) Begin

func (v *Var) Begin() loc.Position

func (*Var) EnclosingScope

func (v *Var) EnclosingScope() Scope

func (*Var) End

func (v *Var) End() loc.Position

Jump to

Keyboard shortcuts

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