public PTypeList getBaseTypes() { PTypeList basetypes = new PTypeList(); if (superobjects.isEmpty()) { basetypes.add(type); } else { for (ObjectValue sup : superobjects) { basetypes.addAll(sup.getBaseTypes()); } } return basetypes; }
@Override public PTypeList caseAProductType(AProductType node) throws AnalysisException { PTypeList list = new PTypeList(); for (PType ptype : node.getTypes()) { list.addAll(ptype.apply(THIS)); } return list; }
@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 PTypeList caseARecordInvariantType(ARecordInvariantType node) throws AnalysisException { if (node.getComposed()) { PTypeList types = new PTypeList(node); for (AFieldField f : node.getFields()) { types.addAll(f.getType().apply(THIS)); } return types; } else { return new PTypeList(); } } }
@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); }
@SuppressWarnings("unchecked") public AFunctionType getPreType(AOperationType type, AStateDefinition state, SClassDefinition classname, boolean isStatic) { if (state != null) { PTypeList params = new PTypeList(); params.addAll((LinkedList<PType>) type.getParameters().clone()); params.add(AstFactory.newAUnresolvedType(state.getName())); return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); } else if (classname != null && !isStatic) { PTypeList params = new PTypeList(); params.addAll((Collection<? extends PType>) type.getParameters().clone()); params.add(AstFactory.newAUnresolvedType(classname.getName())); return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); } else { return AstFactory.newAFunctionType(type.getLocation(), false, (List<PType>) type.getParameters().clone(), AstFactory.newABooleanBasicType(type.getLocation())); } }
@SuppressWarnings("unchecked") public AFunctionType getPostType(AOperationType type, AStateDefinition state, SClassDefinition classname, boolean isStatic) { PTypeList params = new PTypeList(); params.addAll((LinkedList<PType>) type.getParameters().clone()); if (!(type.getResult() instanceof AVoidType)) { params.add(type.getResult().clone()); } if (state != null) { params.add(AstFactory.newAUnresolvedType(state.getName())); params.add(AstFactory.newAUnresolvedType(state.getName())); } else if (classname != null) { AMapMapType map = AstFactory.newAMapMapType(type.getLocation(), AstFactory.newASeqSeqType(type.getLocation(), AstFactory.newACharBasicType(type.getLocation())), AstFactory.newAUnknownType(type.getLocation())); params.add(map); if (!isStatic) { params.add(AstFactory.newAUnresolvedType(classname.getName())); } } return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); }