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

MC.java

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

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