REFACTOR: - code changes to accommodate .NET into WALA. A .NET class maps onto multiple source files, and thus these changes.

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3582 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
omertripp 2009-05-07 14:14:18 +00:00
parent d5e6dd443f
commit 2ca8a07943
10 changed files with 29 additions and 13 deletions

View File

@ -37,10 +37,14 @@ public interface IBytecodeMethod extends IMethod {
* @return the Shrike instructions decoded from the bytecode
*/
IInstruction[] getInstructions() throws InvalidClassFileException;
/**
* @return the call sites declared in the bytecode for this method
*/
Collection<CallSiteReference> getCallSites() throws InvalidClassFileException;
/**
* @return the source file corresponding to the specified bytecode offset
*/
String getSourceFileName(int offset);
}

View File

@ -151,7 +151,7 @@ public class ArrayClass implements IClass, Constants {
/*
* @see com.ibm.wala.classLoader.IClass#getSourceFileName()
*/
public String getSourceFileName() {
public Collection<String> getSourceFileNames() {
return null;
}

View File

@ -154,8 +154,8 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
return typeReference;
}
public String getSourceFileName() {
return loader.getSourceFileName(this);
public Collection<String> getSourceFileNames() {
return loader.getSourceFileNames(this);
}
public InputStream getSource() {

View File

@ -14,6 +14,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -428,12 +429,12 @@ public class ClassLoaderImpl implements IClassLoader {
/*
* @see com.ibm.wala.classLoader.IClassLoader#getSourceFileName(com.ibm.wala.classLoader.IClass)
*/
public String getSourceFileName(IClass klass) {
public Collection<String> getSourceFileNames(IClass klass) {
if (klass == null) {
throw new IllegalArgumentException("klass is null");
}
ModuleEntry e = sourceMap.get(klass.getName());
return e == null ? null : e.getName();
return e == null ? null : Collections.singleton(e.getName());
}
public InputStream getSource(IClass klass) {

View File

@ -91,9 +91,9 @@ public interface IClass extends IClassHierarchyDweller {
TypeReference getReference();
/**
* @return String holding the name of the source file that defined this class, or null if none found
* @return Collection of strings holding the names of the source files that defined this class, or null if none found
*/
String getSourceFileName();
Collection<String> getSourceFileNames();
/**
* @return String representing the source file holding this class, or null if not found

View File

@ -68,7 +68,7 @@ public interface IClassLoader {
/**
* @return name of source file corresponding to the class, or null if not available
*/
public abstract String getSourceFileName(IClass klass);
public abstract Collection<String> getSourceFileNames(IClass klass);
/**
* @return input stream representing the source file for a class, or null if not available

View File

@ -387,4 +387,14 @@ public final class ShrikeCTMethod extends ShrikeBTMethod implements IBytecodeMet
return res;
}
public String getSourceFileName(int offset) {
Collection<String> result = getDeclaringClass().getSourceFileNames();
if (result == null) {
return null;
} else {
assert (result.size() == 1);
return result.iterator().next();
}
}
}

View File

@ -12,6 +12,7 @@
package com.ibm.wala.classLoader;
import java.io.InputStream;
import java.util.Collection;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.ClassLoaderReference;
@ -99,7 +100,7 @@ public abstract class SyntheticClass implements IClass {
/*
* @see com.ibm.wala.classLoader.IClass#getSourceFileName()
*/
public String getSourceFileName() {
public Collection<String> getSourceFileNames() {
return null;
}

View File

@ -115,8 +115,8 @@ public class BypassSyntheticClass extends SyntheticClass {
* @see com.ibm.wala.classLoader.IClass#getSourceFileName()
*/
@Override
public String getSourceFileName() {
return realType.getSourceFileName();
public Collection<String> getSourceFileNames() {
return realType.getSourceFileNames();
}
/*

View File

@ -155,7 +155,7 @@ public class BypassSyntheticClassLoader implements IClassLoader {
/*
* @see com.ibm.wala.classLoader.IClassLoader#getSourceFileName(com.ibm.wala.classLoader.IClass)
*/
public String getSourceFileName(IClass klass) {
public Collection<String> getSourceFileNames(IClass klass) {
return null;
}