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

Reachability.java

00001 package gov.nasa.arc.ase.jpf.tools;
00002 
00003 import java.io.*;
00004 import java.util.*;
00005 import gov.nasa.arc.ase.jpf.*;
00006 
00007 public class Reachability {
00008   public static void main(String[] args) {
00009     TreeMap map = new TreeMap();
00010     Vector files = new Vector();
00011     Vector mappings = new Vector();
00012     Vector counters = new Vector();
00013     String lastfile = null;
00014     Vector lastmapping = null;
00015     Vector lastcounter = null;
00016 
00017     try {
00018       BufferedReader r = new BufferedReader(new FileReader(args[0]));
00019       String line;
00020       while((line = r.readLine()) != null) {
00021     StringTokenizer st = new StringTokenizer(line, "/");
00022     String category = st.nextToken();
00023     if(category.equals("Reachability")) {
00024       String file = st.nextToken();
00025       int lineno = Integer.parseInt(st.nextToken("/:"));
00026       int count = Integer.parseInt(st.nextToken(": "));
00027       if(lastfile == null || !file.equals(lastfile)) {
00028         files.add(lastfile = file);
00029         mappings.add(lastmapping = new Vector());
00030         counters.add(lastcounter = new Vector());
00031       }
00032       lastmapping.add(new Integer(lineno));
00033       lastcounter.add(new Integer(count));
00034     }
00035       }
00036     } catch(IOException e) {
00037       e.printStackTrace();
00038       System.exit(1);
00039     }
00040 
00041     for(int i = 0; i < files.size(); i++) {
00042       String file = (String)files.elementAt(i);
00043       Vector mapping = (Vector)mappings.elementAt(i);
00044       Vector counter = (Vector)counters.elementAt(i);
00045 
00046       System.out.println(file + ":");
00047       try {
00048     LineNumberReader r = new LineNumberReader(new FileReader(file));
00049     PrintWriter w = new PrintWriter(new FileWriter(file + ".reachability"));
00050 
00051     String line = r.readLine();
00052     for(int j = 0; j < mapping.size(); j++) {
00053       int lineno = ((Integer)mapping.elementAt(j)).intValue();
00054       int count = ((Integer)counter.elementAt(j)).intValue();
00055       System.out.println(" " + lineno);
00056       while(r.getLineNumber() < lineno && line != null) {
00057         w.println(line);
00058         line = r.readLine();
00059       }
00060       if(line != null) {
00061         w.println(line + " // " + count);
00062         line = r.readLine();
00063       }
00064     }
00065     while(line != null) {
00066       w.println(line);
00067       line = r.readLine();
00068     }
00069     w.close();
00070       } catch(IOException e) {
00071     e.printStackTrace();
00072     System.exit(1);
00073       }
00074     }
00075   }  
00076 }

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