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

Step.java

00001 package gov.nasa.arc.ase.jpf.jvm;
00002 
00003 import gov.nasa.arc.ase.jpf.jvm.bytecode.Instruction;
00004 import gov.nasa.arc.ase.util.Left;
00005 
00006 public class Step {
00007   public String classname;
00008   public int line;
00009   public Instruction[] bytecodes;
00010   public String[] comments;
00011   public int[] commentLocations;
00012 
00013   public Step(String cname, int l) {
00014     classname = cname;
00015     line = l;
00016     bytecodes = new Instruction[0];
00017     comments = new String[0];
00018     commentLocations = new int[0];
00019   }  
00020   public void addBytecode(Instruction i) {
00021     int l = bytecodes.length;
00022     Instruction[] n = new Instruction[l+1];
00023 
00024     System.arraycopy(bytecodes, 0, n, 0, l);
00025     bytecodes = n;
00026     bytecodes[l] = i;
00027   }  
00028   public void addComment(String c) {
00029     int l = comments.length;
00030     
00031     String[] nc = new String[l+1];
00032     System.arraycopy(comments, 0, nc, 0, l);
00033     comments = nc;
00034 
00035     int[] nl = new int[l+1];
00036     System.arraycopy(commentLocations, 0, nl, 0, l);
00037     commentLocations = nl;
00038 
00039     comments[l] = c;
00040     commentLocations[l] = bytecodes.length;
00041   }  
00042   public String toString() {
00043     StringBuffer sb = new StringBuffer();
00044     ClassInfo ci = ClassInfo.getClassInfo(classname);
00045 
00046     sb.append('\t');
00047     sb.append(Left.format(ci.getSourceFileName() + ":" + line, 20));
00048     sb.append(' ');
00049     sb.append(ci.getSource().get(line));
00050     sb.append('\n');
00051 
00052     if(VirtualMachine.options.bytecode_dump) {
00053       int j = 0, cl = comments.length;
00054 
00055       for(int i = 0, l = bytecodes.length; i < l; i++) {
00056     while(j < cl && i >= commentLocations[j]) {
00057       sb.append("\t\t// ");
00058       sb.append(comments[j++]);
00059       sb.append('\n');
00060     }
00061     sb.append("\t\t");
00062     sb.append(bytecodes[i].getPosition());
00063     sb.append(": ");
00064     sb.append(bytecodes[i].toString());
00065     sb.append('\n');
00066       }
00067       while(j < cl) {
00068     sb.append("\t\t// ");
00069     sb.append(comments[j++]);
00070     sb.append('\n');
00071       }
00072     } else {
00073       for(int j = 0, l = comments.length; j < l; j++) {
00074     sb.append("\t\t// ");
00075     sb.append(comments[j]);
00076     sb.append('\n');
00077       }
00078     }
00079 
00080     return sb.toString();
00081   }  
00082 }

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