<s> package org . eclipse . jdt . internal . compiler . ast ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . impl . * ; import org . eclipse . jdt . internal . compiler . codegen . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; import org . eclipse . jdt . internal . compiler . parser . ScannerHelper ; public class LongLiteral extends NumberLiteral { public LongLiteral ( char [ ] token , int s , int e ) { super ( token , s , e ) ; } public void computeConstant ( ) { int length = this . source . length - 1 ; long computedValue ; if ( this . source [ 0 ] == '0' ) { if ( length == 1 ) { this . constant = LongConstant . fromValue ( 0L ) ; return ; } final int shift , radix ; int j ; if ( ( this . source [ 1 ] == 'x' ) || ( this . source [ 1 ] == 'X' ) ) { shift = 4 ; j = 2 ; radix = 16 ; } else { shift = 3 ; j = 1 ; radix = 8 ; } int nbDigit = 0 ; while ( this . source [ j ] == '0' ) { j ++ ; if ( j == length ) { this . constant = LongConstant . fromValue ( 0L ) ; return ; } } int digitValue ; if ( ( digitValue = ScannerHelper . digit ( this . source [ j ++ ] , radix ) ) < 0 ) { return ; } if ( digitValue >= 8 ) nbDigit = 4 ; else if ( digitValue >= 4 ) nbDigit = 3 ; else if ( digitValue >= 2 ) nbDigit = 2 ; else nbDigit = 1 ; computedValue = digitValue ; while ( j < length ) { if ( ( digitValue = ScannerHelper . digit ( this . source [ j ++ ] , radix ) ) < 0 ) { return ; } if ( ( nbDigit += shift ) > 64 ) return ; computedValue = ( computedValue << shift ) | digitValue ; } } else { long previous = 0 ; computedValue = 0 ; final long limit = Long . MAX_VALUE / 10 ; for ( int i = 0 ; i < length ; i ++ ) { int digitValue ; if ( ( digitValue = ScannerHelper . digit ( this . source [ i ] , 10 ) ) < 0 ) return ; previous = computedValue ; if ( computedValue > limit ) return ; computedValue *= 10 ; if ( ( computedValue + digitValue ) > Long . MAX_VALUE ) return ; computedValue += digitValue ; if ( previous > computedValue ) return ; } } this . constant = LongConstant . fromValue ( computedValue ) ; } public void generateCode ( BlockScope currentScope , CodeStream codeStream , boolean valueRequired ) { int pc = codeStream . position ; if ( valueRequired ) { codeStream . generateConstant ( this . constant , this . implicitConversion ) ; } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } public TypeBinding literalType ( BlockScope scope ) { return TypeBinding . LONG ; } public final boolean mayRepresentMIN_VALUE ( ) { return ( ( this . source . length == 20 ) && ( this . source [ 0 ] == '9' ) && ( this . source [ 1 ] == '2' ) && ( this . source [ 2 ] == '2' ) && ( this . source [ 3 ] == '3' ) && ( this . source [ 4 ] == '3' ) && ( this . source [ 5 ] == '7' ) && ( this . source [ 6 ] == '2' ) && ( this . source [ 7 ] == '0' ) && ( this . source [ 8 ] == '3' ) && ( this . source [ 9 ] == '6' ) && ( this . source [ 10 ] == '8' ) && ( this . source [ 11 ] == '5' ) && ( this . source [ 12 ] == '4' ) && ( this . source [ 13 ] == '7' ) && ( this . source [ 14 ] == '7' ) && ( this . source [ 15 ] == '5' ) && ( this . source [ 16 ] == '8' ) && ( this . source [ 17 ] == '0' ) && ( this . source [ 18 ] == '8' ) && ( ( ( this . bits & ASTNode . ParenthesizedMASK ) >> ASTNode . ParenthesizedSHIFT ) == 0 ) ) ; } public void traverse ( ASTVisitor visitor , BlockScope scope ) { visitor . visit ( this , scope ) ; visitor . endVisit ( this , scope ) ; } } </s>