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

TrailInfo.java

00001 package gov.nasa.arc.ase.jpf.jvm;
00002 
00003 import gov.nasa.arc.ase.jpf.Engine;
00004 import gov.nasa.arc.ase.jpf.iTrailInfo;
00005 import gov.nasa.arc.ase.jpf.jvm.bytecode.Instruction;
00006 import gov.nasa.arc.ase.util.Debug;
00007 
00008 public class TrailInfo implements iTrailInfo {
00009   private int thread;
00010   private int random;
00011   private Step[] steps;
00012 //#ifdef BUCHI
00013   private int buchi_state = -1;
00014 //#endif BUCHI
00015 
00016   public TrailInfo(int t, int r) {
00017     thread = t;
00018     random = r;
00019     steps = new Step[0];
00020   }  
00021   public void addBytecode(Instruction i) {
00022     steps[steps.length-1].addBytecode(i);
00023   }  
00024   public void addComment(String c) {
00025     steps[steps.length-1].addComment(c);
00026   }  
00027   public void addStep(String classname, int line) {
00028     int l = steps.length;
00029 
00030     if(l > 0)
00031       if(steps[l-1].classname.equals(classname))
00032     if(steps[l-1].line == line)
00033       return;
00034 
00035     Step[] n = new Step[l+1];
00036     
00037     System.arraycopy(steps, 0, n, 0, l);
00038     steps = n;
00039     steps[l] = new Step(classname, line);
00040   }  
00041   public int countSteps() {
00042     return steps.length;
00043   }  
00044   public int getBuchiState() {
00045     return buchi_state;
00046   }  
00047   public JVMPathEntry getEntry() {
00048     return new JVMPathEntry(steps[0].line, steps[0].classname, thread, random);
00049   }  
00050   public int getRandom() {
00051     return this.random;
00052   }  
00053   public Step getStep(int index) {
00054     if(index < 0 || index >= steps.length)
00055       return null;
00056 
00057     return steps[index];
00058   }  
00059   public int getThread() {
00060     return this.thread;
00061   }  
00062 //#ifdef BUCHI
00063   public void setBuchiState(int bs) {
00064     buchi_state = bs;
00065   }  
00066 //#endif BUCHI
00067 
00068   public String toString() {
00069     StringBuffer sb = new StringBuffer();
00070 
00071     sb.append("Thread #");
00072     sb.append(thread);
00073     sb.append(" Random #");
00074     sb.append(random);
00075 //#ifdef BUCHI
00076     if(Engine.options.buchi != null) {
00077       sb.append(" Buchi State ");
00078       sb.append(buchi_state);
00079     }
00080 //#endif BUCHI
00081     sb.append('\n');
00082 
00083     for(int i = 0, l = steps.length; i < l; i++)
00084       sb.append(steps[i].toString());
00085 
00086     return sb.toString();
00087   }  
00088 }

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