00001 package edu.ksu.cis.bandera.abstraction.typeinference;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import edu.ksu.cis.bandera.abstraction.util.*;
00036 import ca.mcgill.sable.soot.*;
00037 import ca.mcgill.sable.soot.jimple.*;
00038 import java.util.*;
00039 import edu.ksu.cis.bandera.jext.*;
00040 class LeftAssignExprSwitch extends IRNodes {
00041 private List constraints;
00042 private TypeInference ti;
00043 private UnionFindSet ufs;
00044 private Hashtable dependence;
00045 public LeftAssignExprSwitch(List c, TypeInference t, UnionFindSet ufs, Hashtable dependence) {
00046 constraints = c;
00047 ti = t;
00048 this.ufs = ufs;
00049 this.dependence = dependence;
00050 }
00051
00052
00053
00054
00055
00056
00057 public void addType(Type type) {
00058 if (ufs.find(type) == null) {
00059 ufs.add(type);
00060 ufs.setAttribute(type, type);
00061 }
00062 }
00063 public void caseArrayRef(ArrayRef v) {
00064 TypeStructure varnode = ti.getTypeStructure(v);
00065 ArrayTypeStructure var = (ArrayTypeStructure) ti.getTypeStructure(v.getBase());
00066 TypeStructure index = var.getIndex();
00067 v.getIndex().apply(ti);
00068 constraints.addAll(index.genEqualConstraints((TypeStructure) ti.getResult()));
00069 TypeStructure base = var.getElements();
00070 constraints.addAll(varnode.genEqualConstraints(base));
00071 setResult(varnode);
00072 }
00073
00074
00075
00076
00077 public void caseInstanceFieldRef(InstanceFieldRef v) {
00078 TypeStructure fs = ti.getTypeStructure(v.getField());
00079 TypeStructure ts = ti.getTypeStructure(v);
00080 constraints.addAll(ts.genEqualConstraints(fs));
00081 setResult(ts);
00082 }
00083 public void caseLocal(Local v) {
00084 TypeStructure node = ti.getTypeStructure(v);
00085 setResult(node);
00086 }
00087 public void caseStaticFieldRef(StaticFieldRef v) {
00088 TypeStructure fs = ti.getTypeStructure(v.getField());
00089 TypeStructure ts = ti.getTypeStructure(v);
00090 constraints.addAll(ts.genEqualConstraints(fs));
00091 setResult(ts);
00092 }
00093 public void defaultCase(Object o) {
00094 throw new RuntimeException("Unhandled left hand side" + o);
00095 }
00096 }