From 087e64d6d1b2023f12875486baa33c0ab7ee042d Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 9 Nov 2004 20:23:25 +0000 Subject: [PATCH] Adding Daikon related stuff. --- Repair/RepairCompiler/Daikon/Process.java | 178 ++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100755 Repair/RepairCompiler/Daikon/Process.java diff --git a/Repair/RepairCompiler/Daikon/Process.java b/Repair/RepairCompiler/Daikon/Process.java new file mode 100755 index 0000000..cb0768c --- /dev/null +++ b/Repair/RepairCompiler/Daikon/Process.java @@ -0,0 +1,178 @@ +import java.io.*; +import java.util.*; + +class Process { + static HashSet set=null; + static Hashtable currtable=new Hashtable(); + static String declaration; + + static void debug(String str) { + System.out.println(str); + } + + static public void main(String[] args) { + debug("Opening file:"+args[0]); + BufferedReader br=null; + BufferedWriter bw=null; + try { + br=new BufferedReader(new FileReader(args[0])); + int count=0; + boolean start=false; + while(true) { + String line=br.readLine(); + if (line==null) + break; + String replacewith=line+".elem["; + if (replacewith==null) + break; + currtable.put(line+"[",replacewith); + } + + /* Built table */ + br=new BufferedReader(new FileReader(args[1])); + bw=new BufferedWriter(new FileWriter("fixed-"+args[1])); + count=0; + start=false; + while(true) { + String line=br.readLine(); + if (line==null) + break; + if (line.equals("")) { + bw.newLine(); + continue; + } + if (line.equals("DECLARE")) { + bw.write(line); + bw.newLine(); + start=true; + count=0; + declaration=br.readLine(); + bw.write(declaration); + bw.newLine(); + continue; + } + if (start) { + if ((count%4)==0) { + for(Iterator it=currtable.keySet().iterator();it.hasNext();) { + String str=(String)it.next(); + String replace=(String)currtable.get(str); + line=replace(line,str,replace); + } + } + bw.write(line); + bw.newLine(); + count++; + } else { + bw.write(line); + bw.newLine(); + } + } + bw.close(); + + + /* Built table */ + br=new BufferedReader(new FileReader(args[2])); + bw=new BufferedWriter(new FileWriter("fixed-"+args[2])); + count=0; + start=false; + while(true) { + String line=br.readLine(); + if (line==null) + break; + if (line.equals("")) { + bw.write(line); + bw.newLine(); + start=true; + count=0; + declaration=br.readLine(); + bw.write(declaration); + bw.newLine(); + continue; + } + if (start) { + if ((count%3)==0) { + for(Iterator it=currtable.keySet().iterator();it.hasNext();) { + String str=(String)it.next(); + String replace=(String)currtable.get(str); + line=replace(line,str,replace); + } + } + bw.write(line); + bw.newLine(); + count++; + } else { + bw.write(line); + bw.newLine(); + } + } + bw.close(); + + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + } + + static String generatepostfix(String str, int numderefs) { + if (numderefs==0) + return ""; + int start=str.length(); + for(int i=0;i