本文整理汇总了Java中com.ibm.wala.util.collections.Pair类的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pair类属于com.ibm.wala.util.collections包,在下文中一共展示了Pair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: meetIsectAndObjType
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
private boolean meetIsectAndObjType(IntersectionType isectType,
ObjectType objType) {
ObjectType lhsObj = isectType.findObjectType();
List<Type> isectTypes = isectType.getTypes();
if (lhsObj != null) {
Pair<ObjectType, Boolean> res = meetObjectTypes(lhsObj, objType);
if (res.snd) {
// need to replace object type in intersection
for (int i = 0; i < isectTypes.size(); i++) {
if (isectTypes.get(i).equals(lhsObj)) {
isectTypes.set(i, res.fst);
break;
}
}
return true;
}
return false;
// UGH. need to write test for when something is used both as an object and a function. sigh.
} else {
// add object type as a case
isectTypes.add(objType);
// we changed the type, so return true
return true;
}
}
示例2: collectInitialSeeds
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
/**
* collect the putstatic instructions in the call graph as {@link PathEdge} seeds for the analysis
*/
private Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> collectInitialSeeds() {
Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> result = HashSetFactory.make();
for (BasicBlockInContext<IExplodedBasicBlock> bb : supergraph) {
IExplodedBasicBlock ebb = bb.getDelegate();
SSAInstruction instruction = ebb.getInstruction();
if (instruction instanceof SSAPutInstruction) {
SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
if (putInstr.isStatic()) {
final CGNode cgNode = bb.getNode();
Pair<CGNode, Integer> fact = Pair.make(cgNode, ebb.getFirstInstructionIndex());
int factNum = domain.add(fact);
BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
// note that the fact number used for the source of this path edge doesn't really matter
result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));
}
}
}
return result;
}
示例3: tagInvokeInsts
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
private Map<Pair<CGNode, Integer>, HashSet<String>> tagInvokeInsts() {
Map<Pair<CGNode, Integer>, HashSet<String>> invokeInstTags = new HashMap<>();
for (CGNode node : icfg.getCallGraph()) {
String m = node.getMethod().getDeclaringClass().getName().toString();
if (m.startsWith("Lprologue.js") || m.startsWith("Lpreamble.js"))
continue;
IR ir = node.getIR();
if (ir == null) continue;
SSAInstruction[] instructions = ir.getInstructions();
for (int i = 0; i < instructions.length; i++) {
SSAInstruction instruction = instructions[i];
if (instruction instanceof JavaScriptInvoke) {
JavaScriptInvoke invokeInst = (JavaScriptInvoke) instruction;
Pair<CGNode, Integer> invokeInstItem = Pair.make(node, i);
HashSet<String> tags = this.getReachingTags(node, invokeInst);
invokeInstTags.put(invokeInstItem, tags);
}
}
}
return invokeInstTags;
}
示例4: convertHTMLToJS
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
protected SourceModule convertHTMLToJS(URL url) {
SourceModule ret = null;
try {
Pair<Set<MappedSourceModule>,File> parsed = WebUtil.extractScriptFromHTML(url, true);
File jsfile = parsed.snd;
//Dbg.dbg("JSFILE: " + jsfile.getAbsolutePath());
Set<MappedSourceModule> sms = parsed.fst;
if (sms.size() < 1) {
Dbg.err("Nothing returned from WebUtil.extractScriptFromHTML");
} else if (sms.size() > 1) {
Dbg.err("Unexpected result from WebUtil.extractScriptFromHTML: " + sms);
} else {
ret = (MappedSourceModule)sms.toArray()[0];
}
} catch (Error ex) {
Dbg.warn("Error converting HTML to script: " + ex.getMessage());
}
return ret;
}
示例5: makeValueNumbers
import com.ibm.wala.util.collections.Pair; //导入依赖的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;
}
示例6: handleFunctionReturnTerm
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
private void handleFunctionReturnTerm(
Consumer<IConstraint> constraintAdder,
Set<Pair<ITypeTerm, Integer>> constrainedFunctionTerms,
ITypeConstraint constraint) {
FunctionReturnTerm returnTerm = (FunctionReturnTerm)(constraint.getLeft() instanceof FunctionReturnTerm ? constraint.getLeft() : constraint.getRight());
ITypeTerm otherTerm = constraint.getLeft() instanceof FunctionReturnTerm ? constraint.getRight() : constraint.getLeft();
ITypeTerm functionTerm = returnTerm.getFunctionTerm();
int nrParams = returnTerm.getNrParams();
// TODO make sure we handle constructors with parameters
boolean isConstructorCall = otherTerm instanceof FunctionCallTerm &&
((FunctionCallTerm)otherTerm).getFunctionCall() instanceof NewExpression;
doConstraintsForFunctionTerm(constraintAdder, constrainedFunctionTerms, functionTerm, nrParams, isConstructorCall);
}
示例7: handleFunctionParamTerm
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
private void handleFunctionParamTerm(
Consumer<IConstraint> constraintAdder,
Set<Pair<ITypeTerm, Integer>> constrainedFunctionTerms,
ITypeConstraint constraint) {
FunctionParamTerm paramTerm = (FunctionParamTerm)(constraint.getLeft() instanceof FunctionParamTerm ? constraint.getLeft() : constraint.getRight());
// create type variables for return type and parameters
ITypeTerm functionTerm = paramTerm.getFunctionTerm();
int nrParams = paramTerm.getNrParams();
doConstraintsForFunctionTerm(constraintAdder,
constrainedFunctionTerms, functionTerm, nrParams, false);
}
示例8: meetObjectTypes
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
/**
* meet two object types.
* @param lTy
* @param rTy
* @return <O,b> where O is the meeted type, and b is true if this type differs from lTy. If b is false, O is null.
*/
private Pair<ObjectType,Boolean> meetObjectTypes(ObjectType lTy, ObjectType rTy) {
boolean changed = false;
List<Property> props = new ArrayList<Property>();
for (Property p : rTy.properties()) {
String propName = p.getName();
if (lTy.hasProperty(propName)) {
logger.debug("Common property: {}", propName);
Property lProp = lTy.getProperty(propName);
Property rProp = rTy.getProperty(propName);
typeEquator.accept(lProp.getType(), rProp.getType());
if (lProp.isRO() && rProp.isRW()) {
props.add(new Property(lProp.getName(), lProp.getType(), false, rProp.getSourceLoc()));
changed = true;
} else {
props.add(lProp);
}
} else {
logger.debug("Adding property: {}", propName);
props.add(p);
changed = true;
}
}
if (changed) {
// create a fresh ObjectType for the meet result
// first we need to add the lTy properties that are not on rTy
List<Property> lTyPropsToKeep = lTy.properties().stream()
.filter((p) -> {
return !rTy.hasProperty(p.getName());
}).collect(Collectors.toList());
props.addAll(lTyPropsToKeep);
ObjectType meetResult = new ObjectType(props);
return Pair.make(meetResult,changed);
}
return Pair.make(null,changed);
}
示例9: numberPutStatics
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
/**
* generate a numbering of the putstatic instructions
*/
@SuppressWarnings("unchecked")
private OrdinalSetMapping<Pair<CGNode, Integer>> numberPutStatics() {
ArrayList<Pair<CGNode, Integer>> putInstrs = new ArrayList<Pair<CGNode, Integer>>();
for (CGNode node : icfg.getCallGraph()) {
IR ir = node.getIR();
if (ir == null) {
continue;
}
SSAInstruction[] instructions = ir.getInstructions();
for (int i = 0; i < instructions.length; i++) {
SSAInstruction instruction = instructions[i];
if (instruction instanceof SSAPutInstruction && ((SSAPutInstruction) instruction).isStatic()) {
SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
// instrNum is the number that will be assigned to this putstatic
int instrNum = putInstrs.size();
putInstrs.add(Pair.make(node, i));
// also update the mapping of static fields to def'ing statements
IField field = cha.resolveField(putInstr.getDeclaredField());
assert field != null;
BitVector bv = staticField2DefStatements.get(field);
if (bv == null) {
bv = new BitVector();
staticField2DefStatements.put(field, bv);
}
bv.set(instrNum);
}
}
}
return new ObjectArrayMapping<Pair<CGNode, Integer>>(putInstrs.toArray(new Pair[putInstrs.size()]));
}
示例10: analyze
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
/**
* perform the tabulation analysis and return the {@link TabulationResult}
*/
public TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> analyze() {
PartiallyBalancedTabulationSolver<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> solver = PartiallyBalancedTabulationSolver
.createPartiallyBalancedTabulationSolver(new ReachingDefsProblem(), null);
TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> result = null;
try {
result = solver.solve();
} catch (CancelException e) {
// this shouldn't happen
assert false;
}
return result;
}
示例11: getNumberOfDefs
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
protected int getNumberOfDefs(SSAInstruction inst) {
if (fieldPhiSet.contains(inst)) {
return inst.getNumberOfDefs();
} else {
int[] defs = (int[])valueNumbers.get(Pair.make(inst, DEFS));
if ( defs == null) {
return 0;
} else {
return defs.length;
}
}
}
示例12: getDef
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
protected int getDef(SSAInstruction inst, int index) {
if (fieldPhiSet.contains(inst)) {
return inst.getDef(index);
} else {
return ((int[])valueNumbers.get(Pair.make(inst, DEFS)))[index];
}
}
示例13: getNumberOfUses
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
protected int getNumberOfUses(SSAInstruction inst) {
if (fieldPhiSet.contains(inst)) {
return inst.getNumberOfUses();
} else {
return ((int[])valueNumbers.get(Pair.make(inst, USES))).length;
}
}
示例14: getUse
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
protected int getUse(SSAInstruction inst, int index) {
if (fieldPhiSet.contains(inst)) {
return inst.getUse(index);
} else {
return ((int[])valueNumbers.get(Pair.make(inst, USES)))[index];
}
}
示例15: getNodeTransferFunction
import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
public UnaryOperator getNodeTransferFunction(Object node) {
if (node instanceof Pair) {
return identityTransferFunction;
} else {
return new NodeTransferFunction((CGNode)node);
}
}