@Override public Boolean caseAUnionType(AUnionType node, ILexLocation q) throws AnalysisException { for (PType t : node.getTypes()) { if (t.apply(this, q)) { return true; } } return false; }
@Override public Boolean caseAUnionType(AUnionType type, AAccessSpecifierAccessSpecifier accessSpecifier) throws AnalysisException { for (PType t : type.getTypes()) { if (t.apply(this, accessSpecifier)) // (PTypeAssistantTC.narrowerThan(t, accessSpecifier)) { return true; } } return false; }
public boolean isUnionOfType(AUnionType unionType, Class<? extends PType> type, PTypeAssistantTC typeAssistant) { try { for (PType t : unionType.getTypes()) { if (!typeAssistant.isType(t, type)) { return false; } } } catch (Error t)// Hack for stackoverflowError { return false; } return true; }
@Override public String caseAUnionType(AUnionType node, PrettyPrinterEnv question) throws AnalysisException { List<String> types = new Vector<String>(); for (PType t : node.getTypes()) { types.add(t.apply(this, question)); } return "" + "" + (types.size() == 1 ? types.iterator().next().toString() : Utils.setToString(types, " | ")); }
@Override public String caseAUnionType(AUnionType type) throws AnalysisException { List<PType> types = type.getTypes(); if (types.size() == 1) { return types.iterator().next().toString(); } else { return Utils.setToString(new PTypeSet(types, af), " | "); } }
public boolean isUnknown(AUnionType type) { for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isUnknown(t)) { return true; } } return false; }
@Override public Integer caseAUnionType(AUnionType type) throws AnalysisException { return af.createPTypeAssistant().hashCode(type.getTypes()); }
@Override public Boolean caseAUnionType(AUnionType type) throws AnalysisException { for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isVoid(t)) { return true; } } return false; }
@Override public Boolean caseAUnionType(AUnionType type) throws AnalysisException { for (PType t : type.getTypes()) { if (!af.createPTypeAssistant().isVoid(t)) { return false; // NB. Only true if ALL void, not ANY void (see hasVoid) } } return true; }
@Override public Boolean caseAUnionType(AUnionType type, Class<? extends PType> typeclass) throws AnalysisException { for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isType(t, typeclass)) { return true; } } return false; }
@Override public PType caseAUnionType(AUnionType type, String typename) throws AnalysisException { for (PType t : type.getTypes()) { PType rt = af.createPTypeAssistant().isType(t, typename); if (rt != null) { return rt; } } return null; }
@Override public Boolean caseAUnionType(AUnionType type, Object other) throws AnalysisException { other = deBracket((PType) other); PTypeSet types = new PTypeSet(type.getTypes(), af); if (other instanceof AUnionType) { AUnionType uother = (AUnionType) other; for (PType t : uother.getTypes()) { if (!types.contains(t)) { return false; } } return true; } return types.contains(other); }
@Override public PTypeList caseAUnionType(AUnionType node) throws AnalysisException { PTypeList list = new PTypeList(); for (PType ptype : node.getTypes()) { list.addAll(ptype.apply(THIS)); } return list; }
@Override public ValueList caseAUnionType(AUnionType type, Context ctxt) throws AnalysisException { ValueList v = new ValueList(); for (PType utype : type.getTypes()) { v.addAll(utype.apply(THIS, ctxt)); } return v; }
@Override public PType caseAUnionType(AUnionType type, Context ctxt) throws AnalysisException { return AstFactory.newAUnionType(type.getLocation(), instantiate(type.getTypes(), ctxt)); }
@Override public void caseAUnionType(AUnionType type) throws AnalysisException { if (!type.getResolved()) { return; } else { type.setResolved(false); } for (PType t : type.getTypes()) { t.apply(THIS); } }
@Override public PType caseAUnionType(AUnionType type, Newquestion question) throws AnalysisException { // return AUnionTypeAssistantTC.polymorph(type, question.pname, question.actualType); PTypeSet polytypes = new PTypeSet(af); for (PType ptype : ((AUnionType) type).getTypes()) { polytypes.add(af.createPTypeAssistant().polymorph(ptype, question.pname, question.actualType)); } // TODO: Types in unionType should be a SET PTypeList result = new PTypeList(); result.addAll(polytypes); return AstFactory.newAUnionType(type.getLocation(), result); }
private void handleBinExpSubNode(IPOContextStack question, IProofObligationList obligations, PExp left, PType ltype) throws AnalysisException { PTypeAssistantTC pTA = aF.createPTypeAssistant(); if (pTA.isUnion(ltype)) { for (PType type : pTA.getUnion(ltype).getTypes()){ if (!pTA.isNumeric(type)){ TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(left, AstFactory.newARealNumericBasicType(left.getLocation()), ltype, question, aF); if (sto != null) { obligations.add(sto); } } } } }
@Override public SSeqType caseAUnionType(AUnionType type) throws AnalysisException { // return AUnionTypeAssistantTC.getSeq(type); if (!type.getSeqDone()) { type.setSeqDone(true); // Mark early to avoid recursion. // type.setSeqType(PTypeAssistantTC.getSeq(AstFactory.newAUnknownType(type.getLocation()))); type.setSeqType(af.createPTypeAssistant().getSeq(AstFactory.newAUnknownType(type.getLocation()))); PTypeSet set = new PTypeSet(af); for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isSeq(t)) { set.add(t.apply(THIS).getSeqof()); } } type.setSeqType(set.isEmpty() ? null : AstFactory.newASeqSeqType(type.getLocation(), set.getType(type.getLocation()))); } return type.getSeqType(); }