当前位置: 首页>>代码示例>>Java>>正文


Java BasicBlock类代码示例

本文整理汇总了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;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:20,代码来源:WalaUtils.java

示例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;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:9,代码来源:SMTChecker.java

示例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("----------");
                }
            }
        }

    }
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:45,代码来源:CFGAnalyzer.java

示例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();
}
 
开发者ID:wondee,项目名称:faststring,代码行数:16,代码来源:AnalyzedMethod.java

示例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);
		}

	}
}
 
开发者ID:wondee,项目名称:faststring,代码行数:16,代码来源:AnalyzedMethod.java

示例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);
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:81,代码来源:GUI.java


注:本文中的com.ibm.wala.ssa.SSACFG.BasicBlock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。