Community
Participate
Working Groups
IntegerLiteral.getType() always returns "int". Paul, what are the rules from RBD? I believe we use the smallest type possible: smallint/int/bigint/decimal. Is that right? DecimalLiteralImpl.getType() on a negative number will give the wrong answer. We need to subtract one from the length so as not to count the negative sign as a digit.
If we use my suggestion from Bug 348642 , IntegerLiteral could be fixed this way: public Type getType() { if ( fitsInSmallint() ) return IRUtils.getEGLPrimitiveType(Type_Smallint); else if ( fitsInInt() ) return IRUtils.getEGLPrimitiveType(Type_Int); else if ( fitsInBigint() ) return IRUtils.getEGLPrimitiveType(Type_Bigint); int length = getValue().length(); if ( isNegated() ) { length--; } return IRUtils.getEGLPrimitiveType(Type_Decimal, length, 0); } DecimalLiteral's fix is: public Type getType() { String value = getValue(); int length = value.length() - 1; if ( isNegated() ) { length--; } int decimals = value.substring( value.indexOf( '.' ) + 1 ).length(); return IRUtils.getEGLPrimitiveType( Type_Decimal, length, decimals ); }
i have put in fixes for IntgerLiteralImpl and DecimalLiteralImpl
Looks good. And just for the historical record, integers that are too big to be a bigint have type num, not decimal as I put in the description.