remove Input file related stuff from the compiler and runtime system
authorjzhou <jzhou>
Fri, 1 Jun 2012 03:01:32 +0000 (03:01 +0000)
committerjzhou <jzhou>
Fri, 1 Jun 2012 03:01:32 +0000 (03:01 +0000)
Robust/src/ClassLibrary/MGC/Scanner.java [deleted file]
Robust/src/ClassLibrary/MGC/gnu/Float.java
Robust/src/Util/InputFileTranslator.java [deleted file]
Robust/src/buildscript

diff --git a/Robust/src/ClassLibrary/MGC/Scanner.java b/Robust/src/ClassLibrary/MGC/Scanner.java
deleted file mode 100644 (file)
index 2767e53..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-public class Scanner implements Iterator {\r
-  private FileInputStream source;\r
-  private int currentpos;\r
-  private int isHighbits;\r
-  private int fd;\r
-\r
-  public Scanner (final String source) {\r
-    this.source = new FileInputStream(source);\r
-    this.fd = this.source.getfd();\r
-    this.currentpos = 0;\r
-    this.isHighbits = 1;\r
-  }\r
-\r
-  public void close () {\r
-      this.source.close();\r
-  }\r
-\r
-  public native double nextDouble ();\r
-\r
-  public native int nextInt ();\r
-}\r
index 360145a..a7353d7 100644 (file)
@@ -355,7 +355,7 @@ public final class Float
   public static float parseFloat(String str)
   {
     //return VMFloat.parseFloat(str);
-    return (float)(Long.parseLong(str));
+    return (float)(Double.parseDouble(str));
   }
 
   /**
diff --git a/Robust/src/Util/InputFileTranslator.java b/Robust/src/Util/InputFileTranslator.java
deleted file mode 100644 (file)
index 19b2196..0000000
+++ /dev/null
@@ -1,470 +0,0 @@
-package Util;\r
-\r
-import java.util.Hashtable;\r
-import java.util.Vector;\r
-import java.util.zip.GZIPInputStream;\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.FileInputStream;\r
-import java.io.IOException;\r
-import java.io.PrintWriter;\r
-\r
-public class InputFileTranslator{\r
-    public static String PREFIX="";\r
-    \r
-    public static void main(String args[]){\r
-       try{\r
-           //To Uncompress GZip File Contents we need to open the gzip file.....\r
-           if(args.length<=0){\r
-               System.out.println("Please enter the valid file name");\r
-           }else{\r
-               int offset = 0;\r
-               boolean isCompressed = false;\r
-               \r
-               if (args[offset].equals("-dir")) {\r
-                   PREFIX=args[++offset]+"/";\r
-                   offset++;\r
-               } \r
-               if(args[offset].equals("-compress")) {\r
-                   isCompressed = true;\r
-                   offset++;\r
-               }\r
-               \r
-\r
-               System.out.println("Opening the output file............. : opened");\r
-               \r
-               //Create the .h file \r
-               String outFilename = PREFIX+"InputFileArrays.h";\r
-               PrintWriter out = new PrintWriter(new FileWriter(new File(outFilename)));\r
-               out.println("#ifndef INPUT_FILE_ARRAYS_H");\r
-               out.println("#define INPUT_FILE_ARRAYS_H");\r
-               out.println();\r
-               out.println("#ifndef bool");\r
-               out.println("typedef int bool;");\r
-               out.println("#define true 1");\r
-               out.println("#define false 0");\r
-               out.println("#endif");\r
-               out.println();\r
-               out.println("int filename2fd(char * filename, int length);");\r
-               out.println("int nextInt(int fd, int * pos, int * isHighbits);");\r
-               out.println("double nextDouble(int fd, int * pos, int * isHighbits);");\r
-               out.println("#endif");\r
-               out.close();\r
-               \r
-               //Create the .c file that contains the big two-dimension array and \r
-               //read functions\r
-               outFilename = PREFIX+"InputFileArrays.c";\r
-               out = new PrintWriter(new FileWriter(new File(outFilename)));\r
-               out.println("#include \"InputFileArrays.h\"");\r
-               out.println("#include \"math.h\"");\r
-               out.println();\r
-               Vector<String> sourcefiles=new Vector<String>();\r
-               Vector<Boolean> compressVec = new Vector<Boolean>();\r
-               Hashtable<Byte, Integer> encodemapping = new Hashtable<Byte, Integer>();\r
-               Vector<Byte> encodeVec = new Vector<Byte>();\r
-               int encodenum = 1;\r
-               int returncount = 10;\r
-               for(int i=0; i<args.length-offset; i++)  {\r
-                   if(isCompressed) {\r
-                       encodemapping.clear();\r
-                       encodeVec.clear();\r
-                       encodenum = 1;\r
-                       encodemapping.put((byte)0, 0);\r
-                       encodeVec.add((byte)0);\r
-                   }\r
-                   String inFilename = args[i+offset];\r
-                   String arrayname = inFilename.replaceAll("\\.", "_");\r
-                   sourcefiles.add(inFilename);\r
-                   out.println("#define " + arrayname.toUpperCase() + " " + i);\r
-                   System.out.println("Opening the gzip file.......................... :  opened");\r
-                   GZIPInputStream gzipInputStream = null;\r
-                   FileInputStream fileInputStream = null;\r
-                   gzipInputStream = new GZIPInputStream(new FileInputStream(inFilename));\r
-                   //OutputStream out = new FileOutputStream(outFilename);\r
-                   System.out.println("Trsansferring bytes from the compressed file to the output file........:  Transfer successful");\r
-                   \r
-                   out.println("unsigned char " + arrayname + "[] = {");\r
-\r
-                   boolean printComma = false;\r
-                   boolean printReturn = false;\r
-                   byte[] buf = new byte[1024];  //size can be changed according to programmer's need.\r
-                   int len;\r
-                   int writenum = isCompressed?2:1;\r
-                   compressVec.add(isCompressed?true:false);\r
-                   int bitmask = 0x00FF;\r
-                   while ((len = gzipInputStream.read(buf)) > 0) {\r
-                       //out.write(buf, 0, len);\r
-                       for(int j = 0; j < len; ) {\r
-                           // read out 2 bytes at a time\r
-                           byte[] towrite = new byte[writenum];\r
-                           for(int k = 0; k<writenum&&j<len; k++) {\r
-                               if('#' == buf[j]) {\r
-                                   // skip the comments\r
-                                   while(j<len && buf[j++] != '\n') {\r
-                                   }\r
-                               } else {\r
-                                   towrite[k] = buf[j];\r
-                               }\r
-                               j++;\r
-                           }\r
-                           int writevalue = towrite[0];\r
-                           if(isCompressed) {\r
-                               // compress two value into one for compressed version\r
-                               if(!encodemapping.containsKey(towrite[0])) {\r
-                                   encodemapping.put(towrite[0], encodenum++);\r
-                                   encodeVec.add(towrite[0]);\r
-                               }\r
-                               writevalue = encodemapping.get(towrite[0]);\r
-                               if(!encodemapping.containsKey(towrite[1])) {\r
-                                   encodemapping.put(towrite[1], encodenum++);\r
-                                   encodeVec.add(towrite[1]);\r
-                               }\r
-                               if(encodeVec.size()>=16) {\r
-                                   System.err.println("Error! The compressed file has more than 16 types of characters! It can not be compressed!");\r
-                                   System.exit(-1);\r
-                               }\r
-                               writevalue = ((writevalue<<4)|encodemapping.get(towrite[1]))&bitmask;\r
-                           }\r
-                           if(!printComma) {\r
-                               printComma = true;\r
-                           } else {\r
-                               out.print(',');\r
-                           }\r
-                           if(printReturn) {\r
-                               out.println();\r
-                               printReturn = false;\r
-                           }\r
-                           if(!isCompressed && ('\n' == writevalue)) {\r
-                               out.print("\'\\n\'");\r
-                               printReturn = true;\r
-                           } else {\r
-                               out.print(writevalue);\r
-                               if(isCompressed) {\r
-                                   returncount--;\r
-                                   if(returncount==0) {\r
-                                       printReturn=true;\r
-                                       returncount = 10;\r
-                                   }\r
-                               }\r
-                           }\r
-                       }\r
-                   }\r
-                   out.println("};");\r
-                   out.println();\r
-                   gzipInputStream.close();\r
-                   if(isCompressed) {\r
-                       // print out the decoding array\r
-                       String decodename = arrayname.concat("_decodeTbl");\r
-                       out.println("unsigned char " + decodename + "[] = {");\r
-                       printComma = false;\r
-                       for(int j = 0; j < encodeVec.size(); j++) {\r
-                           byte b = encodeVec.elementAt(j).byteValue();\r
-                           if(!printComma) {\r
-                               printComma = true;\r
-                           } else {\r
-                               out.print(',');\r
-                           }\r
-                           if('\n' == b) {\r
-                               out.print("\'\\n\'");\r
-                               printReturn = true;\r
-                           } else {\r
-                               out.print(b);\r
-                           }\r
-                       }\r
-                       out.println("};");\r
-                       out.println();\r
-                   }\r
-               }\r
-               \r
-               out.println();\r
-               out.println("unsigned char * inputFileArrays[]= {");\r
-               for(int i = 0; i < sourcefiles.size(); i++) {\r
-                   String arrayname = sourcefiles.elementAt(i).replaceAll("\\.", "_");\r
-                   \r
-                   if(i > 0) {\r
-                       out.println(',');\r
-                   }\r
-                   out.print("&"+arrayname+"[0]");\r
-               }\r
-               out.println();\r
-               out.println("};");\r
-               out.println();\r
-               \r
-               out.println("unsigned char * inputFileArrays_decodeTbl[]= {");\r
-               for(int i = 0; i < sourcefiles.size(); i++) {\r
-                   String arrayname = sourcefiles.elementAt(i).replaceAll("\\.", "_");\r
-                   \r
-                   if(i > 0) {\r
-                       out.println(',');\r
-                   }\r
-                   if(compressVec.elementAt(i).booleanValue()) {\r
-                       out.print("&"+arrayname.concat("_decodeTbl")+"[0]");\r
-                   } else {\r
-                       out.print("0");\r
-                   }\r
-               }\r
-               out.println();\r
-               out.println("};");\r
-               out.println();\r
-               \r
-               //Create the read functions\r
-               out.println("int filename2fd(char * filename, int length) {");\r
-               for(int i=0; i<sourcefiles.size(); i++)  {\r
-                   String inFilename = sourcefiles.elementAt(i);\r
-                   String arrayname = inFilename.replaceAll("\\.", "_");\r
-                   out.print("  char " + arrayname + "[] = {");\r
-                   for(int j = 0; j < inFilename.length(); j++) {\r
-                       if(j>0) {\r
-                           out.print(",");\r
-                       }\r
-                       out.print("'"+inFilename.charAt(j)+"'");\r
-                   }\r
-                   out.println("};");\r
-                   out.println("  if(length==" + inFilename.length() + ") {");\r
-                   out.println("    int i;");\r
-                   out.println("    for(i = 0; i < length; i++) {");\r
-                   out.println("      if(filename[i]!="+arrayname+"[i]) {");\r
-                   out.println("        break;");\r
-                   out.println("      }");\r
-                   out.println("    }");\r
-                   out.println("    if(i==length) {");\r
-                   out.println("      return "+arrayname.toUpperCase() + ";");\r
-                   out.println("    }");\r
-                   out.println("  }");\r
-                   out.println();\r
-               }\r
-               out.println("  return -1;");\r
-               out.println("}");\r
-               out.println();\r
-               \r
-               out.println("unsigned char nextValue='\\0';");\r
-               out.println("bool holdVal=false;");\r
-               out.println();\r
-\r
-               out.println("void initVal() {");\r
-               out.println("  nextValue='\\0';");\r
-               out.println("  holdVal=false;");\r
-               out.println("}");\r
-               out.println();\r
-\r
-               out.println("unsigned char peek(unsigned char * filearray, unsigned char * decodearray, int * pos, int * isHighbits, bool isCompressed) {");\r
-               out.println("  if(!isCompressed) {");\r
-               out.println("    return filearray[*pos];");\r
-               out.println("  } else {");\r
-               out.println("    unsigned char value=0;");\r
-               out.println("    if(!holdVal) {");\r
-               out.println("      nextValue=filearray[*pos];");\r
-               out.println("    }");\r
-               out.println("    if(1==*isHighbits) {");\r
-               out.println("      value=((nextValue&0x00F0)>>4)&0x000F;");\r
-               out.println("      holdVal=true;");\r
-               out.println("    } else {");\r
-               out.println("      value=nextValue&0x000F;");\r
-               out.println("      holdVal=false;");\r
-               out.println("    }");\r
-               out.println("    value=decodearray[value];");\r
-               out.println("    return value;");\r
-               out.println("  }");\r
-               out.println("}");\r
-               out.println();\r
-\r
-               out.println("void next(int * pos, int * isHighbits, bool isCompressed) {");\r
-               out.println("  if(!isCompressed||!holdVal) {");\r
-               out.println("    *pos = *pos+1;");\r
-               out.println("  }");\r
-               out.println("  if(isCompressed) {");\r
-               out.println("    if(*isHighbits) {");\r
-               out.println("      *isHighbits=0;");\r
-               out.println("    } else {");\r
-               out.println("      *isHighbits=1;");\r
-               out.println("    }");\r
-               out.println("  }");\r
-               out.println("}");\r
-               out.println();\r
-               \r
-               out.println("int nextInt(int fd, int * pos, int * isHighbits) {");\r
-               out.println("  int i = 0;");\r
-               out.println("  unsigned char * filearray = inputFileArrays[fd];");\r
-               out.println("  unsigned char * decodearray = inputFileArrays_decodeTbl[fd];");\r
-               out.println("  bool isCompressed = false;");\r
-               out.println("  if(decodearray!=0) {");\r
-               out.println("   isCompressed = true;");\r
-               out.println("  }");\r
-               out.println("  initVal();");\r
-               out.println();\r
-               out.println("  unsigned char b='\\0';");\r
-               out.println("  while(true) {");\r
-               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
-               out.println("    if((b==' ')||(b=='\\n')){");\r
-               out.println("      next(pos, isHighbits, isCompressed);");\r
-               out.println("    } else {");\r
-               out.println("      break;");\r
-               out.println("    }");\r
-               out.println("  }");\r
-               out.println();\r
-               out.println("  unsigned int value = 0;");\r
-               out.println("  bool isNeg=false;");\r
-               out.println("  unsigned int radix = 10;");\r
-               out.println();\r
-               out.println("  if (b=='-') {");\r
-               out.println("    isNeg=true;");\r
-               out.println("    next(pos, isHighbits, isCompressed);");\r
-               out.println("  }");\r
-               out.println("  bool cont=true;");\r
-               out.println("  do {");\r
-               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
-               out.println("    unsigned int val=0;");\r
-               out.println("    if (b>='0'&&b<='9')");\r
-               out.println("      val=b-'0';");\r
-               out.println("    else if (b>='a'&&b<='z')");\r
-               out.println("      val=10+b-'a';");\r
-               out.println("    else if (b>='A'&&b<='Z')");\r
-               out.println("      val=10+b-'A';");\r
-               out.println("    else {");\r
-               out.println("      cont=false;");\r
-               out.println("    }");\r
-               out.println("    if (cont) {");\r
-               out.println("      if (val>=radix)");\r
-               out.println("        printf(\"Error in nextInt(): val >= radix\");");\r
-               out.println("      value=value*radix+val;");\r
-               out.println("      next(pos, isHighbits, isCompressed);");\r
-               out.println("    }");\r
-               out.println("  }while(cont);");\r
-               out.println("  if (isNeg)");\r
-               out.println("   value=-value;");\r
-               out.println();\r
-               out.println("  return value;");\r
-               out.println("}");\r
-               out.println();\r
-               \r
-               out.println("double nextDouble(int fd, int * pos, int * isHighbits) {");\r
-               out.println("  int i = 0;");\r
-               out.println("  unsigned char * filearray = inputFileArrays[fd];");\r
-               out.println("  unsigned char * decodearray = inputFileArrays_decodeTbl[fd];");\r
-               out.println("  bool isCompressed = false;");\r
-               out.println("  if(decodearray!=0) {");\r
-               out.println("   isCompressed = true;");\r
-               out.println("  }");\r
-               out.println("  initVal();");\r
-               out.println();\r
-               out.println("  unsigned char b='\\0';");\r
-               out.println("  while(true) {");\r
-               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
-               out.println("    if((b==' ')||(b=='\\n')){");\r
-               out.println("      next(pos, isHighbits, isCompressed);");\r
-               out.println("    } else {");\r
-               out.println("      break;");\r
-               out.println("    }");\r
-               out.println("  }");\r
-               out.println();\r
-               out.println("  double result=0.0;");\r
-               out.println("  unsigned int value=0;");\r
-               out.println("  unsigned int maxvalue=((unsigned int)(1<<32)-1)/10;");\r
-               out.println("  bool isNeg=false;");\r
-               out.println("  bool isDiv=false;");\r
-               out.println("  unsigned int radix = 10;");\r
-               out.println();\r
-               out.println("  if (b=='-') {");\r
-               out.println("    isNeg=true;");\r
-               out.println("    next(pos, isHighbits, isCompressed);");\r
-               out.println("  }");\r
-               out.println("  bool cont=true;");\r
-               out.println("  bool exp=false;");\r
-               out.println("  bool decimal=false;");\r
-               out.println("  bool compute=true;");\r
-               out.println("  bool omit=false;");\r
-               out.println("  unsigned int dcount=0;");\r
-               out.println("  // compute the base");\r
-               out.println("  do {");\r
-               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
-               out.println("    unsigned int val=0;");\r
-               out.println("    if (b>='0'&&b<='9') {");\r
-               out.println("      if (!omit) {");\r
-               out.println("        val=b-'0';");\r
-               out.println("        if(decimal) {");\r
-               out.println("          dcount++;");\r
-               out.println("        }");\r
-               out.println("      }");\r
-               out.println("    } else if (b=='.') {");\r
-               out.println("      decimal=true;");\r
-               out.println("      compute=false;");\r
-               out.println("    } else if (b=='E'||b=='e') {");\r
-               out.println("      exp=true;");\r
-               out.println("      cont=false;");\r
-               out.println("      next(pos, isHighbits, isCompressed);");\r
-               out.println("    } else {");\r
-               out.println("      cont=false;");\r
-               out.println("    }");\r
-               out.println("    if (cont) {");\r
-               out.println("      if (val>=radix)");\r
-               out.println("        printf(\"Error in nextDouble(): val >= radix\");");\r
-               out.println("      if(compute) {");\r
-               out.println("        if(value<maxvalue) {");\r
-               out.println("          value=value*radix+val;");\r
-               out.println("        } else {");\r
-               out.println("          omit=true;");\r
-               out.println("          compute=false;");\r
-               out.println("          dcount--;");\r
-               out.println("        }");\r
-               out.println("      } else if(!omit) {");\r
-               out.println("        compute=true;");\r
-               out.println("      }");\r
-               out.println("      next(pos, isHighbits, isCompressed);");\r
-               out.println("    }");\r
-               out.println("  }while(cont);");\r
-               out.println("  if(exp) {");\r
-               out.println("    // compute the power index");\r
-               out.println("    cont=true;");\r
-               out.println("    unsigned int n=0;");\r
-               out.println("    b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
-               out.println("    if (b=='-') {");\r
-               out.println("      isDiv=true;");\r
-               out.println("      next(pos, isHighbits, isCompressed);");\r
-               out.println("    } else if (b=='+') {");\r
-               out.println("      next(pos, isHighbits, isCompressed);");\r
-               out.println("    }");\r
-               out.println("    do {");\r
-               out.println("      b=peek(filearray, decodearray, pos, isHighbits, isCompressed); ");\r
-               out.println("      unsigned int val;");\r
-               out.println("      if (b>='0'&&b<='9') {");\r
-               out.println("        val=b-'0';");\r
-               out.println("      } else {");\r
-               out.println("        cont=false;");\r
-               out.println("      }");\r
-               out.println("      if (cont) {");\r
-               out.println("        if (val>=radix)");\r
-               out.println("          printf(\"Error in nextDouble(): val >= radix\");");\r
-               out.println("        n=n*10+val;");\r
-               out.println("        next(pos, isHighbits, isCompressed);");\r
-               out.println("      }");\r
-               out.println("    }while(cont);");\r
-               out.println("    if(isDiv) {");\r
-               out.println("      result = (double)value/pow(radix, n+dcount);");\r
-               out.println("    } else {");\r
-               out.println("      if(n>dcount) {");\r
-               out.println("        result = (double)value*pow(radix, n-dcount);");\r
-               out.println("      } else if(n<dcount) {");\r
-               out.println("        result = (double)value/pow(radix, dcount-n);");\r
-               out.println("      } else {");\r
-               out.println("        result = (double)value;");\r
-               out.println("      }");\r
-               out.println("    }");\r
-               out.println("  } else {");\r
-               out.println("    result = (double)value/pow(radix, dcount);");\r
-               out.println("  }");\r
-               out.println("  if (isNeg)");\r
-               out.println("    result=-result;");\r
-               out.println();\r
-               out.println("return result;");\r
-               out.println("  }");\r
-               out.println();\r
-\r
-               System.out.println("The file and stream is ......closing.......... : closed");\r
-               out.close();\r
-           }\r
-       }\r
-       catch(IOException e){\r
-           System.out.println("Exception has been thrown" + e);\r
-       }\r
-    }\r
-}\r
index 109eece..e1b2566 100755 (executable)
@@ -988,8 +988,8 @@ fi
 
 if $INPUTFILEFLAG
 then
-./ourjavac -cp ../cup:.:$(CLASSPATH) Util/InputFileTranslator.java
-if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx${COMPILER_HEAP_SIZE}m -classpath $ROBUSTROOT Util.InputFileTranslator \
+./ourjavac -cp ../cup:.:$(CLASSPATH) ${ROBUSTROOT}/Tilera/Benchmarks/GC/galois/InputFileTranslator.java
+if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx${COMPILER_HEAP_SIZE}m -classpath $ROBUSTROOT/Tilera/Benchmarks/GC/galois InputFileTranslator \
        -dir $BUILDDIR $INPUTFILEOPTS $INPUTFILES
     then exit $?
 fi