Program: 187049
Project: 187049
Buggy source:
public ContextMap<List<HashedString>,Map<Location,ValueMapping>> transfer(InstructionHandle stmt,FlowEdge edge,ContextMap<List<HashedString>,Map<Location,ValueMapping>> input,Interpreter<List<HashedString>,Map<Location,ValueMapping>> interpreter,Map<InstructionHandle,ContextMap<List<HashedString>,Map<Location,ValueMapping>>> state){
  Context context=new Context(input.getContext());
  HashMap<Location,ValueMapping> in=(HashMap<Location,ValueMapping>)input.get(context.callString);
  ContextMap<List<HashedString>,Map<Location,ValueMapping>> retval=new ContextMap<List<HashedString>,Map<Location,ValueMapping>>(context,input);
  HashMap<Location,ValueMapping> result=new HashMap<Location,ValueMapping>();
  retval.put(context.callString,result);
  Instruction instruction=stmt.getInstruction();
switch (instruction.getOpcode()) {
case Constants.ICONST_M1:
case Constants.ICONST_0:
case Constants.ICONST_1:
case Constants.ICONST_2:
case Constants.ICONST_3:
case Constants.ICONST_4:
case Constants.ICONST_5:
case Constants.BIPUSH:
case Constants.SIPUSH:
{
      ConstantPushInstruction instr=(ConstantPushInstruction)instruction;
      result=new HashMap<Location,ValueMapping>(in);
      retval.put(context.callString,result);
      int value=instr.getValue().intValue();
      result.put(new Location(context.stackPtr),new ValueMapping(value));
    }
  break;
case Constants.ACONST_NULL:
result=in;
retval.put(context.callString,result);
break;
case Constants.LDC:
case Constants.LDC_W:
{
LDC instr=(LDC)instruction;
result=new HashMap<Location,ValueMapping>(in);
retval.put(context.callString,result);
Type type=instr.getType(context.constPool);
if (type.equals(Type.INT)) {
Integer value=(Integer)instr.getValue(context.constPool);
result.put(new Location(context.stackPtr),new ValueMapping(value.intValue()));
}
 else if (type.equals(Type.STRING)) {
String value=(String)instr.getValue(context.constPool);
String name="String_Node_Str";
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
result.put(new Location(name + "String_Node_Str"),new ValueMapping(value.length()));
}
}
break;
case Constants.LDC2_W:
result=in;
retval.put(context.callString,result);
break;
case Constants.ISTORE_0:
case Constants.ISTORE_1:
case Constants.ISTORE_2:
case Constants.ISTORE_3:
case Constants.ISTORE:
{
StoreInstruction instr=(StoreInstruction)instruction;
int index=instr.getIndex();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1 && l.stackLoc != index) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(index),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.ASTORE_0:
case Constants.ASTORE_1:
case Constants.ASTORE_2:
case Constants.ASTORE_3:
case Constants.ASTORE:
result=in;
retval.put(context.callString,result);
break;
case Constants.ILOAD_0:
case Constants.ILOAD_1:
case Constants.ILOAD_2:
case Constants.ILOAD_3:
case Constants.ILOAD:
{
LoadInstruction instr=(LoadInstruction)instruction;
int index=instr.getIndex();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr) {
result.put(l,in.get(l));
}
if (l.stackLoc == index) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.source=l;
result.put(new Location(context.stackPtr),m);
}
}
}
break;
case Constants.ALOAD_0:
case Constants.ALOAD_1:
case Constants.ALOAD_2:
case Constants.ALOAD_3:
case Constants.ALOAD:
result=in;
retval.put(context.callString,result);
break;
case Constants.ARRAYLENGTH:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
AppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 1);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String arrayName=i.next();
ValueMapping m=in.get(new Location(arrayName + "String_Node_Str"));
if (m != null) {
ValueMapping value=new ValueMapping(m,false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
if (!valid) {
result.put(new Location(context.stackPtr - 1),new ValueMapping());
}
}
break;
case Constants.PUTFIELD:
{
PUTFIELD instr=(PUTFIELD)instruction;
int fieldSize=instr.getFieldType(context.constPool).getSize();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - 1 - fieldSize) {
result.put(l,in.get(l));
}
}
AppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
String f=fieldName.substring(fieldName.lastIndexOf("String_Node_Str"),fieldName.length());
String strippedName;
if (fieldName.indexOf("String_Node_Str") >= 0) {
strippedName=fieldName.split("String_Node_Str")[0] + f;
}
 else {
strippedName=fieldName;
}
if (p.containsField(strippedName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(fieldName),new ValueMapping(in.get(l),false));
}
}
}
}
}
break;
case Constants.GETFIELD:
{
GETFIELD instr=(GETFIELD)instruction;
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
AppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 1);
boolean valid=false;
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
String f=fieldName.substring(fieldName.lastIndexOf("String_Node_Str"),fieldName.length());
String strippedName;
if (fieldName.indexOf("String_Node_Str") >= 0) {
strippedName=fieldName.split("String_Node_Str")[0] + f;
}
 else {
strippedName=fieldName;
}
if (p.containsField(strippedName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(fieldName)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid && !(instr.getFieldType(context.constPool) instanceof ReferenceType)) {
result.put(new Location(context.stackPtr - 1),new ValueMapping(0));
}
}
break;
case Constants.PUTSTATIC:
{
PUTSTATIC instr=(PUTSTATIC)instruction;
int fieldSize=instr.getFieldType(context.constPool).getSize();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - fieldSize) {
result.put(l,in.get(l));
}
}
AppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
if (p.containsField(fieldName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(fieldName),new ValueMapping(in.get(l),false));
}
}
}
}
}
break;
case Constants.GETSTATIC:
{
GETSTATIC instr=(GETSTATIC)instruction;
result=new HashMap<Location,ValueMapping>(in);
retval.put(context.callString,result);
AppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr);
boolean valid=false;
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
if (p.containsField(fieldName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(fieldName)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid && !(instr.getFieldType(context.constPool) instanceof ReferenceType)) {
result.put(new Location(context.stackPtr),new ValueMapping());
}
}
break;
case Constants.IASTORE:
case Constants.CASTORE:
case Constants.SASTORE:
case Constants.BASTORE:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - 3) {
result.put(l,in.get(l));
}
}
AppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String name=i.next();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name),new ValueMapping(in.get(l),false));
}
}
}
}
break;
case Constants.AASTORE:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 3) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IALOAD:
case Constants.CALOAD:
case Constants.SALOAD:
case Constants.BALOAD:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
}
AppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 2);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String name=i.next();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(name)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid) {
result.put(new Location(context.stackPtr - 2),new ValueMapping(0));
}
}
break;
case Constants.AALOAD:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.DUP:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
result.put(l,in.get(l));
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.DUP_X1:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr - 2),new ValueMapping(in.get(l),true));
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
if (l.stackLoc == context.stackPtr - 2) {
result.put(new Location(context.stackPtr - 1),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.DUP2:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
result.put(l,in.get(l));
if (l.stackLoc == context.stackPtr - 2) {
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr + 1),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.POP:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.POP2:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IINC:
{
IINC instr=(IINC)instruction;
int index=instr.getIndex();
int increment=instr.getIncrement();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr) {
result.put(l,in.get(l));
}
if (l.stackLoc == index) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.add(increment);
m.constrained.add(increment);
if (m.increment != null) {
m.increment.join(new Interval(increment,increment));
}
 else {
m.increment=new Interval(increment,increment);
}
result.put(l,m);
}
}
}
break;
case Constants.IADD:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.add(operand);
m.constrained.add(operand);
if (m.increment != null) {
m.increment.join(operand);
}
 else {
m.increment=operand;
}
result.put(l,m);
}
}
}
break;
case Constants.ISUB:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.sub(operand);
m.constrained.sub(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.INEG:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 1) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.neg();
m.constrained.neg();
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.IUSHR:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.ushr(operand);
m.constrained.ushr(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.ISHR:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.shr(operand);
m.constrained.shr(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.IAND:
case Constants.IOR:
case Constants.IXOR:
case Constants.IMUL:
case Constants.IDIV:
case Constants.IREM:
case Constants.ISHL:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping();
result.put(l,m);
}
}
}
break;
case Constants.I2B:
case Constants.I2C:
case Constants.I2S:
result=in;
retval.put(context.callString,result);
break;
case Constants.MONITORENTER:
result=in;
retval.put(context.callString,result);
context.syncLevel++;
break;
case Constants.MONITOREXIT:
result=in;
retval.put(context.callString,result);
context.syncLevel--;
if (context.syncLevel < 0) {
System.err.println("String_Node_Str");
System.exit(-1);
}
break;
case Constants.CHECKCAST:
result=in;
retval.put(context.callString,result);
break;
case Constants.INSTANCEOF:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
ValueMapping bool=new ValueMapping();
bool.assigned.setLb(0);
bool.assigned.setUb(1);
result.put(new Location(context.stackPtr - 1),bool);
}
break;
case Constants.NEW:
result=in;
retval.put(context.callString,result);
break;
case Constants.NEWARRAY:
{
NEWARRAY instr=(NEWARRAY)instruction;
String name=instr.getType().toString();
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
}
}
}
break;
case Constants.ANEWARRAY:
{
ANEWARRAY instr=(ANEWARRAY)instruction;
String name=instr.getType(context.constPool).toString() + "String_Node_Str";
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
}
}
}
break;
case Constants.MULTIANEWARRAY:
{
MULTIANEWARRAY instr=(MULTIANEWARRAY)instruction;
int dim=instr.getDimensions();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - dim) {
result.put(l,in.get(l));
}
}
String type=instr.getType(context.constPool).toString();
type=type.substring(0,type.indexOf("String_Node_Str"));
for (int i=1; i <= dim; i++) {
String name=type;
for (int k=0; k < i; k++) {
name+="String_Node_Str";
}
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.stackLoc == context.stackPtr - i) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
}
}
}
}
break;
case Constants.GOTO:
result=in;
retval.put(context.callString,result);
break;
case Constants.IFNULL:
case Constants.IFNONNULL:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IF_ACMPEQ:
case Constants.IF_ACMPNE:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IFEQ:
case Constants.IFNE:
case Constants.IFLT:
case Constants.IFGE:
case Constants.IFLE:
case Constants.IFGT:
doIf(stmt,edge,context,in,result);
break;
case Constants.IF_ICMPEQ:
case Constants.IF_ICMPNE:
case Constants.IF_ICMPLT:
case Constants.IF_ICMPGE:
case Constants.IF_ICMPGT:
case Constants.IF_ICMPLE:
doIfIcmp(stmt,edge,context,in,result);
break;
case Constants.LOOKUPSWITCH:
case Constants.TABLESWITCH:
result=in;
retval.put(context.callString,result);
break;
case Constants.INVOKEVIRTUAL:
case Constants.INVOKEINTERFACE:
case Constants.INVOKESTATIC:
case Constants.INVOKESPECIAL:
{
AppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
if (receivers == null) {
System.out.println(context.method + "String_Node_Str" + instruction.toString(context.constPool.getConstantPool())+ "String_Node_Str");
break;
}
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String methodName=i.next();
doInvoke(methodName,stmt,context,input,interpreter,state,retval);
}
}
break;
case Constants.ARETURN:
case Constants.RETURN:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < 0) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IRETURN:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < 0) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(0),new ValueMapping(in.get(l),false));
}
}
}
break;
default :
result=in;
retval.put(context.callString,result);
break;
}
context.stackPtr+=instruction.produceStack(context.constPool) - instruction.consumeStack(context.constPool);
return retval;
}

Fixed version (ground truth):
public ContextMap<List<HashedString>,Map<Location,ValueMapping>> transfer(InstructionHandle stmt,FlowEdge edge,ContextMap<List<HashedString>,Map<Location,ValueMapping>> input,Interpreter<List<HashedString>,Map<Location,ValueMapping>> interpreter,Map<InstructionHandle,ContextMap<List<HashedString>,Map<Location,ValueMapping>>> state){
  Context context=new Context(input.getContext());
  HashMap<Location,ValueMapping> in=(HashMap<Location,ValueMapping>)input.get(context.callString);
  ContextMap<List<HashedString>,Map<Location,ValueMapping>> retval=new ContextMap<List<HashedString>,Map<Location,ValueMapping>>(context,input);
  HashMap<Location,ValueMapping> result=new HashMap<Location,ValueMapping>();
  retval.put(context.callString,result);
  Instruction instruction=stmt.getInstruction();
switch (instruction.getOpcode()) {
case Constants.ICONST_M1:
case Constants.ICONST_0:
case Constants.ICONST_1:
case Constants.ICONST_2:
case Constants.ICONST_3:
case Constants.ICONST_4:
case Constants.ICONST_5:
case Constants.BIPUSH:
case Constants.SIPUSH:
{
      ConstantPushInstruction instr=(ConstantPushInstruction)instruction;
      result=new HashMap<Location,ValueMapping>(in);
      retval.put(context.callString,result);
      int value=instr.getValue().intValue();
      result.put(new Location(context.stackPtr),new ValueMapping(value));
    }
  break;
case Constants.ACONST_NULL:
result=in;
retval.put(context.callString,result);
break;
case Constants.LDC:
case Constants.LDC_W:
{
LDC instr=(LDC)instruction;
result=new HashMap<Location,ValueMapping>(in);
retval.put(context.callString,result);
Type type=instr.getType(context.constPool);
if (type.equals(Type.INT)) {
Integer value=(Integer)instr.getValue(context.constPool);
result.put(new Location(context.stackPtr),new ValueMapping(value.intValue()));
}
 else if (type.equals(Type.STRING)) {
String value=(String)instr.getValue(context.constPool);
String name="String_Node_Str";
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
result.put(new Location(name + "String_Node_Str"),new ValueMapping(value.length()));
}
}
break;
case Constants.LDC2_W:
result=in;
retval.put(context.callString,result);
break;
case Constants.ISTORE_0:
case Constants.ISTORE_1:
case Constants.ISTORE_2:
case Constants.ISTORE_3:
case Constants.ISTORE:
{
StoreInstruction instr=(StoreInstruction)instruction;
int index=instr.getIndex();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1 && l.stackLoc != index) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(index),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.ASTORE_0:
case Constants.ASTORE_1:
case Constants.ASTORE_2:
case Constants.ASTORE_3:
case Constants.ASTORE:
result=in;
retval.put(context.callString,result);
break;
case Constants.ILOAD_0:
case Constants.ILOAD_1:
case Constants.ILOAD_2:
case Constants.ILOAD_3:
case Constants.ILOAD:
{
LoadInstruction instr=(LoadInstruction)instruction;
int index=instr.getIndex();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr) {
result.put(l,in.get(l));
}
if (l.stackLoc == index) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.source=l;
result.put(new Location(context.stackPtr),m);
}
}
}
break;
case Constants.ALOAD_0:
case Constants.ALOAD_1:
case Constants.ALOAD_2:
case Constants.ALOAD_3:
case Constants.ALOAD:
result=in;
retval.put(context.callString,result);
break;
case Constants.ARRAYLENGTH:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 1);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String arrayName=i.next();
ValueMapping m=in.get(new Location(arrayName + "String_Node_Str"));
if (m != null) {
ValueMapping value=new ValueMapping(m,false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
if (!valid) {
result.put(new Location(context.stackPtr - 1),new ValueMapping());
}
}
break;
case Constants.PUTFIELD:
{
PUTFIELD instr=(PUTFIELD)instruction;
int fieldSize=instr.getFieldType(context.constPool).getSize();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - 1 - fieldSize) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
String f=fieldName.substring(fieldName.lastIndexOf("String_Node_Str"),fieldName.length());
String strippedName;
if (fieldName.indexOf("String_Node_Str") >= 0) {
strippedName=fieldName.split("String_Node_Str")[0] + f;
}
 else {
strippedName=fieldName;
}
if (p.containsField(strippedName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(fieldName),new ValueMapping(in.get(l),false));
}
}
}
}
}
break;
case Constants.GETFIELD:
{
GETFIELD instr=(GETFIELD)instruction;
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 1);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
String f=fieldName.substring(fieldName.lastIndexOf("String_Node_Str"),fieldName.length());
String strippedName;
if (fieldName.indexOf("String_Node_Str") >= 0) {
strippedName=fieldName.split("String_Node_Str")[0] + f;
}
 else {
strippedName=fieldName;
}
if (p.containsField(strippedName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(fieldName)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
}
if (!valid && !(instr.getFieldType(context.constPool) instanceof ReferenceType)) {
result.put(new Location(context.stackPtr - 1),new ValueMapping(0));
}
}
break;
case Constants.PUTSTATIC:
{
PUTSTATIC instr=(PUTSTATIC)instruction;
int fieldSize=instr.getFieldType(context.constPool).getSize();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - fieldSize) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
if (p.containsField(fieldName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(fieldName),new ValueMapping(in.get(l),false));
}
}
}
}
}
break;
case Constants.GETSTATIC:
{
GETSTATIC instr=(GETSTATIC)instruction;
result=new HashMap<Location,ValueMapping>(in);
retval.put(context.callString,result);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr);
boolean valid=false;
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
if (p.containsField(fieldName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(fieldName)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid && !(instr.getFieldType(context.constPool) instanceof ReferenceType)) {
result.put(new Location(context.stackPtr),new ValueMapping());
}
}
break;
case Constants.IASTORE:
case Constants.CASTORE:
case Constants.SASTORE:
case Constants.BASTORE:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - 3) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String name=i.next();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name),new ValueMapping(in.get(l),false));
}
}
}
}
break;
case Constants.AASTORE:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 3) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IALOAD:
case Constants.CALOAD:
case Constants.SALOAD:
case Constants.BALOAD:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 2);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String name=i.next();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(name)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid) {
result.put(new Location(context.stackPtr - 2),new ValueMapping(0));
}
}
break;
case Constants.AALOAD:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.DUP:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
result.put(l,in.get(l));
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.DUP_X1:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr - 2),new ValueMapping(in.get(l),true));
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
if (l.stackLoc == context.stackPtr - 2) {
result.put(new Location(context.stackPtr - 1),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.DUP2:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
result.put(l,in.get(l));
if (l.stackLoc == context.stackPtr - 2) {
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr + 1),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.POP:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.POP2:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IINC:
{
IINC instr=(IINC)instruction;
int index=instr.getIndex();
int increment=instr.getIncrement();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr) {
result.put(l,in.get(l));
}
if (l.stackLoc == index) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.add(increment);
m.constrained.add(increment);
if (m.increment != null) {
m.increment.join(new Interval(increment,increment));
}
 else {
m.increment=new Interval(increment,increment);
}
result.put(l,m);
}
}
}
break;
case Constants.IADD:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.add(operand);
m.constrained.add(operand);
if (m.increment != null) {
m.increment.join(operand);
}
 else {
m.increment=operand;
}
result.put(l,m);
}
}
}
break;
case Constants.ISUB:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.sub(operand);
m.constrained.sub(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.INEG:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 1) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.neg();
m.constrained.neg();
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.IUSHR:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.ushr(operand);
m.constrained.ushr(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.ISHR:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.shr(operand);
m.constrained.shr(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.IAND:
case Constants.IOR:
case Constants.IXOR:
case Constants.IMUL:
case Constants.IDIV:
case Constants.IREM:
case Constants.ISHL:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping();
result.put(l,m);
}
}
}
break;
case Constants.I2B:
case Constants.I2C:
case Constants.I2S:
result=in;
retval.put(context.callString,result);
break;
case Constants.MONITORENTER:
result=in;
retval.put(context.callString,result);
context.syncLevel++;
break;
case Constants.MONITOREXIT:
result=in;
retval.put(context.callString,result);
context.syncLevel--;
if (context.syncLevel < 0) {
System.err.println("String_Node_Str");
System.exit(-1);
}
break;
case Constants.CHECKCAST:
result=in;
retval.put(context.callString,result);
break;
case Constants.INSTANCEOF:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
ValueMapping bool=new ValueMapping();
bool.assigned.setLb(0);
bool.assigned.setUb(1);
result.put(new Location(context.stackPtr - 1),bool);
}
break;
case Constants.NEW:
result=in;
retval.put(context.callString,result);
break;
case Constants.NEWARRAY:
{
NEWARRAY instr=(NEWARRAY)instruction;
String name=instr.getType().toString();
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
}
}
}
break;
case Constants.ANEWARRAY:
{
ANEWARRAY instr=(ANEWARRAY)instruction;
String name=instr.getType(context.constPool).toString() + "String_Node_Str";
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
}
}
}
break;
case Constants.MULTIANEWARRAY:
{
MULTIANEWARRAY instr=(MULTIANEWARRAY)instruction;
int dim=instr.getDimensions();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - dim) {
result.put(l,in.get(l));
}
}
String type=instr.getType(context.constPool).toString();
type=type.substring(0,type.indexOf("String_Node_Str"));
for (int i=1; i <= dim; i++) {
String name=type;
for (int k=0; k < i; k++) {
name+="String_Node_Str";
}
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.stackLoc == context.stackPtr - i) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
}
}
}
}
break;
case Constants.GOTO:
result=in;
retval.put(context.callString,result);
break;
case Constants.IFNULL:
case Constants.IFNONNULL:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IF_ACMPEQ:
case Constants.IF_ACMPNE:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IFEQ:
case Constants.IFNE:
case Constants.IFLT:
case Constants.IFGE:
case Constants.IFLE:
case Constants.IFGT:
doIf(stmt,edge,context,in,result);
break;
case Constants.IF_ICMPEQ:
case Constants.IF_ICMPNE:
case Constants.IF_ICMPLT:
case Constants.IF_ICMPGE:
case Constants.IF_ICMPGT:
case Constants.IF_ICMPLE:
doIfIcmp(stmt,edge,context,in,result);
break;
case Constants.LOOKUPSWITCH:
case Constants.TABLESWITCH:
result=in;
retval.put(context.callString,result);
break;
case Constants.INVOKEVIRTUAL:
case Constants.INVOKEINTERFACE:
case Constants.INVOKESTATIC:
case Constants.INVOKESPECIAL:
{
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
if (receivers == null) {
System.out.println(context.method + "String_Node_Str" + instruction.toString(context.constPool.getConstantPool())+ "String_Node_Str");
break;
}
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String methodName=i.next();
doInvoke(methodName,stmt,context,input,interpreter,state,retval);
}
}
break;
case Constants.ARETURN:
case Constants.RETURN:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < 0) {
result.put(l,in.get(l));
}
}
}
break;
case Constants.IRETURN:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < 0) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(0),new ValueMapping(in.get(l),false));
}
}
}
break;
default :
result=in;
retval.put(context.callString,result);
break;
}
context.stackPtr+=instruction.produceStack(context.constPool) - instruction.consumeStack(context.constPool);
return retval;
}