/** * 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(); }
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)); }
/** * 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; }
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)); } }