Add a high_bits method.

This commit is contained in:
Nigel Tao committed 2017-07-13 13:23:01 +10:00
1 parent 73a4f2b263
commit 7e9b3aab67
5 files changed
+55 -15

No files matched your search

+16
View File
@@ -402,6 +402,22 @@ func (g *gen) cName(name string) string {
return string(b)
}
func (g *gen) sizeof(typ *a.TypeExpr) (uint32, error) {
if typ.Decorator() == 0 {
switch typ.Name().Key() {
case t.KeyU8:
return 1, nil
case t.KeyU16:
return 2, nil
case t.KeyU32:
return 4, nil
case t.KeyU64:
return 8, nil
}
}
return 0, fmt.Errorf("unknown sizeof for %q", typ.String(g.tm))
}
func (g *gen) gatherStatuses(n *a.Status) error {
raw := n.Message().String(g.tm)
msg, ok := t.Unescape(raw)