Commit 0f2a2464 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Get rid of NumericLiteral::isChar/isWideChar().

parent 4be3333b
......@@ -254,32 +254,36 @@ bool ResolveExpression::visit(SizeofExpressionAST *)
bool ResolveExpression::visit(NumericLiteralAST *ast)
{
const Token &tk = tokenAt(ast->literal_token);
Type *type = 0;
const NumericLiteral *literal = numericLiteral(ast->literal_token);
bool isUnsigned = false;
if (literal->isChar())
if (tk.is(T_CHAR_LITERAL))
type = control()->integerType(IntegerType::Char);
else if (literal->isWideChar())
else if (tk.is(T_WIDE_CHAR_LITERAL))
type = control()->integerType(IntegerType::WideChar);
else if (literal->isInt())
type = control()->integerType(IntegerType::Int);
else if (literal->isLong())
type = control()->integerType(IntegerType::Long);
else if (literal->isLongLong())
type = control()->integerType(IntegerType::LongLong);
else if (literal->isFloat())
type = control()->floatType(FloatType::Float);
else if (literal->isDouble())
type = control()->floatType(FloatType::Double);
else if (literal->isLongDouble())
type = control()->floatType(FloatType::LongDouble);
else
type = control()->integerType(IntegerType::Int);
else if (const NumericLiteral *literal = numericLiteral(ast->literal_token)) {
isUnsigned = literal->isUnsigned();
if (literal->isInt())
type = control()->integerType(IntegerType::Int);
else if (literal->isLong())
type = control()->integerType(IntegerType::Long);
else if (literal->isLongLong())
type = control()->integerType(IntegerType::LongLong);
else if (literal->isFloat())
type = control()->floatType(FloatType::Float);
else if (literal->isDouble())
type = control()->floatType(FloatType::Double);
else if (literal->isLongDouble())
type = control()->floatType(FloatType::LongDouble);
else
type = control()->integerType(IntegerType::Int);
}
FullySpecifiedType ty(type);
if (literal->isUnsigned())
ty.setUnsigned(true);
ty.setUnsigned(isUnsigned);
addResult(ty, _scope);
return false;
}
......
......@@ -118,8 +118,6 @@ StringLiteral::~StringLiteral()
////////////////////////////////////////////////////////////////////////////////
enum {
NumericLiteralIsChar,
NumericLiteralIsWideChar,
NumericLiteralIsInt,
NumericLiteralIsFloat,
NumericLiteralIsDouble,
......@@ -133,11 +131,7 @@ NumericLiteral::NumericLiteral(const char *chars, unsigned size)
{
f._type = NumericLiteralIsInt;
if (chars[0] == '\'') {
f._type = NumericLiteralIsChar;
} else if (size > 1 && chars[0] == 'L' && chars[1] == '\'') {
f._type = NumericLiteralIsWideChar;
} else if (size > 1 && chars[0] == '0' && (chars[1] == 'x' || chars[1] == 'X')) {
if (size > 1 && chars[0] == '0' && (chars[1] == 'x' || chars[1] == 'X')) {
f._isHex = true;
} else {
const char *begin = chars;
......@@ -192,12 +186,6 @@ bool NumericLiteral::isHex() const
bool NumericLiteral::isUnsigned() const
{ return f._isUnsigned; }
bool NumericLiteral::isChar() const
{ return f._type == NumericLiteralIsChar; }
bool NumericLiteral::isWideChar() const
{ return f._type == NumericLiteralIsWideChar; }
bool NumericLiteral::isInt() const
{ return f._type == NumericLiteralIsInt; }
......
......@@ -104,8 +104,6 @@ public:
NumericLiteral(const char *chars, unsigned size);
virtual ~NumericLiteral();
bool isChar() const;
bool isWideChar() const;
bool isInt() const;
bool isFloat() const;
bool isDouble() const;
......
Markdown is supported
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