type cleanups

This commit is contained in:
Julian Dolby 2017-02-23 10:10:39 -05:00
parent 96be295500
commit a8a3699ee1
8 changed files with 31 additions and 25 deletions

View File

@ -65,6 +65,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.shrikeCT.AnnotationsReader.ConstantElementValue;
import com.ibm.wala.shrikeCT.AnnotationsReader.ElementValue;
import com.ibm.wala.shrikeCT.ClassConstants;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAThrowInstruction;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.ClassLoaderReference;
@ -170,7 +171,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
}
private void addMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
declaredMethods.put(Util.methodEntityToSelector(methodEntity), new ConcreteJavaMethod(methodEntity, owner, cfg, symtab,
hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo));
}
@ -251,7 +252,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
private final TypeReference[] exceptionTypes;
public JavaEntityMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
super(owner, methodEntity.getQualifiers(), cfg, symtab, MethodReference.findOrCreate(owner.getReference(), Util
.methodEntityToSelector(methodEntity)), hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo, JavaSourceLoaderImpl.this.getAnnotations(methodEntity));
this.parameterTypes = computeParameterTypes(methodEntity);
@ -369,7 +370,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
*/
public class ConcreteJavaMethod extends JavaEntityMethod {
public ConcreteJavaMethod(CAstEntity methodEntity, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
super(methodEntity, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo);
}
@ -522,7 +523,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
}
public void defineFunction(CAstEntity n, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
((JavaClass) owner).addMethod(n, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo);
}

View File

@ -37,6 +37,7 @@ import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.ModuleEntry;
import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.TypeName;
@ -244,8 +245,8 @@ public class JavaCAst2IRTranslator extends AstTranslator {
}
@Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
DebuggingInformation debugInfo) {
// N.B.: base class may actually ask to create a synthetic type to wrap
// code bodies, so we may see other things than TYPE_ENTITY here.

View File

@ -46,6 +46,7 @@ import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ssa.DefUse;
import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAOptions;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.TypeReference;
@ -309,8 +310,8 @@ public class ArgumentSpecialization {
}
@Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
DebuggingInformation debugInfo) {
if (N == codeBodyEntity) {
specializedCode = myloader.makeCodeBodyCode(cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, LI, debugInfo, method.getDeclaringClass());

View File

@ -57,6 +57,7 @@ import com.ibm.wala.ipa.callgraph.impl.ClassHierarchyMethodTargetSelector;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.cha.ClassHierarchyFactory;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeName;
@ -192,8 +193,8 @@ public class JSCallGraphUtil extends com.ibm.wala.cast.ipa.callgraph.CAstCallGra
final Set<String> names = new HashSet<String>();
JSAstTranslator toIR = new JSAstTranslator(cl) {
@Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
DebuggingInformation debugInfo) {
String fnName = "L" + composeEntityName(definingContext, N);
names.add(fnName);

View File

@ -168,8 +168,8 @@ public class JSAstTranslator extends AstTranslator {
}
@Override
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation LI,
DebuggingInformation debugInfo) {
if (DEBUG)
System.err.println(("\n\nAdding code for " + N));

View File

@ -11,6 +11,7 @@
package com.ibm.wala.cast.ir.ssa;
import java.util.Map;
import java.util.Map.Entry;
import com.ibm.wala.cast.loader.AstMethod;
import com.ibm.wala.cast.loader.AstMethod.LexicalInformation;
@ -87,8 +88,8 @@ public class AstIRFactory<T extends IMethod> implements IRFactory<T> {
}
}
private void setupCatchTypes(SSACFG cfg, Map<IBasicBlock, TypeReference[]> map) {
for(Map.Entry<IBasicBlock,TypeReference[]> e : map.entrySet()) {
private void setupCatchTypes(SSACFG cfg, Map<IBasicBlock<SSAInstruction>, TypeReference[]> map) {
for(Entry<IBasicBlock<SSAInstruction>, TypeReference[]> e : map.entrySet()) {
if (e.getKey().getNumber() != -1) {
ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) cfg.getNode(e.getKey().getNumber());
for (int j = 0; j < e.getValue().length; j++) {

View File

@ -139,8 +139,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
* fully define a function. invoked after all the code of the function has
* been processed
*/
protected abstract void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock, TypeReference[]> catchTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
protected abstract void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab,
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
DebuggingInformation debugInfo);
/**
@ -2332,7 +2332,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
void setCatchType(CAstNode catchNode, TypeReference catchType);
Map<IBasicBlock,TypeReference[]> getCatchTypes();
Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes();
void addEntityName(CAstEntity e, String name);
@ -2425,7 +2425,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
}
@Override
public Map<IBasicBlock, TypeReference[]> getCatchTypes() {
public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
return parent.getCatchTypes();
}
@ -2530,7 +2530,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
private final IncipientCFG cfg;
private final Map<IBasicBlock,TypeReference[]> catchTypes = HashMapFactory.make();
private final Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes = HashMapFactory.make();
Set<Pair<Pair<String, String>, Integer>> exposedReads;
Set<Pair<Pair<String, String>, Integer>> exposedWrites;
@ -2638,7 +2638,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
}
@Override
public Map<IBasicBlock,TypeReference[]> getCatchTypes() {
public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
return catchTypes;
}
@ -3297,7 +3297,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
// create code entry stuff for this entity
SymbolTable symtab = ((AbstractScope) functionContext.currentScope()).getUnderlyingSymtab();
Map<IBasicBlock,TypeReference[]> catchTypes = functionContext.getCatchTypes();
Map<IBasicBlock<SSAInstruction>,TypeReference[]> catchTypes = functionContext.getCatchTypes();
AstCFG cfg = new AstCFG(n, functionContext.cfg(), symtab, insts);
Position[] line = functionContext.cfg().getLinePositionMap();
boolean katch = functionContext.cfg().hasCatchBlock();
@ -4740,7 +4740,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
}
@Override
public Map<IBasicBlock, TypeReference[]> getCatchTypes() {
public Map<IBasicBlock<SSAInstruction>, TypeReference[]> getCatchTypes() {
return null;
}

View File

@ -24,6 +24,7 @@ import com.ibm.wala.cfg.IBasicBlock;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.shrikeCT.InvalidClassFileException;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
@ -108,13 +109,13 @@ public abstract class AstMethod implements IMethod {
private final MethodReference ref;
private final boolean hasCatchBlock;
private final boolean hasMonitorOp;
private final Map<IBasicBlock, TypeReference[]> catchTypes;
private final Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes;
private final AstLexicalInformation lexicalInfo;
private final DebuggingInformation debugInfo;
private final Collection<Annotation> annotations;
protected AstMethod(IClass cls, Collection qualifiers, AbstractCFG cfg, SymbolTable symtab, MethodReference ref,
boolean hasCatchBlock, Map<IBasicBlock, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo,
DebuggingInformation debugInfo, Collection<Annotation> annotations) {
this.cls = cls;
this.cfg = cfg;
@ -158,7 +159,7 @@ public abstract class AstMethod implements IMethod {
return symtab;
}
public Map<IBasicBlock, TypeReference[]> catchTypes() {
public Map<IBasicBlock<SSAInstruction>, TypeReference[]> catchTypes() {
return catchTypes;
}