private <T extends STypeIR> List<T> getTypes(STypeIR type, Class<T> filter) { List<T> filteredTypes = new LinkedList<>(); if (filter.isInstance(type)) { filteredTypes.add(filter.cast(type)); } else if (type instanceof AUnionTypeIR) { List<STypeIR> types = ((AUnionTypeIR) type).getTypes(); for (STypeIR t : types) { filteredTypes.addAll(getTypes(t, filter)); } } return filteredTypes; }
public boolean mayBeValueType(STypeIR type) { if (type instanceof AUnionTypeIR) { LinkedList<STypeIR> types = ((AUnionTypeIR) type).getTypes(); for (STypeIR t : types) { if (mayBeValueType(t)) { return true; } } return false; } else { return type instanceof ARecordTypeIR || type instanceof ATupleTypeIR || type instanceof SSeqTypeIR || type instanceof SSetTypeIR || type instanceof SMapTypeIR; } }
public List<STypeIR> findElementTypes(AUnionTypeIR unionType, CollectionTypeStrategy strategy) { List<STypeIR> elementTypes = new LinkedList<STypeIR>(); for (int i = 0; i < unionType.getTypes().size(); i++) { STypeIR type = unionType.getTypes().get(i); if (type instanceof AUnionTypeIR) { elementTypes.addAll(findElementTypes((AUnionTypeIR) type, strategy)); } else if (strategy.isCollectionType(type)) { elementTypes.add(strategy.getElementType(type)); } } return elementTypes; }
public boolean isUnionOfType(AUnionTypeIR unionType, Class<? extends STypeIR> type) { try { for (STypeIR t : unionType.getTypes()) { if(t instanceof AUnionTypeIR) { if(!isUnionOfType((AUnionTypeIR) t, type)) { return false; } } else if (!(t instanceof AQuoteTypeIR)) { return false; } } } catch (Error t)// Hack for stackoverflowError { return false; } return true; }
/** * Called by the {@link AUnionTypeIR} node from {@link AUnionTypeIR#apply(IIsaAnalysis)}. * @param node the calling {@link AUnionTypeIR} node */ public void caseAUnionTypeIR(AUnionTypeIR node) throws AnalysisException { _visitedNodes.add(node); inAUnionTypeIR(node); if(node.getNamedInvType() != null && !_visitedNodes.contains(node.getNamedInvType())) { node.getNamedInvType().apply(this); } { List<STypeIR> copy = new ArrayList<STypeIR>(node.getTypes()); for( STypeIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAUnionTypeIR(node); }
/** * Called by the {@link AUnionTypeIR} node from {@link AUnionTypeIR#apply(IAnalysis)}. * @param node the calling {@link AUnionTypeIR} node */ public void caseAUnionTypeIR(AUnionTypeIR node) throws AnalysisException { _visitedNodes.add(node); inAUnionTypeIR(node); if(node.getNamedInvType() != null && !_visitedNodes.contains(node.getNamedInvType())) { node.getNamedInvType().apply(this); } { List<STypeIR> copy = new ArrayList<STypeIR>(node.getTypes()); for( STypeIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAUnionTypeIR(node); }
/** * Called by the {@link AUnionTypeIR} node from {@link AUnionTypeIR#apply(IAnalysis)}. * @param node the calling {@link AUnionTypeIR} node */ public void caseAUnionTypeIR(AUnionTypeIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAUnionTypeIR(node, question); if(node.getNamedInvType() != null && !_visitedNodes.contains(node.getNamedInvType())) { node.getNamedInvType().apply(this, question); } { List<STypeIR> copy = new ArrayList<STypeIR>(node.getTypes()); for( STypeIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } outAUnionTypeIR(node, question); }
/** * Called by the {@link AUnionTypeIR} node from {@link AUnionTypeIR#apply(IAnalysis)}. * @param node the calling {@link AUnionTypeIR} node */ public A caseAUnionTypeIR(AUnionTypeIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAUnionTypeIR(node)); if(node.getNamedInvType() != null && !_visitedNodes.contains(node.getNamedInvType())) { mergeReturns(retVal,node.getNamedInvType().apply(this)); } { List<STypeIR> copy = new ArrayList<STypeIR>(node.getTypes()); for( STypeIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this)); } } } mergeReturns(retVal,outAUnionTypeIR(node)); return retVal; }
/** * Called by the {@link AUnionTypeIR} node from {@link AUnionTypeIR#apply(IAnalysis)}. * @param node the calling {@link AUnionTypeIR} node */ public A caseAUnionTypeIR(AUnionTypeIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAUnionTypeIR(node, question)); if(node.getNamedInvType() != null && !_visitedNodes.contains(node.getNamedInvType())) { mergeReturns(retVal,node.getNamedInvType().apply(this, question)); } { List<STypeIR> copy = new ArrayList<STypeIR>(node.getTypes()); for( STypeIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } mergeReturns(retVal,outAUnionTypeIR(node, question)); return retVal; }
public boolean allowsNull(STypeIR type) { if (type instanceof AUnionTypeIR) { AUnionTypeIR unionType = (AUnionTypeIR) type; if (BooleanUtils.isTrue(unionType.getOptional())) { return true; } for (STypeIR t : unionType.getTypes()) { if (allowsNull(t)) { return true; } } return false; } else { return /* type instanceof AObjectTypeIR || */type != null && (type instanceof AUnknownTypeIR || BooleanUtils.isTrue(type.getOptional()) || isWrapperType(type)); } }
List<STypeIR> types = ((AUnionTypeIR) objectType).getTypes();
LinkedList<STypeIR> types = ((AUnionTypeIR) field.getObject().getType()).getTypes();
List<STypeIR> types = unionType.getTypes(); types = transAssistant.getInfo().getTypeAssistant().clearObjectTypes(types);
unionTypeCg.getTypes().add(typeCg); } else
for (STypeIR t : ((AUnionTypeIR) type).getTypes())
setConstructor.setRoot(setConstructorMember); for(STypeIR t : unionType.getTypes())
List<STypeIR> possibleTypes = ((AUnionTypeIR) fieldObjType).getTypes(); possibleTypes = typeAssistant.clearDuplicates(possibleTypes);
LinkedList<STypeIR> possibleTypes = ((AUnionTypeIR) objType).getTypes(); AIfStmIR ifChecks = new AIfStmIR();