#include <Puma/CConstant.h>
Semantic information object for arithmetic constants.
◆ CConstant() [1/3]
Constructor.
- Parameters
-
v | The value. |
t | The type of the value. |
◆ CConstant() [2/3]
Constructor.
- Parameters
-
v | The value. |
t | The type of the value. |
◆ CConstant() [3/3]
Puma::CConstant::CConstant |
( |
long double | v, |
|
|
CTypeInfo * | t ) |
|
inline |
Constructor.
- Parameters
-
v | The value. |
t | The type of the value. |
◆ ~CConstant()
virtual Puma::CConstant::~CConstant |
( |
| ) |
|
|
inlinevirtual |
◆ cast_to()
Cast the value to the given type.
- Parameters
-
t | The type to which to cast. |
- Returns
- A new object with the casted value. Has to be destroyed by the caller.
◆ compute() [1/2]
CConstant * Puma::CConstant::compute |
( |
int | oper | ) |
const |
Compute the resulting value when applying the given unary operator to the value.
- Parameters
-
oper | The operator to apply to the value (token type). |
- Returns
- A new object with the computed value. Has to be destroyed by the caller.
◆ compute() [2/2]
Compute the resulting value when applying the given binary operator to this and the given value.
- Parameters
-
oper | The operator to apply to the values (token type). |
v | The other operand to the operator. |
- Returns
- A new object with the computed value. Has to be destroyed by the caller.
◆ Constant()
CConstant * Puma::CConstant::Constant |
( |
| ) |
const |
|
inlinevirtual |
◆ convert_to_float()
long double Puma::CConstant::convert_to_float |
( |
| ) |
const |
Convert the value to floating point.
◆ convert_to_int()
LONG_LONG Puma::CConstant::convert_to_int |
( |
| ) |
const |
Convert the value to a signed integer.
◆ convert_to_uint()
Convert the value to an unsiged integer.
◆ duplicate()
CConstant * Puma::CConstant::duplicate |
( |
| ) |
const |
Duplicate this.
- Returns
- A newly allocated duplicate of this. Has to be destroyed by the caller.
◆ isFloat()
bool Puma::CConstant::isFloat |
( |
| ) |
const |
|
inline |
Check is the value is a floating point value.
◆ isNegative()
bool Puma::CConstant::isNegative |
( |
| ) |
const |
Check if the value is negative (< 0).
◆ isNull()
bool Puma::CConstant::isNull |
( |
| ) |
const |
Check if the constant value is 0, regardless of the type.
◆ isPositive()
bool Puma::CConstant::isPositive |
( |
| ) |
const |
Check if the value is positive (>= 0).
◆ isSigned()
bool Puma::CConstant::isSigned |
( |
| ) |
const |
|
inline |
Check if the value is signed.
◆ isUnsigned()
bool Puma::CConstant::isUnsigned |
( |
| ) |
const |
|
inline |
Check if the value is unsigned.
◆ operator!=()
bool Puma::CConstant::operator!= |
( |
const CConstant & | c | ) |
const |
Compare the value of this and the given constant.
Does not compare the types.
- Parameters
-
c | The value to compare to. |
- Returns
- True if the values are not equal.
◆ operator==()
bool Puma::CConstant::operator== |
( |
const CConstant & | c | ) |
const |
Compare the value of this and the given constant.
Does not compare the types.
- Parameters
-
c | The value to compare to. |
- Returns
- True if the values are equal.
◆ print()
virtual void Puma::CConstant::print |
( |
std::ostream & | out | ) |
const |
|
virtual |
Print the value on the given output stream.
- Parameters
-
Implements Puma::CExprValue.