@Override protected SExpIR getEmptyCollection() { return new AEnumMapExpIR(); }
/** * 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; }
/** * 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) ); }
@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 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); }