/** * Returns a deep clone of this {@link AEnumMapExpIR} node. * @return a deep clone of this {@link AEnumMapExpIR} node */ public AEnumMapExpIR clone() { return new AEnumMapExpIR( _sourceNode, _tag, _metaData, cloneNode(_type), cloneList(_members) ); }
/** * Creates a new tree field only constructor {@code AEnumMapExpIR TAG=enum} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param members_ the {@link NodeList} node for the {@code members} child of this {@link AEnumMapExpIR} node */ public AEnumMapExpIR(STypeIR type_, List<? extends AMapletExpIR> members_) { super(null,null,null,type_); this.setMembers(members_); }
/** * Called by the {@link AEnumMapExpIR} node from {@link AEnumMapExpIR#apply(IIsaAnalysis)}. * @param node the calling {@link AEnumMapExpIR} node */ public void caseAEnumMapExpIR(AEnumMapExpIR node) throws AnalysisException { _visitedNodes.add(node); inAEnumMapExpIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } { List<AMapletExpIR> copy = new ArrayList<AMapletExpIR>(node.getMembers()); for( AMapletExpIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAEnumMapExpIR(node); }
@Override public SExpIR caseAMapEnumMapExp(AMapEnumMapExp node, IRInfo question) throws AnalysisException { PType type = node.getType(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); AEnumMapExpIR enumMap = new AEnumMapExpIR(); enumMap.setType(typeCg); LinkedList<AMapletExp> members = node.getMembers(); for (PExp member : members) { SExpIR memberCg = member.apply(question.getExpVisitor(), question); if (!(memberCg instanceof AMapletExpIR)) { question.addUnsupportedNode(node, "Got expected map enumeration member: " + memberCg); return null; } else { enumMap.getMembers().add((AMapletExpIR) memberCg); } } return enumMap; }
@Override public Boolean caseAEnumMapExpIR(AEnumMapExpIR node) throws AnalysisException { for (AMapletExpIR m : node.getMembers()) { if (!m.apply(this)) { return false; } } return true; }
@Override public void caseACompMapExpIR(ACompMapExpIR node) throws AnalysisException { SStmIR enclosingStm = transAssistant.getEnclosingStm(node, "map comprehension"); AMapletExpIR first = node.getFirst(); SExpIR predicate = node.getPredicate(); STypeIR type = node.getType(); ITempVarGen tempVarNameGen = transAssistant.getInfo().getTempVarNameGen(); String var = tempVarNameGen.nextVarName(prefixes.mapComp()); ComplexCompStrategy strategy = consMapCompStrategy(first, predicate, type, tempVarNameGen, var); List<SMultipleBindIR> bindings = filterBindList(node, node.getBindings()); ABlockStmIR block = transAssistant.consComplexCompIterationBlock(bindings, tempVarNameGen, strategy, iteVarPrefixes); if (block.getStatements().isEmpty()) { // In case the block has no statements the result of the map comprehension is the empty map AEnumMapExpIR emptyMap = new AEnumMapExpIR(); emptyMap.setType(type.clone()); // Replace the map comprehension with the empty map transAssistant.replaceNodeWith(node, emptyMap); } else { replaceCompWithTransformation(enclosingStm, block, type, var, node); } block.apply(this); }
@Override protected SExpIR getEmptyCollection() { return new AEnumMapExpIR(); }
/** * Called by the {@link AEnumMapExpIR} node from {@link AEnumMapExpIR#apply(IAnalysis)}. * @param node the calling {@link AEnumMapExpIR} node */ public void caseAEnumMapExpIR(AEnumMapExpIR node) throws AnalysisException { _visitedNodes.add(node); inAEnumMapExpIR(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } { List<AMapletExpIR> copy = new ArrayList<AMapletExpIR>(node.getMembers()); for( AMapletExpIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAEnumMapExpIR(node); }
/** * Called by the {@link AEnumMapExpIR} node from {@link AEnumMapExpIR#apply(IAnalysis)}. * @param node the calling {@link AEnumMapExpIR} node */ public void caseAEnumMapExpIR(AEnumMapExpIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAEnumMapExpIR(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } { List<AMapletExpIR> copy = new ArrayList<AMapletExpIR>(node.getMembers()); for( AMapletExpIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } outAEnumMapExpIR(node, question); }
/** * Creates a deep clone of this {@link AEnumMapExpIR} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link AEnumMapExpIR} node */ public AEnumMapExpIR clone(Map<INode,INode> oldToNewMap) { AEnumMapExpIR node = new AEnumMapExpIR( _sourceNode, _tag, _metaData, cloneNode(_type, oldToNewMap), cloneList(_members, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Creates a new complete constructor {@code AEnumMapExpIR} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param members_ the {@link NodeList} node for the {@code members} child of this {@link AEnumMapExpIR} node */ public AEnumMapExpIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, STypeIR type_, List<? extends AMapletExpIR> members_) { super(sourceNode_,tag_,metaData_,type_); this.setMembers(members_); }
/** * Called by the {@link AEnumMapExpIR} node from {@link AEnumMapExpIR#apply(IAnalysis)}. * @param node the calling {@link AEnumMapExpIR} node */ public A caseAEnumMapExpIR(AEnumMapExpIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAEnumMapExpIR(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } { List<AMapletExpIR> copy = new ArrayList<AMapletExpIR>(node.getMembers()); for( AMapletExpIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } mergeReturns(retVal,outAEnumMapExpIR(node, question)); return retVal; }
/** * Called by the {@link AEnumMapExpIR} node from {@link AEnumMapExpIR#apply(IAnalysis)}. * @param node the calling {@link AEnumMapExpIR} node */ public A caseAEnumMapExpIR(AEnumMapExpIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAEnumMapExpIR(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } { List<AMapletExpIR> copy = new ArrayList<AMapletExpIR>(node.getMembers()); for( AMapletExpIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this)); } } } mergeReturns(retVal,outAEnumMapExpIR(node)); return retVal; }