1 20 26 package gov.nasa.jpf.jvm.choice; 27 28 import gov.nasa.jpf.Config; 29 import gov.nasa.jpf.jvm.IntChoiceGenerator; 30 import gov.nasa.jpf.jvm.JVM; 31 import gov.nasa.jpf.jvm.StaticElementInfo; 32 import gov.nasa.jpf.jvm.ClassInfo; 33 44 50 public class IntChoiceFromStaticVarSet extends IntChoiceGenerator { 51 52 String [] values; 53 int count = -1; 54 55 59 public IntChoiceFromStaticVarSet(Config conf, String id) { 60 super(id); 61 values = conf.getStringArray(id + ".values"); 62 } 63 64 67 public int getNextChoice(JVM vm) { 68 69 String [] varId = values[count].split("[.]+"); 71 72 ClassInfo ci = ClassInfo.getClassInfo(varId[0]); 73 StaticElementInfo ei = vm.getKernelState().sa.get(ci.getName()); 74 int ret = ei.getIntField(varId[1], null); 75 76 vm.println("Choice: "+id + " = " + values[count] + "("+ret+")"); 78 return ret; 79 } 80 81 84 public boolean hasMoreChoices(JVM vm) { 85 if (count < values.length-1) 86 return true; 87 else 88 return false; 89 } 90 91 94 public void advance(JVM vm) { 95 count++; 96 } 97 98 } 99 | Popular Tags |