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

Java IMethod类代码示例

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

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



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

示例1: getLineNumbers

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
/**
     * Get source code line number for each instruction
     * @param sgNodes
     * @param print
     * @return
     */
    public static HashMap<SSAInstructionKey, Integer> getLineNumbers(HashMap<Integer,BasicBlockInContext<IExplodedBasicBlock>> sgNodes) {
        log.debug("** get source code line number for each instruction");
        HashMap<SSAInstructionKey, Integer> map = new HashMap<SSAInstructionKey, Integer>();
        for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) {
            SSAInstruction inst = bbic.getLastInstruction();
            if(inst == null) {
                continue;
            }
//            ConcreteJavaMethod method = (ConcreteJavaMethod) bbic.getMethod();
            IMethod method =  bbic.getMethod();
            int lineNumber = method.getLineNumber(bbic.getLastInstructionIndex());
            map.put(new SSAInstructionKey(inst), lineNumber);
            log.debug(lineNumber + ". " + inst);
        }
        return map;
    }
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:23,代码来源:AnalysisUtil.java


示例2: getIMethod

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
public static IMethod getIMethod(IClassHierarchy cha, String signature) {  // TODO: throw exceptions
	String clazzName = Utils.getFullClassName(signature);
	String selector = signature.substring(clazzName.length()+1); 

	try {
		IClass clazz = WalaUtils.lookupClass(cha, clazzName);
		for (IMethod m: clazz.getAllMethods()) { // DeclaredMethods()) -> only impl./overriden methods
			if (m.getSelector().toString().equals(selector)) {
				return m;
			}
		}
	} catch (ClassNotFoundException e) {
		logger.debug("Classname " + clazzName + " could not be looked up!");
	}
	return null;  // TODO: throw exception
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:17,代码来源:WalaUtils.java


示例3: getCGNode

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
public static CGNode getCGNode(IMethod method, CallGraph cg) {
	logger.debug("Retrieve CGNode for " + method.getSignature());

	MethodReference ref = method.getReference();
	if (ref == null) return null;

	Set<CGNode> cgnode = cg.getNodes(ref);
	if (cgnode.isEmpty()) {
		logger.warn("Number of CGNode(s) for " + method.getSignature() + " is " + cgnode.size());
		return null;
	}
	/*else if (cgnode.size() > 1) {
		logger.warn("Number of CGNode(s) for " + methodSignature + " is " + cgnode.size() +  "  refMethod.sig: " + refMethod.getSignature());
	}*/
					
	return cgnode.iterator().next();
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:18,代码来源:WalaUtils.java


示例4: makeCG

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, WalaException {
  try {
    IClassHierarchy cha = makeHierarchy(scope, loaders);
    com.ibm.wala.cast.js.util.Util.checkForFrontEndErrors(cha);
    Iterable<Entrypoint> roots = makeScriptRoots(cha);
    JSAnalysisOptions options = makeOptions(scope, cha, roots);
    options.setHandleCallApply(builderType.handleCallApply());
    IAnalysisCacheView cache = makeCache(irFactory);
    JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
        builderType.useOneCFA());
    if(builderType.extractCorrelatedPairs())
      builder.setContextSelector(new PropertyNameContextSelector(builder.getAnalysisCache(), 2, builder.getContextSelector()));

    return builder;
  } catch (ClassHierarchyException e) {
    assert false : "internal error building class hierarchy";
    return null;
  }
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:20,代码来源:JSCallGraphBuilderUtil.java


示例5: makeCG

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, WalaException {
  try {
    IClassHierarchy cha = makeHierarchy(scope, loaders);
    com.ibm.wala.cast.js.util.Util.checkForFrontEndErrors(cha);
    Iterable<Entrypoint> roots = makeScriptRoots(cha);
    JSAnalysisOptions options = makeOptions(scope, cha, roots);
    options.setHandleCallApply(builderType.handleCallApply());
    AnalysisCache cache = makeCache(irFactory);
    JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
        builderType.useOneCFA());
    if(builderType.extractCorrelatedPairs())
      builder.setContextSelector(new PropertyNameContextSelector(builder.getAnalysisCache(), 2, builder.getContextSelector()));

    return builder;
  } catch (ClassHierarchyException e) {
    return null;
  }
}
 
开发者ID:ylimit,项目名称:HybridFlow,代码行数:19,代码来源:JSCallGraphBuilderUtil.java


示例6: foundTransferringSite

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
/**
 * Adds a transfer site with every transfer which is not known to be safe. If all of the
 * transfers at a transfer site are known to be safe, then no transfer point is added.
 */
protected void foundTransferringSite(CGNode node, SSAAbstractInvokeInstruction invokeInstr)
{
    // Return static methods and dispatch methods with only the receiver argument.
    if (invokeInstr.isStatic() || invokeInstr.getNumberOfParameters() == 1)
        return;

    // Ignore any method which is not a procedure invocation on a remote capsule instance.
    IMethod targetMethod = cha.resolveMethod(invokeInstr.getDeclaredTarget());
    if (! isRemoteProcedure(targetMethod))
        return;
    
    MutableIntSet transfers = new BitVectorIntSet();
    
    for (int idx = 1; idx < targetMethod.getNumberOfParameters(); idx++)
    {
        TypeReference paramType = targetMethod.getParameterType(idx);
        if (! isKnownSafeTypeForTransfer(paramType)) {
            transfers.add(invokeInstr.getUse(idx));
        }
    }
    
    if (! transfers.isEmpty()) {
        addTransferringSite(node, new InvokeTransferSite(node, transfers, invokeInstr));
    }
}
 
开发者ID:paninij,项目名称:paninij,代码行数:30,代码来源:TransferAnalysis.java


示例7: getCalleeTarget

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
@Override
public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee,
                               InstanceKey[] actualParameters)
{
    // Context selection ignores all parameter instances except for the receiver parameter.
    if (actualParameters == null || callee.isStatic())
    {
        // If there is no receiver object, then the callee uses the same context as the caller.
        return caller.getContext();
    }
    else
    {
        // Use the receiver instance as the callee's context.
        return new ReceiverInstanceContext(actualParameters[0]);
    }
}
 
开发者ID:paninij,项目名称:paninij,代码行数:17,代码来源:ReceiverInstanceContextSelector.java


示例8: SoterAnalysis

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
public SoterAnalysis(CapsuleCore core, CallGraphAnalysis cga, TransferAnalysis ta,
                     TransferLiveAnalysis tla, CallGraphLiveAnalysis cgla, IClassHierarchy cha)
{
    this.core = core;
    this.cga = cga;
    this.ta = ta;
    this.tla = tla;
    this.cgla = cgla;
    this.cha = cha;

    intSetFactory = new MutableSparseIntSetFactory();

    transferSiteResultsMap = new HashMap<TransferSite, TransferSiteResults>();
    unsafeTransferSitesMap = new HashMap<IMethod, IdentitySet<TransferSite>>();

    jsonCreator = new JsonResultsCreator(this);
}
 
开发者ID:paninij,项目名称:paninij,代码行数:18,代码来源:SoterAnalysis.java


示例9: buildUnsafeTransfersMap

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
protected void buildUnsafeTransfersMap()
{
    for (Entry<TransferSite, TransferSiteResults> entry : transferSiteResultsMap.entrySet())
    {
        TransferSite transferSite = entry.getKey();
        TransferSiteResults results = entry.getValue();

        if (results.hasUnsafeTransfers())
        {
            IMethod method = transferSite.getNode().getMethod();
            IdentitySet<TransferSite> unsafeTransferSites = getOrMakeUnsafeTransferSites(method);
            TransferSite unsafeTransferSite = TransferSiteFactory.copyWith(transferSite, results.getUnsafeTransfers());
            unsafeTransferSites.add(unsafeTransferSite);
        }
    }
}
 
开发者ID:paninij,项目名称:paninij,代码行数:17,代码来源:SoterAnalysis.java


示例10: makeHTMLCGBuilder

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
public static JSCFABuilder makeHTMLCGBuilder(URL url,
        CGBuilderType builderType) throws IOException, WalaException {
    IRFactory<IMethod> irFactory = AstIRFactory.makeDefaultFactory();
    CAstRewriterFactory preprocessor = builderType.extractCorrelatedPairs
                                       ? new CorrelatedPairExtractorFactory(translatorFactory, url)
                                       : null;
    JavaScriptLoaderFactory loaders = new WebPageLoaderFactory(
        translatorFactory, preprocessor);
    SourceModule[] scriptsArray = makeHtmlScope(url, loaders);

    JSCFABuilder builder = makeCGBuilder(loaders, scriptsArray,
                                         builderType, irFactory);
    if (builderType.extractCorrelatedPairs)
        builder.setContextSelector(new PropertyNameContextSelector(builder
                                   .getAnalysisCache(), 2, builder.getContextSelector()));
    builder.setBaseURL(url);
    return builder;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:19,代码来源:ImprovedJSCallGraphBuilderUtil.java


示例11: makeCG

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders,
                                     AnalysisScope scope, CGBuilderType builderType,
                                     IRFactory<IMethod> irFactory) throws IOException, WalaException {
    try {
        IClassHierarchy cha = makeHierarchy(scope, loaders);
        com.ibm.wala.cast.util.Util.checkForFrontEndErrors(cha);
        Iterable<Entrypoint> roots = makeScriptRoots(cha);
        JSAnalysisOptions options = makeOptions(scope, cha, roots);
        options.setHandleCallApply(builderType.handleCallApply());
        IAnalysisCacheView cache = makeCache(irFactory);
        JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options,
                cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
                builderType.useOneCFA());
        
        if (builderType.extractCorrelatedPairs())
            builder.setContextSelector(new PropertyNameContextSelector(
                                           builder.getAnalysisCache(), 2, builder
                                           .getContextSelector()));

        return builder;
    } catch (ClassHierarchyException e) {
        // Assert.assertTrue("internal error building class hierarchy",
        // false);
        return null;
    }
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:27,代码来源:ImprovedJSCallGraphBuilderUtil.java


示例12: getShortName

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
public String getShortName(CGNode nd) {
  IMethod method = nd.getMethod();
  String origName = method.getName().toString();
  String result = origName;
  if (origName.equals("do") || origName.equals("ctor")) {
    result = method.getDeclaringClass().getName().toString();
    result = result.substring(result.lastIndexOf('/') + 1);
    if (origName.equals("ctor")) {
      if (result.equals("LFunction")) {
        String s = method.toString();
        if (s.indexOf('(') != -1) {
          String functionName = s.substring(s.indexOf('(') + 1, s.indexOf(')'));
          functionName = functionName.substring(functionName.lastIndexOf('/') + 1);
          result += " " + functionName;
        }
      }
      result = "ctor of " + result;
    }
  } 
  return result;
}
 
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:22,代码来源:WalaClient.java


示例13: makeCG

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, WalaException {
  try {
    IClassHierarchy cha = makeHierarchy(scope, loaders);
    com.ibm.wala.cast.js.util.Util.checkForFrontEndErrors(cha);
    Iterable<Entrypoint> roots = makeScriptRoots(cha);
    JSAnalysisOptions options = makeOptions(scope, cha, roots);
    options.setHandleCallApply(builderType.handleCallApply());
    AnalysisCache cache = makeCache(irFactory);
    JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
        builderType.useOneCFA());
    if(builderType.extractCorrelatedPairs())
      builder.setContextSelector(new PropertyNameContextSelector(builder.getAnalysisCache(), 2, builder.getContextSelector()));

    return builder;
  } catch (ClassHierarchyException e) {
    Assert.assertTrue("internal error building class hierarchy", false);
    return null;
  }
}
 
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:20,代码来源:JSCallGraphBuilderUtil.java


示例14: processClass

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
private void processClass(List<TypeLabel> filteredList,
		TargetApplication targetApplication,
		Map<String, AnalysisResult> analysisResult, IClass clazz) {

	for (IMethod m : clazz.getDeclaredMethods()) {
		try {
			AnalyzedMethod method = targetApplication.findIRMethodForMethod(m);

			if (method != null) {
				MethodAnalyzer analyzer = new MethodAnalyzer(method, filteredList);

				AnalysisResult candidates = analyzer.analyze();

				if (!candidates.isEmpty()) {
					analysisResult.put(m.getSignature(), candidates);
				}
			} else {
				LOG.error("method is skipped");
			}
		} catch (Exception e) {
			FileUtil.handleError(e, m.getSignature());
		}
	}
}
 
开发者ID:wondee,项目名称:faststring,代码行数:25,代码来源:Runner.java


示例15: main

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
/**
 * main method to print out all ir for the test classes
 * @param args no args defined
 * @throws IOException
 * @throws WalaException
 */
public static void main(String[] args) throws IOException, WalaException {
	String pathname = TARGET_IRS;

	if (args.length > 0) {
		pathname = args[0];
	}

	TargetApplication targetApplication = TestUtilities.loadTestJar();

	for (IClass clazz : targetApplication.getApplicationClasses()) {
		for (IMethod m : clazz.getDeclaredMethods()) {
			printToPDF(pathname, targetApplication.getClassHierachy(), targetApplication.findIRForMethod(m));
		}
	}
}
 
开发者ID:wondee,项目名称:faststring,代码行数:22,代码来源:PrintTestIRs.java


示例16: createMethodFor

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
private AnalyzedMethod createMethodFor(String className, String methodName, String jarName) {
	TargetApplication application = TestUtilities.loadTestJar("target/" + jarName);
	for (IClass cl : application.getClassHierachy()) {
		if (cl.getName().toString().endsWith(className)) {
			LOG.info("found class {}", className);
			for (IMethod m : cl.getAllMethods()) {
				if (m.getName().toString().equals(methodName) || m.getSignature().equals(methodName)) {
					try {
						PrintTestIRs.printToPDF("target", application.getClassHierachy(), application.findIRForMethod(m));
					} catch (WalaException | IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}

					LOG.info("found method {}; {}", m.getSignature());
					return application.findIRMethodForMethod(m);

				}
			}
		}
	}

	throw new IllegalStateException(String.format("no method found %s %s", className, methodName));
}
 
开发者ID:wondee,项目名称:faststring,代码行数:25,代码来源:TestExternalJars.java


示例17: getMethodByName

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
/**
 * Looks up a method by name in a class object. If the method is overloaded,
 * the first one found is returned.
 * @param clazz  IClass object
 * @param methodName name of the method to be looked up
 * @return IMethod if method is declared in clazz, null otherwise
 */
public static IMethod getMethodByName(IClass clazz, String methodName) {
	for (IMethod m: clazz.getAllMethods()) { // DeclaredMethods()) -> only impl./overriden methods
		if (m.getSelector().toString().startsWith(methodName)) {
			return m;
		}
	}
	return null;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:16,代码来源:WalaUtils.java


示例18: resolveMethod

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
/**
 * Hierarchical lookup of an {@link IMethod} via {@link IClass} and {@link CallSiteReference}.
 * @param clazz   the {@link IClass} to start with
 * @param csr  the {@link CallSiteReference}
 * @return  a {@link IMethod} object of the resolved method or null
	 */
public static IMethod resolveMethod(IClass clazz, CallSiteReference csr) {
	IMethod targetMethod = null;

	while (targetMethod == null && !WalaUtils.isObjectClass(clazz)) {
		targetMethod = clazz.getMethod(csr.getDeclaredTarget().getSelector());
		if (targetMethod != null)
			break;

		clazz = clazz.getSuperclass();
	}
	return targetMethod;
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:19,代码来源:WalaUtils.java


示例19: makePublicEntrypoints

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
private static Iterable<Entrypoint> makePublicEntrypoints(AnalysisScope scope, IClassHierarchy cha, String entryClass) {
  Collection<Entrypoint> result = new ArrayList<Entrypoint>();
  IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application,
      StringStuff.deployment2CanonicalTypeString(entryClass)));
  for (IMethod m : klass.getDeclaredMethods()) {
    if (m.isPublic()) {
      result.add(new DefaultEntrypoint(m, cha));
    }
  }
  return result;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:12,代码来源:ScopeFileCallGraph.java


示例20: makeScriptCG

import com.ibm.wala.classLoader.IMethod; //导入依赖的package包/类
public static CallGraph makeScriptCG(SourceModule[] scripts, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, IllegalArgumentException,
    CancelException, WalaException {
  CAstRewriterFactory preprocessor = builderType.extractCorrelatedPairs ? new CorrelatedPairExtractorFactory(translatorFactory, scripts) : null;
  PropagationCallGraphBuilder b = makeCGBuilder(makeLoaders(preprocessor), scripts, builderType, irFactory);
  CallGraph CG = b.makeCallGraph(b.getOptions());
  // dumpCG(b.getPointerAnalysis(), CG);
  return CG;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:9,代码来源:JSCallGraphBuilderUtil.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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