00001 package gov.nasa.arc.ase.jpf; 00002 00003 public class Simulation implements iSearch { 00004 public Simulation() { 00005 } 00006 public void Deadlock(){ 00007 boolean deadlock = verifyDeadlock(); 00008 00009 if(!deadlock) 00010 Engine.status.print("The program is deadlock free!"); 00011 } 00012 public ErrorTrailInterface getError() { 00013 return null; 00014 } 00015 public Path getErrorPath() { 00016 return null; 00017 } 00018 public boolean getResult() { 00019 return false; 00020 } 00021 public void Invariant(iProperty p){ 00022 Engine.status.print("Invariant can't be checked in simulation"); 00023 } 00024 private boolean verifyDeadlock() { 00025 boolean notFinished = true; 00026 int result; 00027 int index = 0; 00028 00029 Engine.status.incrStates(index); 00030 while (notFinished) { 00031 result = Engine.vm.simForward(); 00032 switch (result) { 00033 case RESULT.END: 00034 Engine.status.print("Deadlock!"); 00035 Engine.vm.ShowErrorTrail(); 00036 return true; 00037 00038 case RESULT.EXIT: 00039 notFinished = false; 00040 break; 00041 00042 case RESULT.NEW: 00043 Engine.status.incrStates(index); 00044 index++; 00045 } 00046 } 00047 00048 return false; 00049 } 00050 }