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.JPFException; 32 42 public class IntChoiceFromSet extends IntChoiceGenerator { 43 44 String [] values; 46 47 int count = -1; 48 49 52 public IntChoiceFromSet(Config conf, String id) { 53 super(id); 54 values = conf.getStringArray(id + ".values"); 55 if (values == null) { 56 throw new JPFException("value set for <" + id + "> choice did not load"); 57 } 58 } 59 60 63 public int getNextChoice(JVM vm) { 64 65 try { 66 int ret = Integer.parseInt(values[count]); 68 vm.println(id + ": " + ret); 69 return ret; 70 } catch (NumberFormatException nfx) { 71 throw new JPFException("Number format error for <" + id +">: parsing \"" + values[count] +"\""); 72 } 73 } 74 75 78 public boolean hasMoreChoices(JVM vm) { 79 if (count < values.length-1) 80 return true; 81 else 82 return false; 83 } 84 85 88 public void advance(JVM vm) { 89 count++; 90 } 91 92 } 93 | Popular Tags |