本文整理汇总了Java中com.ibm.wala.ssa.SSACFG.BasicBlock类的典型用法代码示例。如果您正苦于以下问题:Java BasicBlock类的具体用法?Java BasicBlock怎么用?Java BasicBlock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicBlock类属于com.ibm.wala.ssa.SSACFG包,在下文中一共展示了BasicBlock类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSSAInstruction
import com.ibm.wala.ssa.SSACFG.BasicBlock; //导入依赖的package包/类
public static SSAInstruction getSSAInstruction(CallGraph cg, String methodSignature, int iindex) {
SSACFG cfg = getSSACFG(methodSignature, cg);
if (cfg == null) {
logger.warn("getSSAInstruction:: Did not find SSACFG for " + methodSignature);
} else {
BasicBlock block = cfg.getBlockForInstruction(iindex);
if (block != null) {
for (Iterator<SSAInstruction> it = block.iterateNormalInstructions(); it.hasNext();) {
SSAInstruction ins = it.next();
if (ins.iindex == iindex) {
return ins;
}
}
logger.warn("getSSAInstruction:: Did not find iindex " + iindex + " in SSACFG (" + methodSignature + ")");
} else
logger.warn("getSSAInstruction:: Did not find basic block for iindex " + iindex + " in SSACFG (" + methodSignature + ")");
}
return null;
}
示例2: getExprForCondition
import com.ibm.wala.ssa.SSACFG.BasicBlock; //导入依赖的package包/类
public static Expr getExprForCondition(ValidityChecker vc, BasicBlock basicBlock, IR entryIR) {
// According to WALA documentation these blocks contain exactly one instruction
SSAConditionalBranchInstruction inst = (SSAConditionalBranchInstruction) basicBlock.getLastInstruction();
int var = inst.getUse(0); // This Instruction contains exactly two uses (0, 1) and use 1 is always 0.
Expr expr = getExprForInstruction(vc, var, entryIR, null);
return expr;
}
示例3: analyzeConditional
import com.ibm.wala.ssa.SSACFG.BasicBlock; //导入依赖的package包/类
/**
* This will search for a SSAConditionalBranchInstruction in the node and
* print information related to this conditional to the console
*
* @param node
*/
public static void analyzeConditional(CGNode node) {
// The symbol table maps a variable number in the ssa to the actual name and value
SymbolTable symtab = node.getIR().getSymbolTable();
SSACFG cfg = node.getIR().getControlFlowGraph();
// Iterate over all basic blocks
for (int i = 0; i < cfg.getNumberOfNodes(); i++) {
BasicBlock bb = cfg.getBasicBlock(i);
// Iterate over all instructions in the basic block
List<SSAInstruction> instructions = bb.getAllInstructions();
if (containsConditional(instructions)) {
for (SSAInstruction ins : instructions) {
if (ins.toString().contains("binaryop")) {
System.out.print(ins);
for (int u = 0; u < ins.getNumberOfUses(); u++) {
System.out.print(" && ");
// In case of null we have a phi instruction. JavaScript apparently does not handle this very well.
if (symtab.getValue(ins.getUse(u)) == null)
System.out.print(ins.getUse(u) + " depends on previous if ");
else
System.out.print(ins.getUse(u) + " = " + symtab.getValue(ins.getUse(u)));
}
System.out.println("");
}
if (ins instanceof SSAConditionalBranchInstruction) {
System.out.println(ins.toString(symtab));
System.out.println("----------");
}
}
}
}
}
示例4: getIndexForPhi
import com.ibm.wala.ssa.SSACFG.BasicBlock; //导入依赖的package包/类
/**
* Tries to determine the bytecode index of the first instruction where a phi definition is created for
* @param instruction the phi instruction to check for
* @return the bytecode index found
*/
public Integer getIndexForPhi(SSAPhiInstruction instruction) {
if (phi2BlockMap == null) {
initializePhiMap();
}
int def = instruction.getDef();
BasicBlock basicBlock = ir.getControlFlowGraph().getBasicBlock(phi2BlockMap.get(def));
return basicBlock.getFirstInstructionIndex();
}
示例5: initializePhiMap
import com.ibm.wala.ssa.SSACFG.BasicBlock; //导入依赖的package包/类
private void initializePhiMap() {
phi2BlockMap = Maps.newHashMap();
SSACFG cfg = ir.getControlFlowGraph();
for (int blockIndex = 0; blockIndex < cfg.getMaxNumber(); blockIndex++) {
BasicBlock block = cfg.getBasicBlock(blockIndex);
Iterator<SSAPhiInstruction> iter = block.iteratePhis();
while (iter.hasNext()) {
SSAPhiInstruction phi = iter.next();
phi2BlockMap.put(phi.getDef(), blockIndex);
}
}
}
示例6: searchReturn
import com.ibm.wala.ssa.SSACFG.BasicBlock; //导入依赖的package包/类
/**
* Searches for ReturnStatement but mainly it replaces evaluated variable .
* Also adds a new line in codes list. with evaluated value . Called by
* ReplaceEvaluated button in mainPanel.
*
* @throws FileNotFoundException
* @throws ScriptException
*/
public void searchReturn(final JTextPane textSliceEdt)
throws FileNotFoundException, ScriptException {
String out = "";
Statement statm = (Statement) sdg.getNode(Integer.parseInt(hallo));
CGNode node = statm.getNode();
SSACFG cfg = node.getIR().getControlFlowGraph();
String names = "";
for (int i = 0; i < cfg.getNumberOfNodes(); i++) {
BasicBlock bb = cfg.getBasicBlock(i);
// Iterate over all instructions in the basic block
List<SSAInstruction> instructions = bb.getAllInstructions();
for (SSAInstruction ins : instructions) {
if (ins.toString().contains("return")) {
System.out.print(ins);
for (int u = 0; u < ins.getNumberOfUses(); u++) {
System.out.println(ins.getUse(u));
names = getLocalNames(node, names, ins, u);
System.out.println(names);
}
}
}
if (codes.get(codes.size() - 3).contains("return")) {
System.out.println("Retrun in letzter reihe");
int temp = codes.get(codes.size() - 1).indexOf("return");
codes.get(codes.size() - 1).substring(temp + 1);
if (codes.get(codes.size() - 1).substring(temp + 1)
.contains(names)) {
System.out
.println("symbol found in return statement in codeliste");
}
}
}
String command = "";
System.out.println("Codes " + codes);
System.out.println("command " + command);
for (int j = 0; j < codes.size(); j++) {
command += codes.get(j);
}
System.out.println("command" + command);
String rudi = Main.evalState(command);
if (names == "") {
codes.add(codes.size() - 4, "var " + "foo" + "=" + "\"" + rudi
+ "\";");
} else {
codes.add(codes.size() - 4, "var " + names + "=" + "\"" + rudi
+ "\";");
}
codes.remove(codes.size() - 4);
System.out.println(codes);
for (int i = 0; i < codes.size(); i++) {
if (codes.get(i).toString().contains("return foo")) {
codes.remove(i);
System.out
.println("removedb return Statement cos it is evaluated");
}
out += codes.get(i) + "\n";
}
textSliceEdt.setText(out);
}