@Override public PType defaultSMapType(SMapType type, Newquestion question) throws AnalysisException { if (type.getResolved()) { return type; } else { type.setResolved(true); } try { if (!type.getEmpty()) { type.setFrom(af.createPTypeAssistant().typeResolve(type.getFrom(), question.root, question.rootVisitor, question.question)); type.setTo(af.createPTypeAssistant().typeResolve(type.getTo(), question.root, question.rootVisitor, question.question)); } return type; } catch (TypeCheckException e) { type.apply(af.getTypeUnresolver()); throw e; } }
@Override public PType defaultSMapType(SMapType type, Context ctxt) throws AnalysisException { return AstFactory.newAMapMapType(type.getLocation(), type.getFrom().apply(this, ctxt), type.getTo().apply(this, ctxt)); }
/** * Sets the {@code _mapType} child of this {@link AMapInverseUnaryExp} node. * @param value the new {@code _mapType} child of this {@link AMapInverseUnaryExp} node */ public void setMapType(SMapType value) { if( value != null && value.parent() == null) { value.parent(this); } this._mapType = value; }
@Override public void defaultSMapType(SMapType type) throws AnalysisException { if (!type.getResolved()) { return; } else { type.setResolved(false); } if (!type.getEmpty()) { type.getFrom().apply(THIS); type.getTo().apply(THIS); } }
public PType mapApply(AApplyExp node, boolean isSimple, SMapType map, TypeCheckInfo question) { if (map.getEmpty()) { TypeCheckerErrors.concern(isSimple, 3267, "Empty map cannot be applied", node.getLocation(), node); } if (node.getArgs().size() != 1) { TypeCheckerErrors.concern(isSimple, 3057, "Map application must have one argument", node.getLocation(), node); } else { PType argtype = node.getArgtypes().get(0); if (!question.assistantFactory.getTypeComparator().compatible(map.getFrom(), argtype)) { TypeCheckerErrors.concern(isSimple, 3058, "Map application argument is incompatible type", node.getLocation(), node); TypeCheckerErrors.detail2(isSimple, "Map domain", map.getFrom(), "Argument", argtype); } } return map.getTo(); }
/** * Called by the {@link AMapInverseUnaryExp} node from {@link AMapInverseUnaryExp#apply(IPOFAnalysis)}. * @param node the calling {@link AMapInverseUnaryExp} node */ public void caseAMapInverseUnaryExp(AMapInverseUnaryExp node) throws AnalysisException { _visitedNodes.add(node); inAMapInverseUnaryExp(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); } if(node.getMapType() != null && !_visitedNodes.contains(node.getMapType())) { node.getMapType().apply(this); } outAMapInverseUnaryExp(node); }
@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(); }
&& question.assistantFactory.createPTypeAssistant().isMap(question.constraint)) PType stype = question.assistantFactory.createPTypeAssistant().getMap(question.constraint).getTo(); rngConstraint = question.newConstraint(AstFactory.newASetSetType(node.getLocation(), stype)); SSetType set = question.assistantFactory.createPTypeAssistant().getSet(rtype); if (!question.assistantFactory.getTypeComparator().compatible(set.getSetof(), map.getTo())) + map.getTo(), node.getLocation(), node);
@Override public ILexLocation defaultSMapType(SMapType node) throws AnalysisException { return node.getLocation(); }
@Override public IProofObligationList caseAMapInverseUnaryExp( AMapInverseUnaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = node.getExp().apply(mainVisitor, question); if (!node.getMapType().getEmpty()) { obligations.add(new org.overture.pog.obligation.MapInverseObligation(node, question, aF)); } return obligations; }
@Override public Boolean defaultSMapType(SMapType type, Object other) throws AnalysisException { // return SMapTypeAssistantTC.equals(type, other); other = af.createPTypeAssistant().deBracket(other); if (other.getClass() == type.getClass()) // inmaps too { SMapType mt = (SMapType) other; // return PTypeAssistantTC.equals(type.getFrom(),mt.getFrom()) && PTypeAssistantTC.equals(type.getTo(), // mt.getTo()); return type.getFrom().apply(this, mt.getFrom()) && type.getTo().apply(this, mt.getTo()); } return false; }
@Override public SMapTypeIR findType(PType type) throws org.overture.ast.analysis.AnalysisException { SMapType mapType = transAssistant.getInfo().getTcFactory().createPTypeAssistant().getMap(type); return mapType != null ? (SMapTypeIR) mapType.apply(transAssistant.getInfo().getTypeVisitor(), transAssistant.getInfo()) : null; } });
&& question.assistantFactory.createPTypeAssistant().isMap(question.constraint)) PType stype = question.assistantFactory.createPTypeAssistant().getMap(question.constraint).getFrom(); domConstraint = question.newConstraint(AstFactory.newASetSetType(node.getLocation(), stype)); SMapType map = question.assistantFactory.createPTypeAssistant().getMap(node.getRight().getType()); if (!question.assistantFactory.getTypeComparator().compatible(set.getSetof(), map.getFrom())) + map.getFrom(), node.getLocation(), node);
&& question.assistantFactory.createPTypeAssistant().isMap(question.constraint)) PType stype = question.assistantFactory.createPTypeAssistant().getMap(question.constraint).getTo(); rngConstraint = question.newConstraint(AstFactory.newASetSetType(node.getLocation(), stype)); SSetType set = question.assistantFactory.createPTypeAssistant().getSet(rtype); if (!question.assistantFactory.getTypeComparator().compatible(set.getSetof(), map.getTo())) + map.getTo(), node.getLocation(), node);
@Override public List<PDefinition> caseAMapPattern(AMapPattern pattern, NewQuestion question) throws AnalysisException { List<PDefinition> defs = new Vector<PDefinition>(); if (!af.createPTypeAssistant().isMap(question.ptype)) { TypeCheckerErrors.report(3314, "Map pattern is not matched against map type", pattern.getLocation(), pattern); TypeCheckerErrors.detail("Actual type", question.ptype); } else { SMapType map = af.createPTypeAssistant().getMap(question.ptype); if (!map.getEmpty()) { for (AMapletPatternMaplet p : pattern.getMaplets()) { defs.addAll(getDefinitions(p, map, question.scope)); // defs.addAll(p.apply(THIS, question)); } } } return defs; }
public Collection<? extends PDefinition> getDefinitions( AMapletPatternMaplet p, SMapType map, NameScope scope) { List<PDefinition> list = new Vector<PDefinition>(); list.addAll(af.createPPatternAssistant().getDefinitions(p.getFrom(), map.getFrom(), scope)); list.addAll(af.createPPatternAssistant().getDefinitions(p.getTo(), map.getTo(), scope)); return list; } }
/** * Called by the {@link AMapInverseUnaryExp} node from {@link AMapInverseUnaryExp#apply(IAnalysis)}. * @param node the calling {@link AMapInverseUnaryExp} node */ public void caseAMapInverseUnaryExp(AMapInverseUnaryExp node) throws AnalysisException { _visitedNodes.add(node); inAMapInverseUnaryExp(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); } if(node.getMapType() != null && !_visitedNodes.contains(node.getMapType())) { node.getMapType().apply(this); } outAMapInverseUnaryExp(node); }