List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) List<PType> copy = new ArrayList<PType>(node.getTypes()); for( PType e : copy) if(node.getSeqType() != null && !_visitedNodes.contains(node.getSeqType())) node.getSeqType().apply(this, question); if(node.getSetType() != null && !_visitedNodes.contains(node.getSetType())) node.getSetType().apply(this, question); if(node.getMapType() != null && !_visitedNodes.contains(node.getMapType())) node.getMapType().apply(this, question); if(node.getProdType() != null && !_visitedNodes.contains(node.getProdType())) node.getProdType().apply(this, question); if(node.getFuncType() != null && !_visitedNodes.contains(node.getFuncType())) node.getFuncType().apply(this, question); if(node.getOpType() != null && !_visitedNodes.contains(node.getOpType())) node.getOpType().apply(this, question);
@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(); }
@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, Context ctxt) throws AnalysisException { return AstFactory.newAUnionType(type.getLocation(), instantiate(type.getTypes(), ctxt)); }
if (!type.getRecDone()) type.setRecDone(true); // Mark early to avoid recursion. type.setRecType(af.createPTypeAssistant().getRecord(AstFactory.newAUnknownType(type.getLocation()))); int recordCount = 0; for (PType t : type.getTypes()) list.add(AstFactory.newAQuoteType(new LexQuoteToken("?", type.getLocation()))); LexNameToken tagname = new LexNameToken("?", tag, type.getLocation()); fields.add(AstFactory.newAFieldField(tagname, tag, typesets.get(tag).getType(type.getLocation()), false)); type.setRecType(fields.isEmpty() ? null : AstFactory.newARecordInvariantType(type.getLocation(), fields)); return type.getRecType() != null;
@Override public SSetType caseAUnionType(AUnionType type) throws AnalysisException { ILexLocation location = type.getLocation(); if (!type.getSetDone()) { type.setSetDone(true); // Mark early to avoid recursion. // type.setSetType(PTypeAssistantTC.getSet(AstFactory.newAUnknownType(location))); type.setSetType(af.createPTypeAssistant().getSet(AstFactory.newAUnknownType(location))); PTypeSet set = new PTypeSet(af); for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isSet(t)) { // set.add(PTypeAssistantTC.getSet(t).getSetof()); set.add(t.apply(THIS).getSetof()); } } type.setSetType(set.isEmpty() ? null : AstFactory.newASetSetType(location, set.getType(location))); } return type.getSetType(); }
@Override public SNumericBasicType caseAUnionType(AUnionType type) throws AnalysisException { if (!type.getNumDone()) { type.setNumDone(true); type.setNumType(AstFactory.newANatNumericBasicType(type.getLocation())); // lightest default boolean found = false; for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isNumeric(t)) { SNumericBasicType nt = af.createPTypeAssistant().getNumeric(t); if (af.createSNumericBasicTypeAssistant().getWeight(nt) > af.createSNumericBasicTypeAssistant().getWeight(type.getNumType())) { type.setNumType(nt); } found = true; } } if (!found) { type.setNumType(null); } } return type.getNumType(); }
throws AnalysisException if (type.getProdCard() != size) type.setProdCard(size); type.setProdType(af.createPTypeAssistant().getProduct(AstFactory.newAUnknownType(type.getLocation()), size)); for (PType t : type.getTypes()) list.add(result.get(i).getType(type.getLocation())); type.setProdType(list.isEmpty() ? null : AstFactory.newAProductType(type.getLocation(), list)); return type.getProdType();
throws AnalysisException if (!type.getOpDone()) type.setOpDone(true); type.setOpType(af.createPTypeAssistant().getOperation(AstFactory.newAUnknownType(type.getLocation()))); PTypeSet result = new PTypeSet(af); Map<Integer, PTypeSet> params = new HashMap<Integer, PTypeSet>(); List<PDefinition> defs = new Vector<PDefinition>(); for (PType t : type.getTypes()) PType rtype = result.getType(type.getLocation()); PTypeList plist = new PTypeList(); PType pt = params.get(i).getType(type.getLocation()); plist.add(pt); type.setOpType(AstFactory.newAOperationType(type.getLocation(), plist, rtype)); type.getOpType().setDefinitions(defs); } else type.setOpType(null); return (AOperationType) type.getOpType();
if (!type.getFuncDone()) type.setFuncDone(true); type.setFuncType(af.createPTypeAssistant().getFunction(AstFactory.newAUnknownType(type.getLocation()))); List<PDefinition> defs = new Vector<PDefinition>(); for (PType t : type.getTypes()) PType rtype = result.getType(type.getLocation()); PTypeList plist = new PTypeList(); PType pt = params.get(i).getType(type.getLocation()); plist.add(pt); type.setFuncType(AstFactory.newAFunctionType(type.getLocation(), true, plist, rtype)); type.getFuncType().setDefinitions(defs); } else type.setFuncType(null); return (AFunctionType) type.getFuncType();
@Override public SMapType caseAUnionType(AUnionType type) throws AnalysisException { ILexLocation location = type.getLocation(); if (!type.getMapDone()) { type.setMapDone(true); // Mark early to avoid recursion. // type.setMapType(PTypeAssistantTC.getMap(AstFactory.newAUnknownType(location))); // Rewritten in an none static form. type.setMapType(af.createPTypeAssistant().getMap(AstFactory.newAUnknownType(location))); PTypeSet from = new PTypeSet(af); PTypeSet to = new PTypeSet(af); for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isMap(t)) { // from.add(PTypeAssistantTC.getMap(t).getFrom()); //Original Code from.add(t.apply(THIS).getFrom()); // My change George. // to.add(PTypeAssistantTC.getMap(t).getTo());//Original code. to.add(t.apply(THIS).getTo());// My change George. } } type.setMapType(from.isEmpty() ? null : AstFactory.newAMapMapType(location, from.getType(location), to.getType(location))); } return type.getMapType(); }
throws AnalysisException if (type.getResolved()) type.setResolved(true); type.setInfinite(true); TypeCheckException problem = null; for (PType t : type.getTypes()) type.setInfinite(type.getInfinite() && question.root.getInfinite()); type.apply(af.getTypeUnresolver()); throw problem; type.setTypes(new Vector<PType>(fixed)); question.root.setInfinite(type.getInfinite()); type.setExpanded(false); af.createAUnionTypeAssistant().expand(type);
@Override public AClassType caseAUnionType(AUnionType type) throws AnalysisException if (!type.getClassDone()) type.setClassDone(true); // Mark early to avoid recursion. type.setClassType(af.createPTypeAssistant().getClassType(AstFactory.newAUnknownType(type.getLocation()), env)); AClassType found = null; for (PType t: type.getTypes()) type.setClassType(found); return found; type.setClassType(null); return null; for (PType t : type.getTypes()) PType ptype = common.get(synthname).getType(type.getLocation()); ILexNameToken newname = null; type.setClassType(classname == null ? null : AstFactory.newAClassType(type.getLocation(), AstFactory.newAClassClassDefinition(classname.clone(), new LexNameList(), newdefs))); return type.getClassType();
public void expand(AUnionType type) if (type.getExpanded()) for (PType t : type.getTypes()) ut.setExpanded(false); expand(ut); exptypes.addAll(ut.getTypes()); } else type.setTypes(v); type.setExpanded(true); List<PDefinition> definitions = type.getDefinitions(); for (PType t : type.getTypes())
@Override public Boolean caseAUnionType(AUnionType node, ILexLocation q) throws AnalysisException { for (PType t : node.getTypes()) { if (t.apply(this, q)) { return true; } } return false; }
throws AnalysisException if (!type.getRecDone()) type.setRecDone(true); // Mark early to avoid recursion. af.createPTypeAssistant(); type.setRecType(af.createPTypeAssistant().getRecord(AstFactory.newAUnknownType(type.getLocation()))); int recordCount = 0; for (PType t : type.getTypes()) list.add(AstFactory.newAQuoteType(new LexQuoteToken("?", type.getLocation()))); LexNameToken tagname = new LexNameToken("?", tag, type.getLocation()); fields.add(AstFactory.newAFieldField(tagname, tag, typesets.get(tag).getType(type.getLocation()), false)); type.setRecType(fields.isEmpty() ? null : AstFactory.newARecordInvariantType(type.getLocation(), fields)); return type.getRecType();
public SNumericBasicType getNumeric(AUnionType type) { if (!type.getNumDone()) { type.setNumDone(true); type.setNumType(AstFactory.newANatNumericBasicType(type.getLocation())); // lightest default boolean found = false; for (PType t : type.getTypes()) { if (af.createPTypeAssistant().isNumeric(t)) { SNumericBasicType nt = af.createPTypeAssistant().getNumeric(t); if (af.createSNumericBasicTypeAssistant().getWeight(nt) > af.createSNumericBasicTypeAssistant().getWeight(type.getNumType())) { type.setNumType(nt); } found = true; } } if (!found) { type.setNumType(null); } } return type.getNumType(); }
@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); }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) List<PType> copy = new ArrayList<PType>(node.getTypes()); for( PType e : copy) if(node.getSeqType() != null && !_visitedNodes.contains(node.getSeqType())) node.getSeqType().apply(this); if(node.getSetType() != null && !_visitedNodes.contains(node.getSetType())) node.getSetType().apply(this); if(node.getMapType() != null && !_visitedNodes.contains(node.getMapType())) node.getMapType().apply(this); if(node.getProdType() != null && !_visitedNodes.contains(node.getProdType())) node.getProdType().apply(this); if(node.getFuncType() != null && !_visitedNodes.contains(node.getFuncType())) node.getFuncType().apply(this); if(node.getOpType() != null && !_visitedNodes.contains(node.getOpType())) node.getOpType().apply(this);