<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 . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . codegen . * ; import org . eclipse . jdt . internal . compiler . flow . * ; import org . eclipse . jdt . internal . compiler . lookup . * ; public class LocalDeclaration extends AbstractVariableDeclaration { public LocalVariableBinding binding ; public LocalDeclaration ( char [ ] name , int sourceStart , int sourceEnd ) { this . name = name ; this . sourceStart = sourceStart ; this . sourceEnd = sourceEnd ; this . declarationEnd = sourceEnd ; } public FlowInfo analyseCode ( BlockScope currentScope , FlowContext flowContext , FlowInfo flowInfo ) { if ( ( flowInfo . tagBits & FlowInfo . UNREACHABLE_OR_DEAD ) == 0 ) { this . bits |= ASTNode . IsLocalDeclarationReachable ; } if ( this . binding != null && this . type . resolvedType instanceof TypeVariableBinding ) { MethodScope methodScope = this . binding . declaringScope . methodScope ( ) ; AbstractMethodDeclaration methodDeclaration = methodScope . referenceMethod ( ) ; if ( methodDeclaration != null && ( ( methodDeclaration . bits & ASTNode . CanBeStatic ) != 0 ) && methodDeclaration . binding != null ) { TypeVariableBinding [ ] typeVariables = methodDeclaration . binding . typeVariables ( ) ; if ( typeVariables == Binding . NO_TYPE_VARIABLES ) { currentScope . resetEnclosingMethodStaticFlag ( ) ; } else { boolean usesEnclosingTypeVar = false ; for ( int i = 0 ; i < typeVariables . length ; i ++ ) { if ( typeVariables [ i ] == this . type . resolvedType ) { usesEnclosingTypeVar = true ; break ; } } if ( ! usesEnclosingTypeVar ) { currentScope . resetEnclosingMethodStaticFlag ( ) ; } } } } if ( this . initialization == null ) { return flowInfo ; } if ( ( this . initialization . implicitConversion & TypeIds . UNBOXING ) != 0 ) { this . initialization . checkNPE ( currentScope , flowContext , flowInfo ) ; } flowInfo = this . initialization . analyseCode ( currentScope , flowContext , flowInfo ) . unconditionalInits ( ) ; int nullStatus = this . initialization . nullStatus ( flowInfo ) ; if ( ! flowInfo . isDefinitelyAssigned ( this . binding ) ) { this . bits |= FirstAssignmentToLocal ; } else { this . bits &= ~ FirstAssignmentToLocal ; } flowInfo . markAsDefinitelyAssigned ( this . binding ) ; nullStatus = checkAgainstNullAnnotation ( currentScope , this . binding , nullStatus ) ; if ( ( this . binding . type . tagBits & TagBits . IsBaseType ) == 0 ) { flowInfo . markNullStatus ( this . binding , nullStatus ) ; } return flowInfo ; } public void checkModifiers ( ) { if ( ( ( this . modifiers & ExtraCompilerModifiers . AccJustFlag ) & ~ ClassFileConstants . AccFinal ) != 0 ) this . modifiers = ( this . modifiers & ~ ExtraCompilerModifiers . AccAlternateModifierProblem ) | ExtraCompilerModifiers . AccModifierProblem ; } public void generateCode ( BlockScope currentScope , CodeStream codeStream ) { if ( this . binding . resolvedPosition != - 1 ) { codeStream . addVisibleLocalVariable ( this . binding ) ; } if ( ( this . bits & IsReachable ) == 0 ) { return ; } int pc = codeStream . position ; generateInit : { if ( this . initialization == null ) break generateInit ; if ( this . binding . resolvedPosition < 0 ) { if ( this . initialization . constant != Constant . NotAConstant ) break generateInit ; this . initialization . generateCode ( currentScope , codeStream , false ) ; break generateInit ; } this . initialization . generateCode ( currentScope , codeStream , true ) ; if ( this . binding . type . isArrayType ( ) && ( this . initialization . resolvedType == TypeBinding . NULL || ( ( this . initialization instanceof CastExpression ) && ( ( ( CastExpression ) this . initialization ) . innermostCastedExpression ( ) . resolvedType == TypeBinding . NULL ) ) ) ) { codeStream . checkcast ( this . binding . type ) ; } codeStream . store ( this . binding , false ) ; if ( ( this . bits & ASTNode . FirstAssignmentToLocal ) != 0 ) { this . binding . recordInitializationStartPC ( codeStream . position ) ; } } codeStream . recordPositionsFrom ( pc , this . sourceStart ) ; } public int getKind ( ) { return LOCAL_VARIABLE ; } public void resolve ( BlockScope scope ) { TypeBinding variableType = this . type . resolveType ( scope , true ) ; checkModifiers ( ) ; if ( variableType != null ) { if ( variableType == TypeBinding . VOID ) { scope . problemReporter ( ) . variableTypeCannotBeVoid ( this ) ; return ; } if ( variableType . isArrayType ( ) && ( ( ArrayBinding ) variableType ) . leafComponentType == TypeBinding . VOID ) { scope . problemReporter ( ) . variableTypeCannotBeVoidArray ( this ) ; return ; } } Binding existingVariable = scope . getBinding ( this . name , Binding . VARIABLE , this , false ) ; if ( existingVariable != null && existingVariable . isValidBinding ( ) ) { if ( existingVariable instanceof LocalVariableBinding && this . hiddenVariableDepth == 0 ) { scope . problemReporter ( ) . redefineLocal ( this ) ; } else { scope . problemReporter ( ) . localVariableHiding ( this , existingVariable , false ) ; } } if ( ( this . modifiers & ClassFileConstants . AccFinal ) != 0 && this . initialization == null ) { this . modifiers |= ExtraCompilerModifiers . AccBlankFinal ; } this . binding = new LocalVariableBinding ( this , variableType , this . modifiers , false ) ; scope . addLocalVariable ( this . binding ) ; this . binding . setConstant ( Constant . NotAConstant ) ; if ( variableType == null ) { if ( this . initialization != null ) this . initialization . resolveType ( scope ) ; return ; } if ( this . initialization != null ) { if ( this . initialization instanceof ArrayInitializer ) { TypeBinding initializationType = this . initialization . resolveTypeExpecting ( scope , variableType ) ; if ( initializationType != null ) { ( ( ArrayInitializer ) this . initialization ) . binding = ( ArrayBinding ) initializationType ; this . initialization . computeConversion ( scope , variableType , initializationType ) ; } } else { this . initialization . setExpectedType ( variableType ) ; TypeBinding initializationType = this . initialization . resolveType ( scope ) ; if ( initializationType != null ) { if ( variableType != initializationType ) scope . compilationUnitScope ( ) . recordTypeConversion ( variableType , initializationType ) ; if ( this . initialization . isConstantValueOfTypeAssignableToType ( initializationType , variableType ) || initializationType . isCompatibleWith ( variableType ) ) { this . initialization . computeConversion ( scope , variableType , initializationType ) ; if ( initializationType . needsUncheckedConversion ( variableType ) ) { scope . problemReporter ( ) . unsafeTypeConversion ( this . initialization , initializationType , variableType ) ; } if ( this . initialization instanceof CastExpression && ( this . initialization . bits & ASTNode . UnnecessaryCast ) == 0 ) { CastExpression . checkNeedForAssignedCast ( scope , variableType , ( CastExpression ) this . initialization ) ; } } else if ( isBoxingCompatible ( initializationType , variableType , this . initialization , scope ) ) { this . initialization . computeConversion ( scope , variableType , initializationType ) ; if ( this . initialization instanceof CastExpression && ( this . initialization . bits & ASTNode . UnnecessaryCast ) == 0 ) { CastExpression . checkNeedForAssignedCast ( scope , variableType , ( CastExpression ) this . initialization ) ; } } else { if ( ( variableType . tagBits & TagBits . HasMissingType ) == 0 ) { scope . problemReporter ( ) . typeMismatchError ( initializationType , variableType , this . initialization , null ) ; } } } } if ( this . binding == Expression . getDirectBinding ( this . initialization ) ) { scope . problemReporter ( ) . assignmentHasNoEffect ( this , this . name ) ; } this . binding . setConstant ( this . binding . isFinal ( ) ? this . initialization . constant . castTo ( ( variableType . id << 4 ) + this . initialization . constant . typeID ( ) ) : Constant . NotAConstant ) ; } resolveAnnotations ( scope , this . annotations , this . binding ) ; } public void traverse ( ASTVisitor visitor , BlockScope scope ) { if ( visitor . visit ( this , scope ) ) { if ( this . annotations != null ) { int annotationsLength = this . annotations . length ; for ( int i = 0 ; i < annotationsLength ; i ++ ) this . annotations [ i ] . traverse ( visitor , scope ) ; } this . type . traverse ( visitor , scope ) ; if ( this . initialization != null ) this . initialization . traverse ( visitor , scope ) ; } visitor . endVisit ( this , scope ) ; } } </s>