-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,026 additions
and
688 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ForLoopSSA { | ||
public static void main(String[] args) { | ||
String input = ""; | ||
for (int i = 0; i < args.length; i++) { | ||
input = input + args[i]; | ||
} | ||
System.out.println(input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
sootup.core/src/main/java/sootup/core/graph/BlockAnalysisDirection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package sootup.core.graph; | ||
/*- | ||
* #%L | ||
* Soot - a J*va Optimization Framework | ||
* %% | ||
* Copyright (C) 2024 Junjie Shen | ||
* %% | ||
* 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 | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* This enum class is used to specify the direction of block analysis. Every enum direction name | ||
* consists two parts: Block Order and Analysis Direction. eg: POSTORDERBACKWARD indicates that the | ||
* sorted blocks are ordered in post-order(POSTORDER) and the analysis direction is from root to | ||
* leaves (BACKWARD). | ||
*/ | ||
public enum BlockAnalysisDirection { | ||
POSTORDERBACKWARD { | ||
@Override | ||
@Nonnull | ||
List<BasicBlock<?>> getPredecessors(BasicBlock<?> block) { | ||
return (List<BasicBlock<?>>) block.getSuccessors(); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
List<BasicBlock<?>> getSortedBlocks(StmtGraph<?> blockGraph) { | ||
PostOrderBlockTraversal traversal = new PostOrderBlockTraversal(blockGraph); | ||
return Collections.unmodifiableList(traversal.getBlocksSorted()); | ||
} | ||
}, | ||
REVERSEPOSTORDERFORWARD { | ||
@Override | ||
@Nonnull | ||
List<BasicBlock<?>> getPredecessors(BasicBlock<?> block) { | ||
return (List<BasicBlock<?>>) block.getPredecessors(); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
List<BasicBlock<?>> getSortedBlocks(StmtGraph<?> blockGraph) { | ||
ReversePostOrderBlockTraversal traversal = new ReversePostOrderBlockTraversal(blockGraph); | ||
return Collections.unmodifiableList(traversal.getBlocksSorted()); | ||
} | ||
}; | ||
|
||
@Nonnull | ||
abstract List<BasicBlock<?>> getPredecessors(BasicBlock<?> block); | ||
|
||
@Nonnull | ||
abstract List<BasicBlock<?>> getSortedBlocks(StmtGraph<?> blockGraph); | ||
} |
26 changes: 26 additions & 0 deletions
26
sootup.core/src/main/java/sootup/core/graph/BlockIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package sootup.core.graph; | ||
/*- | ||
* #%L | ||
* Soot - a J*va Optimization Framework | ||
* %% | ||
* Copyright (C) 2024 Junjie Shen | ||
* %% | ||
* 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 | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
import java.util.Iterator; | ||
|
||
/** Interface of Block Iterator used to iterate each Block in a StmtGraph. */ | ||
public interface BlockIterator extends Iterator<BasicBlock<?>> {} |
41 changes: 41 additions & 0 deletions
41
sootup.core/src/main/java/sootup/core/graph/BlockTraversalStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package sootup.core.graph; | ||
/*- | ||
* #%L | ||
* Soot - a J*va Optimization Framework | ||
* %% | ||
* Copyright (C) 2024 Junjie Shen | ||
* %% | ||
* 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 | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
|
||
import java.util.List; | ||
|
||
/** An interface for defining a strategy to traverse a StmtGraph. */ | ||
public interface BlockTraversalStrategy { | ||
|
||
/** | ||
* This method provides an iterator to traverse a StmtGraph according to the defined strategy. | ||
* | ||
* @return an iterator for traversing StmtGraph | ||
*/ | ||
public BlockIterator iterator(); | ||
/** | ||
* This method returns a list of Blocks ordered by the traversal sequence. | ||
* | ||
* @return a list of Blocks in traversal order | ||
*/ | ||
public List<BasicBlock<?>> getBlocksSorted(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.