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

This commit is contained in:
Roberto Raggi
2010-07-01 15:27:03 +02:00
parent 4be3333bf3
commit 0f2a24641b
3 changed files with 26 additions and 36 deletions

View File

@@ -254,32 +254,36 @@ bool ResolveExpression::visit(SizeofExpressionAST *)
bool ResolveExpression::visit(NumericLiteralAST *ast)
{
Type *type = 0;
const NumericLiteral *literal = numericLiteral(ast->literal_token);
const Token &tk = tokenAt(ast->literal_token);
if (literal->isChar())
Type *type = 0;
bool isUnsigned = false;
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;
}