Puma Reference Manual Puma: Puma::CConstant Class Reference



Puma::CConstant Class Reference

Semantic information object for arithmetic constants. More...

#include <Puma/CConstant.h>

Inheritance diagram for Puma::CConstant:
Inheritance graph

List of all members.

Classes

union  Value

Public Member Functions

 CConstant (LONG_LONG v, CTypeInfo *t)
 Constructor.
 CConstant (U_LONG_LONG v, CTypeInfo *t)
 Constructor.
 CConstant (long double v, CTypeInfo *t)
 Constructor.
virtual ~CConstant ()
 Destructor.
CConstantcast_to (CTypeInfo *t) const
 Cast the value to the given type.
CConstantcompute (int oper) const
 Compute the resulting value when applying the given unary operator to the value.
CConstantcompute (int oper, const CConstant *v) const
 Compute the resulting value when applying the given binary operator to this and the given value.
LONG_LONG convert_to_int () const
 Convert the value to a signed integer.
U_LONG_LONG convert_to_uint () const
 Convert the value to an unsiged integer.
long double convert_to_float () const
 Convert the value to floating point.
CConstantConstant () const
 Get this.
CConstantduplicate () const
 Duplicate this.
bool operator== (const CConstant &c) const
 Compare the value of this and the given constant.
bool operator!= (const CConstant &c) const
 Compare the value of this and the given constant.
bool isNull () const
 Check if the constant value is 0, regardless of the type.
bool isPositive () const
 Check if the value is positive (>= 0).
bool isNegative () const
 Check if the value is negative (< 0).
bool isSigned () const
 Check if the value is signed.
bool isUnsigned () const
 Check if the value is unsigned.
bool isFloat () const
 Check is the value is a floating point value.
virtual void print (ostream &out) const
 Print the value on the given output stream.

Detailed Description

Semantic information object for arithmetic constants.


Constructor & Destructor Documentation

Puma::CConstant::CConstant ( LONG_LONG  v,
CTypeInfo t 
) [inline]

Constructor.

Parameters:
vThe value.
tThe type of the value.
Puma::CConstant::CConstant ( U_LONG_LONG  v,
CTypeInfo t 
) [inline]

Constructor.

Parameters:
vThe value.
tThe type of the value.
Puma::CConstant::CConstant ( long double  v,
CTypeInfo t 
) [inline]

Constructor.

Parameters:
vThe value.
tThe type of the value.
virtual Puma::CConstant::~CConstant ( ) [inline, virtual]

Destructor.


Member Function Documentation

CConstant* Puma::CConstant::cast_to ( CTypeInfo t) const

Cast the value to the given type.

Parameters:
tThe type to which to cast.
Returns:
A new object with the casted value. Has to be destroyed by the caller.
CConstant* Puma::CConstant::compute ( int  oper) const

Compute the resulting value when applying the given unary operator to the value.

Parameters:
operThe operator to apply to the value (token type).
Returns:
A new object with the computed value. Has to be destroyed by the caller.
CConstant* Puma::CConstant::compute ( int  oper,
const CConstant v 
) const

Compute the resulting value when applying the given binary operator to this and the given value.

Parameters:
operThe operator to apply to the values (token type).
vThe other operand to the operator.
Returns:
A new object with the computed value. Has to be destroyed by the caller.
CConstant* Puma::CConstant::Constant ( ) const [inline, virtual]

Get this.

Reimplemented from Puma::CExprValue.

long double Puma::CConstant::convert_to_float ( ) const

Convert the value to floating point.

LONG_LONG Puma::CConstant::convert_to_int ( ) const

Convert the value to a signed integer.

U_LONG_LONG Puma::CConstant::convert_to_uint ( ) const

Convert the value to an unsiged integer.

CConstant* Puma::CConstant::duplicate ( ) const

Duplicate this.

Returns:
A newly allocated duplicate of this. Has to be destroyed by the caller.
bool Puma::CConstant::isFloat ( ) const [inline]

Check is the value is a floating point value.

bool Puma::CConstant::isNegative ( ) const

Check if the value is negative (< 0).

bool Puma::CConstant::isNull ( ) const

Check if the constant value is 0, regardless of the type.

bool Puma::CConstant::isPositive ( ) const

Check if the value is positive (>= 0).

bool Puma::CConstant::isSigned ( ) const [inline]

Check if the value is signed.

bool Puma::CConstant::isUnsigned ( ) const [inline]

Check if the value is unsigned.

bool Puma::CConstant::operator!= ( const CConstant c) const

Compare the value of this and the given constant.

Does not compare the types.

Parameters:
cThe value to compare to.
Returns:
True if the values are not equal.
bool Puma::CConstant::operator== ( const CConstant c) const

Compare the value of this and the given constant.

Does not compare the types.

Parameters:
cThe value to compare to.
Returns:
True if the values are equal.
virtual void Puma::CConstant::print ( ostream &  out) const [virtual]

Print the value on the given output stream.

Parameters:
outThe output stream.

Implements Puma::CExprValue.