more fieldpath ops, fieldpath error handling

master
Jordan Orelli 8 years ago
parent ffab114a0b
commit 01afbe66a2

@ -187,8 +187,16 @@ func (d *Dict) syncBaselines() {
c.baseline = c.New() c.baseline = c.New()
} }
if e.Value == nil || len(e.Value) == 0 {
Debug.Printf("syncBaselines skipping entry with key %s: value is empty", e.Key)
continue
}
d.br.SetSource(e.Value) d.br.SetSource(e.Value)
Debug.Printf("syncBaselines has new baseline for class %v", c) Debug.Printf("syncBaselines has new baseline for class %v", c)
c.baseline.Read(d.br) if err := c.baseline.Read(d.br); err != nil {
Debug.Printf("syncBaselines failed to read a baseline: %v", err)
continue
}
} }
} }

@ -18,6 +18,9 @@ func (e *Entity) Read(br bit.Reader) error {
fp := newFieldPath() fp := newFieldPath()
for fn := walk(htree, br); fn != nil; fn = walk(htree, br) { for fn := walk(htree, br); fn != nil; fn = walk(htree, br) {
if err := br.Err(); err != nil {
return fmt.Errorf("unable to read entity: reader error: %v", err)
}
fn(fp, br) fn(fp, br)
} }
Debug.Printf("fieldpath %s", fp.pathString()) Debug.Printf("fieldpath %s", fp.pathString())

@ -181,15 +181,12 @@ var hlist = nodeList{
}) })
}}, }},
lNode{"NonTopoComplex", 36, 76, func(fp *fieldPath, br bit.Reader) { lNode{"NonTopoComplex", 36, 76, func(fp *fieldPath, br bit.Reader) {
panic("not implemented: NonTopoComplex") fp.replaceAll(func(i int) int {
// for i := 0; i < len(fp.index); i++ { if bit.ReadBool(br) {
// fp.replaceAll(func(i int) int { return i + int(bit.ReadZigZag32(br))
// if bit.ReadBool(br) { }
// return i + bit.ReadVarInt(br) return i
// } })
// return i
// })
// }
}}, }},
lNode{"PushOneLeftDeltaZeroRightZero", 5, 35, func(fp *fieldPath, br bit.Reader) { lNode{"PushOneLeftDeltaZeroRightZero", 5, 35, func(fp *fieldPath, br bit.Reader) {
fp.push(0) fp.push(0)
@ -202,7 +199,13 @@ var hlist = nodeList{
fp.add(1) fp.add(1)
}}, }},
lNode{"PopNAndNonTopographical", 35, 1, func(fp *fieldPath, br bit.Reader) { lNode{"PopNAndNonTopographical", 35, 1, func(fp *fieldPath, br bit.Reader) {
panic("not implemented: PopNAndNonTopographical") fp.last -= int(bit.ReadUBitVarFP(br))
fp.replaceAll(func(i int) int {
if bit.ReadBool(br) {
return i + int(bit.ReadZigZag32(br))
}
return i
})
}}, }},
// all the other operations have weights of 0 in clarity, which makes no // all the other operations have weights of 0 in clarity, which makes no
@ -250,7 +253,8 @@ var hlist = nodeList{
panic("not implemented: PushThreeLeftDeltaZero") panic("not implemented: PushThreeLeftDeltaZero")
}}, }},
lNode{"PushTwoPack5LeftDeltaZero", 14, 1, func(fp *fieldPath, br bit.Reader) { lNode{"PushTwoPack5LeftDeltaZero", 14, 1, func(fp *fieldPath, br bit.Reader) {
panic("not implemented: PushTwoPack5LeftDeltaZero") fp.push(int(br.ReadBits(5)))
fp.push(int(br.ReadBits(5)))
}}, }},
lNode{"PushTwoLeftDeltaZero", 13, 1, func(fp *fieldPath, br bit.Reader) { lNode{"PushTwoLeftDeltaZero", 13, 1, func(fp *fieldPath, br bit.Reader) {
panic("not implemented: PushTwoLeftDeltaZero") panic("not implemented: PushTwoLeftDeltaZero")

Loading…
Cancel
Save