comma::DiscreteType Class Reference

#include <Type.h>

Inheritance diagram for comma::DiscreteType:
Inheritance graph
[legend]
Collaboration diagram for comma::DiscreteType:
Collaboration graph
[legend]

List of all members.

Public Types

enum  ContainmentResult { Is_Contained, Not_Contained, Maybe_Contained }

Public Member Functions

virtual IdentifierInfogetIdInfo () const =0
 Returns the defining identifier for this type.
virtual void getUpperLimit (llvm::APInt &res) const =0
virtual void getLowerLimit (llvm::APInt &res) const =0
virtual uint64_t getSize () const =0
uint64_t length () const
ContainmentResult contains (const DiscreteType *target) const
ContainmentResult contains (const llvm::APInt &value) const
 Returns a ContainmentResult for the given integer value.
bool isSigned () const
bool isStaticallyConstrained () const
 Returns true if this type is constrained and the constraints are static.
bool isDynamicallyConstrained () const
virtual PosADgetPosAttribute ()=0
virtual ValADgetValAttribute ()=0



const DiscreteTypegetRootType () const
 Specialization of PrimaryType::getRootType().
DiscreteTypegetRootType ()
 Specialization of PrimaryType::getRootType().
virtual RangegetConstraint ()=0
virtual const RangegetConstraint () const =0
 Specialization of PrimaryType::getRootType().

Static Public Member Functions

static bool classof (const DiscreteType *node)
 Support isa and dyn_cast.
static bool classof (const Ast *node)

Protected Member Functions

 DiscreteType (AstKind kind, DiscreteType *rootOrParent, bool subtype)

Static Protected Member Functions

static unsigned getPreferredSize (uint64_t bits)

Detailed Description

The DiscreteType class forms a common base for integer and enumeration types.

Definition at line 599 of file Type.h.


Member Enumeration Documentation

The following enumeration is used to report the result of containment predicates. These values define a ternary logic.

Enumerator:
Is_Contained 
Not_Contained 
Maybe_Contained 

Definition at line 635 of file Type.h.


Constructor & Destructor Documentation

comma::DiscreteType::DiscreteType ( AstKind  kind,
DiscreteType rootOrParent,
bool  subtype 
) [inline, protected]

Definition at line 718 of file Type.h.


Member Function Documentation

static bool comma::DiscreteType::classof ( const Ast node  )  [inline, static]

Reimplemented from comma::PrimaryType.

Reimplemented in comma::EnumerationType, and comma::IntegerType.

Definition at line 713 of file Type.h.

static bool comma::DiscreteType::classof ( const DiscreteType node  )  [inline, static]

Support isa and dyn_cast.

Reimplemented from comma::PrimaryType.

Reimplemented in comma::EnumerationType, and comma::IntegerType.

Definition at line 712 of file Type.h.

DiscreteType::ContainmentResult DiscreteType::contains ( const llvm::APInt &  value  )  const

Returns a ContainmentResult for the given integer value.

Definition at line 430 of file Type.cpp.

DiscreteType::ContainmentResult DiscreteType::contains ( const DiscreteType target  )  const

Returns a ContainmentResult indicating if this DiscreteType contains another.

This type and the target type must be of the same category. That is, both must be integer, enumeration, or (when implemented) modular types.

Containment is with respect to the bounds on the types. If a type is constrained, then the constraint is used for the bounds, otherwise the representational limits of the root type are used.

If this type is constrained to a null range it can never contain the target, including other null types (with the only exception being that all types trivially contain themselves). If this type is not constrained to a null range, then it always contains a target type that is.

If this type has a non-static constraint, this method always returns Maby_Contained. If the target has a non-static constraint but the bounds for this type are known, containment is known only if this type contains the root type of the target.

Definition at line 357 of file Type.cpp.

virtual const Range* comma::DiscreteType::getConstraint (  )  const [pure virtual]

Specialization of PrimaryType::getRootType().

Implemented in comma::EnumerationType, and comma::IntegerType.

virtual Range* comma::DiscreteType::getConstraint (  )  [pure virtual]

Returns the constraint associated with this DiscreteType or null if this type is unconstrained.

Implemented in comma::EnumerationType, and comma::IntegerType.

virtual IdentifierInfo* comma::DiscreteType::getIdInfo (  )  const [pure virtual]

Returns the defining identifier for this type.

virtual void comma::DiscreteType::getLowerLimit ( llvm::APInt &  res  )  const [pure virtual]

Returns the lower limit for this type.

The lower limit is the smallest value which can be represented by the underlying root type. Note that this is not a bound as expressed via a subtype constraint.

Implemented in comma::EnumerationType, and comma::IntegerType.

virtual PosAD* comma::DiscreteType::getPosAttribute (  )  [pure virtual]

Returns the declaration corresponding to the Pos attribute for this type.

Implemented in comma::EnumerationType, and comma::IntegerType.

unsigned DiscreteType::getPreferredSize ( uint64_t  bits  )  [static, protected]

Definition at line 470 of file Type.cpp.

DiscreteType* comma::DiscreteType::getRootType (  )  [inline]

Specialization of PrimaryType::getRootType().

Reimplemented from comma::PrimaryType.

Reimplemented in comma::EnumerationType, and comma::IntegerType.

Definition at line 676 of file Type.h.

const DiscreteType* comma::DiscreteType::getRootType (  )  const [inline]

Specialization of PrimaryType::getRootType().

Reimplemented from comma::PrimaryType.

Reimplemented in comma::EnumerationType, and comma::IntegerType.

Definition at line 673 of file Type.h.

virtual uint64_t comma::DiscreteType::getSize (  )  const [pure virtual]

Returns the number of bits needed to represent this type.

The value returned by this method is equivalent to Size attribute. The number returned specifies the minimum number of bits needed to represent values of this type, as opposed to the number of bits used to represent values of this type at runtime.

Implemented in comma::EnumerationType, and comma::IntegerType.

virtual void comma::DiscreteType::getUpperLimit ( llvm::APInt &  res  )  const [pure virtual]

Returns the upper limit for this type.

The upper limit is the greatest value which can be represented by the underlying root type. Note that this is not a bound as expressed via a subtype constraint.

Implemented in comma::EnumerationType, and comma::IntegerType.

virtual ValAD* comma::DiscreteType::getValAttribute (  )  [pure virtual]

Returns the declaration corresponding to the Val attribute for this type.

Implemented in comma::EnumerationType, and comma::IntegerType.

bool comma::DiscreteType::isDynamicallyConstrained (  )  const [inline]

Returns true if this type is constrained and at least one component of the constraint is dynamic.

Definition at line 697 of file Type.h.

bool DiscreteType::isSigned (  )  const

Returns true if this denotes a signed discrete type.

Currently, Integers are signed while enumerations are unsigned.

Definition at line 491 of file Type.cpp.

bool comma::DiscreteType::isStaticallyConstrained (  )  const [inline]

Returns true if this type is constrained and the constraints are static.

Definition at line 689 of file Type.h.

uint64_t DiscreteType::length (  )  const

Returns the number of elements representable by this type.

This method may only be called on a statically constrained or unconstrained type, else an assertion will fire.

Definition at line 497 of file Type.cpp.


The documentation for this class was generated from the following files:

Generated on 1 Feb 2010 for Comma by  doxygen 1.6.1