![JAR search and dependency download from the Maven repository](/logo.png)
soot.dava.toolkits.base.AST.transformations.StrengthenByIfElse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of soot Show documentation
Show all versions of soot Show documentation
A Java Optimization Framework
package soot.dava.toolkits.base.AST.transformations;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Nomair A. Naeem
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import soot.dava.internal.AST.ASTAndCondition;
import soot.dava.internal.AST.ASTCondition;
import soot.dava.internal.AST.ASTIfElseNode;
import soot.dava.internal.AST.ASTLabeledNode;
import soot.dava.internal.AST.ASTNode;
import soot.dava.internal.AST.ASTStatementSequenceNode;
import soot.dava.internal.AST.ASTUnconditionalLoopNode;
import soot.dava.internal.AST.ASTWhileNode;
import soot.dava.internal.SET.SETNodeLabel;
import soot.dava.internal.asg.AugmentedStmt;
import soot.dava.internal.javaRep.DAbruptStmt;
import soot.jimple.ReturnStmt;
import soot.jimple.ReturnVoidStmt;
import soot.jimple.Stmt;
/*
Nomair A. Naeem 18-FEB-2005
PATTERN ONE:
label_1:
while(cond1){ label_1:
if(cond2){ while(cond1 && cond2){
Body 1 Body1
} }
else{
break label_1
}
}
The important thing is that Body2 should contain an abrupt
edge out of the while loop. If Body2 is just a break and nothing
else the body2 in the transformed version is empty
PATTERN TWO:
label_1:
while(true){ label_1:
if(cond2){ while(cond2){
Body 1 Body1
} }
else{ Body2
Body 2
}
}
TO MAKE CODE EFFECIENT BLOCK THE ANALYSIS TO GOING INTO STATEMENTS
this is done by overriding the caseASTStatementSequenceNode
*/
public class StrengthenByIfElse {
/*
* We know this method is called when there is a loop node which has a body consisting entirely of one ASTIfElseNode
*/
public static List getNewNode(ASTNode loopNode, ASTIfElseNode ifElseNode) {
// make sure that elsebody has only a stmtseq node
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy