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


Java IMethod类代码示例

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


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


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