/** * Called by the {@link ATixeStmtAlternative} node from {@link ATixeStmtAlternative#apply(IPOFAnalysis)}. * @param node the calling {@link ATixeStmtAlternative} node */ public void caseATixeStmtAlternative(ATixeStmtAlternative node) throws AnalysisException { _visitedNodes.add(node); inATixeStmtAlternative(node); if(node.getPatternBind() != null && !_visitedNodes.contains(node.getPatternBind())) { node.getPatternBind().apply(this); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } outATixeStmtAlternative(node); }
/** * Creates a new complete constructor {@code ATixeStmtAlternative} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param patternBind_ the {@link ADefPatternBind} node for the {@code patternBind} child of this {@link ATixeStmtAlternative} node * @param statement_ the {@link PStm} node for the {@code statement} child of this {@link ATixeStmtAlternative} node * @param exp_ the {@link PType} <b>graph</a> node for the {@code exp} child of this {@link ATixeStmtAlternative} node. * <i>The parent of this {@code exp } will not be changed by adding it to this node.</i> */ public ATixeStmtAlternative(ADefPatternBind patternBind_, PStm statement_, PType exp_) { super(); this.setPatternBind(patternBind_); this.setStatement(statement_); this.setExp(exp_); }
public static ATixeStmtAlternative newATixeStmtAlternative( ADefPatternBind patternBind, PStm resultStm) { ATixeStmtAlternative result = new ATixeStmtAlternative(); result.setPatternBind(patternBind); result.setStatement(resultStm); return result; }
/** * Returns a deep clone of this {@link ATixeStmtAlternative} node. * @return a deep clone of this {@link ATixeStmtAlternative} node */ public ATixeStmtAlternative clone() { return new ATixeStmtAlternative( cloneNode(_patternBind), cloneNode(_statement), _exp ); }
@Override public void caseATixeStmtAlternative(ATixeStmtAlternative node) throws AnalysisException { openScope(node.getPatternBind(), node.getPatternBind().getDefs(), node.getStatement()); node.getStatement().apply(this); // End scope for (PDefinition def : node.getPatternBind().getDefs()) { removeLocalDefFromScope(def); } }
@Override public void caseATixeStm(ATixeStm node) throws AnalysisException { if (node.getBody() != null) { node.getBody().apply(this); } // The trap alternatives will be responsible for opening/ending the scope for (ATixeStmtAlternative trap : node.getTraps()) { trap.apply(this); } }
obligations.addAll(alt.apply(rootVisitor, question)); if (alt.getPatternBind().getBind() instanceof ASetBind) ASetBind bind = (ASetBind) alt.getPatternBind().getBind(); obligations.addAll(bind.getSet().apply(rootVisitor, question)); obligations.add(new SetMembershipObligation(bind.getPattern(), bind.getSet(), question, aF)); else if (alt.getPatternBind().getBind() instanceof ASeqBind) ASeqBind bind = (ASeqBind) alt.getPatternBind().getBind(); obligations.addAll(bind.getSeq().apply(rootVisitor, question)); obligations.add(new SeqMembershipObligation(bind.getPattern(), bind.getSeq(), question, aF));
private Collection<? extends PType> exitCheck(ATixeStmtAlternative tsa) throws AnalysisException { return tsa.getStatement().apply(THIS); }
@Override public PType caseATixeStm(ATixeStm node, TypeCheckInfo question) throws AnalysisException { PType rt = node.getBody().apply(THIS, question); PTypeSet extypes = exitCheck(node.getBody(), question); if (!extypes.isEmpty()) { PType union = extypes.getType(node.getLocation()); for (ATixeStmtAlternative tsa : node.getTraps()) { tsa.setExp(union); tsa.apply(THIS, question); } } node.setType(rt); return rt; }
} else if ((parent = node.getAncestor(ATixeStmtAlternative.class)) != null) type = ((ATixeStmtAlternative) parent).getExp();
@Override public IProofObligationList caseATixeStmtAlternative( ATixeStmtAlternative node, IPOContextStack question) throws AnalysisException { try { IProofObligationList list = new ProofObligationList(); if (node.getPatternBind().getPattern() != null) { // Nothing to do } else if (node.getPatternBind().getBind() instanceof ATypeBind) { // Nothing to do } else if (node.getPatternBind().getBind() instanceof ASetBind) { ASetBind bind = (ASetBind) node.getPatternBind().getBind(); list.addAll(bind.getSet().apply(this.pogExpVisitor, question)); } list.addAll(node.getStatement().apply(this.pogStmVisitor, question)); return list; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
/** * Called by the {@link ATixeStm} node from {@link ATixeStm#apply(IPOFAnalysis)}. * @param node the calling {@link ATixeStm} node */ public void caseATixeStm(ATixeStm node) throws AnalysisException { _visitedNodes.add(node); inATixeStm(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } { List<ATixeStmtAlternative> copy = new ArrayList<ATixeStmtAlternative>(node.getTraps()); for( ATixeStmtAlternative e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { node.getBody().apply(this); } outATixeStm(node); }
@Override public PExp caseATixeStm(ATixeStm stm, Integer lineno) throws AnalysisException { PExp found = stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(stm.getBody(), // lineno); if (found != null) { return found; } for (ATixeStmtAlternative tsa : stm.getTraps()) { found = tsa.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(tsa.getStatement(), // lineno); if (found != null) { break; } } return found; }
/** * Creates a deep clone of this {@link ATixeStmtAlternative} 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 ATixeStmtAlternative} node */ public ATixeStmtAlternative clone(Map<INode,INode> oldToNewMap) { ATixeStmtAlternative node = new ATixeStmtAlternative( cloneNode(_patternBind, oldToNewMap), cloneNode(_statement, oldToNewMap), _exp ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ATixeStmtAlternative} node from {@link ATixeStmtAlternative#apply(IAnalysis)}. * @param node the calling {@link ATixeStmtAlternative} node */ public void caseATixeStmtAlternative(ATixeStmtAlternative node) throws AnalysisException { _visitedNodes.add(node); inATixeStmtAlternative(node); if(node.getPatternBind() != null && !_visitedNodes.contains(node.getPatternBind())) { node.getPatternBind().apply(this); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } outATixeStmtAlternative(node); }
if (node.getPatternBind().getPattern() != null) evalContext.putList(ctxt.assistantFactory.createPPatternAssistant().getNamedValues(node.getPatternBind().getPattern(), exval, ctxt)); else if (node.getPatternBind().getBind() instanceof ASetBind) ASetBind setbind = (ASetBind) node.getPatternBind().getBind(); ValueSet set = setbind.getSet().apply(VdmRuntime.getStatementEvaluator(), ctxt).setValue(ctxt); else if (node.getPatternBind().getBind() instanceof ASeqBind) ASeqBind seqbind = (ASeqBind) node.getPatternBind().getBind(); ValueList seq = seqbind.getSeq().apply(VdmRuntime.getStatementEvaluator(), ctxt).seqValue(ctxt); ATypeBind typebind = (ATypeBind) node.getPatternBind().getBind(); : node.getStatement().apply(VdmRuntime.getStatementEvaluator(), evalContext);
/** * Called by the {@link ATixeStm} node from {@link ATixeStm#apply(IAnalysis)}. * @param node the calling {@link ATixeStm} node */ public void caseATixeStm(ATixeStm node, Q question) throws AnalysisException { _visitedNodes.add(node); inATixeStm(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } { List<ATixeStmtAlternative> copy = new ArrayList<ATixeStmtAlternative>(node.getTraps()); for( ATixeStmtAlternative e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { node.getBody().apply(this, question); } outATixeStm(node, question); }
@Override public PStm caseATixeStm(ATixeStm stm, Integer lineno) throws AnalysisException { PStm found = findStatementBaseCase(stm, lineno); if (found != null) { return found; } found = stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(stm.getBody(), lineno); if (found != null) { return found; } for (ATixeStmtAlternative tsa : stm.getTraps()) { found = tsa.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findStatement(tsa.getStatement(), // lineno); if (found != null) { break; } } return found; }
/** * Called by the {@link ATixeStmtAlternative} node from {@link ATixeStmtAlternative#apply(IAnalysis)}. * @param node the calling {@link ATixeStmtAlternative} node */ public void caseATixeStmtAlternative(ATixeStmtAlternative node, Q question) throws AnalysisException { _visitedNodes.add(node); inATixeStmtAlternative(node, question); if(node.getPatternBind() != null && !_visitedNodes.contains(node.getPatternBind())) { node.getPatternBind().apply(this, question); } if(node.getStatement() != null && !_visitedNodes.contains(node.getStatement())) { node.getStatement().apply(this, question); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this, question); } outATixeStmtAlternative(node, question); }
node.getPatternBind().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, question.scope)); List<PDefinition> defs = getDefinitions(node.getPatternBind()); question.assistantFactory.createPDefinitionListAssistant().typeCheck(defs, THIS, question); Environment local = new FlatCheckedEnvironment(question.assistantFactory, defs, question.env, question.scope); node.getStatement().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers)); local.unusedCheck();