@Override public PType caseACasesStm(ACasesStm node, TypeCheckInfo question) throws AnalysisException { PType expType = node.getExp().apply(THIS, question); PTypeSet rtypes = new PTypeSet(question.assistantFactory); boolean always = false; for (ACaseAlternativeStm c : node.getCases()) { c.setCtype(expType); rtypes.add(c.apply(THIS, question)); always = always || question.assistantFactory.createPPatternAssistant().alwaysMatches(c.getPattern(), expType); } if (node.getOthers() != null) { rtypes.add(node.getOthers().apply(THIS, question)); } else if (!always) { rtypes.add(AstFactory.newAVoidType(node.getLocation())); } node.setType(rtypes.getType(node.getLocation())); return node.getType(); }
@Override public Value caseACasesStm(ACasesStm node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); Value val = node.getExp().apply(VdmRuntime.getStatementEvaluator(), ctxt); for (ACaseAlternativeStm c : node.getCases()) { Value rv = eval(c, val, ctxt); if (rv != null) { return rv; } } if (node.getOthers() != null) { return node.getOthers().apply(VdmRuntime.getStatementEvaluator(), ctxt); } return new VoidValue(); }