@Override public List<PExp> caseACaseAlternative(ACaseAlternative exp) throws AnalysisException { return exp.getResult().apply(THIS); }
/** * This is not an expression */ @Override public LexNameList caseACaseAlternative(ACaseAlternative c) throws AnalysisException { return af.createPExpAssistant().getOldNames(c.getResult()); }
@Override public void caseACaseAlternative(ACaseAlternative node) throws AnalysisException { if (!proceed(node)) { return; } handleCase(node.getDefs(), node.getPattern(), node.getResult()); }
@Override public SExpIR caseACaseAlternative(ACaseAlternative node, IRInfo question) throws AnalysisException { PPattern pattern = node.getPattern(); PExp result = node.getResult(); SPatternIR patternCg = pattern.apply(question.getPatternVisitor(), question); SExpIR resultCg = result.apply(question.getExpVisitor(), question); ACaseAltExpExpIR altCg = new ACaseAltExpExpIR(); altCg.setPattern(patternCg); altCg.setResult(resultCg); return altCg; }
/** * Utility method for ACaseAlternative * * @param node * @param val * @param ctxt * @return * @throws AnalysisException */ public Value eval(ACaseAlternative node, Value val, Context ctxt) throws AnalysisException { Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "case alternative", ctxt); try { evalContext.putList(ctxt.assistantFactory.createPPatternAssistant().getNamedValues(node.getPattern(), val, ctxt)); return node.getResult().apply(VdmRuntime.getExpressionEvaluator(), evalContext); } catch (PatternMatchException e) { // Silently fail (CasesExpression will try the others) } return null; }
@Override public PExp caseACasesExp(ACasesExp exp, Integer lineno) throws AnalysisException { PExp found = findExpressionBaseCase(exp, lineno); if (found != null) { return found; } found = exp.getExpression().apply(THIS, lineno);// PExpAssistantInterpreter.findExpression(exp.getExpression(), // lineno); if (found != null) { return found; } for (ACaseAlternative c : exp.getCases()) { found = c.getResult().apply(THIS, lineno);// PExpAssistantInterpreter.findExpression(c.getResult(), lineno); if (found != null) { break; } } return found != null ? found : exp.getOthers() != null ? exp.getOthers().apply(THIS, lineno)// PExpAssistantInterpreter.findExpression(exp.getOthers(), // lineno) : null; }
@Override public IProofObligationList caseACaseAlternative(ACaseAlternative node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); question.push(new POCaseContext(node.getPattern(), node.getType(), node.getCexp(), assistantFactory)); obligations.addAll(node.getResult().apply(this.pogExpVisitor, question)); question.pop(); question.push(new PONotCaseContext(node.getPattern(), node.getType(), node.getCexp(), assistantFactory)); return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
c.setType(c.getResult().apply(rootVisitor, question)); local.unusedCheck(); return c.getType();
obligations.addAll(alt.getResult().apply(rootVisitor, question)); question.pop(); question.push(new PONotCaseContext(pattern, type, cexp.clone(), aF));