inACasesStm(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) node.getExp().apply(this, question); List<ACaseAlternativeStm> copy = new ArrayList<ACaseAlternativeStm>(node.getCases()); for( ACaseAlternativeStm e : copy) if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) node.getOthers().apply(this, question);
@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(); }
@Override public IProofObligationList caseACasesStm(ACasesStm node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); boolean hasIgnore = false; for (ACaseAlternativeStm alt : node.getCases()) { if (alt.getPattern() instanceof AIgnorePattern) { hasIgnore = true; } obligations.addAll(alt.apply(mainVisitor, question)); } if (node.getOthers() != null && !hasIgnore) { obligations.addAll(node.getOthers().apply(rootVisitor, question)); } return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
@Override public PExp caseACasesStm(ACasesStm stm, Integer lineno) throws AnalysisException { PExp found = null; for (ACaseAlternativeStm stmt : stm.getCases()) { found = stmt.getResult().apply(THIS, lineno); if (found != null) { break; } } return found; }
@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 PTypeSet caseACasesStm(ACasesStm statement) throws AnalysisException { PTypeSet types = new PTypeSet(af); for (ACaseAlternativeStm c : statement.getCases()) { types.addAll(c.apply(THIS)); } return types; }
node.getDefs().addAll(question.assistantFactory.createPPatternAssistant().getDefinitions(node.getPattern(), stm.getExp().getType(), NameScope.LOCAL));
/** * Creates a deep clone of this {@link ACasesStm} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link ACasesStm} node */ public ACasesStm clone(Map<INode,INode> oldToNewMap) { ACasesStm node = new ACasesStm( _location, _type, cloneNode(_exp, oldToNewMap), cloneList(_cases, oldToNewMap), cloneNode(_others, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
inACasesStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) node.getExp().apply(this); List<ACaseAlternativeStm> copy = new ArrayList<ACaseAlternativeStm>(node.getCases()); for( ACaseAlternativeStm e : copy) if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) node.getOthers().apply(this);
@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 PStm caseACasesStm(ACasesStm stm, Integer lineno) throws AnalysisException { PStm found = findStatementBaseCase(stm, lineno); if (found != null) { return found; } for (ACaseAlternativeStm stmt : stm.getCases()) { found = stmt.getResult().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stmt.getResult(), // lineno); if (found != null) { break; } } return found; }
inACasesStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) node.getExp().apply(this); List<ACaseAlternativeStm> copy = new ArrayList<ACaseAlternativeStm>(node.getCases()); for( ACaseAlternativeStm e : copy) if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) node.getOthers().apply(this);
mergeReturns(retVal,inACasesStm(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this)); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) mergeReturns(retVal,node.getExp().apply(this)); List<ACaseAlternativeStm> copy = new ArrayList<ACaseAlternativeStm>(node.getCases()); for( ACaseAlternativeStm e : copy) if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) mergeReturns(retVal,node.getOthers().apply(this));
mergeReturns(retVal,inACasesStm(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this, question)); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) mergeReturns(retVal,node.getExp().apply(this, question)); List<ACaseAlternativeStm> copy = new ArrayList<ACaseAlternativeStm>(node.getCases()); for( ACaseAlternativeStm e : copy) if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) mergeReturns(retVal,node.getOthers().apply(this, question));