Commit 6d5536da authored by Pedro Olsen Ferreira's avatar Pedro Olsen Ferreira
Browse files

Recognise the Half CXType

This occurs for OpenCL's "half" type.
Use the Float Integral type internally.
parent 4f341479
......@@ -84,6 +84,9 @@ QString ConstantIntegralType::toString() const
case TypeInt:
ret = (modifiers() & UnsignedModifier) ? QStringLiteral("unsigned") : QStringLiteral("int");
break;
case TypeHalf:
ret = QStringLiteral("half");
break;
case TypeFloat:
ret = QStringLiteral("float");
break;
......@@ -120,6 +123,7 @@ QString ConstantIntegralType::valueAsString() const
return (modifiers() & UnsignedModifier) ?
QString::number(( uint )d_func()->m_value) :
QString::number(( int )d_func()->m_value);
case TypeHalf:
case TypeFloat:
return QString::number(value<float>());
case TypeDouble:
......
......@@ -44,6 +44,8 @@ public:
{
if (AbstractType::modifiers() & UnsignedModifier)
setValueInternal<quint64>(value);
else if (IntegralType::dataType() == TypeHalf)
setValueInternal<float>(value);
else if (IntegralType::dataType() == TypeFloat)
setValueInternal<float>(value);
else if (IntegralType::dataType() == TypeDouble)
......@@ -62,6 +64,8 @@ public:
{
if (modifiers() & UnsignedModifier) {
return constant_value<quint64>(&d_func()->m_value);
} else if (dataType() == TypeHalf) {
return constant_value<float>(&d_func()->m_value);
} else if (dataType() == TypeFloat) {
return constant_value<float>(&d_func()->m_value);
} else if (dataType() == TypeDouble) {
......
......@@ -49,6 +49,7 @@ public:
TypeMixed,
TypeChar16_t,
TypeChar32_t,
TypeHalf,
TypeLanguageSpecific = 200
};
......
......@@ -1348,6 +1348,7 @@ AbstractType *Visitor::makeType(CXType type, CXCursor parent)
UseKind(CXType_ULong);
UseKind(CXType_LongLong);
UseKind(CXType_ULongLong);
UseKind(CXType_Half);
UseKind(CXType_Float);
UseKind(CXType_LongDouble);
UseKind(CXType_Double);
......
......@@ -191,6 +191,7 @@ constexpr IntegralType::CommonIntegralTypes integralType(CXTypeKind TK)
{
return TK == CXType_Void ? IntegralType::TypeVoid
: TK == CXType_Bool ? IntegralType::TypeBoolean
: TK == CXType_Half ? IntegralType::TypeHalf
: TK == CXType_Float ? IntegralType::TypeFloat
: TK == CXType_Char16 ? IntegralType::TypeChar16_t
: TK == CXType_Char32 ? IntegralType::TypeChar32_t
......
......@@ -1349,6 +1349,8 @@ AbstractType::Ptr DeclarationBuilder::typeFromName(const QString& name)
type = IntegralType::TypeBoolean;
} else if (name == QLatin1String("int")) {
type = IntegralType::TypeInt;
} else if (name == QLatin1String("half")) {
type = IntegralType::TypeHalf;
} else if (name == QLatin1String("float")) {
type = IntegralType::TypeFloat;
} else if (name == QLatin1String("double") || name == QLatin1String("real")) {
......@@ -1465,6 +1467,7 @@ static bool isNumeric(const IntegralType::Ptr& type)
{
return type->dataType() == IntegralType::TypeInt
|| type->dataType() == IntegralType::TypeIntegral
|| type->dataType() == IntegralType::TypeHalf
|| type->dataType() == IntegralType::TypeFloat
|| type->dataType() == IntegralType::TypeDouble;
}
......
......@@ -209,6 +209,7 @@ DUContext* getInternalContext(const DeclarationPointer& declaration)
baseClass = QStringLiteral("String");
break;
case IntegralType::TypeInt:
case IntegralType::TypeHalf:
case IntegralType::TypeFloat:
case IntegralType::TypeDouble:
baseClass = QStringLiteral("Number");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment