protected Value evalIf ( INode node , ILexLocation ifLocation , PExp testExp , INode thenNode , List < ? extends INode > elseIfNodeList , INode elseNode , Context ctxt ) throws AnalysisException { BreakpointManager . getBreakpoint ( node ) . check ( ifLocation , ctxt ) ; try { if ( testExp . apply ( VdmRuntime . getStatementEvaluator ( ) , ctxt ) . boolValue ( ctxt ) ) { return thenNode . apply ( VdmRuntime . getStatementEvaluator ( ) , ctxt ) ; } else { for ( INode elseif : elseIfNodeList ) { Value r = elseif . apply ( VdmRuntime . getStatementEvaluator ( ) , ctxt ) ; if ( r != null ) { return r ; } } if ( elseNode != null ) { return elseNode . apply ( VdmRuntime . getStatementEvaluator ( ) , ctxt ) ; } return new VoidValue ( ) ; } } catch ( ValueException e ) { return VdmRuntimeError . abort ( ifLocation , e ) ; } }
Utility method to evaluate both if expressions and statements