Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Simulation.java

00001 package gov.nasa.arc.ase.jpf;
00002 
00003 import gov.nasa.arc.ase.util.Debug;
00004 
00005 public class Simulation implements iSearch {
00006   private boolean failed = false;
00007   private boolean deadlock = false;
00008   private ErrorTrailInterface error;
00009   private Path errorPath;
00010   private boolean done;
00011   
00012   public Simulation() {
00013     Debug.println(Debug.WARNING, "Simulation Search");
00014   }  
00015   private void error() {
00016     failed = true;
00017     if (Engine.options.bandera) {
00018       errorPath = Engine.getJPF().vm.getErrorTrail1();
00019     } else {
00020       error = Engine.getJPF().vm.getErrorTrail();        
00021     }
00022     done = !Engine.options.multiple_errors;
00023   }  
00024   public ErrorTrailInterface getError() {
00025     return error;
00026   }  
00027   public String getErrorMessage() {
00028     if(!failed) return "No Errors Found";
00029 
00030     if(deadlock) return "Deadlock found";
00031 
00032     return Engine.getJPF().vm.getErrorMessage();
00033   }  
00034   public Path getErrorPath() {
00035     return errorPath;
00036   }  
00037   public boolean hasFailed() {
00038     return failed;
00039   }  
00040   public void search() {
00041     int depth = 0;
00042 
00043     done = false;
00044     Engine.getJPF().status.states++;
00045     depth++;
00046 
00047     if(Engine.options.deadlocks) {
00048       if(Engine.getJPF().vm.isDeadlocked()) {
00049     deadlock = true;
00050     error();
00051       }
00052     }
00053 
00054     while (!done) {
00055       int tResult = Engine.getJPF().vm.Forward();
00056 
00057       if(TransitionResult.isError(tResult)) {
00058     error();
00059     if(done) break;
00060       }
00061 
00062       switch(TransitionResult.getResults(tResult)) {
00063     case TransitionResult.NEW:
00064     case TransitionResult.OLD:
00065       depth++;
00066       Engine.getJPF().status.states++;
00067       Engine.getJPF().status.transitions++;
00068       if(Engine.options.deadlocks) {
00069         if(Engine.getJPF().vm.isDeadlocked()) {
00070           deadlock = true;
00071           error();
00072         }
00073       }
00074       break;
00075 
00076     case TransitionResult.END:
00077       done = true;
00078       break;
00079       }
00080     }
00081   }  
00082 }

Generated at Thu Feb 7 06:54:56 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001