adapt to abstract invoke changes; move some util functionality to CAst core
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2134 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
562c03d0f3
commit
517ffd91a6
|
@ -23,8 +23,7 @@ import com.ibm.wala.cast.js.translator.JavaScriptTranslatorFactory;
|
|||
import com.ibm.wala.cast.js.types.JavaScriptMethods;
|
||||
import com.ibm.wala.cast.js.types.JavaScriptTypes;
|
||||
import com.ibm.wala.cast.types.AstMethodReference;
|
||||
import com.ibm.wala.classLoader.ClassLoaderFactory;
|
||||
import com.ibm.wala.classLoader.SourceFileModule;
|
||||
import com.ibm.wala.classLoader.*;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
|
@ -49,10 +48,6 @@ public class Util extends com.ibm.wala.cast.ipa.callgraph.Util {
|
|||
return translatorFactory;
|
||||
}
|
||||
|
||||
public static AnalysisCache makeCache(boolean keepIRs) {
|
||||
return new AnalysisCache(AstIRFactory.makeDefaultFactory(keepIRs));
|
||||
}
|
||||
|
||||
public static AnalysisOptions makeOptions(AnalysisScope scope, boolean keepIRs, IClassHierarchy cha, Iterable<Entrypoint> roots) {
|
||||
final AnalysisOptions options = new AnalysisOptions(scope, /* AstIRFactory.makeDefaultFactory(keepIRs), */ roots);
|
||||
|
||||
|
@ -72,24 +67,6 @@ public class Util extends com.ibm.wala.cast.ipa.callgraph.Util {
|
|||
return new JavaScriptLoaderFactory(translatorFactory);
|
||||
}
|
||||
|
||||
public static AnalysisScope makeScope(String[] files, JavaScriptLoaderFactory loaders) throws IOException {
|
||||
AnalysisScope result = new CAstAnalysisScope(files, loaders);
|
||||
result.addLanguageToScope(JavaScriptLoader.JS);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static AnalysisScope makeScope(SourceFileModule[] files, JavaScriptLoaderFactory loaders) throws IOException {
|
||||
AnalysisScope result = new CAstAnalysisScope(files, loaders);
|
||||
result.addLanguageToScope(JavaScriptLoader.JS);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static AnalysisScope makeScope(URL[] files, JavaScriptLoaderFactory loaders) throws IOException {
|
||||
AnalysisScope result = new CAstAnalysisScope(files, loaders);
|
||||
result.addLanguageToScope(JavaScriptLoader.JS);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IClassHierarchy makeHierarchy(AnalysisScope scope, ClassLoaderFactory loaders)
|
||||
throws ClassHierarchyException {
|
||||
return ClassHierarchy.make(scope, loaders, JavaScriptLoader.JS);
|
||||
|
|
|
@ -30,25 +30,24 @@ public class JavaScriptInvoke extends AbstractLexicalInvoke {
|
|||
|
||||
private int function;
|
||||
|
||||
private JavaScriptInvoke(int function, int results[], int[] params, int exception, CallSiteReference site) {
|
||||
super(results, exception, site);
|
||||
this.function = function;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
private JavaScriptInvoke(int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites) {
|
||||
super(results, exception, site, lexicalReads, lexicalWrites);
|
||||
this.function = function;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public JavaScriptInvoke(int function, int result, int[] params, int exception, CallSiteReference site) {
|
||||
super(result, exception, site);
|
||||
this.function = function;
|
||||
this.params = params;
|
||||
this(function, new int[]{result}, params, exception, site);
|
||||
}
|
||||
|
||||
private JavaScriptInvoke(int function, int result, int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites) {
|
||||
super(result, exception, site, lexicalReads, lexicalWrites);
|
||||
this.function = function;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor InvokeInstruction. This case for void return values
|
||||
* @param i
|
||||
* @param params
|
||||
*/
|
||||
public JavaScriptInvoke(int function, int[] params, int exception, CallSiteReference site) {
|
||||
this(function, -1, params, exception, site);
|
||||
this(function, null, params, exception, site);
|
||||
}
|
||||
|
||||
public SSAInstruction copyForSSA(int[] defs, int[] uses) {
|
||||
|
@ -72,15 +71,21 @@ public class JavaScriptInvoke extends AbstractLexicalInvoke {
|
|||
}
|
||||
}
|
||||
|
||||
int newLval = result;
|
||||
int newLvals[] = new int[ results.length ];
|
||||
System.arraycopy(results, 0, newLvals, 0, results.length);
|
||||
int newExp = exception;
|
||||
Access[] writes = lexicalWrites;
|
||||
|
||||
if (defs != null) {
|
||||
int i = 0;
|
||||
newLval = defs[i++];
|
||||
if (getNumberOfReturnValues() > 0) {
|
||||
newLvals[0] = defs[i++];
|
||||
}
|
||||
newExp = defs[i++];
|
||||
|
||||
for(int j = 1; j < getNumberOfReturnValues(); j++) {
|
||||
newLvals[j] = defs[i++];
|
||||
}
|
||||
|
||||
if (lexicalWrites != null) {
|
||||
writes = new Access[ lexicalWrites.length ];
|
||||
for(int j = 0; j < writes.length; j++)
|
||||
|
@ -88,13 +93,14 @@ public class JavaScriptInvoke extends AbstractLexicalInvoke {
|
|||
}
|
||||
}
|
||||
|
||||
return new JavaScriptInvoke(fn, newLval, newParams, newExp, site, reads, writes);
|
||||
return new JavaScriptInvoke(fn, newLvals, newParams, newExp, site, reads, writes);
|
||||
}
|
||||
|
||||
public String toString(SymbolTable symbolTable, ValueDecorator d) {
|
||||
StringBuffer s = new StringBuffer();
|
||||
if (result != -1) {
|
||||
s.append(getValueString(symbolTable, d, result)).append(" = ");
|
||||
if (getNumberOfReturnValues() > 0) {
|
||||
s.append(getValueString(symbolTable, d, getReturnValue(0)));
|
||||
s.append(" = ");
|
||||
}
|
||||
if (site.getDeclaredTarget().equals(JavaScriptMethods.ctorReference))
|
||||
s.append("construct ");
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSZeroOrOneXCFABuilder;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.Util;
|
||||
import com.ibm.wala.cast.js.loader.JavaScriptLoaderFactory;
|
||||
import com.ibm.wala.cast.js.loader.*;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
|
@ -25,7 +25,7 @@ class dumpCallGraph {
|
|||
public static void main(String[] args) throws Exception {
|
||||
|
||||
JavaScriptLoaderFactory loaders = Util.makeLoaders();
|
||||
AnalysisScope scope = Util.makeScope(args, loaders);
|
||||
AnalysisScope scope = Util.makeScope(args, loaders, JavaScriptLoader.JS);
|
||||
IClassHierarchy cha = Util.makeHierarchy(scope, loaders);
|
||||
Iterable<Entrypoint> roots = Util.makeScriptRoots(cha);
|
||||
AnalysisOptions options = Util.makeOptions(scope, false, cha, roots);
|
||||
|
|
Loading…
Reference in New Issue