From 6477c0df8e86be6e2a690cbdb23c482e027891f2 Mon Sep 17 00:00:00 2001 From: yeom Date: Fri, 15 Jul 2011 01:08:45 +0000 Subject: [PATCH] changes. --- Robust/src/Analysis/SSJava/FlowDownCheck.java | 18 ++++- .../ClassLibrary/SSJava/FileInputStream.java | 75 +++++++++++++++++++ Robust/src/ClassLibrary/SSJava/Math.java | 6 +- .../src/Tests/ssJava/mp3decoder/Header.java | 8 ++ .../ssJava/mp3decoder/LayerIDecoder.java | 8 +- .../ssJava/mp3decoder/LayerIIDecoder.java | 11 +-- .../ssJava/mp3decoder/LayerIIIDecoder.java | 14 ++-- .../Tests/ssJava/mp3decoder/SampleBuffer.java | 2 +- .../src/Tests/ssJava/mp3decoder/Subband.java | 2 +- .../ssJava/mp3decoder/SynthesisFilter.java | 5 +- 10 files changed, 123 insertions(+), 26 deletions(-) create mode 100644 Robust/src/ClassLibrary/SSJava/FileInputStream.java diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index 6f1f052e..b68ca26f 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -1058,7 +1058,7 @@ public class FlowDownCheck { return destLocation; } srcLocation = new CompositeLocation(); - System.out.println("checkLocationFromExpressionNode="+an.getSrc().printNode(0)); + System.out.println("checkLocationFromExpressionNode=" + an.getSrc().printNode(0)); srcLocation = checkLocationFromExpressionNode(md, nametable, an.getSrc(), srcLocation); // System.out.println(" an= " + an.printNode(0) + " an.getSrc()=" + // an.getSrc().getClass() @@ -1148,19 +1148,28 @@ public class FlowDownCheck { return deltaLoc; } - private Location parseFieldLocDeclaraton(String decl) { + private Location parseFieldLocDeclaraton(String decl, String msg) { int idx = decl.indexOf("."); String className = decl.substring(0, idx); String fieldName = decl.substring(idx + 1); + + className.replaceAll(" ", ""); + fieldName.replaceAll(" ", ""); Descriptor d = state.getClassSymbolTable().get(className); + if (d == null) { + System.out.println("className="+className+" to d="+d); + throw new Error("The class in the location declaration '" + decl + "' does not exist at " + + msg); + } + assert (d instanceof ClassDescriptor); SSJavaLattice lattice = ssjava.getClassLattice((ClassDescriptor) d); if (!lattice.containsKey(fieldName)) { throw new Error("The location " + fieldName + " is not defined in the field lattice of '" - + className + "'."); + + className + "' at "+msg); } return new Location(d, fieldName); @@ -1196,7 +1205,8 @@ public class FlowDownCheck { for (int i = 1; i < locIdList.size(); i++) { String locName = locIdList.get(i); - Location fieldLoc = parseFieldLocDeclaraton(locName); + Location fieldLoc = + parseFieldLocDeclaraton(locName, generateErrorMessage(md.getClassDesc(), n)); // ClassDescriptor cd = fieldLocName2cd.get(locName); // SSJavaLattice fieldLattice = // CompositeLattice.getLatticeByDescriptor(cd); diff --git a/Robust/src/ClassLibrary/SSJava/FileInputStream.java b/Robust/src/ClassLibrary/SSJava/FileInputStream.java new file mode 100644 index 00000000..44d88892 --- /dev/null +++ b/Robust/src/ClassLibrary/SSJava/FileInputStream.java @@ -0,0 +1,75 @@ +public class FileInputStream extends InputStream { + private int fd; + + public FileInputStream(String pathname) { + fd=nativeOpen(pathname.getBytes()); + } + + public FileInputStream(File path) { + fd=nativeOpen(path.getPath().getBytes()); + } + public int getfd() { + return fd; + } + + private static native int nativeOpen(byte[] filename); + private static native int nativeRead(int fd, byte[] array, int numBytes); + private static native int nativePeek(int fd); + private static native void nativeClose(int fd); + + public int read() { + byte b[]=new byte[1]; + int retval=read(b); + if (retval==-1 || retval==0) + return -1; + + // if carriage return comes back, dump it + if( b[0] == 13 ) { + return read(); + } + + // otherwise return result + return b[0]; + } + + public int peek() { + return nativePeek(fd); + } + + public int read(byte[] b) { + return nativeRead(fd, b, b.length); + } + + public String readLine() { + String line = ""; + int c = read(); + + // if we're already at the end of the file + // or there is an error, don't even return + // the empty string + if( c <= 0 ) { + return null; + } + + // ASCII 13 is carriage return, check for that also + while( c != '\n' && c != 13 && c > 0 ) { + line += (char)c; + c = read(); + } + + // peek and consume characters that are carriage + // returns or line feeds so the whole line is read + // and returned, and none of the line-ending chars + c = peek(); + while( c == '\n' || c == 13 ) { + c = read(); + c = peek(); + } + + return line; + } + + public void close() { + nativeClose(fd); + } +} diff --git a/Robust/src/ClassLibrary/SSJava/Math.java b/Robust/src/ClassLibrary/SSJava/Math.java index 35e6ab98..dd89a554 100644 --- a/Robust/src/ClassLibrary/SSJava/Math.java +++ b/Robust/src/ClassLibrary/SSJava/Math.java @@ -1,5 +1,5 @@ @LATTICE("B private to public @@ -756,6 +762,7 @@ public final class Header * Returns the number of subbands in the current frame. * @return number of subbands */ + @RETURNLOC("THIS") public int number_of_subbands() {return h_number_of_subbands;} /** @@ -765,5 +772,6 @@ public final class Header * subbands above that limit are in intensity stereo mode. * @return intensity */ + @RETURNLOC("THIS") public int intensity_stereo_bound() {return h_intensity_stereo_bound;} } diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java index 2ae6d5d8..dfc39286 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java @@ -298,7 +298,7 @@ /** * Class for layer I subbands in joint stereo mode. */ - @LATTICE("L=0; i--) + for (@LOC("C") int i=31; i>=0; i--) { samples[i] = s[i]*eq[i]; } -- 2.34.1