Program: 132834
Project: 132834
Buggy source:
@Override public List<ValLoc> getResults(){
switch (op) {
case LOAD_SCALAR:
case LOAD_REF:
case LOAD_FILE:
case LOAD_ARRAY:
case LOAD_BAG:
case LOAD_RECURSIVE:
{
      Arg src=getInput(0);
      Var dst=getOutput(0);
      Closed outIsClosed;
      if (op == Opcode.LOAD_REF) {
        outIsClosed=Closed.MAYBE_NOT;
      }
 else {
        outIsClosed=Closed.YES_NOT_RECURSIVE;
      }
      if (op == Opcode.LOAD_REF) {
        return ValLoc.derefCompVal(dst,src.getVar(),IsValCopy.NO,IsAssign.NO).asList();
      }
 else {
        return vanillaResult(outIsClosed,IsAssign.NO).asList();
      }
    }
case STORE_REF:
case STORE_SCALAR:
case STORE_FILE:
case STORE_ARRAY:
case STORE_BAG:
case STORE_RECURSIVE:
{
    ValLoc assign=vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.TO_LOCATION);
    Arg dst=getOutput(0).asArg();
    Arg src=getInput(0);
    if (op == Opcode.STORE_REF) {
      ValLoc retrieve=ValLoc.derefCompVal(src.getVar(),dst.getVar(),IsValCopy.NO,IsAssign.NO);
      return Arrays.asList(retrieve,assign);
    }
 else {
      return assign.asList();
    }
  }
case IS_MAPPED:
{
  ValLoc vanilla=vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.TO_LOCATION);
  assert(vanilla != null);
  Var fileVar=getInput(0).getVar();
  if (fileVar.isMapped() == Ternary.MAYBE) {
    return vanilla.asList();
  }
 else {
    Arg result=Arg.createBoolLit(fileVar.isMapped() == Ternary.TRUE);
    return Arrays.asList(vanilla,ValLoc.makeCopy(getOutput(0),result,IsAssign.NO));
  }
}
case GET_FILENAME:
{
Arg filename=getOutput(0).asArg();
Var file=getInput(0).getVar();
return ValLoc.makeFilename(filename,file).asList();
}
case GET_LOCAL_FILENAME:
{
return ValLoc.makeFilenameLocal(getOutput(0).asArg(),getInput(0).getVar(),IsAssign.TO_LOCATION).asList();
}
case SET_FILENAME_VAL:
{
Var file=getOutput(0);
Arg val=getInput(0);
return ValLoc.makeFilenameVal(file,val,IsAssign.TO_VALUE).asList();
}
case DEREF_SCALAR:
case DEREF_FILE:
{
return ValLoc.derefCompVal(getOutput(0),getInput(0).getVar(),IsValCopy.YES,IsAssign.NO).asList();
}
case STRUCT_INIT_FIELD:
{
ValLoc lookup=ValLoc.makeStructLookupResult(getInput(1).getVar(),getOutput(0),getInput(0).getStringLit());
return lookup.asList();
}
case STRUCT_LOOKUP:
{
ValLoc lookup=ValLoc.makeStructLookupResult(getOutput(0),getInput(0).getVar(),getInput(1).getStringLit());
return lookup.asList();
}
case ARR_STORE:
case ARR_COPY_IN_IMM:
case ARR_STORE_FUTURE:
case ARR_COPY_IN_FUTURE:
case AREF_STORE_IMM:
case AREF_COPY_IN_IMM:
case AREF_STORE_FUTURE:
case AREF_COPY_IN_FUTURE:
{
Var arr;
if (op == Opcode.AREF_STORE_FUTURE || op == Opcode.AREF_STORE_IMM || op == Opcode.AREF_COPY_IN_FUTURE || op == Opcode.AREF_COPY_IN_IMM) {
arr=getOutput(1);
}
 else {
arr=getOutput(0);
}
Arg ix=getInput(0);
Var member=getInput(1).getVar();
boolean insertingRef=(op == Opcode.AREF_COPY_IN_FUTURE || op == Opcode.AREF_COPY_IN_IMM || op == Opcode.ARR_COPY_IN_FUTURE || op == Opcode.ARR_COPY_IN_IMM);
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,member,insertingRef,IsAssign.TO_VALUE));
}
case ARRAY_BUILD:
{
Var arr=getOutput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.buildResult(op,getInputs(),arr.asArg(),Closed.YES_NOT_RECURSIVE,IsAssign.NO));
assert(getInputs().size() % 2 == 0);
int elemCount=getInputs().size() / 2;
for (int i=0; i < elemCount; i++) {
Arg key=getInput(2 * i);
Var val=getInput(2 * i + 1).getVar();
res.add(ValLoc.makeArrayResult(arr,key,val,false,IsAssign.TO_VALUE));
}
res.add(CommonFunctionCall.makeContainerSizeCV(arr,Arg.createIntLit(elemCount),false,IsAssign.NO));
return res;
}
case ARR_RETRIEVE:
case ARR_COPY_OUT_IMM:
case ARR_COPY_OUT_FUTURE:
case AREF_COPY_OUT_FUTURE:
case AREF_COPY_OUT_IMM:
{
Var arr=getInput(0).getVar();
Arg ix=getInput(1);
Var contents=getOutput(0);
if (op == Opcode.ARR_RETRIEVE) {
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,contents,false,IsAssign.NO));
}
 else {
assert(Types.isMemberReference(contents,arr));
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.makeArrayResult(arr,ix,contents,true,IsAssign.TO_LOCATION));
return res;
}
}
case ARR_CREATE_NESTED_FUTURE:
case ARR_CREATE_NESTED_IMM:
case AREF_CREATE_NESTED_FUTURE:
case AREF_CREATE_NESTED_IMM:
case ARRAY_CREATE_BAG:
{
Var nestedArr=getOutput(0);
Var arr;
if (op == Opcode.AREF_CREATE_NESTED_FUTURE || op == Opcode.AREF_CREATE_NESTED_IMM) {
arr=getOutput(2);
}
 else {
arr=getOutput(1);
}
Arg ix=getInput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
boolean returnsRef=op != Opcode.ARR_CREATE_NESTED_IMM && op != Opcode.ARRAY_CREATE_BAG;
res.add(ValLoc.makeArrayResult(arr,ix,nestedArr,returnsRef,IsAssign.NO));
res.add(ValLoc.makeCreateNestedResult(arr,ix,nestedArr,returnsRef));
return res;
}
case COPY_REF:
{
List<ValLoc> res=new ArrayList<ValLoc>();
Var srcRef=getInput(0).getVar();
res.add(ValLoc.makeAlias(getOutput(0),srcRef));
return res;
}
case LOOKUP_CHECKPOINT:
case UNPACK_VALUES:
{
List<ValLoc> res=new ArrayList<ValLoc>(outputs.size());
for (int i=0; i < outputs.size(); i++) {
Var out=outputs.get(i);
res.add(ValLoc.buildResult(op,(Object)i,getInput(0).asList(),out.asArg(),Closed.YES_RECURSIVE,IsValCopy.NO,IsAssign.NO));
}
return res;
}
case PACK_VALUES:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case CHECKPOINT_LOOKUP_ENABLED:
case CHECKPOINT_WRITE_ENABLED:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case UNPACK_ARRAY_TO_FLAT:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
default :
return null;
}
}

Fixed version (ground truth):
@Override public List<ValLoc> getResults(){
switch (op) {
case LOAD_SCALAR:
case LOAD_REF:
case LOAD_FILE:
case LOAD_ARRAY:
case LOAD_BAG:
case LOAD_RECURSIVE:
{
      Arg src=getInput(0);
      Var dst=getOutput(0);
      Closed outIsClosed;
      if (op == Opcode.LOAD_REF) {
        outIsClosed=Closed.MAYBE_NOT;
      }
 else {
        outIsClosed=Closed.YES_NOT_RECURSIVE;
      }
      if (op == Opcode.LOAD_REF) {
        return ValLoc.derefCompVal(dst,src.getVar(),IsValCopy.NO,IsAssign.NO).asList();
      }
 else {
        return vanillaResult(outIsClosed,IsAssign.NO).asList();
      }
    }
case STORE_REF:
case STORE_SCALAR:
case STORE_FILE:
case STORE_ARRAY:
case STORE_BAG:
case STORE_RECURSIVE:
{
    ValLoc assign=vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.TO_LOCATION);
    Arg dst=getOutput(0).asArg();
    Arg src=getInput(0);
    if (op == Opcode.STORE_REF) {
      ValLoc retrieve=ValLoc.derefCompVal(src.getVar(),dst.getVar(),IsValCopy.NO,IsAssign.NO);
      return Arrays.asList(retrieve,assign);
    }
 else {
      return assign.asList();
    }
  }
case IS_MAPPED:
{
  ValLoc vanilla=vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.TO_LOCATION);
  assert(vanilla != null);
  Var fileVar=getInput(0).getVar();
  if (fileVar.isMapped() == Ternary.MAYBE) {
    return vanilla.asList();
  }
 else {
    Arg result=Arg.createBoolLit(fileVar.isMapped() == Ternary.TRUE);
    return Arrays.asList(vanilla,ValLoc.makeCopy(getOutput(0),result,IsAssign.NO));
  }
}
case GET_FILENAME:
{
Arg filename=getOutput(0).asArg();
Var file=getInput(0).getVar();
return ValLoc.makeFilename(filename,file).asList();
}
case GET_LOCAL_FILENAME:
{
return ValLoc.makeFilenameLocal(getOutput(0).asArg(),getInput(0).getVar(),IsAssign.TO_LOCATION).asList();
}
case SET_FILENAME_VAL:
{
Var file=getOutput(0);
Arg val=getInput(0);
return ValLoc.makeFilenameVal(file,val,IsAssign.TO_VALUE).asList();
}
case DEREF_SCALAR:
case DEREF_FILE:
{
return ValLoc.derefCompVal(getOutput(0),getInput(0).getVar(),IsValCopy.YES,IsAssign.NO).asList();
}
case STRUCT_INIT_FIELD:
{
ValLoc lookup=ValLoc.makeStructLookupResult(getInput(1).getVar(),getOutput(0),getInput(0).getStringLit());
return lookup.asList();
}
case STRUCT_LOOKUP:
{
ValLoc lookup=ValLoc.makeStructLookupResult(getOutput(0),getInput(0).getVar(),getInput(1).getStringLit());
return lookup.asList();
}
case ARR_STORE:
case ARR_COPY_IN_IMM:
case ARR_STORE_FUTURE:
case ARR_COPY_IN_FUTURE:
case AREF_STORE_IMM:
case AREF_COPY_IN_IMM:
case AREF_STORE_FUTURE:
case AREF_COPY_IN_FUTURE:
{
Var arr;
if (op == Opcode.AREF_STORE_FUTURE || op == Opcode.AREF_STORE_IMM || op == Opcode.AREF_COPY_IN_FUTURE || op == Opcode.AREF_COPY_IN_IMM) {
arr=getOutput(1);
}
 else {
arr=getOutput(0);
}
Arg ix=getInput(0);
Arg member=getInput(1);
boolean insertingRef=(op == Opcode.AREF_COPY_IN_FUTURE || op == Opcode.AREF_COPY_IN_IMM || op == Opcode.ARR_COPY_IN_FUTURE || op == Opcode.ARR_COPY_IN_IMM);
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,member,insertingRef,IsAssign.TO_VALUE));
}
case ARRAY_BUILD:
{
Var arr=getOutput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.buildResult(op,getInputs(),arr.asArg(),Closed.YES_NOT_RECURSIVE,IsAssign.NO));
assert(getInputs().size() % 2 == 0);
int elemCount=getInputs().size() / 2;
for (int i=0; i < elemCount; i++) {
Arg key=getInput(2 * i);
Arg val=getInput(2 * i + 1);
res.add(ValLoc.makeArrayResult(arr,key,val,false,IsAssign.TO_VALUE));
}
res.add(CommonFunctionCall.makeContainerSizeCV(arr,Arg.createIntLit(elemCount),false,IsAssign.NO));
return res;
}
case ARR_RETRIEVE:
case ARR_COPY_OUT_IMM:
case ARR_COPY_OUT_FUTURE:
case AREF_COPY_OUT_FUTURE:
case AREF_COPY_OUT_IMM:
{
Var arr=getInput(0).getVar();
Arg ix=getInput(1);
Var contents=getOutput(0);
if (op == Opcode.ARR_RETRIEVE) {
return ValLoc.makeArrayResult(arr,ix,contents.asArg(),false,IsAssign.NO).asList();
}
 else {
assert(Types.isMemberReference(contents,arr));
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.makeArrayResult(arr,ix,contents.asArg(),true,IsAssign.TO_LOCATION));
return res;
}
}
case ARR_CREATE_NESTED_FUTURE:
case ARR_CREATE_NESTED_IMM:
case AREF_CREATE_NESTED_FUTURE:
case AREF_CREATE_NESTED_IMM:
case ARRAY_CREATE_BAG:
{
Var nestedArr=getOutput(0);
Var arr;
if (op == Opcode.AREF_CREATE_NESTED_FUTURE || op == Opcode.AREF_CREATE_NESTED_IMM) {
arr=getOutput(2);
}
 else {
arr=getOutput(1);
}
Arg ix=getInput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
boolean returnsRef=op != Opcode.ARR_CREATE_NESTED_IMM && op != Opcode.ARRAY_CREATE_BAG;
res.add(ValLoc.makeArrayResult(arr,ix,nestedArr.asArg(),returnsRef,IsAssign.NO));
res.add(ValLoc.makeCreateNestedResult(arr,ix,nestedArr,returnsRef));
return res;
}
case COPY_REF:
{
List<ValLoc> res=new ArrayList<ValLoc>();
Var srcRef=getInput(0).getVar();
res.add(ValLoc.makeAlias(getOutput(0),srcRef));
return res;
}
case LOOKUP_CHECKPOINT:
case UNPACK_VALUES:
{
List<ValLoc> res=new ArrayList<ValLoc>(outputs.size());
for (int i=0; i < outputs.size(); i++) {
Var out=outputs.get(i);
res.add(ValLoc.buildResult(op,(Object)i,getInput(0).asList(),out.asArg(),Closed.YES_RECURSIVE,IsValCopy.NO,IsAssign.NO));
}
return res;
}
case PACK_VALUES:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case CHECKPOINT_LOOKUP_ENABLED:
case CHECKPOINT_WRITE_ENABLED:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case UNPACK_ARRAY_TO_FLAT:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
default :
return null;
}
}