• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IR类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.ibm.wala.ssa.IR的典型用法代码示例。如果您正苦于以下问题:Java IR类的具体用法?Java IR怎么用?Java IR使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IR类属于com.ibm.wala.ssa包,在下文中一共展示了IR类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: makeInitialFieldNumbers

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
private ObjectArrayMapping makeInitialFieldNumbers(IR ir) {
   Set fields = new LinkedHashSet();
   for(Iterator is = iterateInstructions(ir); is.hasNext(); ) {
     SSAInstruction i = (SSAInstruction)is.next();
     if (i == null) continue;

     PointerKey[] defs = fieldAccesses.getDefs(i);
     for(int f = 0; f < defs.length; f++) {
fields.add( defs[f] );
     }

     PointerKey[] uses = fieldAccesses.getUses(i);
     for(int f = 0; f < uses.length; f++) {
fields.add( uses[f] );
     }
   }

   return new ObjectArrayMapping(
     fields.toArray(new PointerKey[ fields.size() ])
   );
 }
 
开发者ID:wala,项目名称:MemSAT,代码行数:22,代码来源:FieldNameSSAConversion.java


示例2: makeValueNumbers

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
private Map makeValueNumbers(IR ir) {
   Map vns = new LinkedHashMap();
   for(Iterator is = iterateInstructions(ir); is.hasNext(); ) {
     SSAInstruction inst = (SSAInstruction)is.next();
     if (inst == null) continue;

     PointerKey[] uses = fieldAccesses.getUses(inst);
     int[] useValueNumbers = new int[ uses.length ];
     for(int j = 0; j < uses.length; j++) {
useValueNumbers[j] = getInitialFieldNumber( uses[j] );
     }
     vns.put(Pair.make(inst, USES), useValueNumbers);
     
     PointerKey[] defs = fieldAccesses.getDefs(inst);
     int[] defValueNumbers = new int[ defs.length ];
     for(int j = 0; j < defs.length; j++) {
defValueNumbers[j] = getInitialFieldNumber( defs[j] );
     }
     vns.put(Pair.make(inst, DEFS), defValueNumbers);
   }
   
   return vns;
 }
 
开发者ID:wala,项目名称:MemSAT,代码行数:24,代码来源:FieldNameSSAConversion.java


示例3: toString

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public String toString() {
  StringBuffer buf = new StringBuffer("types for " + node + "\n");
  IR ir = node.getIR();
  SymbolTable st = ir.getSymbolTable();
  for(int vn = 1; vn <= st.getMaxValueNumber(); vn++) {
    if (st.isNullConstant(vn)) {
 buf.append(vn + " --> <null constant>\n");
    }
   
    PointerKey pk = new LocalPointerKey(node, vn);
    OrdinalSet<? extends InstanceKey> types = PA.getPointsToSet( pk );

    buf.append(vn + " --> " + types + "\n");
  }

  return buf.toString();
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:18,代码来源:MiniaturJavaScriptTypeData.java


示例4: getInstructions

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
protected Iterator getInstructions(final CGNode node) {
	final PDG pdg = sdg.getPDG(node);
	final IR ir = node.getIR();
	final Map indicesMap = PDG.computeInstructionIndices(ir);
	return new FilterIterator(
			node.getIR().iterateAllInstructions(), new Predicate() {
				private boolean sliceContainsInstruction(
						SSAInstruction s) {
					return slice.contains(PDG
							.ssaInstruction2Statement(node, s,
									indicesMap, ir));
				}

				public boolean test(Object o) {
					return sliceContainsInstruction((SSAInstruction) o);
				}
			});
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:19,代码来源:WalaInformationImpl.java


示例5: createInstructionToIndexMap

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public static Map<SSAInstruction, Integer> createInstructionToIndexMap(IR ir) {

		Map<SSAInstruction, Integer> map = Maps.newHashMap();

		for (int i = 0; i < ir.getInstructions().length; i++) {
			SSAInstruction instruction = ir.getInstructions()[i];
			if (instruction != null) {
				Integer old = map.put(instruction, i);
				if (old != null) {
					throw new IllegalStateException("instruction was set before: actual index = " + i +
							"; old index = " + old + "; instruction = " + instruction);
				}
			}
		}

		return map;
	}
 
开发者ID:wondee,项目名称:faststring,代码行数:18,代码来源:IRUtil.java


示例6: getSSACFG

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public static SSACFG getSSACFG(String methodSignature, CallGraph cg) {
	logger.debug("Retrieve SSACFG for " + methodSignature);

	IR ir = getIR(methodSignature, cg);
	if (ir == null && !methodSignature.startsWith(WALA_FAKE_ROOT_CLASS))
		logger.warn("Could not retrieve IR for " + methodSignature);		
	
	return ir == null? null : ir.getControlFlowGraph();
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:10,代码来源:WalaUtils.java


示例7: getExprForCondition

import com.ibm.wala.ssa.IR; //导入依赖的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


示例8: getExprForConditionalBranchInstruction

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public static Expr getExprForConditionalBranchInstruction(ValidityChecker vc, SSAInstruction inst, IR entryIR) {
    // According to WALA documentation these blocks contain exactly one instruction
    SSAConditionalBranchInstruction condInst = (SSAConditionalBranchInstruction) inst;
    int var = condInst.getUse(0); // This Instruction contains exactly two uses (0, 1) and use 1 is always 0.
    Expr expr = getExprForInstruction(vc, var, entryIR, BinaryOpInstruction.Operator.AND); // The AND operator identifies the expression as a boolean type

    return expr;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:9,代码来源:SMTChecker.java


示例9: printSSA

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
/**
 * Display different values from Nodes maybe interesting for further
 * Analyzing
 *
 * @param nodes
 *            A collection of nodes from a callgraph
 */
public static ArrayList<String> printSSA(Collection<CGNode> nodes) {
    ArrayList<String> liste = new ArrayList<String>();
    for (CGNode cgNode : nodes) {
        // get intermediate representation
        IR ir = cgNode.getIR();

        liste.add("Instruction: " + (ir.getInstructions().toString()));
        System.out.println("Instruction: " + ir.getInstructions());
        liste.add("Methode: " + ir.getMethod());
        System.out.println("Methode: " + ir.getMethod());

        // System.out.println("Flow Graph of Node="+ir.getControlFlowGraph());
        SSACFG cfg = ir.getControlFlowGraph();

        // Iterate over the Basic Blocks of CFG
        Iterator<ISSABasicBlock> cfgIt = cfg.iterator();
        SSAInstruction ssaInstr = null;
        while (cfgIt.hasNext()) {
            ISSABasicBlock ssaBb = cfgIt.next();

            // Iterate over SSA Instructions for a Basic Block
            Iterator<SSAInstruction> ssaIt = ssaBb.iterator();

            while (ssaIt.hasNext()) {
                ssaInstr = ssaIt.next();

                printSSAInstruction(ssaInstr);
                liste.add("  " + ssaInstr.toString() + " |Count Defs="
                          + ssaInstr.getNumberOfDefs() + " |count uses="
                          + ssaInstr.getNumberOfUses());
                System.out.println("  " + ssaInstr.toString()
                                   + " |Count Defs=" + ssaInstr.getNumberOfDefs()
                                   + " |count uses=" + ssaInstr.getNumberOfUses());

            }
        }
    }
    return liste;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:47,代码来源:Main.java


示例10: createIR

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public Map<IMethod, IR> createIR() throws java.io.IOException {
   Map<IMethod, IR> result = new HashMap<IMethod, IR>();
   
   engine.buildAnalysisScope();

   IClassHierarchy cha = engine.getClassHierarchy();

   SSAOptions options = new SSAOptions();
   IRFactory<IMethod> F = AstIRFactory.makeDefaultFactory();
   
   for(Iterator<IClass> clss = cha.iterator(); clss.hasNext(); ) {
     IClass cls = clss.next();
     ClassLoaderReference clr = cls.getClassLoader().getReference(); 
     if ( !(clr.equals(ClassLoaderReference.Primordial)  
                    || 
     clr.equals(ClassLoaderReference.Extension)))
     {		
for (Iterator<IMethod> ms = cls.getDeclaredMethods().iterator(); 
     ms.hasNext(); ) 
{
  IMethod m = ms.next();
  IR ir = F.makeIR(m, Everywhere.EVERYWHERE, options);
  result.put(m, ir);
}
     }
   }
   
   return result;
 }
 
开发者ID:wala,项目名称:MemSAT,代码行数:30,代码来源:IRCreation.java


示例11: FieldNameSSAConversion

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public FieldNameSSAConversion(IR ir, FieldAccesses fieldAccesses) {
  super(ir, new SSAOptions());
  this.ir = ir;
  this.fieldAccesses = fieldAccesses;
  fieldPhiSet = new LinkedHashSet();
  fieldPhiNodes = new LinkedHashMap();
  initialFieldNumbers = makeInitialFieldNumbers(ir);
  valueNumbers = makeValueNumbers(ir);
  nextFreeNumber = getMaxValueNumber() + 1;
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:11,代码来源:FieldNameSSAConversion.java


示例12: evaluate

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public byte evaluate(IVariable lhs, IVariable rhs) {
     FieldAccessesVariable lv = (FieldAccessesVariable)lhs;
     FieldAccessesVariable rv = (FieldAccessesVariable)rhs;

     IR ir = node.getIR();
     Set localReads = new HashSet();
     Set localWrites = new HashSet();
     if (ir != null) {
   	FieldAccesses accesses = localAccesses.get(node);
for(Iterator insts = getInstructions(node); insts.hasNext();) {
  SSAInstruction inst = (SSAInstruction) insts.next();

  PointerKey[] defs = accesses.getDefs(inst);
  for(int f = 0; f < defs.length; f++) {
    localWrites.add( defs[f] );
  }

  PointerKey[] uses = accesses.getUses(inst);
  for(int f = 0; f < uses.length; f++) {
    localReads.add( uses[f] );
  }
}
     }

     boolean changed = false;
     changed |= lv.addReads( rv.readReferences );
     changed |= lv.addReads( localReads );
     changed |= lv.addWrites( rv.writeReferences );
     changed |= lv.addWrites( localWrites );
     if (changed)
return CHANGED;
     else
return NOT_CHANGED;      
   }
 
开发者ID:wala,项目名称:MemSAT,代码行数:35,代码来源:IPFieldAccessAnalysis.java


示例13: TranslationWarning

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
/**
 * Constructs a new warning for the given ir, instruction and reason.
 */
TranslationWarning(IR ir, SSAInstruction inst, String reason) {
	super(CLIENT_MODERATE);
	this.ir = ir;
	this.inst = inst;
	this.reason = reason;
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:10,代码来源:TranslationWarning.java


示例14: AnalyzedMethod

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public AnalyzedMethod(IR ir, DefUse defUse) {
	Preconditions.checkNotNull(ir, "ir is null");
	Preconditions.checkNotNull(defUse, "defUse is null");

	this.ir = ir;
	this.defUse = defUse;
}
 
开发者ID:wondee,项目名称:faststring,代码行数:8,代码来源:AnalyzedMethod.java


示例15: findIRForMethod

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public IR findIRForMethod(IMethod m) {
	try {
		IInstruction[] instructions = ((IBytecodeMethod) m).getInstructions();
		if (instructions != null) {
			return cache.getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE,
				options.getSSAOptions());
		}
	} catch (InvalidClassFileException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:wondee,项目名称:faststring,代码行数:13,代码来源:TargetApplication.java


示例16: findIRMethodForMethod

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public AnalyzedMethod findIRMethodForMethod(IMethod m) {
	LOG.trace("getting ir for {}", m.getSignature());
	IR ir = findIRForMethod(m);
	if (ir == null) {
		LOG.error("could not find ir for method {}", m.getSignature());
		return null;
	}
	DefUse defUse = findDefUseForMethod(m);

	return new AnalyzedMethod(ir, defUse);
}
 
开发者ID:wondee,项目名称:faststring,代码行数:12,代码来源:TargetApplication.java


示例17: printToPDF

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public static void printToPDF(String pathname, ClassHierarchy cha, IR ir) throws WalaException, IOException {

		Properties wp = loadProperties();

		File file = new File(TARGET_IRS);

		if (!file.exists()) {
			file.mkdirs();
		}

		wp.put(WalaProperties.OUTPUT_DIR, TARGET_IRS);

		String pdfFile = wp.getProperty(WalaProperties.OUTPUT_DIR) +
						 File.separatorChar +
						 TestUtilities.createFileName(ir.getMethod().getDeclaringClass().getName().toString(),
								 ir.getMethod().getName().toString()) +
								 ".pdf";

		String dotFile = wp.getProperty(WalaProperties.OUTPUT_DIR)
				+ File.separatorChar + "ir.dt";
		if (new File(pdfFile).exists()) {
			LOG.info("skipping {}", pdfFile);
		} else {
			Graph<ISSABasicBlock> g = ir.getControlFlowGraph();

			NodeDecorator<ISSABasicBlock> labels = PDFViewUtil.makeIRDecorator(ir);
			g = CFGSanitizer.sanitize(ir, cha);

			DotUtil.dotify(g, labels, dotFile, pdfFile, (String)wp.get("dot"));
		}
	}
 
开发者ID:wondee,项目名称:faststring,代码行数:32,代码来源:PrintTestIRs.java


示例18: getIR

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
public static IR getIR(IMethod method, CallGraph cg) {
	CGNode node = getCGNode(method, cg); 
	return node == null? null : node.getIR();
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:5,代码来源:WalaUtils.java


示例19: searchAndReplaceAdd

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
/**
 * @param nodi
 * @param stat
 * @param name
 * @param ssaInstruction
 */
public void searchAndReplaceAdd() {

    sliceVar.removeAllElements();
    for (Statement stat1 : collection) {
        CGNode nodi1 = null;
        boolean lock = false;
        HashMap<Integer, SSAInstruction> instructions = new HashMap<Integer, SSAInstruction>();
        for (Statement stmt : collection) {
            if (lock == false) {
                nodi1 = stmt.getNode();
                IR ir = nodi1.getIR();

                SSACFG cfg = ir.getControlFlowGraph();
                Iterator<ISSABasicBlock> cfgIt = cfg.iterator();
                SSAInstruction ssaInstr = null;
                while (cfgIt.hasNext()) {
                    ISSABasicBlock ssaBb = cfgIt.next();

                    Iterator<SSAInstruction> ssaIt = ssaBb.iterator();

                    while (ssaIt.hasNext()) {
                        ssaInstr = ssaIt.next();
                        instructions.put(ssaInstr.getDef(), ssaInstr);

                    }
                }
            }
            lock = true;
        }
        int zeile = 0;
        String name = null;

        int temp = 0;

        temp = getId(stat1.toString());

        SSAInstruction ssaInstruction = instructions.get(temp);

        if (ssaInstruction.toString().contains("binaryop")) {
            System.out.println("Binary operation");
            SymbolTable symtabs = stat1.getNode().getIR().getSymbolTable();
            System.out.println(symtabs.getValue(ssaInstruction.getUse(0)));
            System.out.println(symtabs.getValue(ssaInstruction.getUse(1)));
            String toReplace = "";
            toReplace += getLocalNames(nodi1, name, ssaInstruction, 0)
                         + "+";
            toReplace += getLocalNames(nodi1, name, ssaInstruction, 1);

            String exactly = toReplace;
            System.out.println(exactly);
            String output = (String.valueOf(
                                 symtabs.getValue(ssaInstruction.getUse(0)))
                             .substring(1) + (String.valueOf(symtabs
                                              .getValue(ssaInstruction.getUse(1))).substring(1)));
            System.out.println("output" + output);
            for (int i = 0; i < getCodes().size(); i++) {
                System.out.println(getCodes().get(i).toString());
                if (getCodes().get(i).toString().contains(exactly)) {
                    System.out.println("Found in codes @" + i);
                    String tempo = getCodes().get(i).replace(exactly,
                                   output);
                    getCodes().remove(i);
                    getCodes().add(i, tempo);
                }

            }

        }
    }
    getCodeSlice(getCodes());

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


示例20: prettyPrint

import com.ibm.wala.ssa.IR; //导入依赖的package包/类
/**
 * Returns a pretty-print String representation
 * of the given IR, with each new line starting
 * indented at least the given number of spaces.
 * @return pretty-print String representation
 * of the given IR
 */
public static String prettyPrint(IR ir, int offset) { 
	return indent(ir.toString(), offset);
	/*
    final StringBuffer result = new StringBuffer();
    result.append("\n"+indent+"CFG:\n");
    final SSACFG cfg = ir.getControlFlowGraph();
    for (int i = 0; i <= cfg.getNumber(cfg.exit()); i++) {
        BasicBlock bb = cfg.getNode(i);
        result.append(indent+"BB").append(i).append("[").append(bb.getFirstInstructionIndex()).append("..").append(bb.getLastInstructionIndex())
            .append("]\n");

        Iterator<ISSABasicBlock> succNodes = cfg.getSuccNodes(bb);
        while (succNodes.hasNext()) {
          result.append(indent+"    -> BB").append(((BasicBlock) succNodes.next()).getNumber()).append("\n");
        }
      }
    result.append(indent+"Instructions:\n");
    for (int i = 0; i <= cfg.getMaxNumber(); i++) {
      BasicBlock bb = cfg.getNode(i);
      int start = bb.getFirstInstructionIndex();
      int end = bb.getLastInstructionIndex();
      result.append(indent+"BB").append(bb.getNumber());
      if (bb instanceof ExceptionHandlerBasicBlock) {
        result.append(indent+"<Handler>");
      }
      result.append("\n");
      final SymbolTable symbolTable = ir.getSymbolTable();
      for (Iterator<SSAPhiInstruction> it = bb.iteratePhis(); it.hasNext();) {
        SSAPhiInstruction phi = it.next();
        if (phi != null) {
          result.append(indent+"           " + phi.toString(symbolTable)).append("\n");
        }
      }
      if (bb instanceof ExceptionHandlerBasicBlock) {
        ExceptionHandlerBasicBlock ebb = (ExceptionHandlerBasicBlock) bb;
        SSAGetCaughtExceptionInstruction s = ebb.getCatchInstruction();
        if (s != null) {
          result.append(indent+"           " + s.toString(symbolTable)).append("\n");
        } else {
          result.append(indent+"           " + " No catch instruction. Unreachable?\n");
        }
      }
      final SSAInstruction[] instructions = ir.getInstructions();
      for (int j = start; j <= end; j++) {
        if (instructions[j] != null) {
          StringBuffer x = new StringBuffer(indent+j + "   " + instructions[j].toString(symbolTable));
          StringStuff.padWithSpaces(x, 45);
          result.append(indent+x);
          result.append("\n");
        }
      }
      for (Iterator<SSAPiInstruction> it = bb.iteratePis(); it.hasNext();) {
        SSAPiInstruction pi = it.next();
        if (pi != null) {
          result.append(indent+"           " + pi.toString(symbolTable)).append("\n");
        }
      }
    }
    return result.toString();
    */
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:69,代码来源:Strings.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ModelManager类代码示例发布时间:2022-05-23
下一篇:
Java StripeException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap