/** * Returns a deep clone of this {@link AForAllStmIR} node. * @return a deep clone of this {@link AForAllStmIR} node */ public AForAllStmIR clone() { return new AForAllStmIR( _sourceNode, _tag, _metaData, cloneNode(_pattern), cloneNode(_exp), cloneNode(_body) ); }
/** * Creates a new complete constructor {@code AForAllStmIR} 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 pattern_ the {@link SPatternIR} node for the {@code pattern} child of this {@link AForAllStmIR} node * @param exp_ the {@link SExpIR} node for the {@code exp} child of this {@link AForAllStmIR} node * @param body_ the {@link SStmIR} node for the {@code body} child of this {@link AForAllStmIR} node */ public AForAllStmIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, SPatternIR pattern_, SExpIR exp_, SStmIR body_) { super(sourceNode_,tag_,metaData_); this.setPattern(pattern_); this.setExp(exp_); this.setBody(body_); }
/** * Essentially this.toString().equals(o.toString()). **/ @Override public boolean equals(Object o) { if (o != null && o instanceof AForAllStmIR) { return toString().equals(o.toString()); } return false; }
/** * Called by the {@link AForAllStmIR} node from {@link AForAllStmIR#apply(IAnalysis)}. * @param node the calling {@link AForAllStmIR} node */ public void caseAForAllStmIR(AForAllStmIR node) throws AnalysisException { _visitedNodes.add(node); inAForAllStmIR(node); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { node.getPattern().apply(this); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { node.getBody().apply(this); } outAForAllStmIR(node); }
@Override public SStmIR caseAForAllStm(AForAllStm node, IRInfo question) throws AnalysisException { // Example: for all x in set {1,2,3} do skip; PPattern pattern = node.getPattern(); PExp set = node.getSet(); PStm body = node.getStatement(); SPatternIR patternCg = pattern.apply(question.getPatternVisitor(), question); SExpIR setExpCg = set.apply(question.getExpVisitor(), question); SStmIR bodyCg = body.apply(question.getStmVisitor(), question); AForAllStmIR forAll = new AForAllStmIR(); forAll.setPattern(patternCg); forAll.setExp(setExpCg); forAll.setBody(bodyCg); return forAll; }
@Override public void caseAForAllStmIR(AForAllStmIR node) throws AnalysisException { if (node.getExp().getType() instanceof AStringTypeIR) { ASeqSeqTypeIR seqType = new ASeqSeqTypeIR(); seqType.setEmpty(false); seqType.setSeq1(false); seqType.setOptional(false); seqType.setSeqOf(new ACharBasicTypeIR()); correctExpToSeq(node.getExp(), seqType); } node.getBody().apply(this); }
/** * Called by the {@link AForAllStmIR} node from {@link AForAllStmIR#apply(IAnalysis)}. * @param node the calling {@link AForAllStmIR} node */ public void caseAForAllStmIR(AForAllStmIR node, Q question) throws AnalysisException { _visitedNodes.add(node); inAForAllStmIR(node, question); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { node.getPattern().apply(this, question); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this, question); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { node.getBody().apply(this, question); } outAForAllStmIR(node, question); }
SStmIR stmCg = stm.apply(question.getStmVisitor(), question); AForAllStmIR forAll = new AForAllStmIR(); forAll.setPattern(patternCg); forAll.setBody(stmCg); reversedExp.setType(seqExpCg.getType().clone()); reversedExp.setExp(seqExpCg); forAll.setExp(reversedExp); } else forAll.setExp(seqExpCg);
/** * Called by the {@link AForAllStmIR} node from {@link AForAllStmIR#apply(IIsaAnalysis)}. * @param node the calling {@link AForAllStmIR} node */ public void caseAForAllStmIR(AForAllStmIR node) throws AnalysisException { _visitedNodes.add(node); inAForAllStmIR(node); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { node.getPattern().apply(this); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { node.getBody().apply(this); } outAForAllStmIR(node); }
/** * Creates a new tree field only constructor {@code AForAllStmIR TAG=forAll} 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 pattern_ the {@link SPatternIR} node for the {@code pattern} child of this {@link AForAllStmIR} node * @param exp_ the {@link SExpIR} node for the {@code exp} child of this {@link AForAllStmIR} node * @param body_ the {@link SStmIR} node for the {@code body} child of this {@link AForAllStmIR} node */ public AForAllStmIR(SPatternIR pattern_, SExpIR exp_, SStmIR body_) { super(null,null,null); this.setPattern(pattern_); this.setExp(exp_); this.setBody(body_); }
/** * Creates a deep clone of this {@link AForAllStmIR} 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 AForAllStmIR} node */ public AForAllStmIR clone(Map<INode,INode> oldToNewMap) { AForAllStmIR node = new AForAllStmIR( _sourceNode, _tag, _metaData, cloneNode(_pattern, oldToNewMap), cloneNode(_exp, oldToNewMap), cloneNode(_body, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link AForAllStmIR} node from {@link AForAllStmIR#apply(IAnalysis)}. * @param node the calling {@link AForAllStmIR} node */ public A caseAForAllStmIR(AForAllStmIR node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAForAllStmIR(node)); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { mergeReturns(retVal,node.getPattern().apply(this)); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { mergeReturns(retVal,node.getExp().apply(this)); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { mergeReturns(retVal,node.getBody().apply(this)); } mergeReturns(retVal,outAForAllStmIR(node)); return retVal; }
/** * Called by the {@link AForAllStmIR} node from {@link AForAllStmIR#apply(IAnalysis)}. * @param node the calling {@link AForAllStmIR} node */ public A caseAForAllStmIR(AForAllStmIR node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAForAllStmIR(node, question)); if(node.getPattern() != null && !_visitedNodes.contains(node.getPattern())) { mergeReturns(retVal,node.getPattern().apply(this, question)); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { mergeReturns(retVal,node.getExp().apply(this, question)); } if(node.getBody() != null && !_visitedNodes.contains(node.getBody())) { mergeReturns(retVal,node.getBody().apply(this, question)); } mergeReturns(retVal,outAForAllStmIR(node, question)); return retVal; }
@Override public void caseAForAllStmIR(AForAllStmIR node) throws AnalysisException { SPatternIR pattern = node.getPattern(); if (pattern instanceof AIdentifierPatternIR) { node.getExp().apply(this); node.getBody().apply(this); return; } if (pattern instanceof AIgnorePatternIR) { AIdentifierPatternIR idPattern = getIdPattern(config.getIgnorePatternPrefix()); transAssistant.replaceNodeWith(pattern, idPattern); } PatternBlockData patternData = new PatternBlockData(MismatchHandling.LOOP_CONTINUE); patternData.setPattern(pattern); ABlockStmIR declBlock = new ABlockStmIR(); patternData.setDeclBlock(declBlock); ABlockStmIR patternHandlingBlock = consPatternCheck(false, pattern, transAssistant.getInfo().getTypeAssistant().findElementType(node.getExp().getType().clone()), patternData, null); if (patternHandlingBlock != null) { declBlock.getStatements().addFirst(patternHandlingBlock); } declBlock.getStatements().add(node.getBody().clone()); transAssistant.replaceNodeWith(node.getBody(), declBlock); node.getExp().apply(this); node.getBody().apply(this); }