UTAP::type_t Class Reference

A reference to a type. More...

#include <type.h>

List of all members.

Public Member Functions

 type_t ()
 Default constructor.
 type_t (const type_t &)
 Copy constructor.
 ~type_t ()
 Destructor.
const type_toperator= (const type_t &)
 Assignment operator.
bool operator== (const type_t &) const
 Equality operator.
bool operator!= (const type_t &) const
 Inequality operator.
Constants::kind_t getKind () const
 Returns the kind of type object.
position_t getPosition () const
 Returns the position of the type in the input file.
size_t size () const
 Returns the number of children.
bool operator< (const type_t &) const
 Less-than operator.
const type_t operator[] (uint32_t) const
 Returns the i'th child.
const type_t get (uint32_t) const
 Returns the i'th child.
const std::string & getLabel (uint32_t) const
 Returns the i'th label.
expression_t getExpression () const
 Returns the expression associated with the type.
type_t getArraySize () const
 Returns the size of an array (this is itself a type).
type_t getSub () const
 Returns the element type of an array.
type_t getSub (size_t) const
 Returns the 'th field of a record or process.
size_t getRecordSize () const
 Returns the number of fields of a record.
std::string getRecordLabel (size_t i) const
 Returns the label of the 'th field of a record.
int32_t findIndexOf (std::string) const
 Returns the index of the record or process field with the given label.
std::pair< expression_t, expression_tgetRange () const
 Returns the range of a RANGE type.
std::string toString () const
 Generates string representation of the type.
bool isInteger () const
 Shortcut for is(INT).
bool isBoolean () const
 Shortcut for is(BOOL).
bool isFunction () const
 Shortcut for is(FUNCTION).
bool isProcess () const
 Shortcut for is(PROCESS).
bool isProcessSet () const
 Shortcut for is(PROCESSSET).
bool isLocation () const
 Shortcut for is(LOCATION).
bool isChannel () const
 Shortcut for is(CHANNEL).
bool isArray () const
 Shortcut for is(ARRAY).
bool isScalar () const
 Shortcut for is(SCALAR).
bool isClock () const
 Shortcut for is(CLOCK).
bool isRecord () const
 Shortcut for is(RECORD).
bool isDiff () const
 Shortcut for is(DIFF).
bool isVoid () const
 Shortcut for is(VOID_TYPE).
bool isCost () const
 Shortcut for is(COST).
bool isIntegral () const
 Returns true if this is a boolean or integer.
bool isInvariant () const
 Returns true if this is an invariant, boolean or integer.
bool isGuard () const
 Returns true if this is a guard, invariant, boolean or integer.
bool isConstraint () const
 Returns true if this is a constraint, guard, invariant, boolean or integer.
bool isFormula () const
 Returns true if this is a formula, constraint, guard, invariant, boolean or integer.
type_t strip () const
 Removes any leading prefixes, RANGE, REF and LABEL types and returns the result.
type_t stripArray () const
 Removes any leading prefixes, RANGE, REF, LABEL and ARRAY types and returns the result.
bool isPrefix () const
 Returns false for non-prefix types and true otherwise.
bool isConstant () const
 Returns true if and only if all elements of the type are constant.
bool isNonConstant () const
 Returns true if and only if all elements of the type are not constant.
bool is (Constants::kind_t kind) const
 Returns true if the type has kind kind or if type is a prefix, RANGE or REF type and the getChild().is(kind) returns true.
bool unknown () const
 Returns true if this is null-type or of kind UNKNOWN.
type_t rename (std::string from, std::string to) const
 Replaces any LABEL labeled from occuring in the type with a LABEL to.
type_t subst (symbol_t symbol, expression_t expr) const
 Substitutes any occurence of symbol in any expression in the type (expressions that occur as ranges either on array sizes, scalars or integers) with expr.
type_t createPrefix (Constants::kind_t kind, position_t=position_t()) const
 Creates a new type by adding a prefix to it.
type_t createLabel (std::string, position_t=position_t()) const
 Creates a LABEL.
type_t createPosition (position_t=position_t()) const

Static Public Member Functions

static type_t createRange (type_t, expression_t, expression_t, position_t=position_t())
static type_t createPrimitive (Constants::kind_t, position_t=position_t())
 Create a primitive type.
static type_t createArray (type_t sub, type_t size, position_t=position_t())
 Creates an array type.
static type_t createTypeDef (std::string, type_t, position_t=position_t())
 Creates a new type definition.
static type_t createProcess (frame_t, position_t=position_t())
 Creates a new process type.
static type_t createProcessSet (type_t instance, position_t=position_t())
 Creates a new processset type.
static type_t createRecord (const std::vector< type_t > &, const std::vector< std::string > &, position_t=position_t())
 Creates a new record type.
static type_t createFunction (type_t, const std::vector< type_t > &, const std::vector< std::string > &, position_t=position_t())
 Creates a new function type.
static type_t createInstance (frame_t, position_t=position_t())
 Creates a new instance type.


Detailed Description

A reference to a type.

Types are represented as trees of types. The type cannot be access directly. You need to use an instance of type_t to access a type. Internally, types are reference counted and do not need to be deallocated manually. Types are immutable.

Types are either primitive such as clocks or channels, or contructed types such as structs and array. Constructed types are created using one of the factory methods in the type_t class. Primitive types are leaves in the tree, constructed types are inner nodes.

All types have a kind - a type for the type. The kind is a value of kind_t. In anticipation of a future homogeneous AST, this kind is defined in the same enumerable as the kind of expressions.

Some constructed types are considered prefixes for other types: URGENT, COMMITTED, BROADCAST, CONSTANT and BROADCAST.

LABEL types are references to named types. These are introduced by references to types defined with a typedef or by scalar set declarations. They have one child: The type which has been named.

Constructed types are:


Constructor & Destructor Documentation

UTAP::type_t::type_t (  ) 

Default constructor.

This creates a null-type.

UTAP::type_t::type_t ( const type_t  ) 

Copy constructor.

UTAP::type_t::~type_t (  ) 

Destructor.


Member Function Documentation

static type_t UTAP::type_t::createArray ( type_t  sub,
type_t  size,
position_t  = position_t() 
) [static]

Creates an array type.

static type_t UTAP::type_t::createFunction ( type_t  ,
const std::vector< type_t > &  ,
const std::vector< std::string > &  ,
position_t  = position_t() 
) [static]

Creates a new function type.

static type_t UTAP::type_t::createInstance ( frame_t  ,
position_t  = position_t() 
) [static]

Creates a new instance type.

type_t UTAP::type_t::createLabel ( std::string  ,
position_t  = position_t() 
) const

Creates a LABEL.

type_t UTAP::type_t::createPosition ( position_t  = position_t()  )  const

type_t UTAP::type_t::createPrefix ( Constants::kind_t  kind,
position_t  = position_t() 
) const

Creates a new type by adding a prefix to it.

The prefix could be anything and it is the responsibility of the caller to make sure that the given kind is a valid prefix.

static type_t UTAP::type_t::createPrimitive ( Constants::kind_t  ,
position_t  = position_t() 
) [static]

Create a primitive type.

static type_t UTAP::type_t::createProcess ( frame_t  ,
position_t  = position_t() 
) [static]

Creates a new process type.

static type_t UTAP::type_t::createProcessSet ( type_t  instance,
position_t  = position_t() 
) [static]

Creates a new processset type.

static type_t UTAP::type_t::createRange ( type_t  ,
expression_t  ,
expression_t  ,
position_t  = position_t() 
) [static]

static type_t UTAP::type_t::createRecord ( const std::vector< type_t > &  ,
const std::vector< std::string > &  ,
position_t  = position_t() 
) [static]

Creates a new record type.

static type_t UTAP::type_t::createTypeDef ( std::string  ,
type_t  ,
position_t  = position_t() 
) [static]

Creates a new type definition.

int32_t UTAP::type_t::findIndexOf ( std::string   )  const

Returns the index of the record or process field with the given label.

Returns -1 if such a field does not exist.

Precondition:
isRecord() or isProcess().

const type_t UTAP::type_t::get ( uint32_t   )  const

Returns the i'th child.

type_t UTAP::type_t::getArraySize (  )  const

Returns the size of an array (this is itself a type).

Precondition:
isArray().

expression_t UTAP::type_t::getExpression (  )  const

Returns the expression associated with the type.

Constants::kind_t UTAP::type_t::getKind (  )  const

Returns the kind of type object.

const std::string& UTAP::type_t::getLabel ( uint32_t   )  const

Returns the i'th label.

position_t UTAP::type_t::getPosition (  )  const

Returns the position of the type in the input file.

This exposes the fact that the type is actually part of the AST.

std::pair<expression_t, expression_t> UTAP::type_t::getRange (  )  const

Returns the range of a RANGE type.

Precondition:
isRange().

std::string UTAP::type_t::getRecordLabel ( size_t  i  )  const

Returns the label of the 'th field of a record.

Precondition:
isRecord().

size_t UTAP::type_t::getRecordSize (  )  const

Returns the number of fields of a record.

Precondition:
isRecord().

type_t UTAP::type_t::getSub ( size_t   )  const

Returns the 'th field of a record or process.

Preserves any prefixes.

Precondition:
isRecord() or isProcess().

type_t UTAP::type_t::getSub (  )  const

Returns the element type of an array.

Preserves any prefixes.

Precondition:
isArray();

bool UTAP::type_t::is ( Constants::kind_t  kind  )  const

Returns true if the type has kind kind or if type is a prefix, RANGE or REF type and the getChild().is(kind) returns true.

bool UTAP::type_t::isArray (  )  const [inline]

Shortcut for is(ARRAY).

bool UTAP::type_t::isBoolean (  )  const [inline]

Shortcut for is(BOOL).

bool UTAP::type_t::isChannel (  )  const [inline]

Shortcut for is(CHANNEL).

bool UTAP::type_t::isClock (  )  const [inline]

Shortcut for is(CLOCK).

bool UTAP::type_t::isConstant (  )  const

Returns true if and only if all elements of the type are constant.

bool UTAP::type_t::isConstraint (  )  const

Returns true if this is a constraint, guard, invariant, boolean or integer.

Shortcut for is(CONSTRAINT) || isGuard().

bool UTAP::type_t::isCost (  )  const [inline]

Shortcut for is(COST).

bool UTAP::type_t::isDiff (  )  const [inline]

Shortcut for is(DIFF).

bool UTAP::type_t::isFormula (  )  const

Returns true if this is a formula, constraint, guard, invariant, boolean or integer.

Shortcut for is(FORMULA) || isConstraint().

bool UTAP::type_t::isFunction (  )  const [inline]

Shortcut for is(FUNCTION).

bool UTAP::type_t::isGuard (  )  const

Returns true if this is a guard, invariant, boolean or integer.

Shortcut for is(GUARD) || isInvariant().

bool UTAP::type_t::isInteger (  )  const [inline]

Shortcut for is(INT).

bool UTAP::type_t::isIntegral (  )  const

Returns true if this is a boolean or integer.

Shortcut for isInt() || isBoolean().

bool UTAP::type_t::isInvariant (  )  const

Returns true if this is an invariant, boolean or integer.

Shortcut for isIntegral() || is(INVARIANT).

bool UTAP::type_t::isLocation (  )  const [inline]

Shortcut for is(LOCATION).

bool UTAP::type_t::isNonConstant (  )  const

Returns true if and only if all elements of the type are not constant.

bool UTAP::type_t::isPrefix (  )  const

Returns false for non-prefix types and true otherwise.

Non-prefix types are PRIMITIVE, ARRAY, RECORD, PROCESS, TEMPLATE, FUNCTION, INSTANCE, RANGE, REF, TYPEDEF.

bool UTAP::type_t::isProcess (  )  const [inline]

Shortcut for is(PROCESS).

bool UTAP::type_t::isProcessSet (  )  const [inline]

Shortcut for is(PROCESSSET).

bool UTAP::type_t::isRecord (  )  const [inline]

Shortcut for is(RECORD).

bool UTAP::type_t::isScalar (  )  const [inline]

Shortcut for is(SCALAR).

bool UTAP::type_t::isVoid (  )  const [inline]

Shortcut for is(VOID_TYPE).

bool UTAP::type_t::operator!= ( const type_t  )  const

Inequality operator.

bool UTAP::type_t::operator< ( const type_t  )  const

Less-than operator.

const type_t& UTAP::type_t::operator= ( const type_t  ) 

Assignment operator.

bool UTAP::type_t::operator== ( const type_t  )  const

Equality operator.

const type_t UTAP::type_t::operator[] ( uint32_t   )  const

Returns the i'th child.

type_t UTAP::type_t::rename ( std::string  from,
std::string  to 
) const

Replaces any LABEL labeled from occuring in the type with a LABEL to.

As always, a type is immutable, so a copy of the type will be created.

size_t UTAP::type_t::size (  )  const

Returns the number of children.

type_t UTAP::type_t::strip (  )  const

Removes any leading prefixes, RANGE, REF and LABEL types and returns the result.

type_t UTAP::type_t::stripArray (  )  const

Removes any leading prefixes, RANGE, REF, LABEL and ARRAY types and returns the result.

type_t UTAP::type_t::subst ( symbol_t  symbol,
expression_t  expr 
) const

Substitutes any occurence of symbol in any expression in the type (expressions that occur as ranges either on array sizes, scalars or integers) with expr.

std::string UTAP::type_t::toString (  )  const

Generates string representation of the type.

bool UTAP::type_t::unknown (  )  const

Returns true if this is null-type or of kind UNKNOWN.


The documentation for this class was generated from the following file:
Generated on Thu Feb 22 14:46:53 2007 for libutap by  doxygen 1.4.7