/** * Called by the {@link ACompBinaryExp} node from {@link ACompBinaryExp#apply(IPOFAnalysis)}. * @param node the calling {@link ACompBinaryExp} node */ public void caseACompBinaryExp(ACompBinaryExp node) throws AnalysisException { _visitedNodes.add(node); inACompBinaryExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this); } if(node.getOp() != null ) { node.getOp().apply(this); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this); } outACompBinaryExp(node); }
/** * Returns a deep clone of this {@link ACompBinaryExp} node. * @return a deep clone of this {@link ACompBinaryExp} node */ public ACompBinaryExp clone() { return new ACompBinaryExp( _type, _location, cloneNode(_left), cloneNode(_op), cloneNode(_right) ); }
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)); } }
node.getLeft().apply(THIS, noConstraint); node.getRight().apply(THIS, noConstraint); if (question.assistantFactory.createPTypeAssistant().isMap(node.getLeft().getType())) if (!question.assistantFactory.createPTypeAssistant().isMap(node.getRight().getType())) TypeCheckerErrors.report(3068, "Right hand of map 'comp' is not a map", node.getLocation(), node); TypeCheckerErrors.detail("Type", node.getRight().getType()); node.setType(AstFactory.newAMapMapType(node.getLocation())); // Unknown return node.getType(); SMapType lm = question.assistantFactory.createPTypeAssistant().getMap(node.getLeft().getType()); SMapType rm = question.assistantFactory.createPTypeAssistant().getMap(node.getRight().getType()); TypeCheckerErrors.report(3069, "Domain of left should equal range of right in map 'comp'", node.getLocation(), node); TypeCheckerErrors.detail2("Dom", lm.getFrom(), "Rng", rm.getTo()); results.add(AstFactory.newAMapMapType(node.getLocation(), rm.getFrom(), lm.getTo())); if (question.assistantFactory.createPTypeAssistant().isFunction(node.getLeft().getType())) if (!question.assistantFactory.createPTypeAssistant().isFunction(node.getRight().getType())) TypeCheckerErrors.report(3070, "Right hand of function 'comp' is not a function", node.getLocation(), node); TypeCheckerErrors.detail("Type", node.getRight().getType()); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType();
@Override public SExpIR caseACompBinaryExp(ACompBinaryExp node, IRInfo question) throws AnalysisException { PExp left = node.getLeft(); PExp right = node.getRight(); SExpIR leftCg = left.apply(question.getExpVisitor(), question); SExpIR rightCg = right.apply(question.getExpVisitor(), question); ACompBinaryExpIR compExp = new ACompBinaryExpIR(); compExp.setLeft(leftCg); compExp.setRight(rightCg); return compExp; }
@Override public void caseACompBinaryExp(ACompBinaryExp node) throws AnalysisException { PTypeAssistantTC typeAssistant = info.getTcFactory().createPTypeAssistant(); if(typeAssistant.isMap(node.getLeft().getType())) { // Supported } else if(typeAssistant.isFunction(node.getLeft().getType())) { info.addUnsupportedNode(node, "Function composition is not supported"); } }
public static ACompBinaryExp newACompBinaryExp(PExp left, LexToken op, PExp right) { ACompBinaryExp result = new ACompBinaryExp(); initExpressionBinary(result, left, op, right); return result; }
node.getLocation().hit(); // Mark as covered Value lv = node.getLeft().apply(VdmRuntime.getExpressionEvaluator(), ctxt).deref(); Value rv = node.getRight().apply(VdmRuntime.getExpressionEvaluator(), ctxt).deref(); } catch (ValueException e) return VdmRuntimeError.abort(node.getLocation(), e); VdmRuntimeError.abort(node.getLocation(), 4162, "The RHS range is not a subset of the LHS domain", ctxt); VdmRuntimeError.abort(node.getLocation(), 4005, "Duplicate map keys have different values", ctxt); } catch (ValueException e) return VdmRuntimeError.abort(node.getLocation(), e);
@Override public IProofObligationList caseACompBinaryExp(ACompBinaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); PExp lExp = node.getLeft(); PType lType = lExp.getType(); PExp rExp = node.getRight(); if (aF.createPTypeAssistant().isFunction(lType)) { ILexNameToken pref1 = getPreName(lExp); ILexNameToken pref2 = getPreName(rExp); if (pref1 == null || !pref1.equals(NO_PRECONDITION)) { obligations.add(new FuncComposeObligation(node, pref1, pref2, question, aF));// gkanos:add on more // argument for the // assistantFactory need // it } } if (aF.createPTypeAssistant().isMap(lType)) { obligations.add(new MapComposeObligation(node, question, aF)); } return obligations; }
/** * Called by the {@link ACompBinaryExp} node from {@link ACompBinaryExp#apply(IAnalysis)}. * @param node the calling {@link ACompBinaryExp} node */ public void caseACompBinaryExp(ACompBinaryExp node) throws AnalysisException { _visitedNodes.add(node); inACompBinaryExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this); } if(node.getOp() != null ) { node.getOp().apply(this); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this); } outACompBinaryExp(node); }
IPogAssistantFactory assistantFactory) throws AnalysisException super(exp, POType.FUNC_COMPOSE, ctxt, exp.getLocation(), assistantFactory); PType leftPType = assistantFactory.createPTypeAssistant().getFunction(exp.getLeft().getType()).getParameters().get(0).clone(); forallExp.setBindList(getMultipleTypeBindList(leftPType, arg)); PExp firstPart = null; preExp.setFunction(exp.getRight().clone()); List<PExp> args = new Vector<PExp>(); args.add(getVarExp(arg)); secondPart = getApplyExp(getVarExp(pref1), getApplyExp(exp.getRight(), getVarExp(arg))); } else preExp.setFunction(exp.getLeft().clone()); List<PExp> args = new Vector<PExp>(); args.add(getApplyExp(exp.getRight().clone(), getVarExp(arg))); preExp.setArgs(args); secondPart = preExp;
/** * Creates a deep clone of this {@link ACompBinaryExp} 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 ACompBinaryExp} node */ public ACompBinaryExp clone(Map<INode,INode> oldToNewMap) { ACompBinaryExp node = new ACompBinaryExp( _type, _location, cloneNode(_left, oldToNewMap), cloneNode(_op, oldToNewMap), cloneNode(_right, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ACompBinaryExp} node from {@link ACompBinaryExp#apply(IAnalysis)}. * @param node the calling {@link ACompBinaryExp} node */ public void caseACompBinaryExp(ACompBinaryExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inACompBinaryExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { node.getLeft().apply(this, question); } if(node.getOp() != null ) { node.getOp().apply(this, question); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { node.getRight().apply(this, question); } outACompBinaryExp(node, question); }
/** * Called by the {@link ACompBinaryExp} node from {@link ACompBinaryExp#apply(IAnalysis)}. * @param node the calling {@link ACompBinaryExp} node */ public A caseACompBinaryExp(ACompBinaryExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inACompBinaryExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { mergeReturns(retVal,node.getLeft().apply(this)); } if(node.getOp() != null ) { mergeReturns(retVal,node.getOp().apply(this)); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { mergeReturns(retVal,node.getRight().apply(this)); } mergeReturns(retVal,outACompBinaryExp(node)); return retVal; }
/** * Called by the {@link ACompBinaryExp} node from {@link ACompBinaryExp#apply(IAnalysis)}. * @param node the calling {@link ACompBinaryExp} node */ public A caseACompBinaryExp(ACompBinaryExp node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inACompBinaryExp(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } if(node.getLeft() != null && !_visitedNodes.contains(node.getLeft())) { mergeReturns(retVal,node.getLeft().apply(this, question)); } if(node.getOp() != null ) { mergeReturns(retVal,node.getOp().apply(this, question)); } if(node.getRight() != null && !_visitedNodes.contains(node.getRight())) { mergeReturns(retVal,node.getRight().apply(this, question)); } mergeReturns(retVal,outACompBinaryExp(node, question)); return retVal; }