From: yeom Date: Tue, 26 Jul 2011 00:24:56 +0000 (+0000) Subject: changes: LayerIDecoder and LayerIIDecoder pass the flow-down rule checking X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9d757bbfd2fe65fbce565cb39396d6a214472a0e;hp=70b8c48e522870feca244a22ead04ad0b78c0bde;p=IRC.git changes: LayerIDecoder and LayerIIDecoder pass the flow-down rule checking --- diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index f1133415..89afe624 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -1309,9 +1309,10 @@ public class FlowDownCheck { return deltaLoc; } - private Location parseFieldLocDeclaraton(String decl, String msg) { + private Location parseFieldLocDeclaraton(String decl, String msg) throws Exception { int idx = decl.indexOf("."); + String className = decl.substring(0, idx); String fieldName = decl.substring(idx + 1); @@ -1321,6 +1322,7 @@ public class FlowDownCheck { Descriptor d = state.getClassSymbolTable().get(className); if (d == null) { + System.out.println("state.getClassSymbolTable()=" + state.getClassSymbolTable()); throw new Error("The class in the location declaration '" + decl + "' does not exist at " + msg); } @@ -1356,28 +1358,23 @@ public class FlowDownCheck { SSJavaLattice localLattice = CompositeLattice.getLatticeByDescriptor(md); Location localLoc = new Location(md, localLocId); if (localLattice == null || (!localLattice.containsKey(localLocId))) { + System.out.println("locDec="+locDec); throw new Error("Location " + localLocId + " is not defined in the local variable lattice at " - + md.getClassDesc().getSourceFileName() + "::" + (n != null ? n.getNumLine() : "") + "."); + + md.getClassDesc().getSourceFileName() + "::" + (n != null ? n.getNumLine() : md) + "."); } compLoc.addLocation(localLoc); for (int i = 1; i < locIdList.size(); i++) { String locName = locIdList.get(i); - - Location fieldLoc = - parseFieldLocDeclaraton(locName, generateErrorMessage(md.getClassDesc(), n)); - // ClassDescriptor cd = fieldLocName2cd.get(locName); - // SSJavaLattice fieldLattice = - // CompositeLattice.getLatticeByDescriptor(cd); - // - // if (fieldLattice == null || (!fieldLattice.containsKey(locName))) { - // throw new Error("Location " + locName + - // " is not defined in the field lattice at " - // + cd.getSourceFileName() + "."); - // } - // Location fieldLoc = new Location(cd, locName); - compLoc.addLocation(fieldLoc); + try { + Location fieldLoc = + parseFieldLocDeclaraton(locName, generateErrorMessage(md.getClassDesc(), n)); + compLoc.addLocation(fieldLoc); + } catch (Exception e) { + throw new Error("The location declaration '" + locName + "' is wrong at " + + generateErrorMessage(md.getClassDesc(), n)); + } } return compLoc; @@ -1463,7 +1460,7 @@ public class FlowDownCheck { public static boolean isGreaterThan(CompositeLocation loc1, CompositeLocation loc2, String msg) { - System.out.println("isGreaterThan=" + loc1 + " " + loc2 + " msg=" + msg); + System.out.println("\nisGreaterThan=" + loc1 + " " + loc2 + " msg=" + msg); int baseCompareResult = compareBaseLocationSet(loc1, loc2, true, msg); if (baseCompareResult == ComparisonResult.EQUAL) { if (compareDelta(loc1, loc2) == ComparisonResult.GREATER) { @@ -1525,7 +1522,7 @@ public class FlowDownCheck { Location loc1 = compLoc1.get(i); if (i >= compLoc2.getSize()) { throw new Error("Failed to compare two locations of " + compLoc1 + " and " + compLoc2 - + " because they are not comparable."); + + " because they are not comparable at " + msg); } Location loc2 = compLoc2.get(i); diff --git a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java index 89913a84..ea708993 100644 --- a/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java +++ b/Robust/src/Tests/ssJava/mp3decoder/LayerIDecoder.java @@ -23,449 +23,395 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ - /** - * Implements decoding of MPEG Audio Layer I frames. + * Implements decoding of MPEG Audio Layer I frames. */ -@LATTICE("L source.length - 3) temp = source.length - 3; - if(temp > groupingtable[0].length - 3) temp = groupingtable[0].length - 3; - - samples[tmp] = groupingtable[0][temp]; - temp++;tmp++; - samples[tmp] = groupingtable[0][temp]; - temp++;tmp++; - samples[tmp] = groupingtable[0][temp]; - - // memcpy (samples, groupingtable + samplecode, 3 * sizeof (real)); - } - else - { - samples[0] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0); - samples[1] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0); - samples[2] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0); - } - - samplenumber = 0; - if (++groupnumber == 12) - return true; - else - return false; - } - - /** + public void read_scalefactor_selection(@LOC("IN") Bitstream stream, @LOC("IN") Crc16 crc) { + if (allocation != 0) { + scfsi = stream.get_bits(2); + if (crc != null) + crc.add_bits(scfsi, 2); + } + } + + /** * */ - @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)) - { - @LOC("SH") float sample = samples[samplenumber]; - - if (groupingtable[0] == null) - sample = (sample + d[0]) * c[0]; - if (groupnumber <= 4) - sample *= scalefactor1; - else if (groupnumber <= 8) - sample *= scalefactor2; - else - sample *= scalefactor3; - filter1.input_sample(sample, subbandnumber); - } - - if (++samplenumber == 3) - return true; - else - return false; - } - }; - - /** - * Class for layer II subbands in joint stereo mode. - */ - @LATTICE("S source.length - 3) temp = source.length - 3; + if (temp > groupingtable[0].length - 3) { + temp = groupingtable[0].length - 3; + } + + samples[tmp] = groupingtable[0][temp]; + temp++; + tmp++; + samples[tmp] = groupingtable[0][temp]; + temp++; + tmp++; + samples[tmp] = groupingtable[0][temp]; + + // memcpy (samples, groupingtable + samplecode, 3 * sizeof (real)); + } else { + samples[0] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0); + samples[1] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0); + samples[2] = (float) ((stream.get_bits(codelength[0])) * factor[0] - 1.0); + } + } + samplenumber = 0; + if (++groupnumber == 12) + return true; + else + return false; + } + + // ssjava + public boolean put_next_sample(@LOC("IN") int channels, @LOC("IN") SynthesisFilter filter1, + @LOC("IN") SynthesisFilter filter2) { + + if ((allocation != 0) && (channels != OutputChannels.RIGHT_CHANNEL)) { + + @LOC("THIS,LayerIIDecoder$SubbandLayer2.SM") float sample = samples[samplenumber]; + + if (groupingtable[0] == null) { + sample = (sample + d[0]) * c[0]; + } + if (groupnumber <= 4) { + sample *= scalefactor1; + } else if (groupnumber <= 8) { + sample *= scalefactor2; + } else { + sample *= scalefactor3; + } + filter1.input_sample(sample, subbandnumber); + } + + if (++samplenumber == 3) + return true; + else + return false; + } + }; + + /** + * Class for layer II subbands in joint stereo mode. + */ + @LATTICE("S