disabled LexicalScopingResolverContexts with new scheme
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4468 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
2dda77a0fb
commit
300377a428
|
@ -12,6 +12,7 @@ package com.ibm.wala.cast.js.ipa.callgraph;
|
||||||
|
|
||||||
import com.ibm.wala.cast.ipa.callgraph.LexicalScopingResolverContexts;
|
import com.ibm.wala.cast.ipa.callgraph.LexicalScopingResolverContexts;
|
||||||
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingKeysContextSelector;
|
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingKeysContextSelector;
|
||||||
|
import com.ibm.wala.cast.ir.translator.AstTranslator;
|
||||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||||
|
@ -64,7 +65,9 @@ public class JSZeroOrOneXCFABuilder extends JSCFABuilder {
|
||||||
if (options.handleCallApply()) {
|
if (options.handleCallApply()) {
|
||||||
contextSelector = new JavaScriptFunctionApplyContextSelector(contextSelector);
|
contextSelector = new JavaScriptFunctionApplyContextSelector(contextSelector);
|
||||||
}
|
}
|
||||||
|
if (!AstTranslator.NEW_LEXICAL) {
|
||||||
contextSelector = new LexicalScopingResolverContexts(this, contextSelector);
|
contextSelector = new LexicalScopingResolverContexts(this, contextSelector);
|
||||||
|
}
|
||||||
if (doOneCFA) {
|
if (doOneCFA) {
|
||||||
contextSelector = new nCFAContextSelector(1, contextSelector);
|
contextSelector = new nCFAContextSelector(1, contextSelector);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ibm.wala.cast.js.ipa.callgraph;
|
package com.ibm.wala.cast.js.ipa.callgraph;
|
||||||
|
|
||||||
|
import com.ibm.wala.cast.ipa.callgraph.LexicalScopingResolverContexts;
|
||||||
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingKeysContextSelector.ScopeMappingContext;
|
import com.ibm.wala.cast.ipa.callgraph.ScopeMappingKeysContextSelector.ScopeMappingContext;
|
||||||
|
import com.ibm.wala.cast.ir.translator.AstTranslator;
|
||||||
import com.ibm.wala.cast.js.ipa.callgraph.JavaScriptConstructTargetSelector.JavaScriptConstructor;
|
import com.ibm.wala.cast.js.ipa.callgraph.JavaScriptConstructTargetSelector.JavaScriptConstructor;
|
||||||
import com.ibm.wala.classLoader.CallSiteReference;
|
import com.ibm.wala.classLoader.CallSiteReference;
|
||||||
import com.ibm.wala.classLoader.IMethod;
|
import com.ibm.wala.classLoader.IMethod;
|
||||||
|
@ -9,6 +11,7 @@ import com.ibm.wala.ipa.callgraph.Context;
|
||||||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||||
import com.ibm.wala.ipa.callgraph.DelegatingContext;
|
import com.ibm.wala.ipa.callgraph.DelegatingContext;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||||
|
import com.ibm.wala.ipa.callgraph.propagation.cfa.CallerSiteContext;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.nCFAContextSelector;
|
import com.ibm.wala.ipa.callgraph.propagation.cfa.nCFAContextSelector;
|
||||||
import com.ibm.wala.util.intset.IntSet;
|
import com.ibm.wala.util.intset.IntSet;
|
||||||
|
|
||||||
|
@ -33,8 +36,11 @@ public class JavaScriptConstructorContextSelector implements ContextSelector {
|
||||||
if (callee instanceof JavaScriptConstructor) {
|
if (callee instanceof JavaScriptConstructor) {
|
||||||
final Context oneLevelContext = oneLevel.getCalleeTarget(caller, site, callee, receiver);
|
final Context oneLevelContext = oneLevel.getCalleeTarget(caller, site, callee, receiver);
|
||||||
final Context callerContext = caller.getContext();
|
final Context callerContext = caller.getContext();
|
||||||
if (callerContext instanceof ScopeMappingContext) {
|
if (!AstTranslator.NEW_LEXICAL && callerContext instanceof ScopeMappingContext) {
|
||||||
return new DelegatingContext(callerContext, new DelegatingContext(oneLevelContext, baseCtxt));
|
return new DelegatingContext(callerContext, new DelegatingContext(oneLevelContext, baseCtxt));
|
||||||
|
} else if (AstTranslator.NEW_LEXICAL && LexicalScopingResolverContexts.hasExposedUses(caller, site)) {
|
||||||
|
// use a caller-site context, to enable lexical scoping lookups
|
||||||
|
return new DelegatingContext(new CallerSiteContext(caller, site), baseCtxt);
|
||||||
} else {
|
} else {
|
||||||
// use at least one-level of call-string sensitivity for constructors always
|
// use at least one-level of call-string sensitivity for constructors always
|
||||||
return oneLevelContext;
|
return oneLevelContext;
|
||||||
|
|
|
@ -548,7 +548,7 @@ public final class LexicalScopingResolverContexts implements ContextSelector {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasExposedUses(CGNode caller, CallSiteReference site) {
|
public static boolean hasExposedUses(CGNode caller, CallSiteReference site) {
|
||||||
int uses[] = ((AstMethod) caller.getMethod()).lexicalInfo().getExposedUses(site.getProgramCounter());
|
int uses[] = ((AstMethod) caller.getMethod()).lexicalInfo().getExposedUses(site.getProgramCounter());
|
||||||
if (uses != null && uses.length > 0) {
|
if (uses != null && uses.length > 0) {
|
||||||
for (int use : uses) {
|
for (int use : uses) {
|
||||||
|
|
|
@ -13,11 +13,13 @@ package com.ibm.wala.cast.ipa.callgraph;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import com.ibm.wala.cast.ipa.callgraph.LexicalScopingResolverContexts.LexicalScopingResolver;
|
import com.ibm.wala.cast.ipa.callgraph.LexicalScopingResolverContexts.LexicalScopingResolver;
|
||||||
|
import com.ibm.wala.cast.ir.translator.AstTranslator;
|
||||||
import com.ibm.wala.classLoader.IClass;
|
import com.ibm.wala.classLoader.IClass;
|
||||||
import com.ibm.wala.classLoader.NewSiteReference;
|
import com.ibm.wala.classLoader.NewSiteReference;
|
||||||
import com.ibm.wala.classLoader.ProgramCounter;
|
import com.ibm.wala.classLoader.ProgramCounter;
|
||||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||||
import com.ibm.wala.ipa.callgraph.ContextItem;
|
import com.ibm.wala.ipa.callgraph.ContextItem;
|
||||||
|
import com.ibm.wala.ipa.callgraph.ContextKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKeyFactory;
|
import com.ibm.wala.ipa.callgraph.propagation.InstanceKeyFactory;
|
||||||
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
||||||
|
@ -91,6 +93,33 @@ abstract public class ScopeMappingInstanceKeys implements InstanceKeyFactory {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Iterator<CGNode> getFunargNodes(Pair<String, String> name) {
|
Iterator<CGNode> getFunargNodes(Pair<String, String> name) {
|
||||||
|
if (AstTranslator.NEW_LEXICAL) {
|
||||||
|
CGNode callerOfConstructor = (CGNode) creator.getContext().get(ContextKey.CALLER);
|
||||||
|
if (callerOfConstructor == null) {
|
||||||
|
System.err.println(creator);
|
||||||
|
assert false;
|
||||||
|
}
|
||||||
|
if (callerOfConstructor.getMethod().getReference().getDeclaringClass().getName().toString().equals(name.snd)){
|
||||||
|
return new NonNullSingletonIterator<CGNode>(callerOfConstructor);
|
||||||
|
} else {
|
||||||
|
PointerKey funcKey = builder.getPointerKeyForLocal(callerOfConstructor, 1);
|
||||||
|
OrdinalSet<InstanceKey> funcPtrs = builder.getPointerAnalysis().getPointsToSet(funcKey);
|
||||||
|
assert funcPtrs.size() == 1;
|
||||||
|
InstanceKey funcPtr = funcPtrs.iterator().next();
|
||||||
|
if (funcPtr instanceof ScopeMappingInstanceKey) {
|
||||||
|
return ((ScopeMappingInstanceKey) funcPtr).getFunargNodes(name);
|
||||||
|
} else {
|
||||||
|
return EmptyIterator.instance();
|
||||||
|
}
|
||||||
|
// Iterator<CGNode> result = EmptyIterator.instance();
|
||||||
|
// for (InstanceKey x : funcPtrs) {
|
||||||
|
// if (x instanceof ScopeMappingInstanceKey) {
|
||||||
|
// result = new CompoundIterator<CGNode>(result, ((ScopeMappingInstanceKey) x).getFunargNodes(name));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return result;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Iterator<CGNode> result = EmptyIterator.instance();
|
Iterator<CGNode> result = EmptyIterator.instance();
|
||||||
|
|
||||||
LexicalScopingResolver r = (LexicalScopingResolver) creator.getContext().get(LexicalScopingResolverContexts.RESOLVER);
|
LexicalScopingResolver r = (LexicalScopingResolver) creator.getContext().get(LexicalScopingResolverContexts.RESOLVER);
|
||||||
|
@ -123,6 +152,7 @@ abstract public class ScopeMappingInstanceKeys implements InstanceKeyFactory {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return base.hashCode() * creator.hashCode();
|
return base.hashCode() * creator.hashCode();
|
||||||
|
|
Loading…
Reference in New Issue