@Override public LexNameSet caseACasesStm(ACasesStm node, FreeVarInfo info) throws AnalysisException { return node.getExp().apply(this, info); }
public static String getCasesString(ACasesStm stm) { StringBuilder sb = new StringBuilder(); sb.append("cases " + stm.getExp() + " :\n"); for (ACaseAlternativeStm csa : stm.getCases()) { sb.append(" "); sb.append(csa.toString()); } if (stm.getOthers() != null) { sb.append(" others -> "); sb.append(stm.getOthers().toString()); } sb.append(" end"); return sb.toString(); }
@Override public void caseACasesStm(ACasesStm node) throws AnalysisException { if (!proceed(node)) { return; } handleCaseNode(node.getExp(), node.getCases(), node.getOthers()); }
@Override public SStmIR caseACasesStm(ACasesStm node, IRInfo question) throws AnalysisException { PExp exp = node.getExp(); PStm others = node.getOthers(); LinkedList<ACaseAlternativeStm> cases = node.getCases(); SExpIR expCg = exp.apply(question.getExpVisitor(), question); SStmIR othersCg = others != null ? others.apply(question.getStmVisitor(), question) : null; ACasesStmIR casesStmCg = new ACasesStmIR(); casesStmCg.setExp(expCg); casesStmCg.setOthers(othersCg); question.getStmAssistant().handleAlternativesCasesStm(question, exp, cases, casesStmCg.getCases()); return casesStmCg; }
@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(); }
node.getDefs().addAll(question.assistantFactory.createPPatternAssistant().getDefinitions(node.getPattern(), stm.getExp().getType(), NameScope.LOCAL));
@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(); }