本文整理汇总了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;
}
示例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
}
示例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();
}
示例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;
}
}
示例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;
}
}
示例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));
}
}
示例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]);
}
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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());
}
}
}
示例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));
}
}
}