inADefPatternBind(node); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) node.getPattern().apply(this); if(node.getBind() != null && !_visitedNodes.contains(node.getBind())) node.getBind().apply(this); List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefs()); for( PDefinition e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this);
/** * Sets the {@code _patternBind} child of this {@link AForPatternBindStm} node. * @param value the new {@code _patternBind} child of this {@link AForPatternBindStm} node */ public void setPatternBind(ADefPatternBind value) { if (this._patternBind != null) { this._patternBind.parent(null); } if (value != null) { if (value.parent() != null) { value.parent().removeChild(value); } value.parent(this); } this._patternBind = value; }
/** * Creates a new complete constructor {@code ADefPatternBind} 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 location_ the {@link ILexLocation} node for the {@code location} child of this {@link ADefPatternBind} node * @param pattern_ the {@link PPattern} node for the {@code pattern} child of this {@link ADefPatternBind} node * @param bind_ the {@link PBind} node for the {@code bind} child of this {@link ADefPatternBind} node * @param defs_ the {@link GraphNodeList} <b>graph</a> node for the {@code defs} child of this {@link ADefPatternBind} node. * <i>The parent of this {@code defs } will not be changed by adding it to this node.</i> * @param type_ the {@link PType} <b>graph</a> node for the {@code type} child of this {@link ADefPatternBind} node. * <i>The parent of this {@code type } will not be changed by adding it to this node.</i> */ public ADefPatternBind(ILexLocation location_, PPattern pattern_, PBind bind_, List<? extends PDefinition> defs_, PType type_) { super(); this.setLocation(location_); this.setPattern(pattern_); this.setBind(bind_); this.setDefs(defs_); this.setType(type_); }
@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()); } }
node.setDefs(null); PBind bind = node.getBind(); PType type = node.getType(); List<PDefinition> defs = new LinkedList<PDefinition>(); defs.add(def); node.setDefs(defs); } else question.assistantFactory.createPPatternAssistant().typeResolve(node.getPattern(), THIS, question); node.setDefs(question.assistantFactory.createPPatternAssistant().getDefinitions(node.getPattern(), type, NameScope.LOCAL));
node.setDefs(null); Node parent = node.getAncestor(AForPatternBindStm.class); if (parent != null) } else if ((parent = node.getAncestor(ATrapStm.class)) != null) } else if ((parent = node.getAncestor(ATixeStmtAlternative.class)) != null) if (node.getBind() != null) if (node.getBind() instanceof ATypeBind) ATypeBind typebind = (ATypeBind) node.getBind(); typebind.setType(question.assistantFactory.createPTypeAssistant().typeResolve(typebind.getType(), null, THIS, question)); if (node.getBind().getPattern() != null) question.assistantFactory.createPPatternAssistant().typeResolve(node.getBind().getPattern(), THIS, question); TypeCheckerErrors.report(3198, "Type bind not compatible with expression", node.getBind().getLocation(), node.getBind()); TypeCheckerErrors.detail2("Bind", typebind.getType(), "Exp", type); else if (node.getBind() instanceof ASetBind) ASetBind setbind = (ASetBind) node.getBind(); PType bindtype = setbind.getSet().apply(THIS, question); TypeCheckerErrors.report(3199, "Set bind not compatible with expression", node.getBind().getLocation(), node.getBind());
/** * 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); }
@Override public void caseAForPatternBindStm(AForPatternBindStm node) throws AnalysisException { if (!proceed(node)) { return; } if (node.getExp() != null) { node.getExp().apply(this); } openScope(node.getPatternBind().getPattern(), node.getPatternBind().getDefs(), node.getStatement()); node.getStatement().apply(this); for (PDefinition def : node.getPatternBind().getDefs()) { removeLocalDefFromScope(def); } }
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));
if (node.getPatternBind().getPattern() != null) else if (node.getPatternBind().getBind() instanceof ATypeBind) else if (node.getPatternBind().getBind() instanceof ASetBind) ASetBind bind = (ASetBind) node.getPatternBind().getBind(); list.addAll(bind.getSet().apply(rootVisitor, question)); list.add(new SetMembershipObligation(bind.getPattern(), bind.getSet(), question, aF)); else if (node.getPatternBind().getBind() instanceof ASeqBind) ASeqBind bind = (ASeqBind) node.getPatternBind().getBind(); list.addAll(bind.getSeq().apply(rootVisitor, question)); list.add(new SeqMembershipObligation(bind.getPattern(), bind.getSeq(), question, aF));
/** * 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); }
@Override public void caseATrapStm(ATrapStm node) throws AnalysisException { if (!proceed(node)) { return; } if (node.getBody() != null) { node.getBody().apply(this); } openScope(node.getPatternBind().getPattern(), node.getPatternBind().getDefs(), node.getWith()); if (node.getWith() != null) { node.getWith().apply(this); } for (PDefinition def : node.getPatternBind().getDefs()) { removeLocalDefFromScope(def); } }
@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); } }
inADefPatternBind(node); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) node.getPattern().apply(this); if(node.getBind() != null && !_visitedNodes.contains(node.getBind())) node.getBind().apply(this); List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefs()); for( PDefinition e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this);
if (node.getPatternBind().getPattern() != null) else if (node.getPatternBind().getBind() instanceof ATypeBind) else if (node.getPatternBind().getBind() instanceof ASetBind) ASetBind bind = (ASetBind) node.getPatternBind().getBind(); list.addAll(bind.getSet().apply(rootVisitor, question)); question.pop(); else if (node.getPatternBind().getBind() instanceof ASeqBind) ASeqBind bind = (ASeqBind) node.getPatternBind().getBind(); list.addAll(bind.getSeq().apply(rootVisitor, question));
/** * 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); }
/** * Sets the {@code _patternBind} child of this {@link ATixeStmtAlternative} node. * @param value the new {@code _patternBind} child of this {@link ATixeStmtAlternative} node */ public void setPatternBind(ADefPatternBind value) { if (this._patternBind != null) { this._patternBind.parent(null); } if (value != null) { if (value.parent() != null) { value.parent().removeChild(value); } value.parent(this); } this._patternBind = value; }
inADefPatternBind(node, question); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) node.getPattern().apply(this, question); if(node.getBind() != null && !_visitedNodes.contains(node.getBind())) node.getBind().apply(this, question); List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefs()); for( PDefinition e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question);
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();