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()
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<String> 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);
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<String> fieldLattice =
// CompositeLattice.getLatticeByDescriptor(cd);
--- /dev/null
+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);
+ }
+}
@LATTICE("B<T")
-@METHODDEFAULT("OUT<IN")
+@METHODDEFAULT("OUT<IN,THISLOC=IN")
public class Math {
@LOC("T") static final double PI=3.14159265358979323846;
public static native double exp(double a);
public static native double sqrt(double a);
public static native double log(double a);
- public static native double pow(double a, double b);
+
+ @RETURNLOC("OUT")
+ public static native double pow(@LOC("IN") double a, @LOC("IN") double b);
public static native double ceil(double a);
public static native double floor(double a);
/**\r
* Returns version.\r
*/\r
+ @RETURNLOC("THIS")\r
public int version() { return h_version; }\r
\r
/**\r
/**\r
* Returns bitrate index.\r
*/\r
+ @RETURNLOC("THIS")\r
public int bitrate_index() { return h_bitrate_index; }\r
\r
/**\r
/**\r
* Returns Mode.\r
*/\r
+ @RETURNLOC("THIS")\r
public int mode() { return h_mode; }\r
\r
/**\r
* Returns Checksum flag.\r
* Compares computed checksum with stream checksum.\r
*/\r
+ @RETURNLOC("THIS")\r
public boolean checksum_ok () { return (checksum == crc.checksum()); }\r
\r
// Seeking and layer III stuff\r
/**\r
* Returns Slots.\r
*/\r
+ @RETURNLOC("THIS")\r
public int slots() { return nSlots; }\r
\r
/**\r
* Returns Mode Extension.\r
*/\r
+ @RETURNLOC("THIS")\r
public int mode_extension() { return h_mode_extension; }\r
\r
// E.B -> private to public\r
* Returns the number of subbands in the current frame.\r
* @return number of subbands\r
*/\r
+ @RETURNLOC("THIS")\r
public int number_of_subbands() {return h_number_of_subbands;}\r
\r
/**\r
* subbands above that limit are in intensity stereo mode.\r
* @return intensity\r
*/\r
+ @RETURNLOC("THIS")\r
public int intensity_stereo_bound() {return h_intensity_stereo_bound;}\r
}\r
/**
* Class for layer I subbands in joint stereo mode.
*/
- @LATTICE("L<H,H<SH,SH*")
+ @LATTICE("S<L,L<H,H<SH,SH*")
@METHODDEFAULT("OUT<V,V<SH,SH<IN,SH*,THISLOC=V,GLOBALLOC=IN")
static class SubbandLayer1IntensityStereo extends SubbandLayer1
{
/**
* Class for layer I subbands in stereo mode.
- */
+ */
@LATTICE("S<L,L<H,H<SH,SH*,S*")
@METHODDEFAULT("OUT<V,V<SH,SH<IN,SH*,THISLOC=V,GLOBALLOC=IN")
static class SubbandLayer1Stereo extends SubbandLayer1
@RETURNLOC("OUT")
public boolean read_sampledata (@LOC("IN")Bitstream stream)
{
- boolean returnvalue = super.read_sampledata(stream);
+ @LOC("OUT") boolean returnvalue = super.read_sampledata(stream);
if (channel2_allocation != 0)
{
channel2_sample = (float) (stream.get_bits(channel2_samplelength));
}
- return(returnvalue);
+ return returnvalue;
}
/**
protected void readScaleFactorSelection()
{
- for (@LOC("V,layerIIDecoder.SH") int i = 0; i < num_subbands; ++i)
+ for (@LOC("V,LayerIIDecoder.SH") int i = 0; i < num_subbands; ++i)
((SubbandLayer2)subbands[i]).read_scalefactor_selection(stream, crc);
}
/**
* Class for layer II subbands in single channel mode.
*/
- @LATTICE("L<H,L<ARR,ARR<F,SN<F,GN<F,F<H,SN*,GN*")
+ @LATTICE("S<L,L<H,L<ARR,ARR<F,SN<F,GN<F,F<H,H<SH,SN*,GN*")
@METHODDEFAULT("OUT<V,V<SH,SH<THIS,THIS<IN,SH*,THISLOC=THIS,GLOBALLOC=IN")
static class SubbandLayer2 extends Subband
{
/**
*
*/
+ @RETURNLOC("THIS")
public boolean put_next_sample(@LOC("IN") int channels, @LOC("IN") SynthesisFilter filter1, @LOC("IN") SynthesisFilter filter2)
{
if ((allocation != 0) && (channels != OutputChannels.RIGHT_CHANNEL))
/**
* Class for layer II subbands in joint stereo mode.
*/
- @LATTICE("L<H,L<ARR,ARR<F,SN<F,GN<F,F<H,SN*,GN*")
+ @LATTICE("S<L,L<H,L<ARR,ARR<F,SN<F,GN<F,F<H,H<SH,SN*,GN*")
@METHODDEFAULT("OUT<V,V<SH,SH<THIS,THIS<IN,SH*,THISLOC=THIS,GLOBALLOC=IN")
static class SubbandLayer2IntensityStereo extends SubbandLayer2
{
/**
*
*/
- @LATTICE("S2<S1,S1<THIS,THIS<GLOBAL,S1*,THISLOC=THIS,GLOBALLOC=GLOBAL")
+ @LATTICE("S2<S1,S1<THIS,THIS<GLOBAL,GLOBAL<IN,S1*,THISLOC=THIS,GLOBALLOC=GLOBAL")
@RETURNLOC("S2")
public boolean put_next_sample(@LOC("IN") int channels, @LOC("IN") SynthesisFilter filter1, @LOC("IN") SynthesisFilter filter2)
{
/**
* Class for layer II subbands in stereo mode.
*/
- @LATTICE("L<H,L<ARR,ARR<F,SN<F,GN<F,F<H,SN*,GN*")
+ @LATTICE("S<L,L<H,L<ARR,ARR<F,SN<F,GN<F,F<H,H<SH,SN*,GN*")
@METHODDEFAULT("OUT<V,V<SH,SH<THIS,THIS<IN,SH*,THISLOC=THIS,GLOBALLOC=IN")
static class SubbandLayer2Stereo extends SubbandLayer2
{
@LOC("THIS,LayerIIIDecoder.D3") int sb;
@LOC("THIS,LayerIIIDecoder.D2") int sb18;
@LOC("MAIN") int main_data_end;
- @LOC("BYTES") int bytes_to_discard;
+ @LOC("BYTE") int bytes_to_discard;
@LOC("VAR") int i;
get_side_info();
@LOC("LY") int[] w = { 0 };
@LATTICE("H<I,I<R,R<B1,B1<B,B<THIS,THIS<IN,I*,THISLOC=THIS,GLOBALLOC=IN")
- private void huffman_decode(int ch, int gr) {
+ private void huffman_decode(@LOC("IN") int ch, @LOC("IN") int gr) {
x[0] = 0;
y[0] = 0;
v[0] = 0;
@LOC("THIS,LayerIIIDecoder.HD2") int num_bits;
@LOC("R") int region1Start;
@LOC("R") int region2Start;
- @LOC("HD3") int index;
+ @LOC("THIS,LayerIIIDecoder.HD3") int index;
@LOC("B") int buf;
@LOC("B1") int buf1;
@LATTICE("IO<THIS,THIS<IN,THISLOC=THIS,GLOBALLOC=IN")
private void stereo(@LOC("IN") int gr) {
- @LOC("SH") int sb;
- @LOC("SH") int ss;
+ @LOC("THIS,LayerIIIDecoder.SH") int sb;
+ @LOC("THIS,LayerIIIDecoder.SH") int ss;
if (channels == 1) { // mono , bypass xr[0][][] to lr[0][][]
/**
*
*/
- @LATTICE("THIS<SRC<SS,SS<SB18,SB18<SB18LIM,SB18LIM<GR,GR<IN,SB18*,SS*,THISLOC=THIS")
+ @LATTICE("THIS<SRC,SRC<SS,SS<SB18,SB18<SB18LIM,SB18LIM<GR,GR<IN,SB18*,SS*,THISLOC=THIS")
private void antialias(@LOC("IN") int ch, @LOC("IN") int gr) {
@LOC("SB18") int sb18;
@LOC("SS") int ss;
@LOC("SRC") int src_idx1 = sb18 + 17 - ss;
@LOC("SRC") int src_idx2 = sb18 + 18 + ss;
@LOC("THIS,LayerIIIDecoder.O") float bu = out_1d[src_idx1];
- @LOC("THIS,LayerIIIDecoder.0") float bd = out_1d[src_idx2];
+ @LOC("THIS,LayerIIIDecoder.O") float bd = out_1d[src_idx2];
out_1d[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);
out_1d[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);
}
@LATTICE("D<IN,D<C,THISLOC=D")
public void appendSamples(@LOC("IN") int channel, @LOC("IN") float[] f)
{
- @LOC("D, SampleBuffer.BUFP") int pos = bufferp[channel];
+ @LOC("D,SampleBuffer.BUFP") int pos = bufferp[channel];
// LOC(bufferp[channel])=[D,SampleBuffer.BUFP]
// LOC(pos)=[D,SampleBuffer.BUFP]
/**
* Abstract base class for subband classes of layer I and II
*/
- @LATTICE("S<L,L<H")
+@LATTICE("S<L,L<H,H<SH")
static abstract class Subband
{
/*
samples[subbandnumber] = eq[subbandnumber]*sample;\r
}\r
\r
- public void input_samples(@LOC("V") float[] s)\r
+ @LATTICE("TH<IN,IN<C,C*,THISLOC=TH")\r
+ public void input_samples(@LOC("IN") float[] s)\r
{\r
- for (int i=31; i>=0; i--)\r
+ for (@LOC("C") int i=31; i>=0; i--)\r
{ \r
samples[i] = s[i]*eq[i];\r
}\r