Index: compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java,v retrieving revision 1.14 diff -u -r1.14 LongLiteral.java --- compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java 23 Feb 2005 02:47:28 -0000 1.14 +++ compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java 30 May 2005 14:26:08 -0000 @@ -30,50 +30,71 @@ public void computeConstant() { //the overflow (when radix=10) is tested using the fact that //the value should always grow during its computation - int length = source.length - 1; //minus one because the last char is 'l' or 'L' long computedValue ; - if (source[0] == '0') - { if (length == 1) { constant = Constant.fromValue(0L); return; } + if (source[0] == '0') { + if (length == 1) { + constant = Constant.fromValue(0L); + return; + } final int shift,radix; int j ; - if ( (source[1] == 'x') || (source[1] == 'X') ) - { shift = 4 ; j = 2; radix = 16;} - else - { shift = 3 ; j = 1; radix = 8;} + if ( (source[1] == 'x') || (source[1] == 'X') ) { + shift = 4 ; j = 2; radix = 16; + } else { + shift = 3 ; j = 1; radix = 8; + } int nbDigit = 0; - while (source[j]=='0') - { j++; //jump over redondant zero - if ( j == length) - { //watch for 0000000000000L + while (source[j]=='0') { + j++; //jump over redondant zero + if ( j == length) { + //watch for 0000000000000L constant = Constant.fromValue(value = 0L); - return ;}} + return ; + } + } int digitValue ; - if ((digitValue = Character.digit(source[j++],radix)) < 0 ) - { constant = FORMAT_ERROR; return ;} - if (digitValue >= 8) nbDigit = 4; - else if (digitValue >= 4) nbDigit = 3; - else if (digitValue >= 2) nbDigit = 2; - else nbDigit = 1; //digitValue is not 0 + if ((digitValue = Character.digit(source[j++],radix)) < 0 ) { + constant = FORMAT_ERROR; return ; + } + if (digitValue >= 8) + nbDigit = 4; + else if (digitValue >= 4) + nbDigit = 3; + else if (digitValue >= 2) + nbDigit = 2; + else + nbDigit = 1; //digitValue is not 0 computedValue = digitValue ; - while (j 64) return /*constant stays null*/ ; - computedValue = (computedValue< 64) + return /*constant stays null*/ ; + computedValue = (computedValue< computedValue) return /*constant stays null*/;}} - + if (computedValue > limit) + return /*constant stays null*/; + computedValue *= 10; + if ((computedValue + digitValue) > Long.MAX_VALUE) + return /*constant stays null*/; + computedValue += digitValue; + if (previous > computedValue) + return /*constant stays null*/; + } + } constant = Constant.fromValue(value = computedValue); } /** @@ -118,7 +139,8 @@ (source[15] == '5') && (source[16] == '8') && (source[17] == '0') && - (source[18] == '8'));} + (source[18] == '8')); +} public TypeBinding resolveType(BlockScope scope) { // the format may be incorrect while the scanner could detect // such error only on painfull tests...easier and faster here