@ SafeVarargs public static < T extends RValue > T checkType ( RValue operand , SyntacticItem context , Class < T > ... types ) { // Got through each type in turn checking for a match for ( int i = 0 ; i != types . length ; ++ i ) { if ( types [ i ] . isInstance ( operand ) ) { // Matched! return ( T ) operand ; } } // No match, therefore through an error if ( operand == null ) { error ( "null operand" , context ) ; } else { error ( "operand returned " + operand . getClass ( ) . getName ( ) + ", expecting one of " + Arrays . toString ( types ) , context ) ; } return null ; }
Check that a given operand value matches an expected type .