Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

CkDataType Class Reference

Complete description of a datatype. More...

#include <datatype.hpp>

List of all members.

Public Types

enum  Types {
  Undefined = 0, PrimVoid, PrimBool, PrimChar,
  PrimInt, Custom = 255
}
 Enum representing all the data types for the Ck language. More...


Public Member Functions

 CkDataType ()
 Default constructor.

 CkDataType (Types type)
 type constructor

 CkDataType (Types type, int dim)
 Single dimension array constructor.

 CkDataType (Types type, int dim1, int dim2)
 double dimension array constructor

 CkDataType (const CkDataType &other)
 Copy constructor.

virtual ~CkDataType ()
 destructor

void expandDimension (int dim)
 Expand type with one dimension.

unsigned int getNumDimensions () const
 Get the number of dimensions for this variable. 0 means that it is not an array.

unsigned int getDim1Size () const
 Returns size of the first dimension.

unsigned int getDim2Size () const
 Returns size of the second dimension.

void setDimensions (int dim1, int dim2=0)
 Set the dimensions of this datatype.

void setReturnType (Types type)
 Set the basic type of this type.

Types getReturnType () const
 Returns the basic type of this type.

std::string toString () const
 Convert this datatype to a string representation.

std::string toJVMString () const
 Converts this datatype to a JVM identification string.

bool operator== (Types type) const
 Compare datatype to basic datatype.

bool operator!= (Types type) const
 Compare datatype to basic datatype.

bool operator== (const CkDataType &other) const
 Compare two datatypes.

bool operator!= (const CkDataType &other) const
 Compare two datatypes.

CkDataType reduceDimensions (unsigned int dimensions) const
 Return this datatype converted around the given dimensions.


Static Public Member Functions

std::string dataTypeToString (Types type)
 Convert DataTypes to string information.


Private Member Functions

void commontInit ()
 Initializes all variables of this class. Common for all constructors.


Private Attributes

Types Type
int Dimensions [2]


Detailed Description

Complete description of a datatype.

All data types have a basic type which is one of the primitives void, boolean, character or integer. Uninitialized datatypes start out with the type Undefined. In addition datatypes can have one or two vectors which mean that they are arrays. This class can be extended later to support custom datatypes like structs and classes.

Definition at line 22 of file datatype.hpp.


Member Enumeration Documentation

enum CkDataType::Types
 

Enum representing all the data types for the Ck language.

Enumeration values:
Undefined  Unspecified data type. The initial state for empty DataType objects
PrimVoid  Primitive void
PrimBool  Primitive boolean
PrimChar  Primitive character
PrimInt  Primitive integer
Custom  Custom datatype, structs or classes

Definition at line 26 of file datatype.hpp.

Referenced by getReturnType().


Member Function Documentation

string CkDataType::dataTypeToString Types  type  )  [static]
 

Convert DataTypes to string information.

Parameters:
type The type you want to convert
Returns:
The string representation of the type.

Definition at line 104 of file datatype.cpp.

References Custom, PrimBool, PrimChar, PrimInt, PrimVoid, and Undefined.

Referenced by toString().

void CkDataType::expandDimension int  dim  ) 
 

Expand type with one dimension.

The new dimension is added in front.

Parameters:
dim Size of new dimension

Definition at line 81 of file datatype.cpp.

CkDataType CkDataType::reduceDimensions unsigned int  varDimensions  )  const
 

Return this datatype converted around the given dimensions.

e.g this datatype is int[2][5]; converting 1 dimensions returns a datatype that is int[5] converting 2 dimensions return a datatype that is int

Definition at line 223 of file datatype.cpp.

References getNumDimensions(), and setDimensions().

void CkDataType::setDimensions int  dim1,
int  dim2 = 0
[inline]
 

Set the dimensions of this datatype.

The default is the 0,0 dimension which means that this type is not an array type.

Parameters:
dim1 The first dimension
dim2 The second dimension

Definition at line 56 of file datatype.hpp.

Referenced by reduceDimensions().

string CkDataType::toJVMString  )  const
 

Converts this datatype to a JVM identification string.

Returns:
the JVM id string.

Definition at line 145 of file datatype.cpp.

References PrimBool, PrimChar, PrimInt, and PrimVoid.

string CkDataType::toString  )  const
 

Convert this datatype to a string representation.

This function converts the datatype to a literal representation: e.g An non array integer type is represented as "int". A multidimensional integer array with dimensions 2 and 4 is represted as "int[2][4]"

Definition at line 125 of file datatype.cpp.

References dataTypeToString().


The documentation for this class was generated from the following files:
Generated on Mon Dec 1 14:26:28 2003 for Ck by doxygen 1.3.3