@Override public List<PMultipleBind> caseASeqBind(ASeqBind bind) throws AnalysisException { List<PPattern> plist = new ArrayList<PPattern>(); plist.add(bind.getPattern()); List<PMultipleBind> mblist = new Vector<PMultipleBind>(); mblist.add(AstFactory.newASeqMultipleBind(plist, bind.getSeq())); return mblist; }
@Override public ValueList caseASeqBind(ASeqBind bind, BindState state) throws AnalysisException { try { return bind.getSeq().apply(VdmRuntime.getExpressionEvaluator(), state.ctxt).seqValue(state.ctxt); } catch (AnalysisException e) { if (e instanceof ValueException) { VdmRuntimeError.abort(bind.getLocation(), (ValueException) e); } return null; } }
public static ASeqBind newASeqBind(PPattern pattern, PExp readExpression) { ASeqBind result = new ASeqBind(); result.setLocation(pattern.getLocation()); result.setPattern(pattern); result.setSeq(readExpression); return result; }
/** * Called by the {@link ASeqCompSeqExp} node from {@link ASeqCompSeqExp#apply(IAnalysis)}. * @param node the calling {@link ASeqCompSeqExp} node */ public void caseASeqCompSeqExp(ASeqCompSeqExp node) throws AnalysisException { _visitedNodes.add(node); inASeqCompSeqExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getFirst() != null && !_visitedNodes.contains(node.getFirst())) { node.getFirst().apply(this); } if(node.getSetBind() != null && !_visitedNodes.contains(node.getSetBind())) { node.getSetBind().apply(this); } if(node.getSeqBind() != null && !_visitedNodes.contains(node.getSeqBind())) { node.getSeqBind().apply(this); } if(node.getPredicate() != null && !_visitedNodes.contains(node.getPredicate())) { node.getPredicate().apply(this); } outASeqCompSeqExp(node); }
@Override public LexNameSet caseASeqBind(ASeqBind node, FreeVarInfo info) throws AnalysisException { return node.getSeq().apply(this, info); }
PType st = node.getSeqbind().getSeq().apply(THIS, question); TypeCheckerErrors.report(3016, "Expression is not compatible with seq bind", node.getSeqbind().getLocation(), node.getSeqbind()); question.assistantFactory.createPPatternAssistant().typeResolve(node.getSeqbind().getPattern(), THIS, question); node.setDefs(question.assistantFactory.createPPatternAssistant().getDefinitions(node.getSeqbind().getPattern(), node.getDefType(), question.scope));
private Value evalSeqBind(ASeqCompSeqExp node, Context ctxt) throws AnalysisException { ValueList allValues = ctxt.assistantFactory.createPBindAssistant().getBindValues(node.getSeqBind(), ctxt, false); ValueList seq = new ValueList(); // Bind variable values for (Value val: allValues) { try { Context evalContext = new Context(ctxt.assistantFactory, node.getLocation(), "seq comprehension", ctxt); NameValuePairList nvpl = ctxt.assistantFactory.createPPatternAssistant().getNamedValues(node.getSeqBind().getPattern(), val, ctxt); evalContext.putList(nvpl); if (node.getPredicate() == null || node.getPredicate().apply(VdmRuntime.getExpressionEvaluator(), evalContext).boolValue(ctxt)) { Value out = node.getFirst().apply(VdmRuntime.getExpressionEvaluator(), evalContext); seq.add(out); } } catch (ValueException e) { VdmRuntimeError.abort(node.getLocation(), e); } catch (PatternMatchException e) { // Ignore mismatches } } return new SeqValue(seq); }
/** * Returns a deep clone of this {@link ASeqBind} node. * @return a deep clone of this {@link ASeqBind} node */ public ASeqBind clone() { return new ASeqBind( _location, _pattern, _seq ); }
/** * Sets the {@code _seqBind} child of this {@link ASeqCompSeqExp} node. * @param value the new {@code _seqBind} child of this {@link ASeqCompSeqExp} node */ public void setSeqBind(ASeqBind value) { if (this._seqBind != null) { this._seqBind.parent(null); } if (value != null) { if (value.parent() != null) { value.parent().removeChild(value); } value.parent(this); } this._seqBind = value; }
/** * Called by the {@link ASeqCompSeqExp} node from {@link ASeqCompSeqExp#apply(IAnalysis)}. * @param node the calling {@link ASeqCompSeqExp} node */ public void caseASeqCompSeqExp(ASeqCompSeqExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inASeqCompSeqExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getFirst() != null && !_visitedNodes.contains(node.getFirst())) { node.getFirst().apply(this, question); } if(node.getSetBind() != null && !_visitedNodes.contains(node.getSetBind())) { node.getSetBind().apply(this, question); } if(node.getSeqBind() != null && !_visitedNodes.contains(node.getSeqBind())) { node.getSeqBind().apply(this, question); } if(node.getPredicate() != null && !_visitedNodes.contains(node.getPredicate())) { node.getPredicate().apply(this, question); } outASeqCompSeqExp(node, question); }
@Override public IProofObligationList caseASeqBind(ASeqBind node, IPOContextStack question) throws AnalysisException { try { return node.getSeq().apply(this.pogExpVisitor, question); } catch (Exception e) { throw new POException(node, e.getMessage()); } }
/** * Creates a deep clone of this {@link ASeqBind} 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 ASeqBind} node */ public ASeqBind clone(Map<INode,INode> oldToNewMap) { ASeqBind node = new ASeqBind( _location, _pattern, _seq ); oldToNewMap.put(this, node); return node; }
/** * Sets the {@code _seqbind} child of this {@link AEqualsDefinition} node. * @param value the new {@code _seqbind} child of this {@link AEqualsDefinition} node */ public void setSeqbind(ASeqBind value) { if (this._seqbind != null) { this._seqbind.parent(null); } if (value != null) { if (value.parent() != null) { value.parent().removeChild(value); } value.parent(this); } this._seqbind = value; }
/** * Called by the {@link ASeqBind} node from {@link ASeqBind#apply(IAnalysis)}. * @param node the calling {@link ASeqBind} node */ public void caseASeqBind(ASeqBind node, Q question) throws AnalysisException { _visitedNodes.add(node); inASeqBind(node, question); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { node.getPattern().apply(this, question); } if(node.getSeq() != null && !_visitedNodes.contains(node.getSeq())) { node.getSeq().apply(this, question); } outASeqBind(node, question); }
/** * Called by the {@link ASeqCompSeqExp} node from {@link ASeqCompSeqExp#apply(IPOFAnalysis)}. * @param node the calling {@link ASeqCompSeqExp} node */ public void caseASeqCompSeqExp(ASeqCompSeqExp node) throws AnalysisException { _visitedNodes.add(node); inASeqCompSeqExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getFirst() != null && !_visitedNodes.contains(node.getFirst())) { node.getFirst().apply(this); } if(node.getSetBind() != null && !_visitedNodes.contains(node.getSetBind())) { node.getSetBind().apply(this); } if(node.getSeqBind() != null && !_visitedNodes.contains(node.getSeqBind())) { node.getSeqBind().apply(this); } if(node.getPredicate() != null && !_visitedNodes.contains(node.getPredicate())) { node.getPredicate().apply(this); } outASeqCompSeqExp(node); }
@Override public ValueList caseASeqBind(ASeqBind bind, ObjectContext ctxt) throws AnalysisException { return af.createPExpAssistant().getValues(bind.getSeq(), ctxt); }
/** * Called by the {@link ASeqBind} node from {@link ASeqBind#apply(IAnalysis)}. * @param node the calling {@link ASeqBind} node */ public void caseASeqBind(ASeqBind node) throws AnalysisException { _visitedNodes.add(node); inASeqBind(node); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { node.getPattern().apply(this); } if(node.getSeq() != null && !_visitedNodes.contains(node.getSeq())) { node.getSeq().apply(this); } outASeqBind(node); }
@Override public LexNameList caseAEqualsDefinition(AEqualsDefinition def) throws AnalysisException { LexNameList list = af.createPExpAssistant().getOldNames(def.getTest()); if (def.getSetbind() != null) { list.addAll(def.getSetbind().apply(this)); } else if (def.getSeqbind() != null) { list.addAll(def.getSeqbind().apply(this)); } return list; }
public List<PMultipleBind> getMultipleBindList(PBind bind) { List<PPattern> plist = new ArrayList<PPattern>(); plist.add(bind.getPattern()); List<PMultipleBind> mblist = new Vector<PMultipleBind>(); if (bind instanceof ASetBind) { mblist.add(AstFactory.newASetMultipleBind(plist, ((ASetBind)bind).getSet())); } else { mblist.add(AstFactory.newASetMultipleBind(plist, ((ASeqBind)bind).getSeq())); } return mblist; } }