
soot.dava.toolkits.base.AST.transformations.IfElseSplitter 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) 1997 - 2018 Raja Vallée-Rai and others
* %%
* 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.Iterator;
import java.util.List;
import soot.G;
import soot.dava.DecompilationException;
import soot.dava.internal.AST.ASTCondition;
import soot.dava.internal.AST.ASTIfElseNode;
import soot.dava.internal.AST.ASTIfNode;
import soot.dava.internal.AST.ASTMethodNode;
import soot.dava.internal.AST.ASTNode;
import soot.dava.internal.AST.ASTStatementSequenceNode;
import soot.dava.internal.AST.ASTTryNode;
import soot.dava.internal.SET.SETNodeLabel;
import soot.dava.internal.asg.AugmentedStmt;
import soot.dava.internal.javaRep.DAbruptStmt;
import soot.dava.toolkits.base.AST.analysis.DepthFirstAdapter;
import soot.dava.toolkits.base.AST.traversals.ASTParentNodeFinder;
import soot.jimple.ReturnStmt;
import soot.jimple.ReturnVoidStmt;
import soot.jimple.Stmt;
/*
* look for patterns of the form
* if(cond1){ if(cond1){
* BodyA BodyA
* abrupt ----> abrupt
* } }
* else{ BodyB
* BodyB
* }
*
* Things to ensure:
* If abrupt then check BodyA does not target a label on the ifelse
*
* ALWAYS Make sure BodyB does not target a label on the ifelse
*
* If the pattern is NOT matched check the reverse i.e. maybe BodyB
* has the abrupt statement in that case we just negated the condition
*/
public class IfElseSplitter extends DepthFirstAdapter {
public static boolean DEBUG = false;
boolean targeted = false;
ASTMethodNode methodNode;
ASTNode parent;
ASTIfElseNode toReplace;
ASTIfNode toInsert;
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy