private Expression computeRangeValue ( SyntheticVarName varName , Optional < ExprNode > expression , int defaultValue , Scope scope , final ImmutableList . Builder < Statement > initStatements ) { if ( ! expression . isPresent ( ) ) { return constant ( defaultValue ) ; } else if ( expression . get ( ) instanceof IntegerNode && ( ( IntegerNode ) expression . get ( ) ) . isInt ( ) ) { int value = Ints . checkedCast ( ( ( IntegerNode ) expression . get ( ) ) . getValue ( ) ) ; return constant ( value ) ; } else { Label startDetachPoint = new Label ( ) ; // Note: If the value of rangeArgs.start() is above 32 bits, Ints.checkedCast() will fail at // runtime with IllegalArgumentException. Expression startExpression = MethodRef . INTS_CHECKED_CAST . invoke ( exprCompiler . compile ( expression . get ( ) , startDetachPoint ) . unboxAsLong ( ) ) ; if ( ! startExpression . isCheap ( ) ) { // bounce it into a local variable Variable startVar = scope . createSynthetic ( varName , startExpression , STORE ) ; initStatements . add ( startVar . initializer ( ) . labelStart ( startDetachPoint ) ) ; startExpression = startVar . local ( ) ; } return startExpression ; } }
Computes a single range argument .