diff --git a/ent/huff.go b/ent/huff.go index 4235c43..c66d74c 100644 --- a/ent/huff.go +++ b/ent/huff.go @@ -137,7 +137,7 @@ var hlist = nodeList{ panic("not implemented: PushOneLeftDeltaOneRightNonZero") }}, lNode{"PopAllButOnePlusOne", 29, 1837, func(r *selectionReader, br bit.Reader) { - r.cur.count = 1 + r.pop(-1) r.add(1) }}, lNode{"PlusThree", 2, 1375, func(r *selectionReader, br bit.Reader) { @@ -147,7 +147,7 @@ var hlist = nodeList{ panic("not implemented: PlusFour") }}, lNode{"PopAllButOnePlusNPack6Bits", 32, 634, func(r *selectionReader, br bit.Reader) { - r.cur.count = 1 + r.pop(-1) r.add(int(br.ReadBits(6)) + 1) }}, lNode{"PushOneLeftDeltaNRightZero", 9, 560, func(r *selectionReader, br bit.Reader) { @@ -174,7 +174,7 @@ var hlist = nodeList{ panic("not implemented: PushOneLeftDeltaNRightNonZeroPack8Bits") }}, lNode{"PopAllButOnePlusN", 30, 149, func(r *selectionReader, br bit.Reader) { - r.cur.count = 1 + r.pop(-1) r.add(int(bit.ReadUBitVarFP(br)) + 1) }}, lNode{"NonTopoComplexPack4Bits", 38, 99, func(r *selectionReader, br bit.Reader) { @@ -200,7 +200,7 @@ var hlist = nodeList{ r.push(int(bit.ReadUBitVarFP(br))) }}, lNode{"PopOnePlusOne", 27, 2, func(r *selectionReader, br bit.Reader) { - r.pop() + r.pop(1) r.add(1) }}, lNode{"PopNAndNonTopographical", 35, 1, func(r *selectionReader, br bit.Reader) { diff --git a/ent/selection.go b/ent/selection.go index b5aa476..4a4a4ec 100644 --- a/ent/selection.go +++ b/ent/selection.go @@ -32,7 +32,6 @@ func (s selection) fill(offset int, displayPath string, dest slotted, br bit.Rea case *Entity: Debug.Printf("%s %s (%s)", s, fmt.Sprintf("%s.%s", displayPath, dest.slotName(slot)), dest.slotType(slot)) return nil - // Info.Fatalf("%v entity has no decoder for slot %d (%v)", v.Class, slot, v.Class.Fields[slot]) default: Info.Printf("slotted value %v has no decoder for slot %d", dest, slot) return nil @@ -96,8 +95,15 @@ func (r *selectionReader) push(i int) { r.cur.count++ } -// pops the last value off of the current selection -func (r *selectionReader) pop() { r.cur.count-- } +// pops n elements from the selection. if n is negative, pops all but n +// elements from the selection. +func (r *selectionReader) pop(n int) { + if n < 0 { + r.cur.count = -n + } else { + r.cur.count -= n + } +} // maps a function over the current set of values in the current selection func (r *selectionReader) måp(fn func(int) int) {