/** * Called by the {@link AMapDomainUnaryExp} node from {@link AMapDomainUnaryExp#apply(IAnalysis)}. * @param node the calling {@link AMapDomainUnaryExp} node */ public void caseAMapDomainUnaryExp(AMapDomainUnaryExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inAMapDomainUnaryExp(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); } outAMapDomainUnaryExp(node, question); }
/** * idx in set dom m */ private List<PMultipleBind> getSetBindList(ILexNameToken finmap, ILexNameToken findex) { AMapDomainUnaryExp domExp = new AMapDomainUnaryExp(); domExp.setType(new ABooleanBasicType()); domExp.setExp(getVarExp(finmap)); return getMultipleSetBindList(domExp, findex); }
@Override public PType caseAMapDomainUnaryExp(AMapDomainUnaryExp node, TypeCheckInfo question) throws AnalysisException { PExp exp = node.getExp(); question.qualifiers = null; PType etype = exp.apply(THIS, question.newConstraint(null)); if (!question.assistantFactory.createPTypeAssistant().isMap(etype)) { TypeCheckerErrors.report(3120, "Argument to 'dom' is not a map", node.getLocation(), node); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); } SMapType mt = question.assistantFactory.createPTypeAssistant().getMap(etype); node.setType(AstFactory.newASetSetType(node.getLocation(), mt.getFrom())); return node.getType(); }
/** * Returns a deep clone of this {@link AMapDomainUnaryExp} node. * @return a deep clone of this {@link AMapDomainUnaryExp} node */ public AMapDomainUnaryExp clone() { return new AMapDomainUnaryExp( _type, _location, cloneNode(_exp) ); }
@Override public Value caseAMapDomainUnaryExp(AMapDomainUnaryExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); try { ValueMap map = node.getExp().apply(VdmRuntime.getExpressionEvaluator(), ctxt).mapValue(ctxt); ValueSet result = new ValueSet(); result.addAll(map.keySet()); return new SetValue(result); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
ILexNameToken rdom = getUnique("rdom"); AMapDomainUnaryExp domLeft = new AMapDomainUnaryExp(); domLeft.setExp(left.clone()); AMapDomainUnaryExp domRight = new AMapDomainUnaryExp(); domRight.setExp(right.clone()); List<PMultipleBind> bindings = getMultipleSetBindList(domLeft, ldom); bindings.addAll(getMultipleSetBindList(domRight, rdom));
@Override public IProofObligationList caseAMapDomainUnaryExp(AMapDomainUnaryExp node, IPOContextStack question) throws AnalysisException { return node.getExp().apply(mainVisitor, question); }
public static AMapDomainUnaryExp newAMapDomainUnaryExp( ILexLocation location, PExp exp) { AMapDomainUnaryExp result = new AMapDomainUnaryExp(); initExpressionUnary(result, location, exp); return result; }
public MapComposeObligation(ACompBinaryExp exp, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(exp, POType.MAP_COMPOSE, ctxt, exp.getLocation(), af); /** * The obligation for m1 comp m2 is: rng m2 subset dom m1 */ AMapRangeUnaryExp rng = new AMapRangeUnaryExp(); rng.setExp(exp.getLeft().clone()); AMapDomainUnaryExp dom = new AMapDomainUnaryExp(); dom.setExp(exp.getRight().clone()); ASubsetBinaryExp subset = new ASubsetBinaryExp(); subset.setLeft(rng); subset.setRight(dom); stitch = subset; valuetree.setPredicate(ctxt.getPredWithContext(subset)); } }
/** * Creates a deep clone of this {@link AMapDomainUnaryExp} 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 AMapDomainUnaryExp} node */ public AMapDomainUnaryExp clone(Map<INode,INode> oldToNewMap) { AMapDomainUnaryExp node = new AMapDomainUnaryExp( _type, _location, cloneNode(_exp, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link AMapDomainUnaryExp} node from {@link AMapDomainUnaryExp#apply(IAnalysis)}. * @param node the calling {@link AMapDomainUnaryExp} node */ public void caseAMapDomainUnaryExp(AMapDomainUnaryExp node) throws AnalysisException { _visitedNodes.add(node); inAMapDomainUnaryExp(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); } outAMapDomainUnaryExp(node); }
public MapApplyObligation(PExp root, PExp arg, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(root, POType.MAP_APPLY, ctxt, root.getLocation(), af); /* <arg> in set dom <root> */ AMapDomainUnaryExp dom_exp = new AMapDomainUnaryExp(); dom_exp.setExp(root.clone()); // We don't care about type of the exp. This is just for the CGP to not crash. dom_exp.setType(new AUnknownType()); AInSetBinaryExp inSetExp = AstExpressionFactory.newAInSetBinaryExp(arg.clone(), dom_exp); stitch = inSetExp; valuetree.setPredicate(ctxt.getPredWithContext(inSetExp)); }
public SeqModificationObligation(APlusPlusBinaryExp arg, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(arg, POType.SEQ_MODIFICATION, ctxt, arg.getLocation(), af); /** * "seq ++ map" produces "dom map subset inds seq" */ ASubsetBinaryExp subsetExp = new ASubsetBinaryExp(); subsetExp.setOp(new LexKeywordToken(VDMToken.SUBSET, null)); AMapDomainUnaryExp domExp = new AMapDomainUnaryExp(); domExp.setExp(arg.getRight().clone()); AIndicesUnaryExp indsExp = new AIndicesUnaryExp(); indsExp.setExp(arg.getLeft().clone()); subsetExp.setLeft(domExp); subsetExp.setRight(indsExp); stitch = subsetExp; valuetree.setPredicate(ctxt.getPredWithContext(stitch)); } }
/** * Called by the {@link AMapDomainUnaryExp} node from {@link AMapDomainUnaryExp#apply(IPOFAnalysis)}. * @param node the calling {@link AMapDomainUnaryExp} node */ public void caseAMapDomainUnaryExp(AMapDomainUnaryExp node) throws AnalysisException { _visitedNodes.add(node); inAMapDomainUnaryExp(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); } outAMapDomainUnaryExp(node); }
/** * exists idx in set dom m & m(idx) =f(a) */ private PExp getImpliesExists(ASetCompSetExp exp, ILexNameToken finmap, ILexNameToken findex) { AExistsExp exists = new AExistsExp(); AMapDomainUnaryExp domExp = new AMapDomainUnaryExp(); domExp.setType(new ABooleanBasicType()); domExp.setExp(getVarExp(finmap)); List<PMultipleBind> bindList = getMultipleSetBindList(domExp, findex); exists.setBindList(bindList); exists.setPredicate(getExistsPredicate(exp, finmap, findex)); return exists; }
ILexNameToken d2 = getUnique("d"); AMapDomainUnaryExp domM1 = new AMapDomainUnaryExp(); domM1.setExp(getVarExp(m1)); AMapDomainUnaryExp domM2 = new AMapDomainUnaryExp(); domM2.setExp(getVarExp(m2));
/** * Called by the {@link AMapDomainUnaryExp} node from {@link AMapDomainUnaryExp#apply(IAnalysis)}. * @param node the calling {@link AMapDomainUnaryExp} node */ public A caseAMapDomainUnaryExp(AMapDomainUnaryExp node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAMapDomainUnaryExp(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)); } mergeReturns(retVal,outAMapDomainUnaryExp(node, question)); return retVal; }
public MapApplyObligation(PStateDesignator root, PExp arg, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(root, POType.MAP_APPLY, ctxt, root.getLocation(), af); AMapDomainUnaryExp dom_exp = new AMapDomainUnaryExp(); dom_exp.setExp(root.clone().apply(new StateDesignatorToExpVisitor())); // We don't care about type of the exp. This is just for the CGP to not crash. dom_exp.setType(new AUnknownType()); AInSetBinaryExp inSetExp = AstExpressionFactory.newAInSetBinaryExp(arg.clone(), dom_exp); stitch = inSetExp; valuetree.setPredicate(ctxt.getPredWithContext(inSetExp)); } }
AMapDomainUnaryExp dom = new AMapDomainUnaryExp(); dom.setExp(exp.getLeft().clone()); ASubsetBinaryExp subset = new ASubsetBinaryExp(); subset.setLeft(rng);
/** * Called by the {@link AMapDomainUnaryExp} node from {@link AMapDomainUnaryExp#apply(IAnalysis)}. * @param node the calling {@link AMapDomainUnaryExp} node */ public A caseAMapDomainUnaryExp(AMapDomainUnaryExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAMapDomainUnaryExp(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)); } mergeReturns(retVal,outAMapDomainUnaryExp(node)); return retVal; }