/** * Returns a deep clone of this {@link ACasesStmIR} node. * @return a deep clone of this {@link ACasesStmIR} node */ public ACasesStmIR clone() { return new ACasesStmIR( _sourceNode, _tag, _metaData, cloneNode(_exp), cloneList(_cases), cloneNode(_others) ); }
/** * Creates a new complete constructor {@code ACasesStmIR} 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 exp_ the {@link SExpIR} node for the {@code exp} child of this {@link ACasesStmIR} node * @param cases_ the {@link NodeList} node for the {@code cases} child of this {@link ACasesStmIR} node * @param others_ the {@link SStmIR} node for the {@code others} child of this {@link ACasesStmIR} node */ public ACasesStmIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, SExpIR exp_, List<? extends ACaseAltStmStmIR> cases_, SStmIR others_) { super(sourceNode_,tag_,metaData_); this.setExp(exp_); this.setCases(cases_); this.setOthers(others_); }
/** * Called by the {@link ACasesStmIR} node from {@link ACasesStmIR#apply(IIsaAnalysis)}. * @param node the calling {@link ACasesStmIR} node */ public void caseACasesStmIR(ACasesStmIR node) throws AnalysisException { _visitedNodes.add(node); inACasesStmIR(node); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } { List<ACaseAltStmStmIR> copy = new ArrayList<ACaseAltStmStmIR>(node.getCases()); for( ACaseAltStmStmIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) { node.getOthers().apply(this); } outACasesStmIR(node); }
@Override public SStmIR caseACasesStm(ACasesStm node, IRInfo question) throws AnalysisException { PExp exp = node.getExp(); PStm others = node.getOthers(); LinkedList<ACaseAlternativeStm> cases = node.getCases(); SExpIR expCg = exp.apply(question.getExpVisitor(), question); SStmIR othersCg = others != null ? others.apply(question.getStmVisitor(), question) : null; ACasesStmIR casesStmCg = new ACasesStmIR(); casesStmCg.setExp(expCg); casesStmCg.setOthers(othersCg); question.getStmAssistant().handleAlternativesCasesStm(question, exp, cases, casesStmCg.getCases()); return casesStmCg; }
/** * Called by the {@link ACasesStmIR} node from {@link ACasesStmIR#apply(IAnalysis)}. * @param node the calling {@link ACasesStmIR} node */ public void caseACasesStmIR(ACasesStmIR node) throws AnalysisException { _visitedNodes.add(node); inACasesStmIR(node); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } { List<ACaseAltStmStmIR> copy = new ArrayList<ACaseAltStmStmIR>(node.getCases()); for( ACaseAltStmStmIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) { node.getOthers().apply(this); } outACasesStmIR(node); }
resultVar.setType(node.getType().clone()); ACasesStmIR casesStm = new ACasesStmIR(); casesStm.setExp(node.getExp().clone()); altStm.setPatternType(altExp.getPatternType().clone()); casesStm.getCases().add(altStm); casesStm.setOthers(assignToVar(resultVar, node.getOthers())); casesStm.apply(this);
/** * Called by the {@link ACasesStmIR} node from {@link ACasesStmIR#apply(IAnalysis)}. * @param node the calling {@link ACasesStmIR} node */ public void caseACasesStmIR(ACasesStmIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inACasesStmIR(node, question); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this, question); } { List<ACaseAltStmStmIR> copy = new ArrayList<ACaseAltStmStmIR>(node.getCases()); for( ACaseAltStmStmIR e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) { node.getOthers().apply(this, question); } outACasesStmIR(node, question); }
/** * Creates a new tree field only constructor {@code ACasesStmIR TAG=cases} 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 exp_ the {@link SExpIR} node for the {@code exp} child of this {@link ACasesStmIR} node * @param cases_ the {@link NodeList} node for the {@code cases} child of this {@link ACasesStmIR} node * @param others_ the {@link SStmIR} node for the {@code others} child of this {@link ACasesStmIR} node */ public ACasesStmIR(SExpIR exp_, List<? extends ACaseAltStmStmIR> cases_, SStmIR others_) { super(null,null,null); this.setExp(exp_); this.setCases(cases_); this.setOthers(others_); }
/** * Creates a deep clone of this {@link ACasesStmIR} 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 ACasesStmIR} node */ public ACasesStmIR clone(Map<INode,INode> oldToNewMap) { ACasesStmIR node = new ACasesStmIR( _sourceNode, _tag, _metaData, cloneNode(_exp, oldToNewMap), cloneList(_cases, oldToNewMap), cloneNode(_others, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ACasesStmIR} node from {@link ACasesStmIR#apply(IAnalysis)}. * @param node the calling {@link ACasesStmIR} node */ public A caseACasesStmIR(ACasesStmIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inACasesStmIR(node, question)); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { mergeReturns(retVal,node.getExp().apply(this, question)); } { List<ACaseAltStmStmIR> copy = new ArrayList<ACaseAltStmStmIR>(node.getCases()); for( ACaseAltStmStmIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) { mergeReturns(retVal,node.getOthers().apply(this, question)); } mergeReturns(retVal,outACasesStmIR(node, question)); return retVal; }
/** * Called by the {@link ACasesStmIR} node from {@link ACasesStmIR#apply(IAnalysis)}. * @param node the calling {@link ACasesStmIR} node */ public A caseACasesStmIR(ACasesStmIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inACasesStmIR(node)); if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { mergeReturns(retVal,node.getExp().apply(this)); } { List<ACaseAltStmStmIR> copy = new ArrayList<ACaseAltStmStmIR>(node.getCases()); for( ACaseAltStmStmIR e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this)); } } } if(node.getOthers() != null && !_visitedNodes.contains(node.getOthers())) { mergeReturns(retVal,node.getOthers().apply(this)); } mergeReturns(retVal,outACasesStmIR(node)); return retVal; }
@Override public void caseACasesStmIR(ACasesStmIR node) throws AnalysisException List<ACaseAltStmStmIR> nodeCases = node.getCases(); SPatternIR firstOriginal = nodeCases.get(0).getPattern().clone(); String expName = transAssistant.getInfo().getTempVarNameGen().nextVarName(casesExpNamePrefix); SExpIR exp = node.getExp(); if (!(node.getExp() instanceof SVarExpIR)) AVarDeclIR expVarDecl = transAssistant.getInfo().getDeclAssistant().consLocalVarDecl(node.getExp().getType().clone(), transAssistant.getInfo().getPatternAssistant().consIdPattern(expName), node.getExp().clone()); replacementBlock.getLocalDefs().add(expVarDecl); exp = transAssistant.getInfo().getExpAssistant().consIdVar(expName, node.getExp().getType().clone()); - 1).getResult().clone()); if (node.getOthers() != null) nextCase.setElseStm(node.getOthers().clone());