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

Java Pair类代码示例

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

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



Pair类属于com.ibm.wala.util.collections包,在下文中一共展示了Pair类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
    }
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:26,代码来源:TypeMeetOperator.java


示例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;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:24,代码来源:ContextSensitiveReachingDefs.java


示例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;
}
 
开发者ID:ylimit,项目名称:HybridFlow,代码行数:26,代码来源:JSTaintAnalysis.java


示例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;
}
 
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:20,代码来源:WalaClient.java


示例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;
 }
 
开发者ID:wala,项目名称:MemSAT,代码行数:24,代码来源:FieldNameSSAConversion.java


示例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);
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:14,代码来源:DirectionalConstraintSolver.java


示例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);
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:12,代码来源:DirectionalConstraintSolver.java


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

}
 
开发者ID:Samsung,项目名称:SJS,代码行数:46,代码来源:TypeMeetOperator.java


示例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()]));
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:34,代码来源:ContextInsensitiveReachingDefs.java


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

}
 
开发者ID:wala,项目名称:WALA-start,代码行数:17,代码来源:ContextSensitiveReachingDefs.java


示例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;
  	}
  }
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:13,代码来源:FieldNameSSAConversion.java


示例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];
  }
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:8,代码来源:FieldNameSSAConversion.java


示例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;
  }
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:8,代码来源:FieldNameSSAConversion.java


示例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];
  }
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:8,代码来源:FieldNameSSAConversion.java


示例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);
}
     }
 
开发者ID:wala,项目名称:MemSAT,代码行数:8,代码来源:IPFieldAccessAnalysis.java


示例16: createOriginal2Optimized

import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
private BiMap<Pair<TypeLabel, Integer>, Integer> createOriginal2Optimized(Set<TypeLabel> labels, Set<Integer> keySet, int maxLocals) {
	BiMap<Pair<TypeLabel, Integer>, Integer> map = HashBiMap.create(keySet.size());
	
	int optLocal = maxLocals + 1;
	
	for (TypeLabel label : labels) {
		
		for (Integer originalLocal : keySet) {
			map.put(Pair.make(label, originalLocal), optLocal);
			optLocal++;
		}
	}
	return map;
}
 
开发者ID:wondee,项目名称:faststring,代码行数:15,代码来源:TransformationInfo.java


示例17: getLocalForLabel

import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
public int getLocalForLabel(TypeLabel from, TypeLabel to, int local) {
	
	if (from == null) {
		return locals.get(Pair.make(to, local));
	} else {
		int orgLocal = locals.inverse().get(local).snd;
		
		if (to != null) {
			return locals.get(Pair.make(to, orgLocal));
		} else {
			return orgLocal;
		}
	}
}
 
开发者ID:wondee,项目名称:faststring,代码行数:15,代码来源:TransformationInfo.java


示例18: handleIndexedTerm

import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
private void handleIndexedTerm(Consumer<IConstraint> constraintAdder,
            Set<ITypeTerm> constrainedIndexTerms,
            Set<Pair<ITypeTerm, Integer>> constrainedFunctionTerms,
            ITypeConstraint constraint) {
        IndexedTerm indexedTerm = (IndexedTerm)(constraint.getLeft() instanceof IndexedTerm ? constraint.getLeft() : constraint.getRight());
        ITypeTerm base = indexedTerm.getBase();
        // TODO temporary hack until we handle function types; remove this condition!
//                if (base instanceof FunctionReturnTerm) continue;
        if (!constrainedIndexTerms.contains(base)) {
            ITypeTerm other = constraint.getLeft() instanceof IndexedTerm ? constraint.getRight() : constraint.getLeft();
            TypeVar elemTypeVar = makeFreshTypeVar();
            TypeVariableTerm elemTypeVarTerm = factory.findOrCreateTypeVariableTerm(elemTypeVar);
            if (base instanceof ArrayLiteralTerm) {
                // mutate the array type to use our elements type variable
                ArrayType arrType = (ArrayType)((ArrayLiteralTerm)base).getType();
                arrType.setElemType(elemTypeVar);
            } else if (base instanceof MapLiteralTerm) {
                // mutate to use our elements type variable
                MapType mapType = (MapType)((MapLiteralTerm)base).getType();
                mapType.setElemType(elemTypeVar);
            } else if (other.toString().startsWith("TP(")) { // TODO HACK!
                // we know we're talking about an array in this case, so
                // don't introduce a type variable for the key
                ArrayType arrayType = new ArrayType(elemTypeVar);
                constraintAdder.accept(new SubTypeConstraint(base, factory.getTermForType(arrayType)));
                // hack!  make sure return type of "push" is an int
                PropertyAccessTerm pushTerm = factory.findOrCreatePropertyAccessTerm(base, "push", null);
                FunctionReturnTerm pushRetTerm = factory.findOrCreateFunctionReturnTerm(pushTerm, 1);
                constraintAdder.accept(new TypeEqualityConstraint(
                        pushRetTerm, factory.getTermForType(IntegerType
                                .make())));
                // another hack!  need this to handle Array function
                if (base instanceof FunctionReturnTerm
                        && base.toString().equals("ret(|Array|)")) {
                    doConstraintsForFunctionTerm(constraintAdder,
                            constrainedFunctionTerms,
                            ((FunctionReturnTerm) base)
                                    .getFunctionTerm(),
                            ((FunctionReturnTerm) base).getNrParams(), false);
                }
            } else {
                TypeVar keyTypeVar = makeFreshTypeVar();
                TypeVariableTerm keyTypeVarTerm = factory.findOrCreateTypeVariableTerm(keyTypeVar);
                UnknownIndexableType mapOrArrayType = new UnknownIndexableType(keyTypeVar, elemTypeVar);
                constraintAdder.accept(new SubTypeConstraint(base, factory.getTermForType(mapOrArrayType)));
                constraintAdder.accept(new TypeEqualityConstraint(keyTypeVarTerm, factory.findOrCreateKeyTerm(base)));
            }
            // always constrain the element type
            constraintAdder.accept(new TypeEqualityConstraint(elemTypeVarTerm, indexedTerm));
            constrainedIndexTerms.add(base);
        }
    }
 
开发者ID:Samsung,项目名称:SJS,代码行数:53,代码来源:DirectionalConstraintSolver.java


示例19: main

import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
/**
	   * Usage: CSReachingDefsDriver -scopeFile file_path -mainClass class_name
	   * 
	   * Uses main() method of class_name as entrypoint.
	   * 
	   * @throws IOException
	   * @throws ClassHierarchyException
	   * @throws CallGraphBuilderCancelException
	   * @throws IllegalArgumentException
	   */
	  public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException, CallGraphBuilderCancelException {
	    long start = System.currentTimeMillis();		
	    Properties p = CommandLine.parse(args);
	    String scopeFile = p.getProperty("scopeFile");
	    if (scopeFile == null) {
	    	throw new IllegalArgumentException("must specify scope file");
	    }
	    String mainClass = p.getProperty("mainClass");
	    if (mainClass == null) {
	      throw new IllegalArgumentException("must specify main class");
	    }
	    AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, null, CSReachingDefsDriver.class.getClassLoader());
	    ExampleUtil.addDefaultExclusions(scope);
	    IClassHierarchy cha = ClassHierarchyFactory.make(scope);
	    System.out.println(cha.getNumberOfClasses() + " classes");
	    System.out.println(Warnings.asString());
	    Warnings.clear();
	    AnalysisOptions options = new AnalysisOptions();
	    Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(scope, cha, mainClass);
	    options.setEntrypoints(entrypoints);
	    // you can dial down reflection handling if you like
	    options.setReflectionOptions(ReflectionOptions.NONE);
	    AnalysisCache cache = new AnalysisCacheImpl();
	    // other builders can be constructed with different Util methods
	    CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
//	    CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
//	    CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
	    System.out.println("building call graph...");
	    CallGraph cg = builder.makeCallGraph(options, null);
//	    System.out.println(cg);
	    long end = System.currentTimeMillis();
	    System.out.println("done");
	    System.out.println("took " + (end-start) + "ms");
	    System.out.println(CallGraphStats.getStats(cg));
	    
	    ContextSensitiveReachingDefs reachingDefs = new ContextSensitiveReachingDefs(cg, cache);
	    TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> result = reachingDefs.analyze();
	    ISupergraph<BasicBlockInContext<IExplodedBasicBlock>, CGNode> supergraph = reachingDefs.getSupergraph();

	    // TODO print out some analysis results
	}
 
开发者ID:wala,项目名称:WALA-start,代码行数:52,代码来源:CSReachingDefsDriver.java


示例20: getNodeAndInstrForNumber

import com.ibm.wala.util.collections.Pair; //导入依赖的package包/类
/**
 * gets putstatic instruction corresponding to some fact number from a bitvector in the analysis result
 */
public Pair<CGNode, Integer> getNodeAndInstrForNumber(int num) {
  return putInstrNumbering.getMappedObject(num);
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:7,代码来源:ContextInsensitiveReachingDefs.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java DataSet类代码示例发布时间:2022-05-23
下一篇:
Java TabItem类代码示例发布时间: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