flexibility in how to model constants

This commit is contained in:
Julian Dolby 2018-04-30 19:09:59 -04:00
parent 2a7a98ed32
commit 8005b665b9
3 changed files with 12 additions and 2 deletions

View File

@ -106,8 +106,8 @@ public class DelegatingAstPointerKeys implements AstPointerKeyFactory {
protected PointerKey getInstanceFieldPointerKeyForConstant(InstanceKey I, ConstantKey<?> F) {
Object v = F.getValue();
// FIXME: current only constant string are handled
if (v instanceof String) {
IField f = I.getConcreteType().getField(Atom.findOrCreateUnicodeAtom((String) v));
if (I.getConcreteType().getClassLoader().getLanguage().modelConstant(v)) {
IField f = I.getConcreteType().getField(Atom.findOrCreateUnicodeAtom(String.valueOf(v)));
return getPointerKeyForInstanceField(I, f);
}
return null;

View File

@ -154,4 +154,7 @@ public interface Language {
AbstractRootMethod getFakeRootMethod(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache);
InducedCFG makeInducedCFG(SSAInstruction[] instructions, IMethod method, Context context);
boolean modelConstant(Object o);
}

View File

@ -74,4 +74,11 @@ public abstract class LanguageImpl implements Language {
InducedCFG makeInducedCFG(SSAInstruction[] instructions, IMethod method, Context context) {
return new InducedCFG(instructions, method, context);
}
@Override
public boolean modelConstant(Object o) {
return o instanceof String;
}
}